Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
addi_common.c
Go to the documentation of this file.
1 
24 /*
25 
26  +-----------------------------------------------------------------------+
27  | (C) ADDI-DATA GmbH Dieselstrasse 3 D-77833 Ottersweier |
28  +-----------------------------------------------------------------------+
29  | Tel : +49 (0) 7223/9493-0 | email : [email protected] |
30  | Fax : +49 (0) 7223/9493-92 | Internet : http://www.addi-data.com |
31  +-----------------------------------------------------------------------+
32  | Project : ADDI DATA | Compiler : GCC |
33  | Modulname : addi_common.c | Version : 2.96 |
34  +-------------------------------+---------------------------------------+
35  | Author : | Date : |
36  +-----------------------------------------------------------------------+
37  | Description : ADDI COMMON Main Module |
38  +-----------------------------------------------------------------------+
39  | CONFIG OPTIONS |
40  | option[0] - PCI bus number - if bus number and slot number are 0, |
41  | then driver search for first unused card |
42  | option[1] - PCI slot number |
43  | |
44  | option[2] = 0 - DMA ENABLE |
45  | = 1 - DMA DISABLE |
46  +----------+-----------+------------------------------------------------+
47 */
48 
49 #include <linux/kernel.h>
50 #include <linux/module.h>
51 #include <linux/sched.h>
52 #include <linux/mm.h>
53 #include <linux/errno.h>
54 #include <linux/ioport.h>
55 #include <linux/delay.h>
56 #include <linux/interrupt.h>
57 #include <linux/timex.h>
58 #include <linux/timer.h>
59 #include <linux/pci.h>
60 #include <linux/gfp.h>
61 #include <linux/io.h>
62 #include "../../comedidev.h"
63 #if defined(CONFIG_APCI_1710) || defined(CONFIG_APCI_3200) || defined(CONFIG_APCI_3300)
64 #include <asm/i387.h>
65 #endif
66 #include "../comedi_fc.h"
67 
68 #include "addi_common.h"
69 #include "addi_amcc_s5933.h"
70 
71 #ifndef ADDIDATA_DRIVER_NAME
72 #define ADDIDATA_DRIVER_NAME "addi_common"
73 #endif
74 
75 /* Update-0.7.57->0.7.68MODULE_AUTHOR("ADDI-DATA GmbH <[email protected]>"); */
76 /* Update-0.7.57->0.7.68MODULE_DESCRIPTION("Comedi ADDI-DATA module"); */
77 /* Update-0.7.57->0.7.68MODULE_LICENSE("GPL"); */
78 
79 #define devpriv ((struct addi_private *)dev->private)
80 #define this_board ((const struct addi_board *)dev->board_ptr)
81 
82 #if defined(CONFIG_APCI_1710) || defined(CONFIG_APCI_3200) || defined(CONFIG_APCI_3300)
83 /* BYTE b_SaveFPUReg [94]; */
84 
85 void fpu_begin(void)
86 {
87  /* asm ("fstenv b_SaveFPUReg"); */
88  kernel_fpu_begin();
89 }
90 
91 void fpu_end(void)
92 {
93  /* asm ("frstor b_SaveFPUReg"); */
95 }
96 #endif
97 
98 #include "addi_eeprom.c"
99 #if (defined (CONFIG_APCI_3120) || defined (CONFIG_APCI_3001))
100 #include "hwdrv_apci3120.c"
101 #endif
102 #ifdef CONFIG_APCI_1032
103 #include "hwdrv_apci1032.c"
104 #endif
105 #ifdef CONFIG_APCI_1516
106 #include "hwdrv_apci1516.c"
107 #endif
108 #ifdef CONFIG_APCI_2016
109 #include "hwdrv_apci2016.c"
110 #endif
111 #ifdef CONFIG_APCI_2032
112 #include "hwdrv_apci2032.c"
113 #endif
114 #ifdef CONFIG_APCI_2200
115 #include "hwdrv_apci2200.c"
116 #endif
117 #ifdef CONFIG_APCI_1564
118 #include "hwdrv_apci1564.c"
119 #endif
120 #ifdef CONFIG_APCI_1500
121 #include "hwdrv_apci1500.c"
122 #endif
123 #ifdef CONFIG_APCI_3501
124 #include "hwdrv_apci3501.c"
125 #endif
126 #ifdef CONFIG_APCI_035
127 #include "hwdrv_apci035.c"
128 #endif
129 #if (defined (CONFIG_APCI_3200) || defined (CONFIG_APCI_3300))
130 #include "hwdrv_apci3200.c"
131 #endif
132 #ifdef CONFIG_APCI_1710
133 #include "hwdrv_APCI1710.c"
134 #endif
135 #ifdef CONFIG_APCI_16XX
136 #include "hwdrv_apci16xx.c"
137 #endif
138 #ifdef CONFIG_APCI_3XXX
139 #include "hwdrv_apci3xxx.c"
140 #endif
141 
142 #ifndef COMEDI_SUBD_TTLIO
143 #define COMEDI_SUBD_TTLIO 11 /* Digital Input Output But TTL */
144 #endif
145 
146 static DEFINE_PCI_DEVICE_TABLE(addi_apci_tbl) = {
147 #ifdef CONFIG_APCI_3120
149 #endif
150 #ifdef CONFIG_APCI_1032
152 #endif
153 #ifdef CONFIG_APCI_1516
155 #endif
156 #ifdef CONFIG_APCI_2016
158 #endif
159 #ifdef CONFIG_APCI_2032
161 #endif
162 #ifdef CONFIG_APCI_2200
164 #endif
165 #ifdef CONFIG_APCI_1564
167 #endif
168 #ifdef CONFIG_APCI_1500
170 #endif
171 #ifdef CONFIG_APCI_3001
173 #endif
174 #ifdef CONFIG_APCI_3501
176 #endif
177 #ifdef CONFIG_APCI_035
179 #endif
180 #ifdef CONFIG_APCI_3200
182 #endif
183 #ifdef CONFIG_APCI_3300
185 #endif
186 #ifdef CONFIG_APCI_1710
188 #endif
189 #ifdef CONFIG_APCI_16XX
192 #endif
193 #ifdef CONFIG_APCI_3XXX
219 #endif
220  {0}
221 };
222 
223 MODULE_DEVICE_TABLE(pci, addi_apci_tbl);
224 
225 static const struct addi_board boardtypes[] = {
226 #ifdef CONFIG_APCI_3120
227  {
228  .pc_DriverName = "apci3120",
229  .i_VendorId = APCI3120_BOARD_VENDOR_ID,
230  .i_DeviceId = 0x818D,
231  .i_IorangeBase0 = AMCC_OP_REG_SIZE,
232  .i_IorangeBase1 = APCI3120_ADDRESS_RANGE,
233  .i_IorangeBase2 = 8,
234  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
235  .i_NbrAiChannel = 16,
236  .i_NbrAiChannelDiff = 8,
237  .i_AiChannelList = 16,
238  .i_NbrAoChannel = 8,
239  .i_AiMaxdata = 0xffff,
240  .i_AoMaxdata = 0x3fff,
241  .pr_AiRangelist = &range_apci3120_ai,
242  .pr_AoRangelist = &range_apci3120_ao,
243  .i_NbrDiChannel = 4,
244  .i_NbrDoChannel = 4,
245  .i_DoMaxdata = 0x0f,
246  .i_Dma = 1,
247  .i_Timer = 1,
248  .b_AvailableConvertUnit = 1,
249  .ui_MinAcquisitiontimeNs = 10000,
250  .ui_MinDelaytimeNs = 100000,
251  .interrupt = v_APCI3120_Interrupt,
252  .reset = i_APCI3120_Reset,
255  .ai_cmdtest = i_APCI3120_CommandTestAnalogInput,
264  .timer_config = i_APCI3120_InsnConfigTimer,
265  .timer_write = i_APCI3120_InsnWriteTimer,
266  .timer_read = i_APCI3120_InsnReadTimer,
267  },
268 #endif
269 #ifdef CONFIG_APCI_1032
270  {
271  .pc_DriverName = "apci1032",
272  .i_VendorId = APCI1032_BOARD_VENDOR_ID,
273  .i_DeviceId = 0x1003,
274  .i_IorangeBase0 = 4,
275  .i_IorangeBase1 = APCI1032_ADDRESS_RANGE,
276  .i_PCIEeprom = ADDIDATA_EEPROM,
277  .pc_EepromChip = ADDIDATA_93C76,
278  .i_NbrDiChannel = 32,
279  .interrupt = v_APCI1032_Interrupt,
280  .reset = i_APCI1032_Reset,
281  .di_config = i_APCI1032_ConfigDigitalInput,
282  .di_read = i_APCI1032_Read1DigitalInput,
284  },
285 #endif
286 #ifdef CONFIG_APCI_1516
287  {
288  .pc_DriverName = "apci1516",
289  .i_VendorId = APCI1516_BOARD_VENDOR_ID,
290  .i_DeviceId = 0x1001,
291  .i_IorangeBase0 = 128,
292  .i_IorangeBase1 = APCI1516_ADDRESS_RANGE,
293  .i_IorangeBase2 = 32,
294  .i_PCIEeprom = ADDIDATA_EEPROM,
295  .pc_EepromChip = ADDIDATA_S5920,
296  .i_NbrDiChannel = 8,
297  .i_NbrDoChannel = 8,
298  .i_Timer = 1,
299  .reset = i_APCI1516_Reset,
300  .di_read = i_APCI1516_Read1DigitalInput,
302  .do_config = i_APCI1516_ConfigDigitalOutput,
303  .do_write = i_APCI1516_WriteDigitalOutput,
304  .do_bits = i_APCI1516_ReadDigitalOutput,
305  .timer_config = i_APCI1516_ConfigWatchdog,
306  .timer_write = i_APCI1516_StartStopWriteWatchdog,
307  .timer_read = i_APCI1516_ReadWatchdog,
308  },
309 #endif
310 #ifdef CONFIG_APCI_2016
311  {
312  .pc_DriverName = "apci2016",
313  .i_VendorId = APCI2016_BOARD_VENDOR_ID,
314  .i_DeviceId = 0x1002,
315  .i_IorangeBase0 = 128,
316  .i_IorangeBase1 = APCI2016_ADDRESS_RANGE,
317  .i_IorangeBase2 = 32,
318  .i_PCIEeprom = ADDIDATA_EEPROM,
319  .pc_EepromChip = ADDIDATA_S5920,
320  .i_NbrDoChannel = 16,
321  .i_Timer = 1,
322  .reset = i_APCI2016_Reset,
323  .do_config = i_APCI2016_ConfigDigitalOutput,
324  .do_write = i_APCI2016_WriteDigitalOutput,
325  .do_bits = i_APCI2016_BitsDigitalOutput,
326  .timer_config = i_APCI2016_ConfigWatchdog,
327  .timer_write = i_APCI2016_StartStopWriteWatchdog,
328  .timer_read = i_APCI2016_ReadWatchdog,
329  },
330 #endif
331 #ifdef CONFIG_APCI_2032
332  {
333  .pc_DriverName = "apci2032",
334  .i_VendorId = APCI2032_BOARD_VENDOR_ID,
335  .i_DeviceId = 0x1004,
336  .i_IorangeBase0 = 4,
337  .i_IorangeBase1 = APCI2032_ADDRESS_RANGE,
338  .i_PCIEeprom = ADDIDATA_EEPROM,
339  .pc_EepromChip = ADDIDATA_93C76,
340  .i_NbrDoChannel = 32,
341  .i_DoMaxdata = 0xffffffff,
342  .i_Timer = 1,
343  .interrupt = v_APCI2032_Interrupt,
344  .reset = i_APCI2032_Reset,
345  .do_config = i_APCI2032_ConfigDigitalOutput,
346  .do_write = i_APCI2032_WriteDigitalOutput,
347  .do_bits = i_APCI2032_ReadDigitalOutput,
349  .timer_config = i_APCI2032_ConfigWatchdog,
350  .timer_write = i_APCI2032_StartStopWriteWatchdog,
351  .timer_read = i_APCI2032_ReadWatchdog,
352  },
353 #endif
354 #ifdef CONFIG_APCI_2200
355  {
356  .pc_DriverName = "apci2200",
357  .i_VendorId = APCI2200_BOARD_VENDOR_ID,
358  .i_DeviceId = 0x1005,
359  .i_IorangeBase0 = 4,
360  .i_IorangeBase1 = APCI2200_ADDRESS_RANGE,
361  .i_PCIEeprom = ADDIDATA_EEPROM,
362  .pc_EepromChip = ADDIDATA_93C76,
363  .i_NbrDiChannel = 8,
364  .i_NbrDoChannel = 16,
365  .i_Timer = 1,
366  .reset = i_APCI2200_Reset,
367  .di_read = i_APCI2200_Read1DigitalInput,
369  .do_config = i_APCI2200_ConfigDigitalOutput,
370  .do_write = i_APCI2200_WriteDigitalOutput,
371  .do_bits = i_APCI2200_ReadDigitalOutput,
372  .timer_config = i_APCI2200_ConfigWatchdog,
373  .timer_write = i_APCI2200_StartStopWriteWatchdog,
374  .timer_read = i_APCI2200_ReadWatchdog,
375  },
376 #endif
377 #ifdef CONFIG_APCI_1564
378  {
379  .pc_DriverName = "apci1564",
380  .i_VendorId = APCI1564_BOARD_VENDOR_ID,
381  .i_DeviceId = 0x1006,
382  .i_IorangeBase0 = 128,
383  .i_IorangeBase1 = APCI1564_ADDRESS_RANGE,
384  .i_PCIEeprom = ADDIDATA_EEPROM,
385  .pc_EepromChip = ADDIDATA_93C76,
386  .i_NbrDiChannel = 32,
387  .i_NbrDoChannel = 32,
388  .i_DoMaxdata = 0xffffffff,
389  .i_Timer = 1,
390  .interrupt = v_APCI1564_Interrupt,
391  .reset = i_APCI1564_Reset,
392  .di_config = i_APCI1564_ConfigDigitalInput,
393  .di_read = i_APCI1564_Read1DigitalInput,
395  .do_config = i_APCI1564_ConfigDigitalOutput,
396  .do_write = i_APCI1564_WriteDigitalOutput,
397  .do_bits = i_APCI1564_ReadDigitalOutput,
402  },
403 #endif
404 #ifdef CONFIG_APCI_1500
405  {
406  .pc_DriverName = "apci1500",
407  .i_VendorId = APCI1500_BOARD_VENDOR_ID,
408  .i_DeviceId = 0x80fc,
409  .i_IorangeBase0 = 128,
410  .i_IorangeBase1 = APCI1500_ADDRESS_RANGE,
411  .i_IorangeBase2 = 4,
412  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
413  .i_NbrDiChannel = 16,
414  .i_NbrDoChannel = 16,
415  .i_DoMaxdata = 0xffff,
416  .i_Timer = 1,
417  .interrupt = v_APCI1500_Interrupt,
418  .reset = i_APCI1500_Reset,
419  .di_config = i_APCI1500_ConfigDigitalInputEvent,
420  .di_read = i_APCI1500_Initialisation,
421  .di_write = i_APCI1500_StartStopInputEvent,
422  .di_bits = i_APCI1500_ReadMoreDigitalInput,
423  .do_config = i_APCI1500_ConfigDigitalOutputErrorInterrupt,
424  .do_write = i_APCI1500_WriteDigitalOutput,
425  .do_bits = i_APCI1500_ConfigureInterrupt,
426  .timer_config = i_APCI1500_ConfigCounterTimerWatchdog,
427  .timer_write = i_APCI1500_StartStopTriggerTimerCounterWatchdog,
428  .timer_read = i_APCI1500_ReadInterruptMask,
429  .timer_bits = i_APCI1500_ReadCounterTimerWatchdog,
430  },
431 #endif
432 #ifdef CONFIG_APCI_3001
433  {
434  .pc_DriverName = "apci3001",
435  .i_VendorId = APCI3120_BOARD_VENDOR_ID,
436  .i_DeviceId = 0x828D,
437  .i_IorangeBase0 = AMCC_OP_REG_SIZE,
438  .i_IorangeBase1 = APCI3120_ADDRESS_RANGE,
439  .i_IorangeBase2 = 8,
440  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
441  .i_NbrAiChannel = 16,
442  .i_NbrAiChannelDiff = 8,
443  .i_AiChannelList = 16,
444  .i_AiMaxdata = 0xfff,
445  .pr_AiRangelist = &range_apci3120_ai,
446  .i_NbrDiChannel = 4,
447  .i_NbrDoChannel = 4,
448  .i_DoMaxdata = 0x0f,
449  .i_Dma = 1,
450  .i_Timer = 1,
451  .b_AvailableConvertUnit = 1,
452  .ui_MinAcquisitiontimeNs = 10000,
453  .ui_MinDelaytimeNs = 100000,
454  .interrupt = v_APCI3120_Interrupt,
455  .reset = i_APCI3120_Reset,
458  .ai_cmdtest = i_APCI3120_CommandTestAnalogInput,
466  .timer_config = i_APCI3120_InsnConfigTimer,
467  .timer_write = i_APCI3120_InsnWriteTimer,
468  .timer_read = i_APCI3120_InsnReadTimer,
469  },
470 #endif
471 #ifdef CONFIG_APCI_3501
472  {
473  .pc_DriverName = "apci3501",
474  .i_VendorId = APCI3501_BOARD_VENDOR_ID,
475  .i_DeviceId = 0x3001,
476  .i_IorangeBase0 = 64,
477  .i_IorangeBase1 = APCI3501_ADDRESS_RANGE,
478  .i_PCIEeprom = ADDIDATA_EEPROM,
479  .pc_EepromChip = ADDIDATA_S5933,
480  .i_AoMaxdata = 16383,
481  .pr_AoRangelist = &range_apci3501_ao,
482  .i_NbrDiChannel = 2,
483  .i_NbrDoChannel = 2,
484  .i_DoMaxdata = 0x3,
485  .i_Timer = 1,
486  .interrupt = v_APCI3501_Interrupt,
487  .reset = i_APCI3501_Reset,
488  .ao_config = i_APCI3501_ConfigAnalogOutput,
489  .ao_write = i_APCI3501_WriteAnalogOutput,
490  .di_bits = i_APCI3501_ReadDigitalInput,
491  .do_config = i_APCI3501_ConfigDigitalOutput,
492  .do_write = i_APCI3501_WriteDigitalOutput,
493  .do_bits = i_APCI3501_ReadDigitalOutput,
497  },
498 #endif
499 #ifdef CONFIG_APCI_035
500  {
501  .pc_DriverName = "apci035",
502  .i_VendorId = APCI035_BOARD_VENDOR_ID,
503  .i_DeviceId = 0x0300,
504  .i_IorangeBase0 = 127,
505  .i_IorangeBase1 = APCI035_ADDRESS_RANGE,
506  .i_PCIEeprom = 1,
507  .pc_EepromChip = ADDIDATA_S5920,
508  .i_NbrAiChannel = 16,
509  .i_NbrAiChannelDiff = 8,
510  .i_AiChannelList = 16,
511  .i_AiMaxdata = 0xff,
512  .pr_AiRangelist = &range_apci035_ai,
513  .i_Timer = 1,
514  .ui_MinAcquisitiontimeNs = 10000,
515  .ui_MinDelaytimeNs = 100000,
516  .interrupt = v_APCI035_Interrupt,
517  .reset = i_APCI035_Reset,
518  .ai_config = i_APCI035_ConfigAnalogInput,
519  .ai_read = i_APCI035_ReadAnalogInput,
520  .timer_config = i_APCI035_ConfigTimerWatchdog,
522  .timer_read = i_APCI035_ReadTimerWatchdog,
523  },
524 #endif
525 #ifdef CONFIG_APCI_3200
526  {
527  .pc_DriverName = "apci3200",
528  .i_VendorId = APCI3200_BOARD_VENDOR_ID,
529  .i_DeviceId = 0x3000,
530  .i_IorangeBase0 = 128,
531  .i_IorangeBase1 = 256,
532  .i_IorangeBase2 = 4,
533  .i_IorangeBase3 = 4,
534  .i_PCIEeprom = ADDIDATA_EEPROM,
535  .pc_EepromChip = ADDIDATA_S5920,
536  .i_NbrAiChannel = 16,
537  .i_NbrAiChannelDiff = 8,
538  .i_AiChannelList = 16,
539  .i_AiMaxdata = 0x3ffff,
540  .pr_AiRangelist = &range_apci3200_ai,
541  .i_NbrDiChannel = 4,
542  .i_NbrDoChannel = 4,
543  .ui_MinAcquisitiontimeNs = 10000,
544  .ui_MinDelaytimeNs = 100000,
545  .interrupt = v_APCI3200_Interrupt,
546  .reset = i_APCI3200_Reset,
547  .ai_config = i_APCI3200_ConfigAnalogInput,
548  .ai_read = i_APCI3200_ReadAnalogInput,
551  .ai_cmdtest = i_APCI3200_CommandTestAnalogInput,
554  .di_bits = i_APCI3200_ReadDigitalInput,
555  .do_config = i_APCI3200_ConfigDigitalOutput,
556  .do_write = i_APCI3200_WriteDigitalOutput,
557  .do_bits = i_APCI3200_ReadDigitalOutput,
558  },
559 #endif
560 #ifdef CONFIG_APCI_3300
561  /* Begin JK .20.10.2004 = APCI-3300 integration */
562  {
563  .pc_DriverName = "apci3300",
564  .i_VendorId = APCI3200_BOARD_VENDOR_ID,
565  .i_DeviceId = 0x3007,
566  .i_IorangeBase0 = 128,
567  .i_IorangeBase1 = 256,
568  .i_IorangeBase2 = 4,
569  .i_IorangeBase3 = 4,
570  .i_PCIEeprom = ADDIDATA_EEPROM,
571  .pc_EepromChip = ADDIDATA_S5920,
572  .i_NbrAiChannelDiff = 8,
573  .i_AiChannelList = 8,
574  .i_AiMaxdata = 0x3ffff,
575  .pr_AiRangelist = &range_apci3300_ai,
576  .i_NbrDiChannel = 4,
577  .i_NbrDoChannel = 4,
578  .ui_MinAcquisitiontimeNs = 10000,
579  .ui_MinDelaytimeNs = 100000,
580  .interrupt = v_APCI3200_Interrupt,
581  .reset = i_APCI3200_Reset,
582  .ai_config = i_APCI3200_ConfigAnalogInput,
583  .ai_read = i_APCI3200_ReadAnalogInput,
586  .ai_cmdtest = i_APCI3200_CommandTestAnalogInput,
589  .di_bits = i_APCI3200_ReadDigitalInput,
590  .do_config = i_APCI3200_ConfigDigitalOutput,
591  .do_write = i_APCI3200_WriteDigitalOutput,
592  .do_bits = i_APCI3200_ReadDigitalOutput,
593  },
594 #endif
595 #ifdef CONFIG_APCI_1710
596  {
597  .pc_DriverName = "apci1710",
598  .i_VendorId = APCI1710_BOARD_VENDOR_ID,
599  .i_DeviceId = APCI1710_BOARD_DEVICE_ID,
600  .i_IorangeBase0 = 128,
601  .i_IorangeBase1 = 8,
602  .i_IorangeBase2 = 256,
603  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
604  .interrupt = v_APCI1710_Interrupt,
605  .reset = i_APCI1710_Reset,
606  },
607 #endif
608 #ifdef CONFIG_APCI_16XX
609  {
610  .pc_DriverName = "apci1648",
611  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
612  .i_DeviceId = 0x1009,
613  .i_IorangeBase0 = 128,
614  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
615  .i_NbrTTLChannel = 48,
616  .reset = i_APCI16XX_Reset,
617  .ttl_config = i_APCI16XX_InsnConfigInitTTLIO,
618  .ttl_bits = i_APCI16XX_InsnBitsReadTTLIO,
620  .ttl_write = i_APCI16XX_InsnBitsWriteTTLIO,
621  }, {
622  .pc_DriverName = "apci1696",
623  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
624  .i_DeviceId = 0x100A,
625  .i_IorangeBase0 = 128,
626  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
627  .i_NbrTTLChannel = 96,
628  .reset = i_APCI16XX_Reset,
629  .ttl_config = i_APCI16XX_InsnConfigInitTTLIO,
630  .ttl_bits = i_APCI16XX_InsnBitsReadTTLIO,
632  .ttl_write = i_APCI16XX_InsnBitsWriteTTLIO,
633  },
634 #endif
635 #ifdef CONFIG_APCI_3XXX
636  {
637  .pc_DriverName = "apci3000-16",
638  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
639  .i_DeviceId = 0x3010,
640  .i_IorangeBase0 = 256,
641  .i_IorangeBase1 = 256,
642  .i_IorangeBase2 = 256,
643  .i_IorangeBase3 = 256,
644  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
645  .pc_EepromChip = ADDIDATA_9054,
646  .i_NbrAiChannel = 16,
647  .i_NbrAiChannelDiff = 8,
648  .i_AiChannelList = 16,
649  .i_AiMaxdata = 4095,
650  .pr_AiRangelist = &range_apci3XXX_ai,
651  .i_NbrTTLChannel = 24,
652  .b_AvailableConvertUnit = 6,
653  .ui_MinAcquisitiontimeNs = 10000,
654  .interrupt = v_APCI3XXX_Interrupt,
655  .reset = i_APCI3XXX_Reset,
656  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
657  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
658  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
659  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
660  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
661  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
662  }, {
663  .pc_DriverName = "apci3000-8",
664  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
665  .i_DeviceId = 0x300F,
666  .i_IorangeBase0 = 256,
667  .i_IorangeBase1 = 256,
668  .i_IorangeBase2 = 256,
669  .i_IorangeBase3 = 256,
670  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
671  .pc_EepromChip = ADDIDATA_9054,
672  .i_NbrAiChannel = 8,
673  .i_NbrAiChannelDiff = 4,
674  .i_AiChannelList = 8,
675  .i_AiMaxdata = 4095,
676  .pr_AiRangelist = &range_apci3XXX_ai,
677  .i_NbrTTLChannel = 24,
678  .b_AvailableConvertUnit = 6,
679  .ui_MinAcquisitiontimeNs = 10000,
680  .interrupt = v_APCI3XXX_Interrupt,
681  .reset = i_APCI3XXX_Reset,
682  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
683  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
684  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
685  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
686  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
687  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
688  }, {
689  .pc_DriverName = "apci3000-4",
690  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
691  .i_DeviceId = 0x300E,
692  .i_IorangeBase0 = 256,
693  .i_IorangeBase1 = 256,
694  .i_IorangeBase2 = 256,
695  .i_IorangeBase3 = 256,
696  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
697  .pc_EepromChip = ADDIDATA_9054,
698  .i_NbrAiChannel = 4,
699  .i_NbrAiChannelDiff = 2,
700  .i_AiChannelList = 4,
701  .i_AiMaxdata = 4095,
702  .pr_AiRangelist = &range_apci3XXX_ai,
703  .i_NbrTTLChannel = 24,
704  .b_AvailableConvertUnit = 6,
705  .ui_MinAcquisitiontimeNs = 10000,
706  .interrupt = v_APCI3XXX_Interrupt,
707  .reset = i_APCI3XXX_Reset,
708  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
709  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
710  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
711  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
712  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
713  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
714  }, {
715  .pc_DriverName = "apci3006-16",
716  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
717  .i_DeviceId = 0x3013,
718  .i_IorangeBase0 = 256,
719  .i_IorangeBase1 = 256,
720  .i_IorangeBase2 = 256,
721  .i_IorangeBase3 = 256,
722  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
723  .pc_EepromChip = ADDIDATA_9054,
724  .i_NbrAiChannel = 16,
725  .i_NbrAiChannelDiff = 8,
726  .i_AiChannelList = 16,
727  .i_AiMaxdata = 65535,
728  .pr_AiRangelist = &range_apci3XXX_ai,
729  .i_NbrTTLChannel = 24,
730  .b_AvailableConvertUnit = 6,
731  .ui_MinAcquisitiontimeNs = 10000,
732  .interrupt = v_APCI3XXX_Interrupt,
733  .reset = i_APCI3XXX_Reset,
734  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
735  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
736  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
737  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
738  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
739  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
740  }, {
741  .pc_DriverName = "apci3006-8",
742  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
743  .i_DeviceId = 0x3014,
744  .i_IorangeBase0 = 256,
745  .i_IorangeBase1 = 256,
746  .i_IorangeBase2 = 256,
747  .i_IorangeBase3 = 256,
748  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
749  .pc_EepromChip = ADDIDATA_9054,
750  .i_NbrAiChannel = 8,
751  .i_NbrAiChannelDiff = 4,
752  .i_AiChannelList = 8,
753  .i_AiMaxdata = 65535,
754  .pr_AiRangelist = &range_apci3XXX_ai,
755  .i_NbrTTLChannel = 24,
756  .b_AvailableConvertUnit = 6,
757  .ui_MinAcquisitiontimeNs = 10000,
758  .interrupt = v_APCI3XXX_Interrupt,
759  .reset = i_APCI3XXX_Reset,
760  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
761  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
762  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
763  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
764  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
765  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
766  }, {
767  .pc_DriverName = "apci3006-4",
768  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
769  .i_DeviceId = 0x3015,
770  .i_IorangeBase0 = 256,
771  .i_IorangeBase1 = 256,
772  .i_IorangeBase2 = 256,
773  .i_IorangeBase3 = 256,
774  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
775  .pc_EepromChip = ADDIDATA_9054,
776  .i_NbrAiChannel = 4,
777  .i_NbrAiChannelDiff = 2,
778  .i_AiChannelList = 4,
779  .i_AiMaxdata = 65535,
780  .pr_AiRangelist = &range_apci3XXX_ai,
781  .i_NbrTTLChannel = 24,
782  .b_AvailableConvertUnit = 6,
783  .ui_MinAcquisitiontimeNs = 10000,
784  .interrupt = v_APCI3XXX_Interrupt,
785  .reset = i_APCI3XXX_Reset,
786  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
787  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
788  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
789  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
790  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
791  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
792  }, {
793  .pc_DriverName = "apci3010-16",
794  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
795  .i_DeviceId = 0x3016,
796  .i_IorangeBase0 = 256,
797  .i_IorangeBase1 = 256,
798  .i_IorangeBase2 = 256,
799  .i_IorangeBase3 = 256,
800  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
801  .pc_EepromChip = ADDIDATA_9054,
802  .i_NbrAiChannel = 16,
803  .i_NbrAiChannelDiff = 8,
804  .i_AiChannelList = 16,
805  .i_AiMaxdata = 4095,
806  .pr_AiRangelist = &range_apci3XXX_ai,
807  .i_NbrDiChannel = 4,
808  .i_NbrDoChannel = 4,
809  .i_DoMaxdata = 1,
810  .i_NbrTTLChannel = 24,
811  .b_AvailableConvertUnit = 6,
812  .ui_MinAcquisitiontimeNs = 5000,
813  .interrupt = v_APCI3XXX_Interrupt,
814  .reset = i_APCI3XXX_Reset,
815  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
816  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
817  .di_read = i_APCI3XXX_InsnReadDigitalInput,
818  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
819  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
820  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
821  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
822  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
823  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
824  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
825  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
826  }, {
827  .pc_DriverName = "apci3010-8",
828  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
829  .i_DeviceId = 0x3017,
830  .i_IorangeBase0 = 256,
831  .i_IorangeBase1 = 256,
832  .i_IorangeBase2 = 256,
833  .i_IorangeBase3 = 256,
834  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
835  .pc_EepromChip = ADDIDATA_9054,
836  .i_NbrAiChannel = 8,
837  .i_NbrAiChannelDiff = 4,
838  .i_AiChannelList = 8,
839  .i_AiMaxdata = 4095,
840  .pr_AiRangelist = &range_apci3XXX_ai,
841  .i_NbrDiChannel = 4,
842  .i_NbrDoChannel = 4,
843  .i_DoMaxdata = 1,
844  .i_NbrTTLChannel = 24,
845  .b_AvailableConvertUnit = 6,
846  .ui_MinAcquisitiontimeNs = 5000,
847  .interrupt = v_APCI3XXX_Interrupt,
848  .reset = i_APCI3XXX_Reset,
849  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
850  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
851  .di_read = i_APCI3XXX_InsnReadDigitalInput,
852  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
853  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
854  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
855  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
856  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
857  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
858  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
859  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
860  }, {
861  .pc_DriverName = "apci3010-4",
862  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
863  .i_DeviceId = 0x3018,
864  .i_IorangeBase0 = 256,
865  .i_IorangeBase1 = 256,
866  .i_IorangeBase2 = 256,
867  .i_IorangeBase3 = 256,
868  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
869  .pc_EepromChip = ADDIDATA_9054,
870  .i_NbrAiChannel = 4,
871  .i_NbrAiChannelDiff = 2,
872  .i_AiChannelList = 4,
873  .i_AiMaxdata = 4095,
874  .pr_AiRangelist = &range_apci3XXX_ai,
875  .i_NbrDiChannel = 4,
876  .i_NbrDoChannel = 4,
877  .i_DoMaxdata = 1,
878  .i_NbrTTLChannel = 24,
879  .b_AvailableConvertUnit = 6,
880  .ui_MinAcquisitiontimeNs = 5000,
881  .interrupt = v_APCI3XXX_Interrupt,
882  .reset = i_APCI3XXX_Reset,
883  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
884  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
885  .di_read = i_APCI3XXX_InsnReadDigitalInput,
886  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
887  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
888  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
889  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
890  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
891  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
892  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
893  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
894  }, {
895  .pc_DriverName = "apci3016-16",
896  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
897  .i_DeviceId = 0x3019,
898  .i_IorangeBase0 = 256,
899  .i_IorangeBase1 = 256,
900  .i_IorangeBase2 = 256,
901  .i_IorangeBase3 = 256,
902  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
903  .pc_EepromChip = ADDIDATA_9054,
904  .i_NbrAiChannel = 16,
905  .i_NbrAiChannelDiff = 8,
906  .i_AiChannelList = 16,
907  .i_AiMaxdata = 65535,
908  .pr_AiRangelist = &range_apci3XXX_ai,
909  .i_NbrDiChannel = 4,
910  .i_NbrDoChannel = 4,
911  .i_DoMaxdata = 1,
912  .i_NbrTTLChannel = 24,
913  .b_AvailableConvertUnit = 6,
914  .ui_MinAcquisitiontimeNs = 5000,
915  .interrupt = v_APCI3XXX_Interrupt,
916  .reset = i_APCI3XXX_Reset,
917  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
918  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
919  .di_read = i_APCI3XXX_InsnReadDigitalInput,
920  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
921  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
922  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
923  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
924  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
925  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
926  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
927  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
928  }, {
929  .pc_DriverName = "apci3016-8",
930  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
931  .i_DeviceId = 0x301A,
932  .i_IorangeBase0 = 256,
933  .i_IorangeBase1 = 256,
934  .i_IorangeBase2 = 256,
935  .i_IorangeBase3 = 256,
936  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
937  .pc_EepromChip = ADDIDATA_9054,
938  .i_NbrAiChannel = 8,
939  .i_NbrAiChannelDiff = 4,
940  .i_AiChannelList = 8,
941  .i_AiMaxdata = 65535,
942  .pr_AiRangelist = &range_apci3XXX_ai,
943  .i_NbrDiChannel = 4,
944  .i_NbrDoChannel = 4,
945  .i_DoMaxdata = 1,
946  .i_NbrTTLChannel = 24,
947  .b_AvailableConvertUnit = 6,
948  .ui_MinAcquisitiontimeNs = 5000,
949  .interrupt = v_APCI3XXX_Interrupt,
950  .reset = i_APCI3XXX_Reset,
951  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
952  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
953  .di_read = i_APCI3XXX_InsnReadDigitalInput,
954  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
955  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
956  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
957  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
958  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
959  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
960  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
961  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
962  }, {
963  .pc_DriverName = "apci3016-4",
964  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
965  .i_DeviceId = 0x301B,
966  .i_IorangeBase0 = 256,
967  .i_IorangeBase1 = 256,
968  .i_IorangeBase2 = 256,
969  .i_IorangeBase3 = 256,
970  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
971  .pc_EepromChip = ADDIDATA_9054,
972  .i_NbrAiChannel = 4,
973  .i_NbrAiChannelDiff = 2,
974  .i_AiChannelList = 4,
975  .i_AiMaxdata = 65535,
976  .pr_AiRangelist = &range_apci3XXX_ai,
977  .i_NbrDiChannel = 4,
978  .i_NbrDoChannel = 4,
979  .i_DoMaxdata = 1,
980  .i_NbrTTLChannel = 24,
981  .b_AvailableConvertUnit = 6,
982  .ui_MinAcquisitiontimeNs = 5000,
983  .interrupt = v_APCI3XXX_Interrupt,
984  .reset = i_APCI3XXX_Reset,
985  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
986  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
987  .di_read = i_APCI3XXX_InsnReadDigitalInput,
988  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
989  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
990  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
991  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
992  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
993  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
994  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
995  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
996  }, {
997  .pc_DriverName = "apci3100-16-4",
998  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
999  .i_DeviceId = 0x301C,
1000  .i_IorangeBase0 = 256,
1001  .i_IorangeBase1 = 256,
1002  .i_IorangeBase2 = 256,
1003  .i_IorangeBase3 = 256,
1004  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1005  .pc_EepromChip = ADDIDATA_9054,
1006  .i_NbrAiChannel = 16,
1007  .i_NbrAiChannelDiff = 8,
1008  .i_AiChannelList = 16,
1009  .i_NbrAoChannel = 4,
1010  .i_AiMaxdata = 4095,
1011  .i_AoMaxdata = 4095,
1012  .pr_AiRangelist = &range_apci3XXX_ai,
1013  .pr_AoRangelist = &range_apci3XXX_ao,
1014  .i_NbrTTLChannel = 24,
1015  .b_AvailableConvertUnit = 6,
1016  .ui_MinAcquisitiontimeNs = 10000,
1017  .interrupt = v_APCI3XXX_Interrupt,
1018  .reset = i_APCI3XXX_Reset,
1019  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1020  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1021  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1022  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1023  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1024  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1025  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1026  }, {
1027  .pc_DriverName = "apci3100-8-4",
1028  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1029  .i_DeviceId = 0x301D,
1030  .i_IorangeBase0 = 256,
1031  .i_IorangeBase1 = 256,
1032  .i_IorangeBase2 = 256,
1033  .i_IorangeBase3 = 256,
1034  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1035  .pc_EepromChip = ADDIDATA_9054,
1036  .i_NbrAiChannel = 8,
1037  .i_NbrAiChannelDiff = 4,
1038  .i_AiChannelList = 8,
1039  .i_NbrAoChannel = 4,
1040  .i_AiMaxdata = 4095,
1041  .i_AoMaxdata = 4095,
1042  .pr_AiRangelist = &range_apci3XXX_ai,
1043  .pr_AoRangelist = &range_apci3XXX_ao,
1044  .i_NbrTTLChannel = 24,
1045  .b_AvailableConvertUnit = 6,
1046  .ui_MinAcquisitiontimeNs = 10000,
1047  .interrupt = v_APCI3XXX_Interrupt,
1048  .reset = i_APCI3XXX_Reset,
1049  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1050  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1051  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1052  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1053  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1054  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1055  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1056  }, {
1057  .pc_DriverName = "apci3106-16-4",
1058  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1059  .i_DeviceId = 0x301E,
1060  .i_IorangeBase0 = 256,
1061  .i_IorangeBase1 = 256,
1062  .i_IorangeBase2 = 256,
1063  .i_IorangeBase3 = 256,
1064  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1065  .pc_EepromChip = ADDIDATA_9054,
1066  .i_NbrAiChannel = 16,
1067  .i_NbrAiChannelDiff = 8,
1068  .i_AiChannelList = 16,
1069  .i_NbrAoChannel = 4,
1070  .i_AiMaxdata = 65535,
1071  .i_AoMaxdata = 4095,
1072  .pr_AiRangelist = &range_apci3XXX_ai,
1073  .pr_AoRangelist = &range_apci3XXX_ao,
1074  .i_NbrTTLChannel = 24,
1075  .b_AvailableConvertUnit = 6,
1076  .ui_MinAcquisitiontimeNs = 10000,
1077  .interrupt = v_APCI3XXX_Interrupt,
1078  .reset = i_APCI3XXX_Reset,
1079  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1080  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1081  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1082  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1083  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1084  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1085  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1086  }, {
1087  .pc_DriverName = "apci3106-8-4",
1088  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1089  .i_DeviceId = 0x301F,
1090  .i_IorangeBase0 = 256,
1091  .i_IorangeBase1 = 256,
1092  .i_IorangeBase2 = 256,
1093  .i_IorangeBase3 = 256,
1094  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1095  .pc_EepromChip = ADDIDATA_9054,
1096  .i_NbrAiChannel = 8,
1097  .i_NbrAiChannelDiff = 4,
1098  .i_AiChannelList = 8,
1099  .i_NbrAoChannel = 4,
1100  .i_AiMaxdata = 65535,
1101  .i_AoMaxdata = 4095,
1102  .pr_AiRangelist = &range_apci3XXX_ai,
1103  .pr_AoRangelist = &range_apci3XXX_ao,
1104  .i_NbrTTLChannel = 24,
1105  .b_AvailableConvertUnit = 6,
1106  .ui_MinAcquisitiontimeNs = 10000,
1107  .interrupt = v_APCI3XXX_Interrupt,
1108  .reset = i_APCI3XXX_Reset,
1109  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1110  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1111  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1112  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1113  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1114  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1115  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1116  }, {
1117  .pc_DriverName = "apci3110-16-4",
1118  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1119  .i_DeviceId = 0x3020,
1120  .i_IorangeBase0 = 256,
1121  .i_IorangeBase1 = 256,
1122  .i_IorangeBase2 = 256,
1123  .i_IorangeBase3 = 256,
1124  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1125  .pc_EepromChip = ADDIDATA_9054,
1126  .i_NbrAiChannel = 16,
1127  .i_NbrAiChannelDiff = 8,
1128  .i_AiChannelList = 16,
1129  .i_NbrAoChannel = 4,
1130  .i_AiMaxdata = 4095,
1131  .i_AoMaxdata = 4095,
1132  .pr_AiRangelist = &range_apci3XXX_ai,
1133  .pr_AoRangelist = &range_apci3XXX_ao,
1134  .i_NbrDiChannel = 4,
1135  .i_NbrDoChannel = 4,
1136  .i_DoMaxdata = 1,
1137  .i_NbrTTLChannel = 24,
1138  .b_AvailableConvertUnit = 6,
1139  .ui_MinAcquisitiontimeNs = 5000,
1140  .interrupt = v_APCI3XXX_Interrupt,
1141  .reset = i_APCI3XXX_Reset,
1142  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1143  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1144  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1145  .di_read = i_APCI3XXX_InsnReadDigitalInput,
1146  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
1147  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
1148  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
1149  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
1150  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1151  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1152  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1153  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1154  }, {
1155  .pc_DriverName = "apci3110-8-4",
1156  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1157  .i_DeviceId = 0x3021,
1158  .i_IorangeBase0 = 256,
1159  .i_IorangeBase1 = 256,
1160  .i_IorangeBase2 = 256,
1161  .i_IorangeBase3 = 256,
1162  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1163  .pc_EepromChip = ADDIDATA_9054,
1164  .i_NbrAiChannel = 8,
1165  .i_NbrAiChannelDiff = 4,
1166  .i_AiChannelList = 8,
1167  .i_NbrAoChannel = 4,
1168  .i_AiMaxdata = 4095,
1169  .i_AoMaxdata = 4095,
1170  .pr_AiRangelist = &range_apci3XXX_ai,
1171  .pr_AoRangelist = &range_apci3XXX_ao,
1172  .i_NbrDiChannel = 4,
1173  .i_NbrDoChannel = 4,
1174  .i_DoMaxdata = 1,
1175  .i_NbrTTLChannel = 24,
1176  .b_AvailableConvertUnit = 6,
1177  .ui_MinAcquisitiontimeNs = 5000,
1178  .interrupt = v_APCI3XXX_Interrupt,
1179  .reset = i_APCI3XXX_Reset,
1180  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1181  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1182  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1183  .di_read = i_APCI3XXX_InsnReadDigitalInput,
1184  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
1185  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
1186  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
1187  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
1188  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1189  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1190  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1191  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1192  }, {
1193  .pc_DriverName = "apci3116-16-4",
1194  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1195  .i_DeviceId = 0x3022,
1196  .i_IorangeBase0 = 256,
1197  .i_IorangeBase1 = 256,
1198  .i_IorangeBase2 = 256,
1199  .i_IorangeBase3 = 256,
1200  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1201  .pc_EepromChip = ADDIDATA_9054,
1202  .i_NbrAiChannel = 16,
1203  .i_NbrAiChannelDiff = 8,
1204  .i_AiChannelList = 16,
1205  .i_NbrAoChannel = 4,
1206  .i_AiMaxdata = 65535,
1207  .i_AoMaxdata = 4095,
1208  .pr_AiRangelist = &range_apci3XXX_ai,
1209  .pr_AoRangelist = &range_apci3XXX_ao,
1210  .i_NbrDiChannel = 4,
1211  .i_NbrDoChannel = 4,
1212  .i_DoMaxdata = 1,
1213  .i_NbrTTLChannel = 24,
1214  .b_AvailableConvertUnit = 6,
1215  .ui_MinAcquisitiontimeNs = 5000,
1216  .interrupt = v_APCI3XXX_Interrupt,
1217  .reset = i_APCI3XXX_Reset,
1218  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1219  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1220  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1221  .di_read = i_APCI3XXX_InsnReadDigitalInput,
1222  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
1223  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
1224  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
1225  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
1226  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1227  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1228  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1229  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1230  }, {
1231  .pc_DriverName = "apci3116-8-4",
1232  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1233  .i_DeviceId = 0x3023,
1234  .i_IorangeBase0 = 256,
1235  .i_IorangeBase1 = 256,
1236  .i_IorangeBase2 = 256,
1237  .i_IorangeBase3 = 256,
1238  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1239  .pc_EepromChip = ADDIDATA_9054,
1240  .i_NbrAiChannel = 8,
1241  .i_NbrAiChannelDiff = 4,
1242  .i_AiChannelList = 8,
1243  .i_NbrAoChannel = 4,
1244  .i_AiMaxdata = 65535,
1245  .i_AoMaxdata = 4095,
1246  .pr_AiRangelist = &range_apci3XXX_ai,
1247  .pr_AoRangelist = &range_apci3XXX_ao,
1248  .i_NbrDiChannel = 4,
1249  .i_NbrDoChannel = 4,
1250  .i_DoMaxdata = 1,
1251  .i_NbrTTLChannel = 24,
1252  .b_AvailableConvertUnit = 6,
1253  .ui_MinAcquisitiontimeNs = 5000,
1254  .interrupt = v_APCI3XXX_Interrupt,
1255  .reset = i_APCI3XXX_Reset,
1256  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1257  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1258  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1259  .di_read = i_APCI3XXX_InsnReadDigitalInput,
1260  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
1261  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
1262  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
1263  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
1264  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1265  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1266  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1267  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1268  }, {
1269  .pc_DriverName = "apci3003",
1270  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1271  .i_DeviceId = 0x300B,
1272  .i_IorangeBase0 = 256,
1273  .i_IorangeBase1 = 256,
1274  .i_IorangeBase2 = 256,
1275  .i_IorangeBase3 = 256,
1276  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1277  .pc_EepromChip = ADDIDATA_9054,
1278  .i_NbrAiChannelDiff = 4,
1279  .i_AiChannelList = 4,
1280  .i_AiMaxdata = 65535,
1281  .pr_AiRangelist = &range_apci3XXX_ai,
1282  .i_NbrDiChannel = 4,
1283  .i_NbrDoChannel = 4,
1284  .i_DoMaxdata = 1,
1285  .b_AvailableConvertUnit = 7,
1286  .ui_MinAcquisitiontimeNs = 2500,
1287  .interrupt = v_APCI3XXX_Interrupt,
1288  .reset = i_APCI3XXX_Reset,
1289  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1290  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1291  .di_read = i_APCI3XXX_InsnReadDigitalInput,
1292  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
1293  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
1294  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
1295  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
1296  }, {
1297  .pc_DriverName = "apci3002-16",
1298  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1299  .i_DeviceId = 0x3002,
1300  .i_IorangeBase0 = 256,
1301  .i_IorangeBase1 = 256,
1302  .i_IorangeBase2 = 256,
1303  .i_IorangeBase3 = 256,
1304  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1305  .pc_EepromChip = ADDIDATA_9054,
1306  .i_NbrAiChannelDiff = 16,
1307  .i_AiChannelList = 16,
1308  .i_AiMaxdata = 65535,
1309  .pr_AiRangelist = &range_apci3XXX_ai,
1310  .i_NbrDiChannel = 4,
1311  .i_NbrDoChannel = 4,
1312  .i_DoMaxdata = 1,
1313  .b_AvailableConvertUnit = 6,
1314  .ui_MinAcquisitiontimeNs = 5000,
1315  .interrupt = v_APCI3XXX_Interrupt,
1316  .reset = i_APCI3XXX_Reset,
1317  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1318  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1319  .di_read = i_APCI3XXX_InsnReadDigitalInput,
1320  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
1321  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
1322  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
1323  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
1324  }, {
1325  .pc_DriverName = "apci3002-8",
1326  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1327  .i_DeviceId = 0x3003,
1328  .i_IorangeBase0 = 256,
1329  .i_IorangeBase1 = 256,
1330  .i_IorangeBase2 = 256,
1331  .i_IorangeBase3 = 256,
1332  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1333  .pc_EepromChip = ADDIDATA_9054,
1334  .i_NbrAiChannelDiff = 8,
1335  .i_AiChannelList = 8,
1336  .i_AiMaxdata = 65535,
1337  .pr_AiRangelist = &range_apci3XXX_ai,
1338  .i_NbrDiChannel = 4,
1339  .i_NbrDoChannel = 4,
1340  .i_DoMaxdata = 1,
1341  .b_AvailableConvertUnit = 6,
1342  .ui_MinAcquisitiontimeNs = 5000,
1343  .interrupt = v_APCI3XXX_Interrupt,
1344  .reset = i_APCI3XXX_Reset,
1345  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1346  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1347  .di_read = i_APCI3XXX_InsnReadDigitalInput,
1348  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
1349  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
1350  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
1351  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
1352  }, {
1353  .pc_DriverName = "apci3002-4",
1354  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1355  .i_DeviceId = 0x3004,
1356  .i_IorangeBase0 = 256,
1357  .i_IorangeBase1 = 256,
1358  .i_IorangeBase2 = 256,
1359  .i_IorangeBase3 = 256,
1360  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1361  .pc_EepromChip = ADDIDATA_9054,
1362  .i_NbrAiChannelDiff = 4,
1363  .i_AiChannelList = 4,
1364  .i_AiMaxdata = 65535,
1365  .pr_AiRangelist = &range_apci3XXX_ai,
1366  .i_NbrDiChannel = 4,
1367  .i_NbrDoChannel = 4,
1368  .i_DoMaxdata = 1,
1369  .b_AvailableConvertUnit = 6,
1370  .ui_MinAcquisitiontimeNs = 5000,
1371  .interrupt = v_APCI3XXX_Interrupt,
1372  .reset = i_APCI3XXX_Reset,
1373  .ai_config = i_APCI3XXX_InsnConfigAnalogInput,
1374  .ai_read = i_APCI3XXX_InsnReadAnalogInput,
1375  .di_read = i_APCI3XXX_InsnReadDigitalInput,
1376  .di_bits = i_APCI3XXX_InsnBitsDigitalInput,
1377  .do_write = i_APCI3XXX_InsnWriteDigitalOutput,
1378  .do_bits = i_APCI3XXX_InsnBitsDigitalOutput,
1379  .do_read = i_APCI3XXX_InsnReadDigitalOutput,
1380  }, {
1381  .pc_DriverName = "apci3500",
1382  .i_VendorId = PCI_VENDOR_ID_ADDIDATA,
1383  .i_DeviceId = 0x3024,
1384  .i_IorangeBase0 = 256,
1385  .i_IorangeBase1 = 256,
1386  .i_IorangeBase2 = 256,
1387  .i_IorangeBase3 = 256,
1388  .i_PCIEeprom = ADDIDATA_NO_EEPROM,
1389  .pc_EepromChip = ADDIDATA_9054,
1390  .i_NbrAoChannel = 4,
1391  .i_AoMaxdata = 4095,
1392  .pr_AoRangelist = &range_apci3XXX_ao,
1393  .i_NbrTTLChannel = 24,
1394  .interrupt = v_APCI3XXX_Interrupt,
1395  .reset = i_APCI3XXX_Reset,
1396  .ao_write = i_APCI3XXX_InsnWriteAnalogOutput,
1397  .ttl_config = i_APCI3XXX_InsnConfigInitTTLIO,
1398  .ttl_bits = i_APCI3XXX_InsnBitsTTLIO,
1399  .ttl_read = i_APCI3XXX_InsnReadTTLIO,
1400  .ttl_write = i_APCI3XXX_InsnWriteTTLIO,
1401  },
1402 #endif
1403 };
1404 
1405 static struct comedi_driver driver_addi = {
1406  .driver_name = ADDIDATA_DRIVER_NAME,
1407  .module = THIS_MODULE,
1408  .attach = i_ADDI_Attach,
1409  .detach = i_ADDI_Detach,
1410  .num_names = ARRAY_SIZE(boardtypes),
1411  .board_name = &boardtypes[0].pc_DriverName,
1412  .offset = sizeof(struct addi_board),
1413 };
1414 
1415 static int __devinit driver_addi_pci_probe(struct pci_dev *dev,
1416  const struct pci_device_id *ent)
1417 {
1418  return comedi_pci_auto_config(dev, &driver_addi);
1419 }
1420 
1421 static void __devexit driver_addi_pci_remove(struct pci_dev *dev)
1422 {
1424 }
1425 
1426 static struct pci_driver driver_addi_pci_driver = {
1427  .id_table = addi_apci_tbl,
1428  .probe = &driver_addi_pci_probe,
1429  .remove = __devexit_p(&driver_addi_pci_remove)
1430 };
1431 
1432 static int __init driver_addi_init_module(void)
1433 {
1434  int retval;
1435 
1436  retval = comedi_driver_register(&driver_addi);
1437  if (retval < 0)
1438  return retval;
1439 
1440  driver_addi_pci_driver.name = (char *)driver_addi.driver_name;
1441  return pci_register_driver(&driver_addi_pci_driver);
1442 }
1443 
1444 static void __exit driver_addi_cleanup_module(void)
1445 {
1446  pci_unregister_driver(&driver_addi_pci_driver);
1447  comedi_driver_unregister(&driver_addi);
1448 }
1449 
1450 module_init(driver_addi_init_module);
1451 module_exit(driver_addi_cleanup_module);
1452 
1453 /*
1454 +----------------------------------------------------------------------------+
1455 | Function name :static int i_ADDI_Attach(struct comedi_device *dev, |
1456 | struct comedi_devconfig *it) |
1457 | |
1458 +----------------------------------------------------------------------------+
1459 | Task :Detects the card. |
1460 | Configure the driver for a particular board. |
1461 | This function does all the initializations and memory |
1462 | allocation of data structures for the driver. |
1463 +----------------------------------------------------------------------------+
1464 | Input Parameters :struct comedi_device *dev |
1465 | struct comedi_devconfig *it |
1466 | |
1467 +----------------------------------------------------------------------------+
1468 | Return Value : 0 |
1469 | |
1470 +----------------------------------------------------------------------------+
1471 */
1472 
1473 static int i_ADDI_Attach(struct comedi_device *dev, struct comedi_devconfig *it)
1474 {
1475  struct comedi_subdevice *s;
1476  int ret, pages, i, n_subdevices;
1477  unsigned int dw_Dummy;
1479  unsigned int irq;
1480  resource_size_t iobase_a, iobase_main, iobase_addon, iobase_reserved;
1481  struct pcilst_struct *card = NULL;
1482  unsigned char pci_bus, pci_slot, pci_func;
1483  int i_Dma = 0;
1484 
1485  ret = alloc_private(dev, sizeof(struct addi_private));
1486  if (ret < 0)
1487  return -ENOMEM;
1488 
1489  if (!pci_list_builded) {
1490  v_pci_card_list_init(this_board->i_VendorId, 1); /* 1 for displaying the list.. */
1491  pci_list_builded = 1;
1492  }
1493  /* printk("comedi%d: "ADDIDATA_DRIVER_NAME": board=%s",dev->minor,this_board->pc_DriverName); */
1494 
1495  if ((this_board->i_Dma) && (it->options[2] == 0)) {
1496  i_Dma = 1;
1497  }
1498 
1499  card = ptr_select_and_alloc_pci_card(this_board->i_VendorId,
1500  this_board->i_DeviceId,
1501  it->options[0],
1502  it->options[1], i_Dma);
1503 
1504  if (card == NULL)
1505  return -EIO;
1506 
1507  devpriv->allocated = 1;
1508 
1509  if ((i_pci_card_data(card, &pci_bus, &pci_slot, &pci_func, &io_addr[0],
1510  &irq)) < 0) {
1511  i_pci_card_free(card);
1512  printk(" - Can't get AMCC data!\n");
1513  return -EIO;
1514  }
1515 
1516  iobase_a = io_addr[0];
1517  iobase_main = io_addr[1];
1518  iobase_addon = io_addr[2];
1519  iobase_reserved = io_addr[3];
1520  printk("\nBus %d: Slot %d: Funct%d\nBase0: 0x%8llx\nBase1: 0x%8llx\nBase2: 0x%8llx\nBase3: 0x%8llx\n", pci_bus, pci_slot, pci_func, (unsigned long long)io_addr[0], (unsigned long long)io_addr[1], (unsigned long long)io_addr[2], (unsigned long long)io_addr[3]);
1521 
1522  if ((this_board->pc_EepromChip == NULL)
1523  || (strcmp(this_board->pc_EepromChip, ADDIDATA_9054) != 0)) {
1524  /************************************/
1525  /* Test if more that 1 address used */
1526  /************************************/
1527 
1528  if (this_board->i_IorangeBase1 != 0) {
1529  dev->iobase = (unsigned long)iobase_main; /* DAQ base address... */
1530  } else {
1531  dev->iobase = (unsigned long)iobase_a; /* DAQ base address... */
1532  }
1533 
1534  dev->board_name = this_board->pc_DriverName;
1535  devpriv->amcc = card;
1536  devpriv->iobase = (int) dev->iobase;
1537  devpriv->i_IobaseAmcc = (int) iobase_a; /* AMCC base address... */
1538  devpriv->i_IobaseAddon = (int) iobase_addon; /* ADD ON base address.... */
1539  devpriv->i_IobaseReserved = (int) iobase_reserved;
1540  } else {
1541  dev->board_name = this_board->pc_DriverName;
1542  dev->iobase = (unsigned long)io_addr[2];
1543  devpriv->amcc = card;
1544  devpriv->iobase = (int) io_addr[2];
1545  devpriv->i_IobaseReserved = (int) io_addr[3];
1546  printk("\nioremap begin");
1547  devpriv->dw_AiBase = ioremap(io_addr[3],
1548  this_board->i_IorangeBase3);
1549  printk("\nioremap end");
1550  }
1551 
1552  /* Initialize parameters that can be overridden in EEPROM */
1553  devpriv->s_EeParameters.i_NbrAiChannel = this_board->i_NbrAiChannel;
1554  devpriv->s_EeParameters.i_NbrAoChannel = this_board->i_NbrAoChannel;
1555  devpriv->s_EeParameters.i_AiMaxdata = this_board->i_AiMaxdata;
1556  devpriv->s_EeParameters.i_AoMaxdata = this_board->i_AoMaxdata;
1557  devpriv->s_EeParameters.i_NbrDiChannel = this_board->i_NbrDiChannel;
1558  devpriv->s_EeParameters.i_NbrDoChannel = this_board->i_NbrDoChannel;
1559  devpriv->s_EeParameters.i_DoMaxdata = this_board->i_DoMaxdata;
1560  devpriv->s_EeParameters.i_Dma = this_board->i_Dma;
1561  devpriv->s_EeParameters.i_Timer = this_board->i_Timer;
1562  devpriv->s_EeParameters.ui_MinAcquisitiontimeNs =
1563  this_board->ui_MinAcquisitiontimeNs;
1564  devpriv->s_EeParameters.ui_MinDelaytimeNs =
1565  this_board->ui_MinDelaytimeNs;
1566 
1567  /* ## */
1568 
1569  if (irq > 0) {
1570  if (request_irq(irq, v_ADDI_Interrupt, IRQF_SHARED,
1571  this_board->pc_DriverName, dev) < 0) {
1572  printk(", unable to allocate IRQ %u, DISABLING IT",
1573  irq);
1574  irq = 0; /* Can't use IRQ */
1575  } else {
1576  printk("\nirq=%u", irq);
1577  }
1578  } else {
1579  printk(", IRQ disabled");
1580  }
1581 
1582  printk("\nOption %d %d %d\n", it->options[0], it->options[1],
1583  it->options[2]);
1584  dev->irq = irq;
1585 
1586  /* Read eepeom and fill addi_board Structure */
1587 
1588  if (this_board->i_PCIEeprom) {
1589  printk("\nPCI Eeprom used");
1590  if (!(strcmp(this_board->pc_EepromChip, "S5920"))) {
1591  /* Set 3 wait stait */
1592  if (!(strcmp(this_board->pc_DriverName, "apci035"))) {
1593  outl(0x80808082, devpriv->i_IobaseAmcc + 0x60);
1594  } else {
1595  outl(0x83838383, devpriv->i_IobaseAmcc + 0x60);
1596  }
1597  /* Enable the interrupt for the controller */
1598  dw_Dummy = inl(devpriv->i_IobaseAmcc + 0x38);
1599  outl(dw_Dummy | 0x2000, devpriv->i_IobaseAmcc + 0x38);
1600  printk("\nEnable the interrupt for the controller");
1601  }
1602  printk("\nRead Eeprom");
1603  i_EepromReadMainHeader(io_addr[0], this_board->pc_EepromChip,
1604  dev);
1605  } else {
1606  printk("\nPCI Eeprom unused");
1607  }
1608 
1609  if (it->options[2] > 0) {
1610  devpriv->us_UseDma = ADDI_DISABLE;
1611  } else {
1612  devpriv->us_UseDma = ADDI_ENABLE;
1613  }
1614 
1615  if (devpriv->s_EeParameters.i_Dma) {
1616  printk("\nDMA used");
1617  if (devpriv->us_UseDma == ADDI_ENABLE) {
1618  /* alloc DMA buffers */
1619  devpriv->b_DmaDoubleBuffer = 0;
1620  for (i = 0; i < 2; i++) {
1621  for (pages = 4; pages >= 0; pages--) {
1622  devpriv->ul_DmaBufferVirtual[i] =
1623  (void *) __get_free_pages(GFP_KERNEL, pages);
1624 
1625  if (devpriv->ul_DmaBufferVirtual[i])
1626  break;
1627  }
1628  if (devpriv->ul_DmaBufferVirtual[i]) {
1629  devpriv->ui_DmaBufferPages[i] = pages;
1630  devpriv->ui_DmaBufferSize[i] =
1631  PAGE_SIZE * pages;
1632  devpriv->ui_DmaBufferSamples[i] =
1633  devpriv->
1634  ui_DmaBufferSize[i] >> 1;
1635  devpriv->ul_DmaBufferHw[i] =
1636  virt_to_bus((void *)devpriv->
1637  ul_DmaBufferVirtual[i]);
1638  }
1639  }
1640  if (!devpriv->ul_DmaBufferVirtual[0]) {
1641  printk
1642  (", Can't allocate DMA buffer, DMA disabled!");
1643  devpriv->us_UseDma = ADDI_DISABLE;
1644  }
1645 
1646  if (devpriv->ul_DmaBufferVirtual[1]) {
1647  devpriv->b_DmaDoubleBuffer = 1;
1648  }
1649  }
1650 
1651  if ((devpriv->us_UseDma == ADDI_ENABLE)) {
1652  printk("\nDMA ENABLED\n");
1653  } else {
1654  printk("\nDMA DISABLED\n");
1655  }
1656  }
1657 
1658  if (!strcmp(this_board->pc_DriverName, "apci1710")) {
1659 #ifdef CONFIG_APCI_1710
1660  i_ADDI_AttachPCI1710(dev);
1661 
1662  /* save base address */
1663  devpriv->s_BoardInfos.ui_Address = io_addr[2];
1664 #endif
1665  } else {
1666  n_subdevices = 7;
1667  ret = comedi_alloc_subdevices(dev, n_subdevices);
1668  if (ret)
1669  return ret;
1670 
1671  /* Allocate and Initialise AI Subdevice Structures */
1672  s = &dev->subdevices[0];
1673  if ((devpriv->s_EeParameters.i_NbrAiChannel)
1674  || (this_board->i_NbrAiChannelDiff)) {
1675  dev->read_subdev = s;
1676  s->type = COMEDI_SUBD_AI;
1677  s->subdev_flags =
1679  | SDF_DIFF;
1680  if (devpriv->s_EeParameters.i_NbrAiChannel) {
1681  s->n_chan =
1682  devpriv->s_EeParameters.i_NbrAiChannel;
1683  devpriv->b_SingelDiff = 0;
1684  } else {
1685  s->n_chan = this_board->i_NbrAiChannelDiff;
1686  devpriv->b_SingelDiff = 1;
1687  }
1688  s->maxdata = devpriv->s_EeParameters.i_AiMaxdata;
1689  s->len_chanlist = this_board->i_AiChannelList;
1690  s->range_table = this_board->pr_AiRangelist;
1691 
1692  /* Set the initialisation flag */
1693  devpriv->b_AiInitialisation = 1;
1694 
1695  s->insn_config = this_board->ai_config;
1696  s->insn_read = this_board->ai_read;
1697  s->insn_write = this_board->ai_write;
1698  s->insn_bits = this_board->ai_bits;
1699  s->do_cmdtest = this_board->ai_cmdtest;
1700  s->do_cmd = this_board->ai_cmd;
1701  s->cancel = this_board->ai_cancel;
1702 
1703  } else {
1704  s->type = COMEDI_SUBD_UNUSED;
1705  }
1706 
1707  /* Allocate and Initialise AO Subdevice Structures */
1708  s = &dev->subdevices[1];
1709  if (devpriv->s_EeParameters.i_NbrAoChannel) {
1710  s->type = COMEDI_SUBD_AO;
1712  s->n_chan = devpriv->s_EeParameters.i_NbrAoChannel;
1713  s->maxdata = devpriv->s_EeParameters.i_AoMaxdata;
1714  s->len_chanlist =
1715  devpriv->s_EeParameters.i_NbrAoChannel;
1716  s->range_table = this_board->pr_AoRangelist;
1717  s->insn_config = this_board->ao_config;
1718  s->insn_write = this_board->ao_write;
1719  } else {
1720  s->type = COMEDI_SUBD_UNUSED;
1721  }
1722  /* Allocate and Initialise DI Subdevice Structures */
1723  s = &dev->subdevices[2];
1724  if (devpriv->s_EeParameters.i_NbrDiChannel) {
1725  s->type = COMEDI_SUBD_DI;
1727  s->n_chan = devpriv->s_EeParameters.i_NbrDiChannel;
1728  s->maxdata = 1;
1729  s->len_chanlist =
1730  devpriv->s_EeParameters.i_NbrDiChannel;
1731  s->range_table = &range_digital;
1732  s->io_bits = 0; /* all bits input */
1733  s->insn_config = this_board->di_config;
1734  s->insn_read = this_board->di_read;
1735  s->insn_write = this_board->di_write;
1736  s->insn_bits = this_board->di_bits;
1737  } else {
1738  s->type = COMEDI_SUBD_UNUSED;
1739  }
1740  /* Allocate and Initialise DO Subdevice Structures */
1741  s = &dev->subdevices[3];
1742  if (devpriv->s_EeParameters.i_NbrDoChannel) {
1743  s->type = COMEDI_SUBD_DO;
1744  s->subdev_flags =
1746  s->n_chan = devpriv->s_EeParameters.i_NbrDoChannel;
1747  s->maxdata = devpriv->s_EeParameters.i_DoMaxdata;
1748  s->len_chanlist =
1749  devpriv->s_EeParameters.i_NbrDoChannel;
1750  s->range_table = &range_digital;
1751  s->io_bits = 0xf; /* all bits output */
1752 
1753  /* insn_config - for digital output memory */
1754  s->insn_config = this_board->do_config;
1755  s->insn_write = this_board->do_write;
1756  s->insn_bits = this_board->do_bits;
1757  s->insn_read = this_board->do_read;
1758  } else {
1759  s->type = COMEDI_SUBD_UNUSED;
1760  }
1761 
1762  /* Allocate and Initialise Timer Subdevice Structures */
1763  s = &dev->subdevices[4];
1764  if (devpriv->s_EeParameters.i_Timer) {
1765  s->type = COMEDI_SUBD_TIMER;
1767  s->n_chan = 1;
1768  s->maxdata = 0;
1769  s->len_chanlist = 1;
1770  s->range_table = &range_digital;
1771 
1772  s->insn_write = this_board->timer_write;
1773  s->insn_read = this_board->timer_read;
1774  s->insn_config = this_board->timer_config;
1775  s->insn_bits = this_board->timer_bits;
1776  } else {
1777  s->type = COMEDI_SUBD_UNUSED;
1778  }
1779 
1780  /* Allocate and Initialise TTL */
1781  s = &dev->subdevices[5];
1782  if (this_board->i_NbrTTLChannel) {
1783  s->type = COMEDI_SUBD_TTLIO;
1784  s->subdev_flags =
1786  s->n_chan = this_board->i_NbrTTLChannel;
1787  s->maxdata = 1;
1788  s->io_bits = 0; /* all bits input */
1789  s->len_chanlist = this_board->i_NbrTTLChannel;
1790  s->range_table = &range_digital;
1791  s->insn_config = this_board->ttl_config;
1792  s->insn_bits = this_board->ttl_bits;
1793  s->insn_read = this_board->ttl_read;
1794  s->insn_write = this_board->ttl_write;
1795  } else {
1796  s->type = COMEDI_SUBD_UNUSED;
1797  }
1798 
1799  /* EEPROM */
1800  s = &dev->subdevices[6];
1801  if (this_board->i_PCIEeprom) {
1802  s->type = COMEDI_SUBD_MEMORY;
1804  s->n_chan = 256;
1805  s->maxdata = 0xffff;
1806  s->insn_read = i_ADDIDATA_InsnReadEeprom;
1807  } else {
1808  s->type = COMEDI_SUBD_UNUSED;
1809  }
1810  }
1811 
1812  printk("\ni_ADDI_Attach end\n");
1813  i_ADDI_Reset(dev);
1814  devpriv->b_ValidDriver = 1;
1815  return 0;
1816 }
1817 
1818 static void i_ADDI_Detach(struct comedi_device *dev)
1819 {
1820  if (dev->private) {
1821  if (devpriv->b_ValidDriver)
1822  i_ADDI_Reset(dev);
1823  if (dev->irq)
1824  free_irq(dev->irq, dev);
1825  if ((this_board->pc_EepromChip == NULL) ||
1826  (strcmp(this_board->pc_EepromChip, ADDIDATA_9054) != 0)) {
1827  if (devpriv->allocated)
1828  i_pci_card_free(devpriv->amcc);
1829  if (devpriv->ul_DmaBufferVirtual[0]) {
1830  free_pages((unsigned long)devpriv->
1831  ul_DmaBufferVirtual[0],
1832  devpriv->ui_DmaBufferPages[0]);
1833  }
1834  if (devpriv->ul_DmaBufferVirtual[1]) {
1835  free_pages((unsigned long)devpriv->
1836  ul_DmaBufferVirtual[1],
1837  devpriv->ui_DmaBufferPages[1]);
1838  }
1839  } else {
1840  iounmap(devpriv->dw_AiBase);
1841  if (devpriv->allocated)
1842  i_pci_card_free(devpriv->amcc);
1843  }
1844  if (pci_list_builded) {
1845  v_pci_card_list_cleanup(this_board->i_VendorId);
1846  pci_list_builded = 0;
1847  }
1848  }
1849 }
1850 
1851 /*
1852 +----------------------------------------------------------------------------+
1853 | Function name : static int i_ADDI_Reset(struct comedi_device *dev) |
1854 | |
1855 +----------------------------------------------------------------------------+
1856 | Task : Disables all interrupts, Resets digital output to low, |
1857 | Set all analog output to low |
1858 | |
1859 +----------------------------------------------------------------------------+
1860 | Input Parameters : struct comedi_device *dev |
1861 | |
1862 | |
1863 +----------------------------------------------------------------------------+
1864 | Return Value : 0 |
1865 | |
1866 +----------------------------------------------------------------------------+
1867 */
1868 
1869 static int i_ADDI_Reset(struct comedi_device *dev)
1870 {
1871 
1872  this_board->reset(dev);
1873  return 0;
1874 }
1875 
1876 /* Interrupt function */
1877 /*
1878 +----------------------------------------------------------------------------+
1879 | Function name : |
1880 |static void v_ADDI_Interrupt(int irq, void *d) |
1881 | |
1882 +----------------------------------------------------------------------------+
1883 | Task : Registerd interrupt routine |
1884 | |
1885 +----------------------------------------------------------------------------+
1886 | Input Parameters : int irq |
1887 | |
1888 | |
1889 +----------------------------------------------------------------------------+
1890 | Return Value : |
1891 | |
1892 +----------------------------------------------------------------------------+
1893 */
1894 
1895 static irqreturn_t v_ADDI_Interrupt(int irq, void *d)
1896 {
1897  struct comedi_device *dev = d;
1898  this_board->interrupt(irq, d);
1899  return IRQ_RETVAL(1);
1900 }
1901 
1902 /* EEPROM Read Function */
1903 /*
1904 +----------------------------------------------------------------------------+
1905 | Function name : |
1906 |INT i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev,struct comedi_subdevice *s,
1907  struct comedi_insn *insn,unsigned int *data)
1908 | |
1909 +----------------------------------------------------------------------------+
1910 | Task : Read 256 words from EEPROM |
1911 | |
1912 +----------------------------------------------------------------------------+
1913 | Input Parameters :(struct comedi_device *dev,struct comedi_subdevice *s,
1914  struct comedi_insn *insn,unsigned int *data) |
1915 | |
1916 | |
1917 +----------------------------------------------------------------------------+
1918 | Return Value : |
1919 | |
1920 +----------------------------------------------------------------------------+
1921 */
1922 
1923 static int i_ADDIDATA_InsnReadEeprom(struct comedi_device *dev, struct comedi_subdevice *s,
1924  struct comedi_insn *insn, unsigned int *data)
1925 {
1926  unsigned short w_Data;
1927  unsigned short w_Address;
1928  w_Address = CR_CHAN(insn->chanspec); /* address to be read as 0,1,2,3...255 */
1929 
1930  w_Data = w_EepromReadWord(devpriv->i_IobaseAmcc,
1931  this_board->pc_EepromChip, 0x100 + (2 * w_Address));
1932  data[0] = w_Data;
1933  /* multiplied by 2 bcozinput will be like 0,1,2...255 */
1934  return insn->n;
1935 
1936 }