57 #include "../comedidev.h"
63 #define PC236_DRIVER_NAME "amplc_pc236"
65 #define DO_ISA IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)
66 #define DO_PCI IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI)
69 #define PCI_VENDOR_ID_AMPLICON 0x14dc
70 #define PCI_DEVICE_ID_AMPLICON_PCI236 0x0009
71 #define PCI_DEVICE_ID_INVALID 0xffff
75 #define PC236_IO_SIZE 4
76 #define PC236_LCR_IO_SIZE 128
82 #define PCI236_INTR_DISABLE (PLX9052_INTCSR_LI1ENAB_DISABLED \
83 | PLX9052_INTCSR_LI1POL_HIGH \
84 | PLX9052_INTCSR_LI2POL_HIGH \
85 | PLX9052_INTCSR_PCIENAB_DISABLED \
86 | PLX9052_INTCSR_LI1SEL_EDGE \
87 | PLX9052_INTCSR_LI1CLRINT_ASSERTED)
89 #define PCI236_INTR_ENABLE (PLX9052_INTCSR_LI1ENAB_ENABLED \
90 | PLX9052_INTCSR_LI1POL_HIGH \
91 | PLX9052_INTCSR_LI2POL_HIGH \
92 | PLX9052_INTCSR_PCIENAB_ENABLED \
93 | PLX9052_INTCSR_LI1SEL_EDGE \
94 | PLX9052_INTCSR_LI1CLRINT_ASSERTED)
161 for (i = 0; i <
ARRAY_SIZE(pc236_boards); i++)
162 if (is_pci_board(&pc236_boards[i]) &&
164 return &pc236_boards[i];
176 struct pci_dev *pci_dev =
NULL;
182 if (bus != pci_dev->
bus->number ||
193 foundboard = pc236_find_pci_board(pci_dev);
194 if (foundboard ==
NULL)
206 "No supported board found! (req. bus %d, slot %d)\n",
233 const struct pc236_board *thisboard = comedi_board(dev);
239 if (is_pci_board(thisboard))
241 spin_unlock_irqrestore(&dev->
spinlock, flags);
251 const struct pc236_board *thisboard = comedi_board(dev);
257 if (is_pci_board(thisboard))
259 spin_unlock_irqrestore(&dev->
spinlock, flags);
271 const struct pc236_board *thisboard = comedi_board(dev);
279 if (is_pci_board(thisboard)) {
291 spin_unlock_irqrestore(&dev->
spinlock, flags);
374 pc236_intr_enable(dev);
385 pc236_intr_disable(dev);
400 handled = pc236_intr_check(dev);
409 static void pc236_report_attach(
struct comedi_device *dev,
unsigned int irq)
411 const struct pc236_board *thisboard = comedi_board(dev);
412 struct pci_dev *
pcidev = comedi_to_pci_dev(dev);
416 if (is_isa_board(thisboard))
417 tmplen =
scnprintf(tmpbuf,
sizeof(tmpbuf),
418 "(base %#lx) ", dev->
iobase);
419 else if (is_pci_board(thisboard))
420 tmplen =
scnprintf(tmpbuf,
sizeof(tmpbuf),
421 "(pci %s) ", pci_name(pcidev));
425 tmplen +=
scnprintf(&tmpbuf[tmplen],
sizeof(tmpbuf) - tmplen,
427 (dev->
irq ?
"" :
" UNAVAILABLE"));
429 tmplen +=
scnprintf(&tmpbuf[tmplen],
sizeof(tmpbuf) - tmplen,
436 unsigned int irq,
unsigned long req_irq_flags)
438 const struct pc236_board *thisboard = comedi_board(dev);
459 pc236_intr_disable(dev);
461 if (
request_irq(irq, pc236_interrupt, req_irq_flags,
471 s->
do_cmd = pc236_intr_cmd;
472 s->
cancel = pc236_intr_cancel;
475 pc236_report_attach(dev, irq);
479 static int pc236_pci_common_attach(
struct comedi_device *dev,
480 struct pci_dev *pci_dev)
486 comedi_set_hw_dev(dev, &pci_dev->
dev);
491 "error! cannot enable PCI device and request regions!\n");
496 return pc236_common_attach(dev, iobase, pci_dev->
irq,
IRQF_SHARED);
507 const struct pc236_board *thisboard = comedi_board(dev);
517 if (is_isa_board(thisboard)) {
518 unsigned long iobase = it->
options[0];
519 unsigned int irq = it->
options[1];
523 return pc236_common_attach(dev, iobase, irq, 0);
524 }
else if (is_pci_board(thisboard)) {
527 pci_dev = pc236_find_pci_dev(dev, it);
530 return pc236_pci_common_attach(dev, pci_dev);
533 ": BUG! cannot determine board type!\n");
544 struct pci_dev *pci_dev)
558 dev->
board_ptr = pc236_find_pci_board(pci_dev);
570 return pc236_pci_common_attach(dev, pci_dev);
575 const struct pc236_board *thisboard = comedi_board(dev);
580 pc236_intr_disable(dev);
585 if (is_isa_board(thisboard)) {
588 }
else if (is_pci_board(thisboard)) {
589 struct pci_dev *pcidev = comedi_to_pci_dev(dev);
607 .attach = pc236_attach,
608 .attach_pci = pc236_attach_pci,
609 .detach = pc236_detach,
610 .board_name = &pc236_boards[0].
name,
623 static int __devinit amplc_pc236_pci_probe(
struct pci_dev *dev,
629 static void __devexit amplc_pc236_pci_remove(
struct pci_dev *dev)
634 static struct pci_driver amplc_pc236_pci_driver = {
636 .id_table = pc236_pci_table,
637 .probe = &lc_pc236_pci_probe,