| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
|
| 3 |
/*************************************************************************** |
| 4 |
* copyright : (C) 1999 Axel Dziemba ([email protected]) |
| 5 |
* (C) 2002 by Frank Mori Hess |
| 6 |
***************************************************************************/ |
| 7 |
|
| 8 |
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 9 |
#define dev_fmt pr_fmt |
| 10 |
#define DRV_NAME KBUILD_MODNAME |
| 11 |
|
| 12 |
#include "ines.h" |
| 13 |
|
| 14 |
#include <linux/pci.h> |
| 15 |
#include <linux/pci_ids.h> |
| 16 |
#include <linux/bitops.h> |
| 17 |
#include <asm/dma.h> |
| 18 |
#include <linux/io.h> |
| 19 |
#include <linux/module.h> |
| 20 |
#include <linux/init.h> |
| 21 |
#include <linux/sched.h> |
| 22 |
#include <linux/slab.h> |
| 23 |
#include "gpib_pci_ids.h" |
| 24 |
|
| 25 |
MODULE_LICENSE("GPL"); |
| 26 |
MODULE_DESCRIPTION("GPIB driver for Ines iGPIB 72010"); |
| 27 |
|
| 28 |
static irqreturn_t ines_interrupt(struct gpib_board *board); |
| 29 |
|
| 30 |
static int ines_line_status(const struct gpib_board *board) |
| 31 |
{ |
| 32 |
int status = VALID_ALL; |
| 33 |
int bcm_bits; |
| 34 |
struct ines_priv *ines_priv; |
| 35 |
|
| 36 |
ines_priv = board->private_data; |
| 37 |
|
| 38 |
bcm_bits = ines_inb(ines_priv, BUS_CONTROL_MONITOR); |
| 39 |
|
| 40 |
if (bcm_bits & BCM_REN_BIT) |
| 41 |
status |= BUS_REN; |
| 42 |
if (bcm_bits & BCM_IFC_BIT) |
| 43 |
status |= BUS_IFC; |
| 44 |
if (bcm_bits & BCM_SRQ_BIT) |
| 45 |
status |= BUS_SRQ; |
| 46 |
if (bcm_bits & BCM_EOI_BIT) |
| 47 |
status |= BUS_EOI; |
| 48 |
if (bcm_bits & BCM_NRFD_BIT) |
| 49 |
status |= BUS_NRFD; |
| 50 |
if (bcm_bits & BCM_NDAC_BIT) |
| 51 |
status |= BUS_NDAC; |
| 52 |
if (bcm_bits & BCM_DAV_BIT) |
| 53 |
status |= BUS_DAV; |
| 54 |
if (bcm_bits & BCM_ATN_BIT) |
| 55 |
status |= BUS_ATN; |
| 56 |
|
| 57 |
return status; |
| 58 |
} |
| 59 |
|
| 60 |
static void ines_set_xfer_counter(struct ines_priv *priv, unsigned int count) |
| 61 |
{ |
| 62 |
if (count > 0xffff) { |
| 63 |
pr_err("bug! tried to set xfer counter > 0xffff\n"); |
| 64 |
return; |
| 65 |
} |
| 66 |
ines_outb(priv, (count >> 8) & 0xff, XFER_COUNT_UPPER); |
| 67 |
ines_outb(priv, count & 0xff, XFER_COUNT_LOWER); |
| 68 |
} |
| 69 |
|
| 70 |
static int ines_t1_delay(struct gpib_board *board, unsigned int nano_sec) |
| 71 |
{ |
| 72 |
struct ines_priv *ines_priv = board->private_data; |
| 73 |
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; |
| 74 |
unsigned int retval; |
| 75 |
|
| 76 |
retval = nec7210_t1_delay(board, nec_priv, nano_sec); |
| 77 |
|
| 78 |
if (nano_sec <= 250) { |
| 79 |
write_byte(nec_priv, INES_AUXD | INES_FOLLOWING_T1_250ns | |
| 80 |
INES_INITIAL_T1_2000ns, AUXMR); |
| 81 |
retval = 250; |
| 82 |
} else if (nano_sec <= 350) { |
| 83 |
write_byte(nec_priv, INES_AUXD | INES_FOLLOWING_T1_350ns | |
| 84 |
INES_INITIAL_T1_2000ns, AUXMR); |
| 85 |
retval = 350; |
| 86 |
} else { |
| 87 |
write_byte(nec_priv, INES_AUXD | INES_FOLLOWING_T1_500ns | |
| 88 |
INES_INITIAL_T1_2000ns, AUXMR); |
| 89 |
retval = 500; |
| 90 |
} |
| 91 |
|
| 92 |
return retval; |
| 93 |
} |
| 94 |
|
| 95 |
static inline unsigned short num_in_fifo_bytes(struct ines_priv *ines_priv) |
| 96 |
{ |
| 97 |
return ines_inb(ines_priv, IN_FIFO_COUNT); |
| 98 |
} |
| 99 |
|
| 100 |
static ssize_t pio_read(struct gpib_board *board, struct ines_priv *ines_priv, u8 *buffer, |
| 101 |
size_t length, size_t *nbytes) |
| 102 |
{ |
| 103 |
ssize_t retval = 0; |
| 104 |
unsigned int num_fifo_bytes, i; |
| 105 |
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; |
| 106 |
|
| 107 |
*nbytes = 0; |
| 108 |
while (*nbytes < length) { |
| 109 |
if (wait_event_interruptible(board->wait, |
| 110 |
num_in_fifo_bytes(ines_priv) || |
| 111 |
test_bit(RECEIVED_END_BN, &nec_priv->state) || |
| 112 |
test_bit(DEV_CLEAR_BN, &nec_priv->state) || |
| 113 |
test_bit(TIMO_NUM, &board->status))) |
| 114 |
return -ERESTARTSYS; |
| 115 |
|
| 116 |
if (test_bit(TIMO_NUM, &board->status)) |
| 117 |
return -ETIMEDOUT; |
| 118 |
if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) |
| 119 |
return -EINTR; |
| 120 |
|
| 121 |
num_fifo_bytes = num_in_fifo_bytes(ines_priv); |
| 122 |
if (num_fifo_bytes + *nbytes > length) |
| 123 |
num_fifo_bytes = length - *nbytes; |
| 124 |
|
| 125 |
for (i = 0; i < num_fifo_bytes; i++) |
| 126 |
buffer[(*nbytes)++] = read_byte(nec_priv, DIR); |
| 127 |
if (test_bit(RECEIVED_END_BN, &nec_priv->state) && |
| 128 |
num_in_fifo_bytes(ines_priv) == 0) |
| 129 |
break; |
| 130 |
if (need_resched()) |
| 131 |
schedule(); |
| 132 |
} |
| 133 |
/* make sure RECEIVED_END is in sync */ |
| 134 |
ines_interrupt(board); |
| 135 |
return retval; |
| 136 |
} |
| 137 |
|
| 138 |
static int ines_accel_read(struct gpib_board *board, u8 *buffer, |
| 139 |
size_t length, int *end, size_t *bytes_read) |
| 140 |
{ |
| 141 |
ssize_t retval = 0; |
| 142 |
struct ines_priv *ines_priv = board->private_data; |
| 143 |
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; |
| 144 |
int counter_setting; |
| 145 |
|
| 146 |
*end = 0; |
| 147 |
*bytes_read = 0; |
| 148 |
if (length == 0) |
| 149 |
return 0; |
| 150 |
|
| 151 |
clear_bit(DEV_CLEAR_BN, &nec_priv->state); |
| 152 |
|
| 153 |
write_byte(nec_priv, INES_RFD_HLD_IMMEDIATE, AUXMR); |
| 154 |
|
| 155 |
// clear in fifo |
| 156 |
nec7210_set_reg_bits(nec_priv, ADMR, IN_FIFO_ENABLE_BIT, 0); |
| 157 |
nec7210_set_reg_bits(nec_priv, ADMR, IN_FIFO_ENABLE_BIT, IN_FIFO_ENABLE_BIT); |
| 158 |
|
| 159 |
ines_priv->extend_mode_bits |= LAST_BYTE_HANDLING_BIT; |
| 160 |
ines_priv->extend_mode_bits &= ~XFER_COUNTER_OUTPUT_BIT & ~XFER_COUNTER_ENABLE_BIT; |
| 161 |
ines_outb(ines_priv, ines_priv->extend_mode_bits, EXTEND_MODE); |
| 162 |
|
| 163 |
counter_setting = length - num_in_fifo_bytes(ines_priv); |
| 164 |
if (counter_setting > 0) { |
| 165 |
ines_set_xfer_counter(ines_priv, length); |
| 166 |
ines_priv->extend_mode_bits |= XFER_COUNTER_ENABLE_BIT; |
| 167 |
ines_outb(ines_priv, ines_priv->extend_mode_bits, EXTEND_MODE); |
| 168 |
|
| 169 |
// holdoff on END |
| 170 |
nec7210_set_handshake_mode(board, nec_priv, HR_HLDE); |
| 171 |
/* release rfd holdoff */ |
| 172 |
write_byte(nec_priv, AUX_FH, AUXMR); |
| 173 |
} |
| 174 |
|
| 175 |
retval = pio_read(board, ines_priv, buffer, length, bytes_read); |
| 176 |
ines_priv->extend_mode_bits &= ~XFER_COUNTER_ENABLE_BIT; |
| 177 |
ines_outb(ines_priv, ines_priv->extend_mode_bits, EXTEND_MODE); |
| 178 |
if (retval < 0) { |
| 179 |
write_byte(nec_priv, INES_RFD_HLD_IMMEDIATE, AUXMR); |
| 180 |
return retval; |
| 181 |
} |
| 182 |
if (test_and_clear_bit(RECEIVED_END_BN, &nec_priv->state)) |
| 183 |
*end = 1; |
| 184 |
|
| 185 |
return retval; |
| 186 |
} |
| 187 |
|
| 188 |
static const int out_fifo_size = 0xff; |
| 189 |
|
| 190 |
static inline unsigned short num_out_fifo_bytes(struct ines_priv *ines_priv) |
| 191 |
{ |
| 192 |
return ines_inb(ines_priv, OUT_FIFO_COUNT); |
| 193 |
} |
| 194 |
|
| 195 |
static int ines_write_wait(struct gpib_board *board, struct ines_priv *ines_priv, |
| 196 |
unsigned int fifo_threshold) |
| 197 |
{ |
| 198 |
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; |
| 199 |
|
| 200 |
// wait until byte is ready to be sent |
| 201 |
if (wait_event_interruptible(board->wait, |
| 202 |
num_out_fifo_bytes(ines_priv) < fifo_threshold || |
| 203 |
test_bit(BUS_ERROR_BN, &nec_priv->state) || |
| 204 |
test_bit(DEV_CLEAR_BN, &nec_priv->state) || |
| 205 |
test_bit(TIMO_NUM, &board->status))) |
| 206 |
return -ERESTARTSYS; |
| 207 |
|
| 208 |
if (test_bit(BUS_ERROR_BN, &nec_priv->state)) |
| 209 |
return -EIO; |
| 210 |
if (test_bit(DEV_CLEAR_BN, &nec_priv->state)) |
| 211 |
return -EINTR; |
| 212 |
if (test_bit(TIMO_NUM, &board->status)) |
| 213 |
return -ETIMEDOUT; |
| 214 |
|
| 215 |
return 0; |
| 216 |
} |
| 217 |
|
| 218 |
static int ines_accel_write(struct gpib_board *board, u8 *buffer, size_t length, |
| 219 |
int send_eoi, size_t *bytes_written) |
| 220 |
{ |
| 221 |
size_t count = 0; |
| 222 |
ssize_t retval = 0; |
| 223 |
struct ines_priv *ines_priv = board->private_data; |
| 224 |
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; |
| 225 |
unsigned int num_bytes, i; |
| 226 |
|
| 227 |
*bytes_written = 0; |
| 228 |
// clear out fifo |
| 229 |
nec7210_set_reg_bits(nec_priv, ADMR, OUT_FIFO_ENABLE_BIT, 0); |
| 230 |
nec7210_set_reg_bits(nec_priv, ADMR, OUT_FIFO_ENABLE_BIT, OUT_FIFO_ENABLE_BIT); |
| 231 |
|
| 232 |
ines_priv->extend_mode_bits |= XFER_COUNTER_OUTPUT_BIT; |
| 233 |
ines_priv->extend_mode_bits &= ~XFER_COUNTER_ENABLE_BIT; |
| 234 |
ines_priv->extend_mode_bits &= ~LAST_BYTE_HANDLING_BIT; |
| 235 |
ines_outb(ines_priv, ines_priv->extend_mode_bits, EXTEND_MODE); |
| 236 |
|
| 237 |
ines_set_xfer_counter(ines_priv, length); |
| 238 |
if (send_eoi) |
| 239 |
ines_priv->extend_mode_bits |= LAST_BYTE_HANDLING_BIT; |
| 240 |
ines_priv->extend_mode_bits |= XFER_COUNTER_ENABLE_BIT; |
| 241 |
ines_outb(ines_priv, ines_priv->extend_mode_bits, EXTEND_MODE); |
| 242 |
|
| 243 |
while (count < length) { |
| 244 |
retval = ines_write_wait(board, ines_priv, out_fifo_size); |
| 245 |
if (retval < 0) |
| 246 |
break; |
| 247 |
|
| 248 |
num_bytes = out_fifo_size - num_out_fifo_bytes(ines_priv); |
| 249 |
if (num_bytes + count > length) |
| 250 |
num_bytes = length - count; |
| 251 |
for (i = 0; i < num_bytes; i++) |
| 252 |
write_byte(nec_priv, buffer[count++], CDOR); |
| 253 |
} |
| 254 |
if (retval < 0) { |
| 255 |
ines_priv->extend_mode_bits &= ~XFER_COUNTER_ENABLE_BIT; |
| 256 |
ines_outb(ines_priv, ines_priv->extend_mode_bits, EXTEND_MODE); |
| 257 |
*bytes_written = length - num_out_fifo_bytes(ines_priv); |
| 258 |
return retval; |
| 259 |
} |
| 260 |
// wait last byte has been sent |
| 261 |
retval = ines_write_wait(board, ines_priv, 1); |
| 262 |
ines_priv->extend_mode_bits &= ~XFER_COUNTER_ENABLE_BIT; |
| 263 |
ines_outb(ines_priv, ines_priv->extend_mode_bits, EXTEND_MODE); |
| 264 |
*bytes_written = length - num_out_fifo_bytes(ines_priv); |
| 265 |
|
| 266 |
return retval; |
| 267 |
} |
| 268 |
|
| 269 |
static irqreturn_t ines_pci_interrupt(int irq, void *arg) |
| 270 |
{ |
| 271 |
struct gpib_board *board = arg; |
| 272 |
struct ines_priv *priv = board->private_data; |
| 273 |
struct nec7210_priv *nec_priv = &priv->nec7210_priv; |
| 274 |
|
| 275 |
if (priv->pci_chip_type == PCI_CHIP_QUANCOM) { |
| 276 |
if ((inb(nec_priv->iobase + |
| 277 |
QUANCOM_IRQ_CONTROL_STATUS_REG) & |
| 278 |
QUANCOM_IRQ_ASSERTED_BIT)) |
| 279 |
outb(QUANCOM_IRQ_ENABLE_BIT, nec_priv->iobase + |
| 280 |
QUANCOM_IRQ_CONTROL_STATUS_REG); |
| 281 |
} |
| 282 |
|
| 283 |
return ines_interrupt(board); |
| 284 |
} |
| 285 |
|
| 286 |
static irqreturn_t ines_interrupt(struct gpib_board *board) |
| 287 |
{ |
| 288 |
struct ines_priv *priv = board->private_data; |
| 289 |
struct nec7210_priv *nec_priv = &priv->nec7210_priv; |
| 290 |
unsigned int isr3_bits, isr4_bits; |
| 291 |
unsigned long flags; |
| 292 |
int wake = 0; |
| 293 |
|
| 294 |
spin_lock_irqsave(&board->spinlock, flags); |
| 295 |
|
| 296 |
nec7210_interrupt(board, nec_priv); |
| 297 |
isr3_bits = ines_inb(priv, ISR3); |
| 298 |
isr4_bits = ines_inb(priv, ISR4); |
| 299 |
if (isr3_bits & IFC_ACTIVE_BIT) { |
| 300 |
push_gpib_event(board, EVENT_IFC); |
| 301 |
wake++; |
| 302 |
} |
| 303 |
if (isr3_bits & FIFO_ERROR_BIT) |
| 304 |
dev_err(board->gpib_dev, "fifo error\n"); |
| 305 |
if (isr3_bits & XFER_COUNT_BIT) |
| 306 |
wake++; |
| 307 |
|
| 308 |
if (isr4_bits & (IN_FIFO_WATERMARK_BIT | IN_FIFO_FULL_BIT | OUT_FIFO_WATERMARK_BIT | |
| 309 |
OUT_FIFO_EMPTY_BIT)) |
| 310 |
wake++; |
| 311 |
|
| 312 |
if (wake) |
| 313 |
wake_up_interruptible(&board->wait); |
| 314 |
spin_unlock_irqrestore(&board->spinlock, flags); |
| 315 |
return IRQ_HANDLED; |
| 316 |
} |
| 317 |
|
| 318 |
static int ines_pci_attach(struct gpib_board *board, const struct gpib_board_config *config); |
| 319 |
static int ines_pci_accel_attach(struct gpib_board *board, const struct gpib_board_config *config); |
| 320 |
static int ines_isa_attach(struct gpib_board *board, const struct gpib_board_config *config); |
| 321 |
|
| 322 |
static void ines_pci_detach(struct gpib_board *board); |
| 323 |
static void ines_isa_detach(struct gpib_board *board); |
| 324 |
|
| 325 |
enum ines_pci_vendor_ids { |
| 326 |
PCI_VENDOR_ID_INES_QUICKLOGIC = 0x16da |
| 327 |
}; |
| 328 |
|
| 329 |
enum ines_pci_device_ids { |
| 330 |
PCI_DEVICE_ID_INES_GPIB_AMCC = 0x8507, |
| 331 |
PCI_DEVICE_ID_INES_GPIB_QL5030 = 0x11, |
| 332 |
}; |
| 333 |
|
| 334 |
enum ines_pci_subdevice_ids { |
| 335 |
PCI_SUBDEVICE_ID_INES_GPIB = 0x1072 |
| 336 |
}; |
| 337 |
|
| 338 |
static struct pci_device_id ines_pci_table[] = { |
| 339 |
{PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_VENDOR_ID_PLX, |
| 340 |
PCI_SUBDEVICE_ID_INES_GPIB, 0, 0, 0}, |
| 341 |
{PCI_VENDOR_ID_AMCC, PCI_DEVICE_ID_INES_GPIB_AMCC, PCI_VENDOR_ID_AMCC, |
| 342 |
PCI_SUBDEVICE_ID_INES_GPIB, 0, 0, 0}, |
| 343 |
{PCI_VENDOR_ID_INES_QUICKLOGIC, PCI_DEVICE_ID_INES_GPIB_QL5030, |
| 344 |
PCI_VENDOR_ID_INES_QUICKLOGIC, PCI_DEVICE_ID_INES_GPIB_QL5030, 0, 0, 0}, |
| 345 |
{PCI_DEVICE(PCI_VENDOR_ID_QUANCOM, PCI_DEVICE_ID_QUANCOM_GPIB)}, |
| 346 |
{0} |
| 347 |
}; |
| 348 |
MODULE_DEVICE_TABLE(pci, ines_pci_table); |
| 349 |
|
| 350 |
struct ines_pci_id { |
| 351 |
unsigned int vendor_id; |
| 352 |
unsigned int device_id; |
| 353 |
int subsystem_vendor_id; |
| 354 |
int subsystem_device_id; |
| 355 |
unsigned int gpib_region; |
| 356 |
unsigned int io_offset; |
| 357 |
enum ines_pci_chip pci_chip_type; |
| 358 |
}; |
| 359 |
|
| 360 |
static struct ines_pci_id pci_ids[] = { |
| 361 |
{.vendor_id = PCI_VENDOR_ID_PLX, |
| 362 |
.device_id = PCI_DEVICE_ID_PLX_9050, |
| 363 |
.subsystem_vendor_id = PCI_VENDOR_ID_PLX, |
| 364 |
.subsystem_device_id = PCI_SUBDEVICE_ID_INES_GPIB, |
| 365 |
.gpib_region = 2, |
| 366 |
.io_offset = 1, |
| 367 |
.pci_chip_type = PCI_CHIP_PLX9050, |
| 368 |
}, |
| 369 |
{.vendor_id = PCI_VENDOR_ID_AMCC, |
| 370 |
.device_id = PCI_DEVICE_ID_INES_GPIB_AMCC, |
| 371 |
.subsystem_vendor_id = PCI_VENDOR_ID_AMCC, |
| 372 |
.subsystem_device_id = PCI_SUBDEVICE_ID_INES_GPIB, |
| 373 |
.gpib_region = 1, |
| 374 |
.io_offset = 1, |
| 375 |
.pci_chip_type = PCI_CHIP_AMCC5920, |
| 376 |
}, |
| 377 |
{.vendor_id = PCI_VENDOR_ID_INES_QUICKLOGIC, |
| 378 |
.device_id = PCI_DEVICE_ID_INES_GPIB_QL5030, |
| 379 |
.subsystem_vendor_id = PCI_VENDOR_ID_INES_QUICKLOGIC, |
| 380 |
.subsystem_device_id = PCI_DEVICE_ID_INES_GPIB_QL5030, |
| 381 |
.gpib_region = 1, |
| 382 |
.io_offset = 1, |
| 383 |
.pci_chip_type = PCI_CHIP_QUICKLOGIC5030, |
| 384 |
}, |
| 385 |
{.vendor_id = PCI_VENDOR_ID_QUANCOM, |
| 386 |
.device_id = PCI_DEVICE_ID_QUANCOM_GPIB, |
| 387 |
.subsystem_vendor_id = -1, |
| 388 |
.subsystem_device_id = -1, |
| 389 |
.gpib_region = 0, |
| 390 |
.io_offset = 4, |
| 391 |
.pci_chip_type = PCI_CHIP_QUANCOM, |
| 392 |
}, |
| 393 |
}; |
| 394 |
|
| 395 |
static const int num_pci_chips = ARRAY_SIZE(pci_ids); |
| 396 |
|
| 397 |
// wrappers for interface functions |
| 398 |
static int ines_read(struct gpib_board *board, u8 *buffer, size_t length, |
| 399 |
int *end, size_t *bytes_read) |
| 400 |
{ |
| 401 |
struct ines_priv *priv = board->private_data; |
| 402 |
struct nec7210_priv *nec_priv = &priv->nec7210_priv; |
| 403 |
ssize_t retval; |
| 404 |
int dummy; |
| 405 |
|
| 406 |
retval = nec7210_read(board, &priv->nec7210_priv, buffer, length, end, bytes_read); |
| 407 |
if (retval < 0) { |
| 408 |
write_byte(nec_priv, INES_RFD_HLD_IMMEDIATE, AUXMR); |
| 409 |
|
| 410 |
set_bit(RFD_HOLDOFF_BN, &nec_priv->state); |
| 411 |
|
| 412 |
nec7210_read_data_in(board, nec_priv, &dummy); |
| 413 |
} |
| 414 |
return retval; |
| 415 |
} |
| 416 |
|
| 417 |
static int ines_write(struct gpib_board *board, u8 *buffer, size_t length, int send_eoi, |
| 418 |
size_t *bytes_written) |
| 419 |
{ |
| 420 |
struct ines_priv *priv = board->private_data; |
| 421 |
|
| 422 |
return nec7210_write(board, &priv->nec7210_priv, buffer, length, send_eoi, bytes_written); |
| 423 |
} |
| 424 |
|
| 425 |
static int ines_command(struct gpib_board *board, u8 *buffer, size_t length, size_t *bytes_written) |
| 426 |
{ |
| 427 |
struct ines_priv *priv = board->private_data; |
| 428 |
|
| 429 |
return nec7210_command(board, &priv->nec7210_priv, buffer, length, bytes_written); |
| 430 |
} |
| 431 |
|
| 432 |
static int ines_take_control(struct gpib_board *board, int synchronous) |
| 433 |
{ |
| 434 |
struct ines_priv *priv = board->private_data; |
| 435 |
|
| 436 |
return nec7210_take_control(board, &priv->nec7210_priv, synchronous); |
| 437 |
} |
| 438 |
|
| 439 |
static int ines_go_to_standby(struct gpib_board *board) |
| 440 |
{ |
| 441 |
struct ines_priv *priv = board->private_data; |
| 442 |
|
| 443 |
return nec7210_go_to_standby(board, &priv->nec7210_priv); |
| 444 |
} |
| 445 |
|
| 446 |
static int ines_request_system_control(struct gpib_board *board, int request_control) |
| 447 |
{ |
| 448 |
struct ines_priv *priv = board->private_data; |
| 449 |
|
| 450 |
return nec7210_request_system_control(board, &priv->nec7210_priv, request_control); |
| 451 |
} |
| 452 |
|
| 453 |
static void ines_interface_clear(struct gpib_board *board, int assert) |
| 454 |
{ |
| 455 |
struct ines_priv *priv = board->private_data; |
| 456 |
|
| 457 |
nec7210_interface_clear(board, &priv->nec7210_priv, assert); |
| 458 |
} |
| 459 |
|
| 460 |
static void ines_remote_enable(struct gpib_board *board, int enable) |
| 461 |
{ |
| 462 |
struct ines_priv *priv = board->private_data; |
| 463 |
|
| 464 |
nec7210_remote_enable(board, &priv->nec7210_priv, enable); |
| 465 |
} |
| 466 |
|
| 467 |
static int ines_enable_eos(struct gpib_board *board, u8 eos_byte, int compare_8_bits) |
| 468 |
{ |
| 469 |
struct ines_priv *priv = board->private_data; |
| 470 |
|
| 471 |
return nec7210_enable_eos(board, &priv->nec7210_priv, eos_byte, compare_8_bits); |
| 472 |
} |
| 473 |
|
| 474 |
static void ines_disable_eos(struct gpib_board *board) |
| 475 |
{ |
| 476 |
struct ines_priv *priv = board->private_data; |
| 477 |
|
| 478 |
nec7210_disable_eos(board, &priv->nec7210_priv); |
| 479 |
} |
| 480 |
|
| 481 |
static unsigned int ines_update_status(struct gpib_board *board, unsigned int clear_mask) |
| 482 |
{ |
| 483 |
struct ines_priv *priv = board->private_data; |
| 484 |
|
| 485 |
return nec7210_update_status(board, &priv->nec7210_priv, clear_mask); |
| 486 |
} |
| 487 |
|
| 488 |
static int ines_primary_address(struct gpib_board *board, unsigned int address) |
| 489 |
{ |
| 490 |
struct ines_priv *priv = board->private_data; |
| 491 |
|
| 492 |
return nec7210_primary_address(board, &priv->nec7210_priv, address); |
| 493 |
} |
| 494 |
|
| 495 |
static int ines_secondary_address(struct gpib_board *board, unsigned int address, int enable) |
| 496 |
{ |
| 497 |
struct ines_priv *priv = board->private_data; |
| 498 |
|
| 499 |
return nec7210_secondary_address(board, &priv->nec7210_priv, address, enable); |
| 500 |
} |
| 501 |
|
| 502 |
static int ines_parallel_poll(struct gpib_board *board, u8 *result) |
| 503 |
{ |
| 504 |
struct ines_priv *priv = board->private_data; |
| 505 |
|
| 506 |
return nec7210_parallel_poll(board, &priv->nec7210_priv, result); |
| 507 |
} |
| 508 |
|
| 509 |
static void ines_parallel_poll_configure(struct gpib_board *board, u8 config) |
| 510 |
{ |
| 511 |
struct ines_priv *priv = board->private_data; |
| 512 |
|
| 513 |
nec7210_parallel_poll_configure(board, &priv->nec7210_priv, config); |
| 514 |
} |
| 515 |
|
| 516 |
static void ines_parallel_poll_response(struct gpib_board *board, int ist) |
| 517 |
{ |
| 518 |
struct ines_priv *priv = board->private_data; |
| 519 |
|
| 520 |
nec7210_parallel_poll_response(board, &priv->nec7210_priv, ist); |
| 521 |
} |
| 522 |
|
| 523 |
static void ines_serial_poll_response(struct gpib_board *board, u8 status) |
| 524 |
{ |
| 525 |
struct ines_priv *priv = board->private_data; |
| 526 |
|
| 527 |
nec7210_serial_poll_response(board, &priv->nec7210_priv, status); |
| 528 |
} |
| 529 |
|
| 530 |
static u8 ines_serial_poll_status(struct gpib_board *board) |
| 531 |
{ |
| 532 |
struct ines_priv *priv = board->private_data; |
| 533 |
|
| 534 |
return nec7210_serial_poll_status(board, &priv->nec7210_priv); |
| 535 |
} |
| 536 |
|
| 537 |
static void ines_return_to_local(struct gpib_board *board) |
| 538 |
{ |
| 539 |
struct ines_priv *priv = board->private_data; |
| 540 |
|
| 541 |
nec7210_return_to_local(board, &priv->nec7210_priv); |
| 542 |
} |
| 543 |
|
| 544 |
static struct gpib_interface ines_pci_unaccel_interface = { |
| 545 |
.name = "ines_pci_unaccel", |
| 546 |
.attach = ines_pci_attach, |
| 547 |
.detach = ines_pci_detach, |
| 548 |
.read = ines_read, |
| 549 |
.write = ines_write, |
| 550 |
.command = ines_command, |
| 551 |
.take_control = ines_take_control, |
| 552 |
.go_to_standby = ines_go_to_standby, |
| 553 |
.request_system_control = ines_request_system_control, |
| 554 |
.interface_clear = ines_interface_clear, |
| 555 |
.remote_enable = ines_remote_enable, |
| 556 |
.enable_eos = ines_enable_eos, |
| 557 |
.disable_eos = ines_disable_eos, |
| 558 |
.parallel_poll = ines_parallel_poll, |
| 559 |
.parallel_poll_configure = ines_parallel_poll_configure, |
| 560 |
.parallel_poll_response = ines_parallel_poll_response, |
| 561 |
.local_parallel_poll_mode = NULL, // XXX |
| 562 |
.line_status = ines_line_status, |
| 563 |
.update_status = ines_update_status, |
| 564 |
.primary_address = ines_primary_address, |
| 565 |
.secondary_address = ines_secondary_address, |
| 566 |
.serial_poll_response = ines_serial_poll_response, |
| 567 |
.serial_poll_status = ines_serial_poll_status, |
| 568 |
.t1_delay = ines_t1_delay, |
| 569 |
.return_to_local = ines_return_to_local, |
| 570 |
}; |
| 571 |
|
| 572 |
static struct gpib_interface ines_pci_interface = { |
| 573 |
.name = "ines_pci", |
| 574 |
.attach = ines_pci_accel_attach, |
| 575 |
.detach = ines_pci_detach, |
| 576 |
.read = ines_accel_read, |
| 577 |
.write = ines_accel_write, |
| 578 |
.command = ines_command, |
| 579 |
.take_control = ines_take_control, |
| 580 |
.go_to_standby = ines_go_to_standby, |
| 581 |
.request_system_control = ines_request_system_control, |
| 582 |
.interface_clear = ines_interface_clear, |
| 583 |
.remote_enable = ines_remote_enable, |
| 584 |
.enable_eos = ines_enable_eos, |
| 585 |
.disable_eos = ines_disable_eos, |
| 586 |
.parallel_poll = ines_parallel_poll, |
| 587 |
.parallel_poll_configure = ines_parallel_poll_configure, |
| 588 |
.parallel_poll_response = ines_parallel_poll_response, |
| 589 |
.local_parallel_poll_mode = NULL, // XXX |
| 590 |
.line_status = ines_line_status, |
| 591 |
.update_status = ines_update_status, |
| 592 |
.primary_address = ines_primary_address, |
| 593 |
.secondary_address = ines_secondary_address, |
| 594 |
.serial_poll_response = ines_serial_poll_response, |
| 595 |
.serial_poll_status = ines_serial_poll_status, |
| 596 |
.t1_delay = ines_t1_delay, |
| 597 |
.return_to_local = ines_return_to_local, |
| 598 |
}; |
| 599 |
|
| 600 |
static struct gpib_interface ines_pci_accel_interface = { |
| 601 |
.name = "ines_pci_accel", |
| 602 |
.attach = ines_pci_accel_attach, |
| 603 |
.detach = ines_pci_detach, |
| 604 |
.read = ines_accel_read, |
| 605 |
.write = ines_accel_write, |
| 606 |
.command = ines_command, |
| 607 |
.take_control = ines_take_control, |
| 608 |
.go_to_standby = ines_go_to_standby, |
| 609 |
.request_system_control = ines_request_system_control, |
| 610 |
.interface_clear = ines_interface_clear, |
| 611 |
.remote_enable = ines_remote_enable, |
| 612 |
.enable_eos = ines_enable_eos, |
| 613 |
.disable_eos = ines_disable_eos, |
| 614 |
.parallel_poll = ines_parallel_poll, |
| 615 |
.parallel_poll_configure = ines_parallel_poll_configure, |
| 616 |
.parallel_poll_response = ines_parallel_poll_response, |
| 617 |
.local_parallel_poll_mode = NULL, // XXX |
| 618 |
.line_status = ines_line_status, |
| 619 |
.update_status = ines_update_status, |
| 620 |
.primary_address = ines_primary_address, |
| 621 |
.secondary_address = ines_secondary_address, |
| 622 |
.serial_poll_response = ines_serial_poll_response, |
| 623 |
.serial_poll_status = ines_serial_poll_status, |
| 624 |
.t1_delay = ines_t1_delay, |
| 625 |
.return_to_local = ines_return_to_local, |
| 626 |
}; |
| 627 |
|
| 628 |
static struct gpib_interface ines_isa_interface = { |
| 629 |
.name = "ines_isa", |
| 630 |
.attach = ines_isa_attach, |
| 631 |
.detach = ines_isa_detach, |
| 632 |
.read = ines_accel_read, |
| 633 |
.write = ines_accel_write, |
| 634 |
.command = ines_command, |
| 635 |
.take_control = ines_take_control, |
| 636 |
.go_to_standby = ines_go_to_standby, |
| 637 |
.request_system_control = ines_request_system_control, |
| 638 |
.interface_clear = ines_interface_clear, |
| 639 |
.remote_enable = ines_remote_enable, |
| 640 |
.enable_eos = ines_enable_eos, |
| 641 |
.disable_eos = ines_disable_eos, |
| 642 |
.parallel_poll = ines_parallel_poll, |
| 643 |
.parallel_poll_configure = ines_parallel_poll_configure, |
| 644 |
.parallel_poll_response = ines_parallel_poll_response, |
| 645 |
.local_parallel_poll_mode = NULL, // XXX |
| 646 |
.line_status = ines_line_status, |
| 647 |
.update_status = ines_update_status, |
| 648 |
.primary_address = ines_primary_address, |
| 649 |
.secondary_address = ines_secondary_address, |
| 650 |
.serial_poll_response = ines_serial_poll_response, |
| 651 |
.serial_poll_status = ines_serial_poll_status, |
| 652 |
.t1_delay = ines_t1_delay, |
| 653 |
.return_to_local = ines_return_to_local, |
| 654 |
}; |
| 655 |
|
| 656 |
static int ines_allocate_private(struct gpib_board *board) |
| 657 |
{ |
| 658 |
struct ines_priv *priv; |
| 659 |
|
| 660 |
board->private_data = kzalloc_obj(struct ines_priv); |
| 661 |
if (!board->private_data) |
| 662 |
return -ENOMEM; |
| 663 |
priv = board->private_data; |
| 664 |
init_nec7210_private(&priv->nec7210_priv); |
| 665 |
return 0; |
| 666 |
} |
| 667 |
|
| 668 |
static void ines_free_private(struct gpib_board *board) |
| 669 |
{ |
| 670 |
kfree(board->private_data); |
| 671 |
board->private_data = NULL; |
| 672 |
} |
| 673 |
|
| 674 |
static int ines_generic_attach(struct gpib_board *board) |
| 675 |
{ |
| 676 |
struct ines_priv *ines_priv; |
| 677 |
struct nec7210_priv *nec_priv; |
| 678 |
int retval; |
| 679 |
|
| 680 |
board->status = 0; |
| 681 |
|
| 682 |
retval = ines_allocate_private(board); |
| 683 |
if (retval) |
| 684 |
return retval; |
| 685 |
ines_priv = board->private_data; |
| 686 |
nec_priv = &ines_priv->nec7210_priv; |
| 687 |
nec_priv->read_byte = nec7210_ioport_read_byte; |
| 688 |
nec_priv->write_byte = nec7210_ioport_write_byte; |
| 689 |
nec_priv->offset = 1; |
| 690 |
nec_priv->type = IGPIB7210; |
| 691 |
ines_priv->pci_chip_type = PCI_CHIP_NONE; |
| 692 |
|
| 693 |
return 0; |
| 694 |
} |
| 695 |
|
| 696 |
static void ines_online(struct ines_priv *ines_priv, const struct gpib_board *board, int use_accel) |
| 697 |
{ |
| 698 |
struct nec7210_priv *nec_priv = &ines_priv->nec7210_priv; |
| 699 |
|
| 700 |
/* ines doesn't seem to use internal count register */ |
| 701 |
write_byte(nec_priv, ICR | 0, AUXMR); |
| 702 |
|
| 703 |
write_byte(nec_priv, INES_AUX_XMODE, AUXMR); |
| 704 |
write_byte(nec_priv, INES_RFD_HLD_IMMEDIATE, AUXMR); |
| 705 |
|
| 706 |
set_bit(RFD_HOLDOFF_BN, &nec_priv->state); |
| 707 |
|
| 708 |
write_byte(nec_priv, INES_AUXD | 0, AUXMR); |
| 709 |
ines_outb(ines_priv, 0, XDMA_CONTROL); |
| 710 |
ines_priv->extend_mode_bits = 0; |
| 711 |
ines_outb(ines_priv, ines_priv->extend_mode_bits, EXTEND_MODE); |
| 712 |
if (use_accel) { |
| 713 |
ines_outb(ines_priv, 0x80, OUT_FIFO_WATERMARK); |
| 714 |
ines_outb(ines_priv, 0x80, IN_FIFO_WATERMARK); |
| 715 |
ines_outb(ines_priv, IFC_ACTIVE_BIT | ATN_ACTIVE_BIT | |
| 716 |
FIFO_ERROR_BIT | XFER_COUNT_BIT, IMR3); |
| 717 |
ines_outb(ines_priv, IN_FIFO_WATERMARK_BIT | IN_FIFO_FULL_BIT | |
| 718 |
OUT_FIFO_WATERMARK_BIT | OUT_FIFO_EMPTY_BIT, IMR4); |
| 719 |
} else { |
| 720 |
nec7210_set_reg_bits(nec_priv, ADMR, IN_FIFO_ENABLE_BIT | OUT_FIFO_ENABLE_BIT, 0); |
| 721 |
ines_outb(ines_priv, IFC_ACTIVE_BIT | FIFO_ERROR_BIT, IMR3); |
| 722 |
ines_outb(ines_priv, 0, IMR4); |
| 723 |
} |
| 724 |
|
| 725 |
nec7210_board_online(nec_priv, board); |
| 726 |
if (use_accel) |
| 727 |
nec7210_set_reg_bits(nec_priv, IMR1, HR_DOIE | HR_DIIE, 0); |
| 728 |
} |
| 729 |
|
| 730 |
static int ines_common_pci_attach(struct gpib_board *board, const struct gpib_board_config *config) |
| 731 |
{ |
| 732 |
struct ines_priv *ines_priv; |
| 733 |
struct nec7210_priv *nec_priv; |
| 734 |
int isr_flags = 0; |
| 735 |
int retval; |
| 736 |
struct ines_pci_id found_id; |
| 737 |
unsigned int i; |
| 738 |
struct pci_dev *pdev; |
| 739 |
|
| 740 |
memset(&found_id, 0, sizeof(found_id)); |
| 741 |
|
| 742 |
retval = ines_generic_attach(board); |
| 743 |
if (retval) |
| 744 |
return retval; |
| 745 |
|
| 746 |
ines_priv = board->private_data; |
| 747 |
nec_priv = &ines_priv->nec7210_priv; |
| 748 |
|
| 749 |
// find board |
| 750 |
ines_priv->pci_device = NULL; |
| 751 |
for (i = 0; i < num_pci_chips && !ines_priv->pci_device; i++) { |
| 752 |
pdev = NULL; |
| 753 |
do { |
| 754 |
if (pci_ids[i].subsystem_vendor_id >= 0 && |
| 755 |
pci_ids[i].subsystem_device_id >= 0) |
| 756 |
pdev = pci_get_subsys(pci_ids[i].vendor_id, pci_ids[i].device_id, |
| 757 |
pci_ids[i].subsystem_vendor_id, |
| 758 |
pci_ids[i].subsystem_device_id, pdev); |
| 759 |
else |
| 760 |
pdev = pci_get_device(pci_ids[i].vendor_id, pci_ids[i].device_id, |
| 761 |
pdev); |
| 762 |
if (!pdev) |
| 763 |
break; |
| 764 |
if (config->pci_bus >= 0 && config->pci_bus != pdev->bus->number) |
| 765 |
continue; |
| 766 |
if (config->pci_slot >= 0 && config->pci_slot != PCI_SLOT(pdev->devfn)) |
| 767 |
continue; |
| 768 |
found_id = pci_ids[i]; |
| 769 |
ines_priv->pci_device = pdev; |
| 770 |
break; |
| 771 |
} while (1); |
| 772 |
} |
| 773 |
if (!ines_priv->pci_device) { |
| 774 |
dev_err(board->gpib_dev, "could not find ines PCI board\n"); |
| 775 |
return -1; |
| 776 |
} |
| 777 |
|
| 778 |
if (pci_enable_device(ines_priv->pci_device)) { |
| 779 |
dev_err(board->gpib_dev, "error enabling pci device\n"); |
| 780 |
return -1; |
| 781 |
} |
| 782 |
|
| 783 |
if (pci_request_regions(ines_priv->pci_device, DRV_NAME)) |
| 784 |
return -1; |
| 785 |
nec_priv->iobase = pci_resource_start(ines_priv->pci_device, |
| 786 |
found_id.gpib_region); |
| 787 |
|
| 788 |
ines_priv->pci_chip_type = found_id.pci_chip_type; |
| 789 |
nec_priv->offset = found_id.io_offset; |
| 790 |
switch (ines_priv->pci_chip_type) { |
| 791 |
case PCI_CHIP_PLX9050: |
| 792 |
ines_priv->plx_iobase = pci_resource_start(ines_priv->pci_device, 1); |
| 793 |
break; |
| 794 |
case PCI_CHIP_AMCC5920: |
| 795 |
ines_priv->amcc_iobase = pci_resource_start(ines_priv->pci_device, 0); |
| 796 |
break; |
| 797 |
case PCI_CHIP_QUANCOM: |
| 798 |
break; |
| 799 |
case PCI_CHIP_QUICKLOGIC5030: |
| 800 |
break; |
| 801 |
default: |
| 802 |
dev_err(board->gpib_dev, "unspecified chip type? (bug)\n"); |
| 803 |
nec_priv->iobase = 0; |
| 804 |
pci_release_regions(ines_priv->pci_device); |
| 805 |
return -1; |
| 806 |
} |
| 807 |
|
| 808 |
nec7210_board_reset(nec_priv, board); |
| 809 |
#ifdef QUANCOM_PCI |
| 810 |
if (ines_priv->pci_chip_type == PCI_CHIP_QUANCOM) { |
| 811 |
/* change interrupt polarity */ |
| 812 |
nec_priv->auxb_bits |= HR_INV; |
| 813 |
ines_outb(ines_priv, nec_priv->auxb_bits, AUXMR); |
| 814 |
} |
| 815 |
#endif |
| 816 |
isr_flags |= IRQF_SHARED; |
| 817 |
if (request_irq(ines_priv->pci_device->irq, ines_pci_interrupt, isr_flags, |
| 818 |
DRV_NAME, board)) { |
| 819 |
dev_err(board->gpib_dev, "can't request IRQ %d\n", ines_priv->pci_device->irq); |
| 820 |
return -1; |
| 821 |
} |
| 822 |
ines_priv->irq = ines_priv->pci_device->irq; |
| 823 |
|
| 824 |
// enable interrupts on pci chip |
| 825 |
switch (ines_priv->pci_chip_type) { |
| 826 |
case PCI_CHIP_PLX9050: |
| 827 |
outl(PLX9050_LINTR1_EN_BIT | PLX9050_LINTR1_POLARITY_BIT | PLX9050_PCI_INTR_EN_BIT, |
| 828 |
ines_priv->plx_iobase + PLX9050_INTCSR_REG); |
| 829 |
break; |
| 830 |
case PCI_CHIP_AMCC5920: |
| 831 |
{ |
| 832 |
static const int region = 1; |
| 833 |
static const int num_wait_states = 7; |
| 834 |
u32 bits; |
| 835 |
|
| 836 |
bits = amcc_prefetch_bits(region, PREFETCH_DISABLED); |
| 837 |
bits |= amcc_PTADR_mode_bit(region); |
| 838 |
bits |= amcc_disable_write_fifo_bit(region); |
| 839 |
bits |= amcc_wait_state_bits(region, num_wait_states); |
| 840 |
outl(bits, ines_priv->amcc_iobase + AMCC_PASS_THRU_REG); |
| 841 |
outl(AMCC_ADDON_INTR_ENABLE_BIT, ines_priv->amcc_iobase + AMCC_INTCS_REG); |
| 842 |
} |
| 843 |
break; |
| 844 |
case PCI_CHIP_QUANCOM: |
| 845 |
outb(QUANCOM_IRQ_ENABLE_BIT, nec_priv->iobase + |
| 846 |
QUANCOM_IRQ_CONTROL_STATUS_REG); |
| 847 |
break; |
| 848 |
case PCI_CHIP_QUICKLOGIC5030: |
| 849 |
break; |
| 850 |
default: |
| 851 |
dev_err(board->gpib_dev, "unspecified chip type? (bug)\n"); |
| 852 |
return -1; |
| 853 |
} |
| 854 |
|
| 855 |
return 0; |
| 856 |
} |
| 857 |
|
| 858 |
static int ines_pci_attach(struct gpib_board *board, const struct gpib_board_config *config) |
| 859 |
{ |
| 860 |
struct ines_priv *ines_priv; |
| 861 |
int retval; |
| 862 |
|
| 863 |
retval = ines_common_pci_attach(board, config); |
| 864 |
if (retval < 0) |
| 865 |
return retval; |
| 866 |
|
| 867 |
ines_priv = board->private_data; |
| 868 |
ines_online(ines_priv, board, 0); |
| 869 |
|
| 870 |
return 0; |
| 871 |
} |
| 872 |
|
| 873 |
static int ines_pci_accel_attach(struct gpib_board *board, const struct gpib_board_config *config) |
| 874 |
{ |
| 875 |
struct ines_priv *ines_priv; |
| 876 |
int retval; |
| 877 |
|
| 878 |
retval = ines_common_pci_attach(board, config); |
| 879 |
if (retval < 0) |
| 880 |
return retval; |
| 881 |
|
| 882 |
ines_priv = board->private_data; |
| 883 |
ines_online(ines_priv, board, 1); |
| 884 |
|
| 885 |
return 0; |
| 886 |
} |
| 887 |
|
| 888 |
static const int ines_isa_iosize = 0x20; |
| 889 |
|
| 890 |
static int ines_isa_attach(struct gpib_board *board, const struct gpib_board_config *config) |
| 891 |
{ |
| 892 |
struct ines_priv *ines_priv; |
| 893 |
struct nec7210_priv *nec_priv; |
| 894 |
int isr_flags = 0; |
| 895 |
int retval; |
| 896 |
|
| 897 |
retval = ines_generic_attach(board); |
| 898 |
if (retval) |
| 899 |
return retval; |
| 900 |
|
| 901 |
ines_priv = board->private_data; |
| 902 |
nec_priv = &ines_priv->nec7210_priv; |
| 903 |
|
| 904 |
if (!request_region(config->ibbase, ines_isa_iosize, DRV_NAME)) { |
| 905 |
dev_err(board->gpib_dev, "ioports at 0x%x already in use\n", |
| 906 |
config->ibbase); |
| 907 |
return -EBUSY; |
| 908 |
} |
| 909 |
nec_priv->iobase = config->ibbase; |
| 910 |
nec_priv->offset = 1; |
| 911 |
nec7210_board_reset(nec_priv, board); |
| 912 |
if (request_irq(config->ibirq, ines_pci_interrupt, isr_flags, DRV_NAME, board)) { |
| 913 |
dev_err(board->gpib_dev, "failed to allocate IRQ %d\n", config->ibirq); |
| 914 |
return -1; |
| 915 |
} |
| 916 |
ines_priv->irq = config->ibirq; |
| 917 |
ines_online(ines_priv, board, 1); |
| 918 |
return 0; |
| 919 |
} |
| 920 |
|
| 921 |
static void ines_pci_detach(struct gpib_board *board) |
| 922 |
{ |
| 923 |
struct ines_priv *ines_priv = board->private_data; |
| 924 |
struct nec7210_priv *nec_priv; |
| 925 |
|
| 926 |
if (ines_priv) { |
| 927 |
nec_priv = &ines_priv->nec7210_priv; |
| 928 |
if (ines_priv->irq) { |
| 929 |
// disable interrupts |
| 930 |
switch (ines_priv->pci_chip_type) { |
| 931 |
case PCI_CHIP_AMCC5920: |
| 932 |
if (ines_priv->plx_iobase) |
| 933 |
outl(0, ines_priv->plx_iobase + PLX9050_INTCSR_REG); |
| 934 |
break; |
| 935 |
case PCI_CHIP_QUANCOM: |
| 936 |
if (nec_priv->iobase) |
| 937 |
outb(0, nec_priv->iobase + |
| 938 |
QUANCOM_IRQ_CONTROL_STATUS_REG); |
| 939 |
break; |
| 940 |
default: |
| 941 |
break; |
| 942 |
} |
| 943 |
free_irq(ines_priv->irq, board); |
| 944 |
} |
| 945 |
if (nec_priv->iobase) { |
| 946 |
nec7210_board_reset(nec_priv, board); |
| 947 |
pci_release_regions(ines_priv->pci_device); |
| 948 |
} |
| 949 |
if (ines_priv->pci_device) |
| 950 |
pci_dev_put(ines_priv->pci_device); |
| 951 |
} |
| 952 |
ines_free_private(board); |
| 953 |
} |
| 954 |
|
| 955 |
static void ines_isa_detach(struct gpib_board *board) |
| 956 |
{ |
| 957 |
struct ines_priv *ines_priv = board->private_data; |
| 958 |
struct nec7210_priv *nec_priv; |
| 959 |
|
| 960 |
if (ines_priv) { |
| 961 |
nec_priv = &ines_priv->nec7210_priv; |
| 962 |
if (ines_priv->irq) |
| 963 |
free_irq(ines_priv->irq, board); |
| 964 |
if (nec_priv->iobase) { |
| 965 |
nec7210_board_reset(nec_priv, board); |
| 966 |
release_region(nec_priv->iobase, ines_isa_iosize); |
| 967 |
} |
| 968 |
} |
| 969 |
ines_free_private(board); |
| 970 |
} |
| 971 |
|
| 972 |
static int ines_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) |
| 973 |
{ |
| 974 |
return 0; |
| 975 |
} |
| 976 |
|
| 977 |
static struct pci_driver ines_pci_driver = { |
| 978 |
.name = "ines_gpib", |
| 979 |
.id_table = ines_pci_table, |
| 980 |
.probe = &ines_pci_probe |
| 981 |
}; |
| 982 |
|
| 983 |
#ifdef CONFIG_GPIB_PCMCIA |
| 984 |
|
| 985 |
#include <linux/kernel.h> |
| 986 |
#include <linux/ptrace.h> |
| 987 |
#include <linux/string.h> |
| 988 |
#include <linux/timer.h> |
| 989 |
|
| 990 |
#include <pcmcia/cistpl.h> |
| 991 |
#include <pcmcia/ds.h> |
| 992 |
#include <pcmcia/cisreg.h> |
| 993 |
|
| 994 |
static const int ines_pcmcia_iosize = 0x20; |
| 995 |
|
| 996 |
/* |
| 997 |
* The event() function is this driver's Card Services event handler. |
| 998 |
* It will be called by Card Services when an appropriate card status |
| 999 |
* event is received. The config() and release() entry points are |
| 1000 |
* used to configure or release a socket, in response to card insertion |
| 1001 |
* and ejection events. They are invoked from the gpib event |
| 1002 |
* handler. |
| 1003 |
*/ |
| 1004 |
|
| 1005 |
static int ines_gpib_config(struct pcmcia_device *link); |
| 1006 |
static void ines_gpib_release(struct pcmcia_device *link); |
| 1007 |
static int ines_pcmcia_attach(struct gpib_board *board, const struct gpib_board_config *config); |
| 1008 |
static int ines_pcmcia_accel_attach(struct gpib_board *board, |
| 1009 |
const struct gpib_board_config *config); |
| 1010 |
static void ines_pcmcia_detach(struct gpib_board *board); |
| 1011 |
static int ines_common_pcmcia_attach(struct gpib_board *board); |
| 1012 |
/* |
| 1013 |
* A linked list of "instances" of the gpib device. Each actual |
| 1014 |
* PCMCIA card corresponds to one device instance, and is described |
| 1015 |
* by one dev_link_t structure (defined in ds.h). |
| 1016 |
* |
| 1017 |
* You may not want to use a linked list for this -- for example, the |
| 1018 |
* memory card driver uses an array of dev_link_t pointers, where minor |
| 1019 |
* device numbers are used to derive the corresponding array index. |
| 1020 |
*/ |
| 1021 |
|
| 1022 |
static struct pcmcia_device *curr_dev; |
| 1023 |
|
| 1024 |
/* |
| 1025 |
* A dev_link_t structure has fields for most things that are needed |
| 1026 |
* to keep track of a socket, but there will usually be some device |
| 1027 |
* specific information that also needs to be kept track of. The |
| 1028 |
* 'priv' pointer in a dev_link_t structure can be used to point to |
| 1029 |
* a device-specific private data structure, like this. |
| 1030 |
* |
| 1031 |
* A driver needs to provide a dev_node_t structure for each device |
| 1032 |
* on a card. In some cases, there is only one device per card (for |
| 1033 |
* example, ethernet cards, modems). In other cases, there may be |
| 1034 |
* many actual or logical devices (SCSI adapters, memory cards with |
| 1035 |
* multiple partitions). The dev_node_t structures need to be kept |
| 1036 |
* in a linked list starting at the 'dev' field of a dev_link_t |
| 1037 |
* structure. We allocate them in the card's private data structure, |
| 1038 |
* because they generally can't be allocated dynamically. |
| 1039 |
*/ |
| 1040 |
|
| 1041 |
struct local_info { |
| 1042 |
struct pcmcia_device *p_dev; |
| 1043 |
struct gpib_board *dev; |
| 1044 |
u_short manfid; |
| 1045 |
u_short cardid; |
| 1046 |
}; |
| 1047 |
|
| 1048 |
/* |
| 1049 |
* gpib_attach() creates an "instance" of the driver, allocating |
| 1050 |
* local data structures for one device. The device is registered |
| 1051 |
* with Card Services. |
| 1052 |
* |
| 1053 |
* The dev_link structure is initialized, but we don't actually |
| 1054 |
* configure the card at this point -- we wait until we receive a |
| 1055 |
* card insertion event. |
| 1056 |
*/ |
| 1057 |
static int ines_gpib_probe(struct pcmcia_device *link) |
| 1058 |
{ |
| 1059 |
struct local_info *info; |
| 1060 |
|
| 1061 |
// int ret, i; |
| 1062 |
|
| 1063 |
/* Allocate space for private device-specific data */ |
| 1064 |
info = kzalloc_obj(*info); |
| 1065 |
if (!info) |
| 1066 |
return -ENOMEM; |
| 1067 |
|
| 1068 |
info->p_dev = link; |
| 1069 |
link->priv = info; |
| 1070 |
|
| 1071 |
/* The io structure describes IO port mapping */ |
| 1072 |
link->resource[0]->end = 32; |
| 1073 |
link->resource[0]->flags &= ~IO_DATA_PATH_WIDTH; |
| 1074 |
link->resource[0]->flags |= IO_DATA_PATH_WIDTH_8; |
| 1075 |
link->io_lines = 5; |
| 1076 |
|
| 1077 |
/* General socket configuration */ |
| 1078 |
link->config_flags = CONF_ENABLE_IRQ | CONF_AUTO_SET_IO; |
| 1079 |
|
| 1080 |
/* Register with Card Services */ |
| 1081 |
curr_dev = link; |
| 1082 |
return ines_gpib_config(link); |
| 1083 |
} |
| 1084 |
|
| 1085 |
/* |
| 1086 |
* This deletes a driver "instance". The device is de-registered |
| 1087 |
* with Card Services. If it has been released, all local data |
| 1088 |
* structures are freed. Otherwise, the structures will be freed |
| 1089 |
* when the device is released. |
| 1090 |
*/ |
| 1091 |
static void ines_gpib_remove(struct pcmcia_device *link) |
| 1092 |
{ |
| 1093 |
struct local_info *info = link->priv; |
| 1094 |
//struct struct gpib_board *dev = info->dev; |
| 1095 |
|
| 1096 |
if (info->dev) |
| 1097 |
ines_pcmcia_detach(info->dev); |
| 1098 |
ines_gpib_release(link); |
| 1099 |
|
| 1100 |
//free_netdev(dev); |
| 1101 |
kfree(info); |
| 1102 |
} |
| 1103 |
|
| 1104 |
static int ines_gpib_config_iteration(struct pcmcia_device *link, void *priv_data) |
| 1105 |
{ |
| 1106 |
return pcmcia_request_io(link); |
| 1107 |
} |
| 1108 |
|
| 1109 |
/* |
| 1110 |
* gpib_config() is scheduled to run after a CARD_INSERTION event |
| 1111 |
* is received, to configure the PCMCIA socket, and to make the |
| 1112 |
* device available to the system. |
| 1113 |
*/ |
| 1114 |
static int ines_gpib_config(struct pcmcia_device *link) |
| 1115 |
{ |
| 1116 |
int retval; |
| 1117 |
void __iomem *virt; |
| 1118 |
|
| 1119 |
retval = pcmcia_loop_config(link, &ines_gpib_config_iteration, NULL); |
| 1120 |
if (retval) { |
| 1121 |
dev_warn(&link->dev, "no configuration found\n"); |
| 1122 |
ines_gpib_release(link); |
| 1123 |
return -ENODEV; |
| 1124 |
} |
| 1125 |
|
| 1126 |
dev_dbg(&link->dev, "ines_cs: manufacturer: 0x%x card: 0x%x\n", |
| 1127 |
link->manf_id, link->card_id); |
| 1128 |
|
| 1129 |
/* |
| 1130 |
* for the ines card we have to setup the configuration registers in |
| 1131 |
* attribute memory here |
| 1132 |
*/ |
| 1133 |
link->resource[2]->flags |= WIN_MEMORY_TYPE_AM | WIN_DATA_WIDTH_8 | WIN_ENABLE; |
| 1134 |
link->resource[2]->end = 0x1000; |
| 1135 |
retval = pcmcia_request_window(link, link->resource[2], 250); |
| 1136 |
if (retval) { |
| 1137 |
dev_warn(&link->dev, "pcmcia_request_window failed\n"); |
| 1138 |
ines_gpib_release(link); |
| 1139 |
return -ENODEV; |
| 1140 |
} |
| 1141 |
retval = pcmcia_map_mem_page(link, link->resource[2], 0); |
| 1142 |
if (retval) { |
| 1143 |
dev_warn(&link->dev, "pcmcia_map_mem_page failed\n"); |
| 1144 |
ines_gpib_release(link); |
| 1145 |
return -ENODEV; |
| 1146 |
} |
| 1147 |
virt = ioremap(link->resource[2]->start, resource_size(link->resource[2])); |
| 1148 |
writeb((link->resource[2]->start >> 2) & 0xff, virt + 0xf0); // IOWindow base |
| 1149 |
iounmap(virt); |
| 1150 |
|
| 1151 |
/* |
| 1152 |
* This actually configures the PCMCIA socket -- setting up |
| 1153 |
* the I/O windows and the interrupt mapping. |
| 1154 |
*/ |
| 1155 |
retval = pcmcia_enable_device(link); |
| 1156 |
if (retval) { |
| 1157 |
ines_gpib_release(link); |
| 1158 |
return -ENODEV; |
| 1159 |
} |
| 1160 |
return 0; |
| 1161 |
} /* gpib_config */ |
| 1162 |
|
| 1163 |
/* |
| 1164 |
* After a card is removed, gpib_release() will unregister the net |
| 1165 |
* device, and release the PCMCIA configuration. If the device is |
| 1166 |
* still open, this will be postponed until it is closed. |
| 1167 |
*/ |
| 1168 |
|
| 1169 |
static void ines_gpib_release(struct pcmcia_device *link) |
| 1170 |
{ |
| 1171 |
pcmcia_disable_device(link); |
| 1172 |
} /* gpib_release */ |
| 1173 |
|
| 1174 |
static int ines_gpib_suspend(struct pcmcia_device *link) |
| 1175 |
{ |
| 1176 |
//struct local_info *info = link->priv; |
| 1177 |
//struct struct gpib_board *dev = info->dev; |
| 1178 |
|
| 1179 |
if (link->open) |
| 1180 |
dev_err(&link->dev, "Device still open\n"); |
| 1181 |
//netif_device_detach(dev); |
| 1182 |
|
| 1183 |
return 0; |
| 1184 |
} |
| 1185 |
|
| 1186 |
static int ines_gpib_resume(struct pcmcia_device *link) |
| 1187 |
{ |
| 1188 |
//struct local_info_t *info = link->priv; |
| 1189 |
//struct struct gpib_board *dev = info->dev; |
| 1190 |
|
| 1191 |
/*if (link->open) { |
| 1192 |
* ni_gpib_probe(dev); / really? |
| 1193 |
* //netif_device_attach(dev); |
| 1194 |
*} |
| 1195 |
*/ |
| 1196 |
return ines_gpib_config(link); |
| 1197 |
} |
| 1198 |
|
| 1199 |
static struct pcmcia_device_id ines_pcmcia_ids[] = { |
| 1200 |
PCMCIA_DEVICE_MANF_CARD(0x01b4, 0x4730), |
| 1201 |
PCMCIA_DEVICE_NULL |
| 1202 |
}; |
| 1203 |
MODULE_DEVICE_TABLE(pcmcia, ines_pcmcia_ids); |
| 1204 |
|
| 1205 |
static struct pcmcia_driver ines_gpib_cs_driver = { |
| 1206 |
.owner = THIS_MODULE, |
| 1207 |
.name = "ines_gpib_cs", |
| 1208 |
.id_table = ines_pcmcia_ids, |
| 1209 |
.probe = ines_gpib_probe, |
| 1210 |
.remove = ines_gpib_remove, |
| 1211 |
.suspend = ines_gpib_suspend, |
| 1212 |
.resume = ines_gpib_resume, |
| 1213 |
}; |
| 1214 |
|
| 1215 |
static void ines_pcmcia_cleanup_module(void) |
| 1216 |
{ |
| 1217 |
pcmcia_unregister_driver(&ines_gpib_cs_driver); |
| 1218 |
} |
| 1219 |
|
| 1220 |
static struct gpib_interface ines_pcmcia_unaccel_interface = { |
| 1221 |
.name = "ines_pcmcia_unaccel", |
| 1222 |
.attach = ines_pcmcia_attach, |
| 1223 |
.detach = ines_pcmcia_detach, |
| 1224 |
.read = ines_read, |
| 1225 |
.write = ines_write, |
| 1226 |
.command = ines_command, |
| 1227 |
.take_control = ines_take_control, |
| 1228 |
.go_to_standby = ines_go_to_standby, |
| 1229 |
.request_system_control = ines_request_system_control, |
| 1230 |
.interface_clear = ines_interface_clear, |
| 1231 |
.remote_enable = ines_remote_enable, |
| 1232 |
.enable_eos = ines_enable_eos, |
| 1233 |
.disable_eos = ines_disable_eos, |
| 1234 |
.parallel_poll = ines_parallel_poll, |
| 1235 |
.parallel_poll_configure = ines_parallel_poll_configure, |
| 1236 |
.parallel_poll_response = ines_parallel_poll_response, |
| 1237 |
.local_parallel_poll_mode = NULL, // XXX |
| 1238 |
.line_status = ines_line_status, |
| 1239 |
.update_status = ines_update_status, |
| 1240 |
.primary_address = ines_primary_address, |
| 1241 |
.secondary_address = ines_secondary_address, |
| 1242 |
.serial_poll_response = ines_serial_poll_response, |
| 1243 |
.serial_poll_status = ines_serial_poll_status, |
| 1244 |
.t1_delay = ines_t1_delay, |
| 1245 |
.return_to_local = ines_return_to_local, |
| 1246 |
}; |
| 1247 |
|
| 1248 |
static struct gpib_interface ines_pcmcia_accel_interface = { |
| 1249 |
.name = "ines_pcmcia_accel", |
| 1250 |
.attach = ines_pcmcia_accel_attach, |
| 1251 |
.detach = ines_pcmcia_detach, |
| 1252 |
.read = ines_accel_read, |
| 1253 |
.write = ines_accel_write, |
| 1254 |
.command = ines_command, |
| 1255 |
.take_control = ines_take_control, |
| 1256 |
.go_to_standby = ines_go_to_standby, |
| 1257 |
.request_system_control = ines_request_system_control, |
| 1258 |
.interface_clear = ines_interface_clear, |
| 1259 |
.remote_enable = ines_remote_enable, |
| 1260 |
.enable_eos = ines_enable_eos, |
| 1261 |
.disable_eos = ines_disable_eos, |
| 1262 |
.parallel_poll = ines_parallel_poll, |
| 1263 |
.parallel_poll_configure = ines_parallel_poll_configure, |
| 1264 |
.parallel_poll_response = ines_parallel_poll_response, |
| 1265 |
.local_parallel_poll_mode = NULL, // XXX |
| 1266 |
.line_status = ines_line_status, |
| 1267 |
.update_status = ines_update_status, |
| 1268 |
.primary_address = ines_primary_address, |
| 1269 |
.secondary_address = ines_secondary_address, |
| 1270 |
.serial_poll_response = ines_serial_poll_response, |
| 1271 |
.serial_poll_status = ines_serial_poll_status, |
| 1272 |
.t1_delay = ines_t1_delay, |
| 1273 |
.return_to_local = ines_return_to_local, |
| 1274 |
}; |
| 1275 |
|
| 1276 |
static struct gpib_interface ines_pcmcia_interface = { |
| 1277 |
.name = "ines_pcmcia", |
| 1278 |
.attach = ines_pcmcia_accel_attach, |
| 1279 |
.detach = ines_pcmcia_detach, |
| 1280 |
.read = ines_accel_read, |
| 1281 |
.write = ines_accel_write, |
| 1282 |
.command = ines_command, |
| 1283 |
.take_control = ines_take_control, |
| 1284 |
.go_to_standby = ines_go_to_standby, |
| 1285 |
.request_system_control = ines_request_system_control, |
| 1286 |
.interface_clear = ines_interface_clear, |
| 1287 |
.remote_enable = ines_remote_enable, |
| 1288 |
.enable_eos = ines_enable_eos, |
| 1289 |
.disable_eos = ines_disable_eos, |
| 1290 |
.parallel_poll = ines_parallel_poll, |
| 1291 |
.parallel_poll_configure = ines_parallel_poll_configure, |
| 1292 |
.parallel_poll_response = ines_parallel_poll_response, |
| 1293 |
.local_parallel_poll_mode = NULL, // XXX |
| 1294 |
.line_status = ines_line_status, |
| 1295 |
.update_status = ines_update_status, |
| 1296 |
.primary_address = ines_primary_address, |
| 1297 |
.secondary_address = ines_secondary_address, |
| 1298 |
.serial_poll_response = ines_serial_poll_response, |
| 1299 |
.serial_poll_status = ines_serial_poll_status, |
| 1300 |
.t1_delay = ines_t1_delay, |
| 1301 |
.return_to_local = ines_return_to_local, |
| 1302 |
}; |
| 1303 |
|
| 1304 |
static irqreturn_t ines_pcmcia_interrupt(int irq, void *arg) |
| 1305 |
{ |
| 1306 |
struct gpib_board *board = arg; |
| 1307 |
|
| 1308 |
return ines_interrupt(board); |
| 1309 |
} |
| 1310 |
|
| 1311 |
static int ines_common_pcmcia_attach(struct gpib_board *board) |
| 1312 |
{ |
| 1313 |
struct ines_priv *ines_priv; |
| 1314 |
struct nec7210_priv *nec_priv; |
| 1315 |
int retval; |
| 1316 |
|
| 1317 |
if (!curr_dev) { |
| 1318 |
dev_err(board->gpib_dev, "no ines pcmcia cards found\n"); |
| 1319 |
return -1; |
| 1320 |
} |
| 1321 |
|
| 1322 |
retval = ines_generic_attach(board); |
| 1323 |
if (retval) |
| 1324 |
return retval; |
| 1325 |
|
| 1326 |
ines_priv = board->private_data; |
| 1327 |
nec_priv = &ines_priv->nec7210_priv; |
| 1328 |
|
| 1329 |
if (!request_region(curr_dev->resource[0]->start, |
| 1330 |
resource_size(curr_dev->resource[0]), DRV_NAME)) { |
| 1331 |
dev_err(board->gpib_dev, "ioports at 0x%lx already in use\n", |
| 1332 |
(unsigned long)(curr_dev->resource[0]->start)); |
| 1333 |
return -1; |
| 1334 |
} |
| 1335 |
|
| 1336 |
nec_priv->iobase = curr_dev->resource[0]->start; |
| 1337 |
|
| 1338 |
nec7210_board_reset(nec_priv, board); |
| 1339 |
|
| 1340 |
if (request_irq(curr_dev->irq, ines_pcmcia_interrupt, IRQF_SHARED, |
| 1341 |
"pcmcia-gpib", board)) { |
| 1342 |
dev_err(board->gpib_dev, "can't request IRQ %d\n", curr_dev->irq); |
| 1343 |
return -1; |
| 1344 |
} |
| 1345 |
ines_priv->irq = curr_dev->irq; |
| 1346 |
|
| 1347 |
return 0; |
| 1348 |
} |
| 1349 |
|
| 1350 |
static int ines_pcmcia_attach(struct gpib_board *board, const struct gpib_board_config *config) |
| 1351 |
{ |
| 1352 |
struct ines_priv *ines_priv; |
| 1353 |
int retval; |
| 1354 |
|
| 1355 |
retval = ines_common_pcmcia_attach(board); |
| 1356 |
if (retval < 0) |
| 1357 |
return retval; |
| 1358 |
|
| 1359 |
ines_priv = board->private_data; |
| 1360 |
ines_online(ines_priv, board, 0); |
| 1361 |
|
| 1362 |
return 0; |
| 1363 |
} |
| 1364 |
|
| 1365 |
static int ines_pcmcia_accel_attach(struct gpib_board *board, |
| 1366 |
const struct gpib_board_config *config) |
| 1367 |
{ |
| 1368 |
struct ines_priv *ines_priv; |
| 1369 |
int retval; |
| 1370 |
|
| 1371 |
retval = ines_common_pcmcia_attach(board); |
| 1372 |
if (retval < 0) |
| 1373 |
return retval; |
| 1374 |
|
| 1375 |
ines_priv = board->private_data; |
| 1376 |
ines_online(ines_priv, board, 1); |
| 1377 |
|
| 1378 |
return 0; |
| 1379 |
} |
| 1380 |
|
| 1381 |
static void ines_pcmcia_detach(struct gpib_board *board) |
| 1382 |
{ |
| 1383 |
struct ines_priv *ines_priv = board->private_data; |
| 1384 |
struct nec7210_priv *nec_priv; |
| 1385 |
|
| 1386 |
if (ines_priv) { |
| 1387 |
nec_priv = &ines_priv->nec7210_priv; |
| 1388 |
if (ines_priv->irq) |
| 1389 |
free_irq(ines_priv->irq, board); |
| 1390 |
if (nec_priv->iobase) { |
| 1391 |
nec7210_board_reset(nec_priv, board); |
| 1392 |
release_region(nec_priv->iobase, ines_pcmcia_iosize); |
| 1393 |
} |
| 1394 |
} |
| 1395 |
ines_free_private(board); |
| 1396 |
} |
| 1397 |
|
| 1398 |
#endif /* CONFIG_GPIB_PCMCIA */ |
| 1399 |
|
| 1400 |
static int __init ines_init_module(void) |
| 1401 |
{ |
| 1402 |
int ret; |
| 1403 |
|
| 1404 |
ret = pci_register_driver(&ines_pci_driver); |
| 1405 |
if (ret) { |
| 1406 |
pr_err("pci_register_driver failed: error = %d\n", ret); |
| 1407 |
return ret; |
| 1408 |
} |
| 1409 |
|
| 1410 |
ret = gpib_register_driver(&ines_pci_interface, THIS_MODULE); |
| 1411 |
if (ret) { |
| 1412 |
pr_err("gpib_register_driver failed: error = %d\n", ret); |
| 1413 |
goto err_pci; |
| 1414 |
} |
| 1415 |
|
| 1416 |
ret = gpib_register_driver(&ines_pci_unaccel_interface, THIS_MODULE); |
| 1417 |
if (ret) { |
| 1418 |
pr_err("gpib_register_driver failed: error = %d\n", ret); |
| 1419 |
goto err_pci_unaccel; |
| 1420 |
} |
| 1421 |
|
| 1422 |
ret = gpib_register_driver(&ines_pci_accel_interface, THIS_MODULE); |
| 1423 |
if (ret) { |
| 1424 |
pr_err("gpib_register_driver failed: error = %d\n", ret); |
| 1425 |
goto err_pci_accel; |
| 1426 |
} |
| 1427 |
|
| 1428 |
ret = gpib_register_driver(&ines_isa_interface, THIS_MODULE); |
| 1429 |
if (ret) { |
| 1430 |
pr_err("gpib_register_driver failed: error = %d\n", ret); |
| 1431 |
goto err_isa; |
| 1432 |
} |
| 1433 |
|
| 1434 |
#ifdef CONFIG_GPIB_PCMCIA |
| 1435 |
ret = gpib_register_driver(&ines_pcmcia_interface, THIS_MODULE); |
| 1436 |
if (ret) { |
| 1437 |
pr_err("gpib_register_driver failed: error = %d\n", ret); |
| 1438 |
goto err_pcmcia; |
| 1439 |
} |
| 1440 |
|
| 1441 |
ret = gpib_register_driver(&ines_pcmcia_unaccel_interface, THIS_MODULE); |
| 1442 |
if (ret) { |
| 1443 |
pr_err("gpib_register_driver failed: error = %d\n", ret); |
| 1444 |
goto err_pcmcia_unaccel; |
| 1445 |
} |
| 1446 |
|
| 1447 |
ret = gpib_register_driver(&ines_pcmcia_accel_interface, THIS_MODULE); |
| 1448 |
if (ret) { |
| 1449 |
pr_err("gpib_register_driver failed: error = %d\n", ret); |
| 1450 |
goto err_pcmcia_accel; |
| 1451 |
} |
| 1452 |
|
| 1453 |
ret = pcmcia_register_driver(&ines_gpib_cs_driver); |
| 1454 |
if (ret) { |
| 1455 |
pr_err("pcmcia_register_driver failed: error = %d\n", ret); |
| 1456 |
goto err_pcmcia_driver; |
| 1457 |
} |
| 1458 |
#endif |
| 1459 |
|
| 1460 |
return 0; |
| 1461 |
|
| 1462 |
#ifdef CONFIG_GPIB_PCMCIA |
| 1463 |
err_pcmcia_driver: |
| 1464 |
gpib_unregister_driver(&ines_pcmcia_accel_interface); |
| 1465 |
err_pcmcia_accel: |
| 1466 |
gpib_unregister_driver(&ines_pcmcia_unaccel_interface); |
| 1467 |
err_pcmcia_unaccel: |
| 1468 |
gpib_unregister_driver(&ines_pcmcia_interface); |
| 1469 |
err_pcmcia: |
| 1470 |
#endif |
| 1471 |
gpib_unregister_driver(&ines_isa_interface); |
| 1472 |
err_isa: |
| 1473 |
gpib_unregister_driver(&ines_pci_accel_interface); |
| 1474 |
err_pci_accel: |
| 1475 |
gpib_unregister_driver(&ines_pci_unaccel_interface); |
| 1476 |
err_pci_unaccel: |
| 1477 |
gpib_unregister_driver(&ines_pci_interface); |
| 1478 |
err_pci: |
| 1479 |
pci_unregister_driver(&ines_pci_driver); |
| 1480 |
|
| 1481 |
return ret; |
| 1482 |
} |
| 1483 |
|
| 1484 |
static void __exit ines_exit_module(void) |
| 1485 |
{ |
| 1486 |
gpib_unregister_driver(&ines_pci_interface); |
| 1487 |
gpib_unregister_driver(&ines_pci_unaccel_interface); |
| 1488 |
gpib_unregister_driver(&ines_pci_accel_interface); |
| 1489 |
gpib_unregister_driver(&ines_isa_interface); |
| 1490 |
#ifdef CONFIG_GPIB_PCMCIA |
| 1491 |
gpib_unregister_driver(&ines_pcmcia_interface); |
| 1492 |
gpib_unregister_driver(&ines_pcmcia_unaccel_interface); |
| 1493 |
gpib_unregister_driver(&ines_pcmcia_accel_interface); |
| 1494 |
ines_pcmcia_cleanup_module(); |
| 1495 |
#endif |
| 1496 |
|
| 1497 |
pci_unregister_driver(&ines_pci_driver); |
| 1498 |
} |
| 1499 |
|
| 1500 |
module_init(ines_init_module); |
| 1501 |
module_exit(ines_exit_module); |