2 comedi/drivers/ni_pcimio.c
3 Hardware driver for NI PCI-MIO E series cards
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 1997-8 David A. Schleef <ds@schleef.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 Description: National Instruments PCI-MIO-E series and M series (all boards)
25 Author: ds, John Hallen, Frank Mori Hess, Rolf Mueller, Herbert Peremans,
26 Herman Bruyninckx, Terry Barnaby
28 Devices: [National Instruments] PCI-MIO-16XE-50 (ni_pcimio),
29 PCI-MIO-16XE-10, PXI-6030E, PCI-MIO-16E-1, PCI-MIO-16E-4, PCI-6014, PCI-6040E,
30 PXI-6040E, PCI-6030E, PCI-6031E, PCI-6032E, PCI-6033E, PCI-6071E, PCI-6023E,
31 PCI-6024E, PCI-6025E, PXI-6025E, PCI-6034E, PCI-6035E, PCI-6052E,
32 PCI-6110, PCI-6111, PCI-6220, PCI-6221, PCI-6224, PXI-6224, PCI-6225, PXI-6225,
33 PCI-6229, PCI-6250, PCI-6251, PCIe-6251, PCI-6254, PCI-6259, PCIe-6259,
34 PCI-6280, PCI-6281, PXI-6281, PCI-6284, PCI-6289,
35 PCI-6711, PXI-6711, PCI-6713, PXI-6713,
36 PXI-6071E, PCI-6070E, PXI-6070E,
37 PXI-6052E, PCI-6036E, PCI-6731, PCI-6733, PXI-6733,
39 Updated: Wed, 03 Dec 2008 10:51:47 +0000
41 These boards are almost identical to the AT-MIO E series, except that
42 they use the PCI bus instead of ISA (i.e., AT). See the notes for
43 the ni_atmio.o driver for additional information about these boards.
45 Autocalibration is supported on many of the devices, using the
46 comedi_calibrate (or comedi_soft_calibrate for m-series) utility.
47 M-Series boards do analog input and analog output calibration entirely
48 in software. The software calibration corrects
49 the analog input for offset, gain and
50 nonlinearity. The analog outputs are corrected for offset and gain.
51 See the comedilib documentation on comedi_get_softcal_converter() for
54 By default, the driver uses DMA to transfer analog input data to
55 memory. When DMA is enabled, not all triggering features are
58 Digital I/O may not work on 673x.
60 Note that the PCI-6143 is a simultaineous sampling device with 8 convertors.
61 With this board all of the convertors perform one simultaineous sample during
62 a scan interval. The period for a scan is used for the convert time in a
63 Comedi cmd. The convert trigger source is normally set to TRIG_NOW by default.
65 The RTSI trigger bus is supported on these cards on
66 subdevice 10. See the comedilib documentation for details.
68 Information (number of channels, bits, etc.) for some devices may be
69 incorrect. Please check this and submit a bug if there are problems
72 SCXI is probably broken for m-series boards.
75 - When DMA is enabled, COMEDI_EV_CONVERT does
80 The PCI-MIO E series driver was originally written by
81 Tomasz Motylewski <...>, and ported to comedi by ds.
85 341079b.pdf PCI E Series Register-Level Programmer Manual
86 340934b.pdf DAQ-STC reference manual
88 322080b.pdf 6711/6713/6715 User Manual
90 320945c.pdf PCI E Series User Manual
91 322138a.pdf PCI-6052E and DAQPad-6052E User Manual
95 need to deal with external reference for DAC, and other DAC
96 properties in board properties
98 deal with at-mio-16de-10 revision D to N changes, etc.
100 need to add other CALDAC type
102 need to slow down DAC loading. I don't trust NI's claim that
103 two writes to the PCI bus slows IO enough. I would prefer to
104 use udelay(). Timing specs: (clock)
112 #include "../comedidev.h"
114 #include <asm/byteorder.h>
115 #include <linux/delay.h>
120 /* #define PCI_DEBUG */
127 #define MAX_N_CALDACS (16+16+2)
129 #define DRV_NAME "ni_pcimio"
131 /* The following two tables must be in the same order */
132 static DEFINE_PCI_DEVICE_TABLE(ni_pci_table
) = {
134 PCI_VENDOR_ID_NATINST
, 0x0162, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
135 PCI_VENDOR_ID_NATINST
, 0x1170, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
136 PCI_VENDOR_ID_NATINST
, 0x1180, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
137 PCI_VENDOR_ID_NATINST
, 0x1190, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
138 PCI_VENDOR_ID_NATINST
, 0x11b0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
139 PCI_VENDOR_ID_NATINST
, 0x11c0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
140 PCI_VENDOR_ID_NATINST
, 0x11d0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
141 PCI_VENDOR_ID_NATINST
, 0x1270, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
142 PCI_VENDOR_ID_NATINST
, 0x1330, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
143 PCI_VENDOR_ID_NATINST
, 0x1340, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
144 PCI_VENDOR_ID_NATINST
, 0x1350, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
145 PCI_VENDOR_ID_NATINST
, 0x14e0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
146 PCI_VENDOR_ID_NATINST
, 0x14f0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
147 PCI_VENDOR_ID_NATINST
, 0x1580, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
148 PCI_VENDOR_ID_NATINST
, 0x15b0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
149 PCI_VENDOR_ID_NATINST
, 0x1880, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
150 PCI_VENDOR_ID_NATINST
, 0x1870, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
151 PCI_VENDOR_ID_NATINST
, 0x18b0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
152 PCI_VENDOR_ID_NATINST
, 0x18c0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
153 PCI_VENDOR_ID_NATINST
, 0x2410, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
154 PCI_VENDOR_ID_NATINST
, 0x2420, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
155 PCI_VENDOR_ID_NATINST
, 0x2430, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
156 PCI_VENDOR_ID_NATINST
, 0x2890, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
157 PCI_VENDOR_ID_NATINST
, 0x28c0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
158 PCI_VENDOR_ID_NATINST
, 0x2a60, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
159 PCI_VENDOR_ID_NATINST
, 0x2a70, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
160 PCI_VENDOR_ID_NATINST
, 0x2a80, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
161 PCI_VENDOR_ID_NATINST
, 0x2ab0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
162 PCI_VENDOR_ID_NATINST
, 0x2b80, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
163 PCI_VENDOR_ID_NATINST
, 0x2b90, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
164 PCI_VENDOR_ID_NATINST
, 0x2c80, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
165 PCI_VENDOR_ID_NATINST
, 0x2ca0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
166 PCI_VENDOR_ID_NATINST
, 0x70aa, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
167 PCI_VENDOR_ID_NATINST
, 0x70ab, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
168 PCI_VENDOR_ID_NATINST
, 0x70ac, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
169 PCI_VENDOR_ID_NATINST
, 0x70af, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
170 PCI_VENDOR_ID_NATINST
, 0x70b0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
171 PCI_VENDOR_ID_NATINST
, 0x70b4, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
172 PCI_VENDOR_ID_NATINST
, 0x70b6, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
173 PCI_VENDOR_ID_NATINST
, 0x70b7, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
174 PCI_VENDOR_ID_NATINST
, 0x70b8, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
175 PCI_VENDOR_ID_NATINST
, 0x70bc, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
176 PCI_VENDOR_ID_NATINST
, 0x70bd, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
177 PCI_VENDOR_ID_NATINST
, 0x70bf, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
178 PCI_VENDOR_ID_NATINST
, 0x70c0, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
179 PCI_VENDOR_ID_NATINST
, 0x70f2, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
180 PCI_VENDOR_ID_NATINST
, 0x710d, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
181 PCI_VENDOR_ID_NATINST
, 0x716c, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
182 PCI_VENDOR_ID_NATINST
, 0x716d, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
183 PCI_VENDOR_ID_NATINST
, 0x717f, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
184 PCI_VENDOR_ID_NATINST
, 0x71bc, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
185 PCI_VENDOR_ID_NATINST
, 0x717d, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0}, {
189 MODULE_DEVICE_TABLE(pci
, ni_pci_table
);
191 /* These are not all the possible ao ranges for 628x boards.
192 They can do OFFSET +- REFERENCE where OFFSET can be
193 0V, 5V, APFI<0,1>, or AO<0...3> and RANGE can
194 be 10V, 5V, 2V, 1V, APFI<0,1>, AO<0...3>. That's
195 63 different possibilities. An AO channel
196 can not act as it's own OFFSET or REFERENCE.
198 static const struct comedi_lrange range_ni_M_628x_ao
= { 8, {
211 static const struct comedi_lrange range_ni_M_625x_ao
= { 3, {
218 static const struct comedi_lrange range_ni_M_622x_ao
= { 1, {
223 static const struct ni_board_struct ni_boards
[] = {
225 .device_id
= 0x0162, /* NI also says 0x1620. typo? */
226 .name
= "pci-mio-16xe-50",
229 .ai_fifo_depth
= 2048,
231 .gainlkup
= ai_gain_8
,
236 .ao_range_table
= &range_bipolar10
,
239 .num_p0_dio_channels
= 8,
240 .caldac
= {dac8800
, dac8043
},
245 .name
= "pci-mio-16xe-10", /* aka pci-6030E */
248 .ai_fifo_depth
= 512,
250 .gainlkup
= ai_gain_14
,
254 .ao_fifo_depth
= 2048,
255 .ao_range_table
= &range_ni_E_ao_ext
,
258 .num_p0_dio_channels
= 8,
259 .caldac
= {dac8800
, dac8043
, ad8522
},
267 .ai_fifo_depth
= 512,
269 .gainlkup
= ai_gain_4
,
274 .ao_range_table
= &range_bipolar10
,
277 .num_p0_dio_channels
= 8,
278 .caldac
= {ad8804_debug
},
286 .ai_fifo_depth
= 512,
288 .gainlkup
= ai_gain_14
,
292 .ao_fifo_depth
= 2048,
293 .ao_range_table
= &range_ni_E_ao_ext
,
296 .num_p0_dio_channels
= 8,
297 .caldac
= {dac8800
, dac8043
, ad8522
},
302 .name
= "pci-mio-16e-1", /* aka pci-6070e */
305 .ai_fifo_depth
= 512,
307 .gainlkup
= ai_gain_16
,
311 .ao_fifo_depth
= 2048,
312 .ao_range_table
= &range_ni_E_ao_ext
,
315 .num_p0_dio_channels
= 8,
321 .name
= "pci-mio-16e-4", /* aka pci-6040e */
324 .ai_fifo_depth
= 512,
326 .gainlkup
= ai_gain_16
,
327 /* .Note = there have been reported problems with full speed
332 .ao_fifo_depth
= 512,
333 .ao_range_table
= &range_ni_E_ao_ext
,
336 .num_p0_dio_channels
= 8,
337 .caldac
= {ad8804_debug
}, /* doc says mb88341 */
345 .ai_fifo_depth
= 512,
347 .gainlkup
= ai_gain_16
,
351 .ao_fifo_depth
= 512,
352 .ao_range_table
= &range_ni_E_ao_ext
,
355 .num_p0_dio_channels
= 8,
365 .ai_fifo_depth
= 512,
367 .gainlkup
= ai_gain_14
,
371 .ao_fifo_depth
= 2048,
372 .ao_range_table
= &range_ni_E_ao_ext
,
375 .num_p0_dio_channels
= 8,
376 .caldac
= {dac8800
, dac8043
, ad8522
},
384 .ai_fifo_depth
= 512,
386 .gainlkup
= ai_gain_14
,
392 .num_p0_dio_channels
= 8,
393 .caldac
= {dac8800
, dac8043
, ad8522
},
401 .ai_fifo_depth
= 512,
403 .gainlkup
= ai_gain_14
,
409 .num_p0_dio_channels
= 8,
410 .caldac
= {dac8800
, dac8043
, ad8522
},
418 .ai_fifo_depth
= 512,
420 .gainlkup
= ai_gain_16
,
424 .ao_fifo_depth
= 2048,
425 .ao_range_table
= &range_ni_E_ao_ext
,
428 .num_p0_dio_channels
= 8,
429 .caldac
= {ad8804_debug
},
437 .ai_fifo_depth
= 512,
439 .gainlkup
= ai_gain_4
,
444 .num_p0_dio_channels
= 8,
445 .caldac
= {ad8804_debug
}, /* manual is wrong */
453 .ai_fifo_depth
= 512,
455 .gainlkup
= ai_gain_4
,
460 .ao_range_table
= &range_bipolar10
,
463 .num_p0_dio_channels
= 8,
464 .caldac
= {ad8804_debug
}, /* manual is wrong */
472 .ai_fifo_depth
= 512,
474 .gainlkup
= ai_gain_4
,
479 .ao_range_table
= &range_bipolar10
,
482 .num_p0_dio_channels
= 8,
483 .caldac
= {ad8804_debug
}, /* manual is wrong */
491 .ai_fifo_depth
= 512,
493 .gainlkup
= ai_gain_4
,
498 .ao_range_table
= &range_ni_E_ao_ext
,
501 .num_p0_dio_channels
= 8,
502 .caldac
= {ad8804_debug
}, /* manual is wrong */
511 .ai_fifo_depth
= 512,
513 .gainlkup
= ai_gain_4
,
519 .num_p0_dio_channels
= 8,
520 .caldac
= {ad8804_debug
},
528 .ai_fifo_depth
= 512,
530 .gainlkup
= ai_gain_4
,
535 .ao_range_table
= &range_bipolar10
,
538 .num_p0_dio_channels
= 8,
539 .caldac
= {ad8804_debug
},
547 .ai_fifo_depth
= 512,
549 .gainlkup
= ai_gain_16
,
554 .ao_fifo_depth
= 2048,
555 .ao_range_table
= &range_ni_E_ao_ext
,
557 .num_p0_dio_channels
= 8,
558 .caldac
= {ad8804_debug
, ad8804_debug
, ad8522
}, /* manual is wrong */
560 {.device_id
= 0x14e0,
564 .ai_fifo_depth
= 8192,
566 .gainlkup
= ai_gain_611x
,
570 .reg_type
= ni_reg_611x
,
571 .ao_range_table
= &range_bipolar10
,
573 .ao_fifo_depth
= 2048,
575 .num_p0_dio_channels
= 8,
576 .caldac
= {ad8804
, ad8804
},
583 .ai_fifo_depth
= 8192,
585 .gainlkup
= ai_gain_611x
,
589 .reg_type
= ni_reg_611x
,
590 .ao_range_table
= &range_bipolar10
,
592 .ao_fifo_depth
= 2048,
594 .num_p0_dio_channels
= 8,
595 .caldac
= {ad8804
, ad8804
},
598 /* The 6115 boards probably need their own driver */
604 .ai_fifo_depth
= 8192,
606 .gainlkup
= ai_gain_611x
,
612 .ao_fifo_depth
= 2048,
614 .num_p0_dio_channels
= 8,
616 .caldac
= {ad8804_debug
, ad8804_debug
, ad8804_debug
}, /* XXX */
625 .ai_fifo_depth
= 8192,
627 .gainlkup
= ai_gain_611x
,
633 .ao_fifo_depth
= 2048,
636 .num_p0_dio_channels
= 8,
637 caldac
= {ad8804_debug
, ad8804_debug
, ad8804_debug
}, /* XXX */
643 .n_adchan
= 0, /* no analog input */
647 .ao_fifo_depth
= 16384,
648 /* data sheet says 8192, but fifo really holds 16384 samples */
649 .ao_range_table
= &range_bipolar10
,
651 .num_p0_dio_channels
= 8,
652 .reg_type
= ni_reg_6711
,
653 .caldac
= {ad8804_debug
},
658 .n_adchan
= 0, /* no analog input */
662 .ao_fifo_depth
= 16384,
663 .ao_range_table
= &range_bipolar10
,
665 .num_p0_dio_channels
= 8,
666 .reg_type
= ni_reg_6711
,
667 .caldac
= {ad8804_debug
},
672 .n_adchan
= 0, /* no analog input */
676 .ao_fifo_depth
= 16384,
677 .ao_range_table
= &range_bipolar10
,
679 .num_p0_dio_channels
= 8,
680 .reg_type
= ni_reg_6713
,
681 .caldac
= {ad8804_debug
, ad8804_debug
},
686 .n_adchan
= 0, /* no analog input */
690 .ao_fifo_depth
= 16384,
691 .ao_range_table
= &range_bipolar10
,
693 .num_p0_dio_channels
= 8,
694 .reg_type
= ni_reg_6713
,
695 .caldac
= {ad8804_debug
, ad8804_debug
},
700 .n_adchan
= 0, /* no analog input */
704 .ao_fifo_depth
= 8192,
705 .ao_range_table
= &range_bipolar10
,
707 .num_p0_dio_channels
= 8,
708 .reg_type
= ni_reg_6711
,
709 .caldac
= {ad8804_debug
},
711 #if 0 /* need device ids */
715 .n_adchan
= 0, /* no analog input */
719 .ao_fifo_depth
= 8192,
720 .ao_range_table
= &range_bipolar10
,
721 .num_p0_dio_channels
= 8,
722 .reg_type
= ni_reg_6711
,
723 .caldac
= {ad8804_debug
},
729 .n_adchan
= 0, /* no analog input */
733 .ao_fifo_depth
= 16384,
734 .ao_range_table
= &range_bipolar10
,
736 .num_p0_dio_channels
= 8,
737 .reg_type
= ni_reg_6713
,
738 .caldac
= {ad8804_debug
, ad8804_debug
},
743 .n_adchan
= 0, /* no analog input */
747 .ao_fifo_depth
= 16384,
748 .ao_range_table
= &range_bipolar10
,
750 .num_p0_dio_channels
= 8,
751 .reg_type
= ni_reg_6713
,
752 .caldac
= {ad8804_debug
, ad8804_debug
},
759 .ai_fifo_depth
= 512,
761 .gainlkup
= ai_gain_16
,
765 .ao_fifo_depth
= 2048,
766 .ao_range_table
= &range_ni_E_ao_ext
,
769 .num_p0_dio_channels
= 8,
770 .caldac
= {ad8804_debug
},
778 .ai_fifo_depth
= 512,
780 .gainlkup
= ai_gain_16
,
784 .ao_fifo_depth
= 2048,
785 .ao_range_table
= &range_ni_E_ao_ext
,
788 .num_p0_dio_channels
= 8,
789 .caldac
= {ad8804_debug
},
797 .ai_fifo_depth
= 512,
799 .gainlkup
= ai_gain_16
,
804 .ao_fifo_depth
= 2048,
805 .ao_range_table
= &range_ni_E_ao_ext
,
807 .num_p0_dio_channels
= 8,
808 .caldac
= {mb88341
, mb88341
, ad8522
},
815 .ai_fifo_depth
= 512,
817 .gainlkup
= ai_gain_14
,
821 .ao_fifo_depth
= 2048,
822 .ao_range_table
= &range_ni_E_ao_ext
,
825 .num_p0_dio_channels
= 8,
826 .caldac
= {dac8800
, dac8043
, ad8522
},
833 .ai_fifo_depth
= 512,
835 .gainlkup
= ai_gain_4
,
840 .ao_range_table
= &range_bipolar10
,
843 .num_p0_dio_channels
= 8,
844 .caldac
= {ad8804_debug
},
852 .ai_fifo_depth
= 512,
854 .gainlkup
= ai_gain_622x
,
859 .num_p0_dio_channels
= 8,
860 .reg_type
= ni_reg_622x
,
862 .caldac
= {caldac_none
},
870 .ai_fifo_depth
= 4095,
871 .gainlkup
= ai_gain_622x
,
875 .ao_fifo_depth
= 8191,
876 .ao_range_table
= &range_ni_M_622x_ao
,
877 .reg_type
= ni_reg_622x
,
880 .num_p0_dio_channels
= 8,
881 .caldac
= {caldac_none
},
886 .name
= "pci-6221_37pin",
889 .ai_fifo_depth
= 4095,
890 .gainlkup
= ai_gain_622x
,
894 .ao_fifo_depth
= 8191,
895 .ao_range_table
= &range_ni_M_622x_ao
,
896 .reg_type
= ni_reg_622x
,
899 .num_p0_dio_channels
= 8,
900 .caldac
= {caldac_none
},
908 .ai_fifo_depth
= 4095,
909 .gainlkup
= ai_gain_622x
,
914 .reg_type
= ni_reg_622x
,
916 .num_p0_dio_channels
= 32,
917 .caldac
= {caldac_none
},
925 .ai_fifo_depth
= 4095,
926 .gainlkup
= ai_gain_622x
,
931 .reg_type
= ni_reg_622x
,
933 .num_p0_dio_channels
= 32,
934 .caldac
= {caldac_none
},
942 .ai_fifo_depth
= 4095,
943 .gainlkup
= ai_gain_622x
,
947 .ao_fifo_depth
= 8191,
948 .ao_range_table
= &range_ni_M_622x_ao
,
949 .reg_type
= ni_reg_622x
,
952 .num_p0_dio_channels
= 32,
953 .caldac
= {caldac_none
},
961 .ai_fifo_depth
= 4095,
962 .gainlkup
= ai_gain_622x
,
966 .ao_fifo_depth
= 8191,
967 .ao_range_table
= &range_ni_M_622x_ao
,
968 .reg_type
= ni_reg_622x
,
971 .num_p0_dio_channels
= 32,
972 .caldac
= {caldac_none
},
980 .ai_fifo_depth
= 4095,
981 .gainlkup
= ai_gain_622x
,
985 .ao_fifo_depth
= 8191,
986 .ao_range_table
= &range_ni_M_622x_ao
,
987 .reg_type
= ni_reg_622x
,
990 .num_p0_dio_channels
= 32,
991 .caldac
= {caldac_none
},
999 .ai_fifo_depth
= 4095,
1000 .gainlkup
= ai_gain_628x
,
1005 .reg_type
= ni_reg_625x
,
1007 .num_p0_dio_channels
= 8,
1008 .caldac
= {caldac_none
},
1012 .device_id
= 0x70b8,
1016 .ai_fifo_depth
= 4095,
1017 .gainlkup
= ai_gain_628x
,
1021 .ao_fifo_depth
= 8191,
1022 .ao_range_table
= &range_ni_M_625x_ao
,
1023 .reg_type
= ni_reg_625x
,
1026 .num_p0_dio_channels
= 8,
1027 .caldac
= {caldac_none
},
1031 .device_id
= 0x717d,
1032 .name
= "pcie-6251",
1035 .ai_fifo_depth
= 4095,
1036 .gainlkup
= ai_gain_628x
,
1040 .ao_fifo_depth
= 8191,
1041 .ao_range_table
= &range_ni_M_625x_ao
,
1042 .reg_type
= ni_reg_625x
,
1045 .num_p0_dio_channels
= 8,
1046 .caldac
= {caldac_none
},
1050 .device_id
= 0x70b7,
1054 .ai_fifo_depth
= 4095,
1055 .gainlkup
= ai_gain_628x
,
1060 .reg_type
= ni_reg_625x
,
1062 .num_p0_dio_channels
= 32,
1063 .caldac
= {caldac_none
},
1067 .device_id
= 0x70ab,
1071 .ai_fifo_depth
= 4095,
1072 .gainlkup
= ai_gain_628x
,
1076 .ao_fifo_depth
= 8191,
1077 .ao_range_table
= &range_ni_M_625x_ao
,
1078 .reg_type
= ni_reg_625x
,
1081 .num_p0_dio_channels
= 32,
1082 .caldac
= {caldac_none
},
1086 .device_id
= 0x717f,
1087 .name
= "pcie-6259",
1090 .ai_fifo_depth
= 4095,
1091 .gainlkup
= ai_gain_628x
,
1095 .ao_fifo_depth
= 8191,
1096 .ao_range_table
= &range_ni_M_625x_ao
,
1097 .reg_type
= ni_reg_625x
,
1100 .num_p0_dio_channels
= 32,
1101 .caldac
= {caldac_none
},
1105 .device_id
= 0x70b6,
1109 .ai_fifo_depth
= 2047,
1110 .gainlkup
= ai_gain_628x
,
1114 .ao_fifo_depth
= 8191,
1115 .reg_type
= ni_reg_628x
,
1117 .num_p0_dio_channels
= 8,
1118 .caldac
= {caldac_none
},
1122 .device_id
= 0x70bd,
1126 .ai_fifo_depth
= 2047,
1127 .gainlkup
= ai_gain_628x
,
1131 .ao_fifo_depth
= 8191,
1132 .ao_range_table
= &range_ni_M_628x_ao
,
1133 .reg_type
= ni_reg_628x
,
1136 .num_p0_dio_channels
= 8,
1137 .caldac
= {caldac_none
},
1141 .device_id
= 0x70bf,
1145 .ai_fifo_depth
= 2047,
1146 .gainlkup
= ai_gain_628x
,
1150 .ao_fifo_depth
= 8191,
1151 .ao_range_table
= &range_ni_M_628x_ao
,
1152 .reg_type
= ni_reg_628x
,
1155 .num_p0_dio_channels
= 8,
1156 .caldac
= {caldac_none
},
1160 .device_id
= 0x70bc,
1164 .ai_fifo_depth
= 2047,
1165 .gainlkup
= ai_gain_628x
,
1170 .reg_type
= ni_reg_628x
,
1172 .num_p0_dio_channels
= 32,
1173 .caldac
= {caldac_none
},
1177 .device_id
= 0x70ac,
1181 .ai_fifo_depth
= 2047,
1182 .gainlkup
= ai_gain_628x
,
1186 .ao_fifo_depth
= 8191,
1187 .ao_range_table
= &range_ni_M_628x_ao
,
1188 .reg_type
= ni_reg_628x
,
1191 .num_p0_dio_channels
= 32,
1192 .caldac
= {caldac_none
},
1196 .device_id
= 0x70C0,
1200 .ai_fifo_depth
= 1024,
1202 .gainlkup
= ai_gain_6143
,
1206 .reg_type
= ni_reg_6143
,
1209 .num_p0_dio_channels
= 8,
1210 .caldac
= {ad8804_debug
, ad8804_debug
},
1213 .device_id
= 0x710D,
1217 .ai_fifo_depth
= 1024,
1219 .gainlkup
= ai_gain_6143
,
1223 .reg_type
= ni_reg_6143
,
1226 .num_p0_dio_channels
= 8,
1227 .caldac
= {ad8804_debug
, ad8804_debug
},
1231 #define n_pcimio_boards ARRAY_SIZE(ni_boards)
1233 static int pcimio_attach(struct comedi_device
*dev
,
1234 struct comedi_devconfig
*it
);
1235 static int pcimio_detach(struct comedi_device
*dev
);
1236 static struct comedi_driver driver_pcimio
= {
1237 .driver_name
= DRV_NAME
,
1238 .module
= THIS_MODULE
,
1239 .attach
= pcimio_attach
,
1240 .detach
= pcimio_detach
,
1243 COMEDI_PCI_INITCLEANUP(driver_pcimio
, ni_pci_table
)
1247 #define devpriv ((struct ni_private *)dev->private)
1249 /* How we access registers */
1251 #define ni_writel(a, b) (writel((a), devpriv->mite->daq_io_addr + (b)))
1252 #define ni_readl(a) (readl(devpriv->mite->daq_io_addr + (a)))
1253 #define ni_writew(a, b) (writew((a), devpriv->mite->daq_io_addr + (b)))
1254 #define ni_readw(a) (readw(devpriv->mite->daq_io_addr + (a)))
1255 #define ni_writeb(a, b) (writeb((a), devpriv->mite->daq_io_addr + (b)))
1256 #define ni_readb(a) (readb(devpriv->mite->daq_io_addr + (a)))
1258 /* How we access STC registers */
1260 /* We automatically take advantage of STC registers that can be
1261 * read/written directly in the I/O space of the board. Most
1262 * PCIMIO devices map the low 8 STC registers to iobase+addr*2.
1263 * The 611x devices map the write registers to iobase+addr*2, and
1264 * the read registers to iobase+(addr-1)*2. */
1265 /* However, the 611x boards still aren't working, so I'm disabling
1266 * non-windowed STC access temporarily */
1268 static void e_series_win_out(struct comedi_device
*dev
, uint16_t data
, int reg
)
1270 unsigned long flags
;
1272 spin_lock_irqsave(&devpriv
->window_lock
, flags
);
1273 ni_writew(reg
, Window_Address
);
1274 ni_writew(data
, Window_Data
);
1275 spin_unlock_irqrestore(&devpriv
->window_lock
, flags
);
1278 static uint16_t e_series_win_in(struct comedi_device
*dev
, int reg
)
1280 unsigned long flags
;
1283 spin_lock_irqsave(&devpriv
->window_lock
, flags
);
1284 ni_writew(reg
, Window_Address
);
1285 ret
= ni_readw(Window_Data
);
1286 spin_unlock_irqrestore(&devpriv
->window_lock
, flags
);
1291 static void m_series_stc_writew(struct comedi_device
*dev
, uint16_t data
,
1296 case ADC_FIFO_Clear
:
1297 offset
= M_Offset_AI_FIFO_Clear
;
1299 case AI_Command_1_Register
:
1300 offset
= M_Offset_AI_Command_1
;
1302 case AI_Command_2_Register
:
1303 offset
= M_Offset_AI_Command_2
;
1305 case AI_Mode_1_Register
:
1306 offset
= M_Offset_AI_Mode_1
;
1308 case AI_Mode_2_Register
:
1309 offset
= M_Offset_AI_Mode_2
;
1311 case AI_Mode_3_Register
:
1312 offset
= M_Offset_AI_Mode_3
;
1314 case AI_Output_Control_Register
:
1315 offset
= M_Offset_AI_Output_Control
;
1317 case AI_Personal_Register
:
1318 offset
= M_Offset_AI_Personal
;
1320 case AI_SI2_Load_A_Register
:
1321 /* this is actually a 32 bit register on m series boards */
1322 ni_writel(data
, M_Offset_AI_SI2_Load_A
);
1325 case AI_SI2_Load_B_Register
:
1326 /* this is actually a 32 bit register on m series boards */
1327 ni_writel(data
, M_Offset_AI_SI2_Load_B
);
1330 case AI_START_STOP_Select_Register
:
1331 offset
= M_Offset_AI_START_STOP_Select
;
1333 case AI_Trigger_Select_Register
:
1334 offset
= M_Offset_AI_Trigger_Select
;
1336 case Analog_Trigger_Etc_Register
:
1337 offset
= M_Offset_Analog_Trigger_Etc
;
1339 case AO_Command_1_Register
:
1340 offset
= M_Offset_AO_Command_1
;
1342 case AO_Command_2_Register
:
1343 offset
= M_Offset_AO_Command_2
;
1345 case AO_Mode_1_Register
:
1346 offset
= M_Offset_AO_Mode_1
;
1348 case AO_Mode_2_Register
:
1349 offset
= M_Offset_AO_Mode_2
;
1351 case AO_Mode_3_Register
:
1352 offset
= M_Offset_AO_Mode_3
;
1354 case AO_Output_Control_Register
:
1355 offset
= M_Offset_AO_Output_Control
;
1357 case AO_Personal_Register
:
1358 offset
= M_Offset_AO_Personal
;
1360 case AO_Start_Select_Register
:
1361 offset
= M_Offset_AO_Start_Select
;
1363 case AO_Trigger_Select_Register
:
1364 offset
= M_Offset_AO_Trigger_Select
;
1366 case Clock_and_FOUT_Register
:
1367 offset
= M_Offset_Clock_and_FOUT
;
1369 case Configuration_Memory_Clear
:
1370 offset
= M_Offset_Configuration_Memory_Clear
;
1372 case DAC_FIFO_Clear
:
1373 offset
= M_Offset_AO_FIFO_Clear
;
1375 case DIO_Control_Register
:
1377 ("%s: FIXME: register 0x%x does not map cleanly on to m-series boards.\n",
1381 case G_Autoincrement_Register(0):
1382 offset
= M_Offset_G0_Autoincrement
;
1384 case G_Autoincrement_Register(1):
1385 offset
= M_Offset_G1_Autoincrement
;
1387 case G_Command_Register(0):
1388 offset
= M_Offset_G0_Command
;
1390 case G_Command_Register(1):
1391 offset
= M_Offset_G1_Command
;
1393 case G_Input_Select_Register(0):
1394 offset
= M_Offset_G0_Input_Select
;
1396 case G_Input_Select_Register(1):
1397 offset
= M_Offset_G1_Input_Select
;
1399 case G_Mode_Register(0):
1400 offset
= M_Offset_G0_Mode
;
1402 case G_Mode_Register(1):
1403 offset
= M_Offset_G1_Mode
;
1405 case Interrupt_A_Ack_Register
:
1406 offset
= M_Offset_Interrupt_A_Ack
;
1408 case Interrupt_A_Enable_Register
:
1409 offset
= M_Offset_Interrupt_A_Enable
;
1411 case Interrupt_B_Ack_Register
:
1412 offset
= M_Offset_Interrupt_B_Ack
;
1414 case Interrupt_B_Enable_Register
:
1415 offset
= M_Offset_Interrupt_B_Enable
;
1417 case Interrupt_Control_Register
:
1418 offset
= M_Offset_Interrupt_Control
;
1420 case IO_Bidirection_Pin_Register
:
1421 offset
= M_Offset_IO_Bidirection_Pin
;
1423 case Joint_Reset_Register
:
1424 offset
= M_Offset_Joint_Reset
;
1426 case RTSI_Trig_A_Output_Register
:
1427 offset
= M_Offset_RTSI_Trig_A_Output
;
1429 case RTSI_Trig_B_Output_Register
:
1430 offset
= M_Offset_RTSI_Trig_B_Output
;
1432 case RTSI_Trig_Direction_Register
:
1433 offset
= M_Offset_RTSI_Trig_Direction
;
1435 /* FIXME: DIO_Output_Register (16 bit reg) is replaced by M_Offset_Static_Digital_Output (32 bit)
1436 and M_Offset_SCXI_Serial_Data_Out (8 bit) */
1438 printk("%s: bug! unhandled register=0x%x in switch.\n",
1444 ni_writew(data
, offset
);
1447 static uint16_t m_series_stc_readw(struct comedi_device
*dev
, int reg
)
1451 case AI_Status_1_Register
:
1452 offset
= M_Offset_AI_Status_1
;
1454 case AO_Status_1_Register
:
1455 offset
= M_Offset_AO_Status_1
;
1457 case AO_Status_2_Register
:
1458 offset
= M_Offset_AO_Status_2
;
1460 case DIO_Serial_Input_Register
:
1461 return ni_readb(M_Offset_SCXI_Serial_Data_In
);
1463 case Joint_Status_1_Register
:
1464 offset
= M_Offset_Joint_Status_1
;
1466 case Joint_Status_2_Register
:
1467 offset
= M_Offset_Joint_Status_2
;
1469 case G_Status_Register
:
1470 offset
= M_Offset_G01_Status
;
1473 printk("%s: bug! unhandled register=0x%x in switch.\n",
1479 return ni_readw(offset
);
1482 static void m_series_stc_writel(struct comedi_device
*dev
, uint32_t data
,
1487 case AI_SC_Load_A_Registers
:
1488 offset
= M_Offset_AI_SC_Load_A
;
1490 case AI_SI_Load_A_Registers
:
1491 offset
= M_Offset_AI_SI_Load_A
;
1493 case AO_BC_Load_A_Register
:
1494 offset
= M_Offset_AO_BC_Load_A
;
1496 case AO_UC_Load_A_Register
:
1497 offset
= M_Offset_AO_UC_Load_A
;
1499 case AO_UI_Load_A_Register
:
1500 offset
= M_Offset_AO_UI_Load_A
;
1502 case G_Load_A_Register(0):
1503 offset
= M_Offset_G0_Load_A
;
1505 case G_Load_A_Register(1):
1506 offset
= M_Offset_G1_Load_A
;
1508 case G_Load_B_Register(0):
1509 offset
= M_Offset_G0_Load_B
;
1511 case G_Load_B_Register(1):
1512 offset
= M_Offset_G1_Load_B
;
1515 printk("%s: bug! unhandled register=0x%x in switch.\n",
1521 ni_writel(data
, offset
);
1524 static uint32_t m_series_stc_readl(struct comedi_device
*dev
, int reg
)
1528 case G_HW_Save_Register(0):
1529 offset
= M_Offset_G0_HW_Save
;
1531 case G_HW_Save_Register(1):
1532 offset
= M_Offset_G1_HW_Save
;
1534 case G_Save_Register(0):
1535 offset
= M_Offset_G0_Save
;
1537 case G_Save_Register(1):
1538 offset
= M_Offset_G1_Save
;
1541 printk("%s: bug! unhandled register=0x%x in switch.\n",
1547 return ni_readl(offset
);
1550 #define interrupt_pin(a) 0
1551 #define IRQ_POLARITY 1
1553 #define NI_E_IRQ_FLAGS IRQF_SHARED
1555 #include "ni_mio_common.c"
1557 static int pcimio_find_device(struct comedi_device
*dev
, int bus
, int slot
);
1558 static int pcimio_ai_change(struct comedi_device
*dev
,
1559 struct comedi_subdevice
*s
, unsigned long new_size
);
1560 static int pcimio_ao_change(struct comedi_device
*dev
,
1561 struct comedi_subdevice
*s
, unsigned long new_size
);
1562 static int pcimio_gpct0_change(struct comedi_device
*dev
,
1563 struct comedi_subdevice
*s
,
1564 unsigned long new_size
);
1565 static int pcimio_gpct1_change(struct comedi_device
*dev
,
1566 struct comedi_subdevice
*s
,
1567 unsigned long new_size
);
1568 static int pcimio_dio_change(struct comedi_device
*dev
,
1569 struct comedi_subdevice
*s
,
1570 unsigned long new_size
);
1572 static void m_series_init_eeprom_buffer(struct comedi_device
*dev
)
1574 static const int Start_Cal_EEPROM
= 0x400;
1575 static const unsigned window_size
= 10;
1576 static const int serial_number_eeprom_offset
= 0x4;
1577 static const int serial_number_eeprom_length
= 0x4;
1578 unsigned old_iodwbsr_bits
;
1579 unsigned old_iodwbsr1_bits
;
1580 unsigned old_iodwcr1_bits
;
1583 old_iodwbsr_bits
= readl(devpriv
->mite
->mite_io_addr
+ MITE_IODWBSR
);
1584 old_iodwbsr1_bits
= readl(devpriv
->mite
->mite_io_addr
+ MITE_IODWBSR_1
);
1585 old_iodwcr1_bits
= readl(devpriv
->mite
->mite_io_addr
+ MITE_IODWCR_1
);
1586 writel(0x0, devpriv
->mite
->mite_io_addr
+ MITE_IODWBSR
);
1587 writel(((0x80 | window_size
) | devpriv
->mite
->daq_phys_addr
),
1588 devpriv
->mite
->mite_io_addr
+ MITE_IODWBSR_1
);
1589 writel(0x1 | old_iodwcr1_bits
,
1590 devpriv
->mite
->mite_io_addr
+ MITE_IODWCR_1
);
1591 writel(0xf, devpriv
->mite
->mite_io_addr
+ 0x30);
1593 BUG_ON(serial_number_eeprom_length
> sizeof(devpriv
->serial_number
));
1594 for (i
= 0; i
< serial_number_eeprom_length
; ++i
) {
1595 char *byte_ptr
= (char *)&devpriv
->serial_number
+ i
;
1596 *byte_ptr
= ni_readb(serial_number_eeprom_offset
+ i
);
1598 devpriv
->serial_number
= be32_to_cpu(devpriv
->serial_number
);
1600 for (i
= 0; i
< M_SERIES_EEPROM_SIZE
; ++i
) {
1601 devpriv
->eeprom_buffer
[i
] = ni_readb(Start_Cal_EEPROM
+ i
);
1604 writel(old_iodwbsr1_bits
, devpriv
->mite
->mite_io_addr
+ MITE_IODWBSR_1
);
1605 writel(old_iodwbsr_bits
, devpriv
->mite
->mite_io_addr
+ MITE_IODWBSR
);
1606 writel(old_iodwcr1_bits
, devpriv
->mite
->mite_io_addr
+ MITE_IODWCR_1
);
1607 writel(0x0, devpriv
->mite
->mite_io_addr
+ 0x30);
1610 static void init_6143(struct comedi_device
*dev
)
1612 /* Disable interrupts */
1613 devpriv
->stc_writew(dev
, 0, Interrupt_Control_Register
);
1615 /* Initialise 6143 AI specific bits */
1616 ni_writeb(0x00, Magic_6143
); /* Set G0,G1 DMA mode to E series version */
1617 ni_writeb(0x80, PipelineDelay_6143
); /* Set EOCMode, ADCMode and pipelinedelay */
1618 ni_writeb(0x00, EOC_Set_6143
); /* Set EOC Delay */
1620 ni_writel(boardtype
.ai_fifo_depth
/ 2, AIFIFO_Flag_6143
); /* Set the FIFO half full level */
1622 /* Strobe Relay disable bit */
1623 devpriv
->ai_calib_source_enabled
= 0;
1624 ni_writew(devpriv
->ai_calib_source
| Calibration_Channel_6143_RelayOff
,
1625 Calibration_Channel_6143
);
1626 ni_writew(devpriv
->ai_calib_source
, Calibration_Channel_6143
);
1629 /* cleans up allocated resources */
1630 static int pcimio_detach(struct comedi_device
*dev
)
1632 mio_common_detach(dev
);
1634 free_irq(dev
->irq
, dev
);
1637 mite_free_ring(devpriv
->ai_mite_ring
);
1638 mite_free_ring(devpriv
->ao_mite_ring
);
1639 mite_free_ring(devpriv
->cdo_mite_ring
);
1640 mite_free_ring(devpriv
->gpct_mite_ring
[0]);
1641 mite_free_ring(devpriv
->gpct_mite_ring
[1]);
1643 mite_unsetup(devpriv
->mite
);
1649 static int pcimio_attach(struct comedi_device
*dev
, struct comedi_devconfig
*it
)
1653 printk("comedi%d: ni_pcimio:", dev
->minor
);
1655 ret
= ni_alloc_private(dev
);
1659 ret
= pcimio_find_device(dev
, it
->options
[0], it
->options
[1]);
1663 printk(" %s", boardtype
.name
);
1664 dev
->board_name
= boardtype
.name
;
1666 if (boardtype
.reg_type
& ni_reg_m_series_mask
) {
1667 devpriv
->stc_writew
= &m_series_stc_writew
;
1668 devpriv
->stc_readw
= &m_series_stc_readw
;
1669 devpriv
->stc_writel
= &m_series_stc_writel
;
1670 devpriv
->stc_readl
= &m_series_stc_readl
;
1672 devpriv
->stc_writew
= &e_series_win_out
;
1673 devpriv
->stc_readw
= &e_series_win_in
;
1674 devpriv
->stc_writel
= &win_out2
;
1675 devpriv
->stc_readl
= &win_in2
;
1678 ret
= mite_setup(devpriv
->mite
);
1680 printk(" error setting up mite\n");
1683 comedi_set_hw_dev(dev
, &devpriv
->mite
->pcidev
->dev
);
1684 devpriv
->ai_mite_ring
= mite_alloc_ring(devpriv
->mite
);
1685 if (devpriv
->ai_mite_ring
== NULL
)
1687 devpriv
->ao_mite_ring
= mite_alloc_ring(devpriv
->mite
);
1688 if (devpriv
->ao_mite_ring
== NULL
)
1690 devpriv
->cdo_mite_ring
= mite_alloc_ring(devpriv
->mite
);
1691 if (devpriv
->cdo_mite_ring
== NULL
)
1693 devpriv
->gpct_mite_ring
[0] = mite_alloc_ring(devpriv
->mite
);
1694 if (devpriv
->gpct_mite_ring
[0] == NULL
)
1696 devpriv
->gpct_mite_ring
[1] = mite_alloc_ring(devpriv
->mite
);
1697 if (devpriv
->gpct_mite_ring
[1] == NULL
)
1700 if (boardtype
.reg_type
& ni_reg_m_series_mask
)
1701 m_series_init_eeprom_buffer(dev
);
1702 if (boardtype
.reg_type
== ni_reg_6143
)
1705 dev
->irq
= mite_irq(devpriv
->mite
);
1707 if (dev
->irq
== 0) {
1708 printk(" unknown irq (bad)\n");
1710 printk(" ( irq = %u )", dev
->irq
);
1711 ret
= request_irq(dev
->irq
, ni_E_interrupt
, NI_E_IRQ_FLAGS
,
1714 printk(" irq not available\n");
1719 ret
= ni_E_init(dev
, it
);
1723 dev
->subdevices
[NI_AI_SUBDEV
].buf_change
= &pcimio_ai_change
;
1724 dev
->subdevices
[NI_AO_SUBDEV
].buf_change
= &pcimio_ao_change
;
1725 dev
->subdevices
[NI_GPCT_SUBDEV(0)].buf_change
= &pcimio_gpct0_change
;
1726 dev
->subdevices
[NI_GPCT_SUBDEV(1)].buf_change
= &pcimio_gpct1_change
;
1727 dev
->subdevices
[NI_DIO_SUBDEV
].buf_change
= &pcimio_dio_change
;
1732 static int pcimio_find_device(struct comedi_device
*dev
, int bus
, int slot
)
1734 struct mite_struct
*mite
;
1737 for (mite
= mite_devices
; mite
; mite
= mite
->next
) {
1741 if (bus
!= mite
->pcidev
->bus
->number
||
1742 slot
!= PCI_SLOT(mite
->pcidev
->devfn
))
1746 for (i
= 0; i
< n_pcimio_boards
; i
++) {
1747 if (mite_device_id(mite
) == ni_boards
[i
].device_id
) {
1748 dev
->board_ptr
= ni_boards
+ i
;
1749 devpriv
->mite
= mite
;
1755 printk("no device found\n");
1756 mite_list_devices();
1760 static int pcimio_ai_change(struct comedi_device
*dev
,
1761 struct comedi_subdevice
*s
, unsigned long new_size
)
1765 ret
= mite_buf_change(devpriv
->ai_mite_ring
, s
->async
);
1772 static int pcimio_ao_change(struct comedi_device
*dev
,
1773 struct comedi_subdevice
*s
, unsigned long new_size
)
1777 ret
= mite_buf_change(devpriv
->ao_mite_ring
, s
->async
);
1784 static int pcimio_gpct0_change(struct comedi_device
*dev
,
1785 struct comedi_subdevice
*s
,
1786 unsigned long new_size
)
1790 ret
= mite_buf_change(devpriv
->gpct_mite_ring
[0], s
->async
);
1797 static int pcimio_gpct1_change(struct comedi_device
*dev
,
1798 struct comedi_subdevice
*s
,
1799 unsigned long new_size
)
1803 ret
= mite_buf_change(devpriv
->gpct_mite_ring
[1], s
->async
);
1810 static int pcimio_dio_change(struct comedi_device
*dev
,
1811 struct comedi_subdevice
*s
, unsigned long new_size
)
1815 ret
= mite_buf_change(devpriv
->cdo_mite_ring
, s
->async
);