32 #include "../comedidev.h"
39 #define PCI_VENDOR_ID_ADVANTECH 0x13fe
59 #define MAX_DI_SUBDEVS 2
60 #define MAX_DO_SUBDEVS 2
61 #define MAX_DIO_SUBDEVG 2
63 #define MAX_8254_SUBDEVS 1
71 #define PCIDIO_MAINREG 2
80 #define PCI1730_3_INT_EN 0x08
81 #define PCI1730_3_INT_RF 0x0c
83 #define PCI1730_3_INT_CLR 0x10
85 #define PCI173x_BOARDID 4
90 #define PCI1735_C8254 4
91 #define PCI1735_BOARDID 8
96 #define PCI1736_3_INT_EN 0x08
97 #define PCI1736_3_INT_RF 0x0c
99 #define PCI1736_3_INT_CLR 0x10
100 #define PCI1736_BOARDID 4
101 #define PCI1736_MAINREG 0
104 #define PCI1739_DIO 0
105 #define PCI1739_ICR 32
106 #define PCI1739_ISR 32
107 #define PCI1739_BOARDID 8
110 #define PCI1750_IDI 0
111 #define PCI1750_IDO 0
112 #define PCI1750_ICR 32
113 #define PCI1750_ISR 32
116 #define PCI1751_DIO 0
117 #define PCI1751_CNT 24
118 #define PCI1751_ICR 32
119 #define PCI1751_ISR 32
120 #define PCI1753_DIO 0
121 #define PCI1753_ICR0 16
122 #define PCI1753_ICR1 17
123 #define PCI1753_ICR2 18
124 #define PCI1753_ICR3 19
125 #define PCI1753E_DIO 32
126 #define PCI1753E_ICR0 48
127 #define PCI1753E_ICR1 49
128 #define PCI1753E_ICR2 50
129 #define PCI1753E_ICR3 51
132 #define PCI1752_IDO 0
133 #define PCI1752_IDO2 4
134 #define PCI1754_IDI 0
135 #define PCI1754_IDI2 4
136 #define PCI1756_IDI 0
137 #define PCI1756_IDO 4
138 #define PCI1754_6_ICR0 0x08
139 #define PCI1754_6_ICR1 0x0a
140 #define PCI1754_ICR2 0x0c
141 #define PCI1754_ICR3 0x0e
142 #define PCI1752_6_CFC 0x12
143 #define PCI175x_BOARDID 0x10
147 #define PCI1762_IDI 2
148 #define PCI1762_BOARDID 4
149 #define PCI1762_ICR 6
150 #define PCI1762_ISR 6
167 #define CMD_ClearIMB2 0x00
169 #define CMD_SetRelaysOutput 0x01
170 #define CMD_GetRelaysStatus 0x02
171 #define CMD_ReadCurrentStatus 0x07
173 #define CMD_ReadFirmwareVersion 0x0e
175 #define CMD_ReadHardwareVersion 0x0f
177 #define CMD_EnableIDIFilters 0x20
179 #define CMD_EnableIDIPatternMatch 0x21
181 #define CMD_SetIDIPatternMatch 0x22
183 #define CMD_EnableIDICounters 0x28
185 #define CMD_ResetIDICounters 0x29
187 #define CMD_OverflowIDICounters 0x2a
189 #define CMD_MatchIntIDICounters 0x2b
191 #define CMD_EdgeIDICounters 0x2c
193 #define CMD_GetIDICntCurValue 0x2f
195 #define CMD_SetIDI0CntResetValue 0x40
197 #define CMD_SetIDI1CntResetValue 0x41
199 #define CMD_SetIDI2CntResetValue 0x42
201 #define CMD_SetIDI3CntResetValue 0x43
203 #define CMD_SetIDI4CntResetValue 0x44
205 #define CMD_SetIDI5CntResetValue 0x45
207 #define CMD_SetIDI6CntResetValue 0x46
209 #define CMD_SetIDI7CntResetValue 0x47
211 #define CMD_SetIDI0CntMatchValue 0x48
213 #define CMD_SetIDI1CntMatchValue 0x49
215 #define CMD_SetIDI2CntMatchValue 0x4a
217 #define CMD_SetIDI3CntMatchValue 0x4b
219 #define CMD_SetIDI4CntMatchValue 0x4c
221 #define CMD_SetIDI5CntMatchValue 0x4d
223 #define CMD_SetIDI6CntMatchValue 0x4e
225 #define CMD_SetIDI7CntMatchValue 0x4f
228 #define OMBCMD_RETRY 0x03
396 .main_pci_region = 0,
480 s->
state &= ~data[0];
481 s->
state |= (data[0] & data[1]);
502 s->
state &= ~data[0];
503 s->
state |= (data[0] & data[1]);
526 chipchan = chan - (3 *
chip);
542 unsigned int chan,
chip, chipchan;
547 chipchan = chan - (3 *
chip);
550 0, chipchan, data[0]);
563 unsigned int chan,
chip, chipchan;
570 chipchan = chan - (3 *
chip);
575 ret = i8254_set_mode(iobase, 0, chipchan, data[1]);
580 data[1] = i8254_status(iobase, 0, chipchan);
587 return ret < 0 ?
ret : insn->
n;
593 static int pci1760_unchecked_mbxrequest(
struct comedi_device *dev,
594 unsigned char *omb,
unsigned char *imb,
597 int cnt, tout, ok = 0;
599 for (cnt = 0; cnt < repeats; cnt++) {
604 for (tout = 0; tout < 251; tout++) {
606 if (imb[2] == omb[2]) {
626 unsigned char imb[4];
630 return pci1760_unchecked_mbxrequest(dev, omb, imb,
OMBCMD_RETRY);
634 unsigned char *omb,
unsigned char *imb)
638 "bug! this function should not be used for CMD_ClearIMB2 command");
643 retval = pci1760_clear_imb2(dev);
647 return pci1760_unchecked_mbxrequest(dev, omb, imb,
OMBCMD_RETRY);
670 unsigned char omb[4] = {
676 unsigned char imb[4];
679 s->
state &= ~data[0];
680 s->
state |= (data[0] & data[1]);
682 ret = pci1760_mbxrequest(dev, omb, imb);
699 unsigned char omb[4] = {
705 unsigned char imb[4];
707 for (n = 0; n < insn->
n; n++) {
708 ret = pci1760_mbxrequest(dev, omb, imb);
711 data[
n] = (imb[1] << 8) + imb[0];
727 unsigned char bitmask = 1 << chan;
728 unsigned char omb[4] = {
730 (data[0] >> 8) & 0xff,
734 unsigned char imb[4];
737 if (devpriv->
CntResValue[chan] != (data[0] & 0xffff)) {
738 ret = pci1760_mbxrequest(dev, omb, imb);
746 ret = pci1760_mbxrequest(dev, omb, imb);
754 ret = pci1760_mbxrequest(dev, omb, imb);
769 unsigned char omb[4] = { 0x00, 0x00, 0x00, 0x00 };
770 unsigned char imb[4];
780 pci1760_mbxrequest(dev, omb, imb);
784 pci1760_mbxrequest(dev, omb, imb);
790 pci1760_mbxrequest(dev, omb, imb);
796 pci1760_mbxrequest(dev, omb, imb);
801 for (i = 0; i < 8; i++) {
803 pci1760_mbxrequest(dev, omb, imb);
809 for (i = 0; i < 8; i++) {
811 pci1760_mbxrequest(dev, omb, imb);
818 pci1760_mbxrequest(dev, omb, imb);
822 pci1760_mbxrequest(dev, omb, imb);
827 pci1760_mbxrequest(dev, omb, imb);
832 pci1760_mbxrequest(dev, omb, imb);
837 pci1760_mbxrequest(dev, omb, imb);
1080 static const void *pci_dio_find_boardinfo(
struct comedi_device *dev,
1087 this_board = &boardtypes[
i];
1103 comedi_set_hw_dev(dev, &pcidev->
dev);
1105 this_board = pci_dio_find_boardinfo(dev, pcidev);
1111 ret = alloc_private(dev,
sizeof(*devpriv));
1127 if (this_board->
sdi[i].chans) {
1129 pci_dio_add_di(dev, s, &this_board->
sdi[i]);
1134 if (this_board->
sdo[i].chans) {
1136 pci_dio_add_do(dev, s, &this_board->
sdo[i]);
1141 for (j = 0; j < this_board->
sdio[
i].regs; j++) {
1145 this_board->
sdio[i].addr +
1150 if (this_board->
boardid.chans) {
1153 pci_dio_add_di(dev, s, &this_board->
boardid);
1158 if (this_board->
s8254[i].chans) {
1160 pci_dio_add_8254(dev, s, &this_board->
s8254[i]);
1165 pci1760_attach(dev);
1177 struct pci_dev *pcidev = comedi_to_pci_dev(dev);
1200 .driver_name =
"adv_pci_dio",
1202 .attach_pci = pci_dio_attach_pci,
1203 .detach = pci_dio_detach,
1236 static struct pci_driver adv_pci_dio_pci_driver = {
1237 .name =
"adv_pci_dio",
1238 .id_table = adv_pci_dio_pci_table,
1239 .probe = adv_pci_dio_pci_probe,