113 #include "../comedidev.h"
115 #include <asm/byteorder.h>
128 #define MAX_N_CALDACS (16+16+2)
130 #define DRV_NAME "ni_pcimio"
139 static const struct comedi_lrange range_ni_M_628x_ao = { 8, {
152 static const struct comedi_lrange range_ni_M_625x_ao = { 3, {
159 static const struct comedi_lrange range_ni_M_622x_ao = { 1, {
167 .name =
"pci-mio-16xe-50",
170 .ai_fifo_depth = 2048,
180 .num_p0_dio_channels = 8,
186 .name =
"pci-mio-16xe-10",
189 .ai_fifo_depth = 512,
195 .ao_fifo_depth = 2048,
196 .ao_range_table = &range_ni_E_ao_ext,
199 .num_p0_dio_channels = 8,
208 .ai_fifo_depth = 512,
218 .num_p0_dio_channels = 8,
227 .ai_fifo_depth = 512,
233 .ao_fifo_depth = 2048,
234 .ao_range_table = &range_ni_E_ao_ext,
237 .num_p0_dio_channels = 8,
243 .name =
"pci-mio-16e-1",
246 .ai_fifo_depth = 512,
252 .ao_fifo_depth = 2048,
253 .ao_range_table = &range_ni_E_ao_ext,
256 .num_p0_dio_channels = 8,
262 .name =
"pci-mio-16e-4",
265 .ai_fifo_depth = 512,
273 .ao_fifo_depth = 512,
274 .ao_range_table = &range_ni_E_ao_ext,
277 .num_p0_dio_channels = 8,
286 .ai_fifo_depth = 512,
292 .ao_fifo_depth = 512,
293 .ao_range_table = &range_ni_E_ao_ext,
296 .num_p0_dio_channels = 8,
306 .ai_fifo_depth = 512,
312 .ao_fifo_depth = 2048,
313 .ao_range_table = &range_ni_E_ao_ext,
316 .num_p0_dio_channels = 8,
325 .ai_fifo_depth = 512,
333 .num_p0_dio_channels = 8,
342 .ai_fifo_depth = 512,
350 .num_p0_dio_channels = 8,
359 .ai_fifo_depth = 512,
365 .ao_fifo_depth = 2048,
366 .ao_range_table = &range_ni_E_ao_ext,
369 .num_p0_dio_channels = 8,
378 .ai_fifo_depth = 512,
385 .num_p0_dio_channels = 8,
394 .ai_fifo_depth = 512,
404 .num_p0_dio_channels = 8,
413 .ai_fifo_depth = 512,
423 .num_p0_dio_channels = 8,
432 .ai_fifo_depth = 512,
439 .ao_range_table = &range_ni_E_ao_ext,
442 .num_p0_dio_channels = 8,
452 .ai_fifo_depth = 512,
460 .num_p0_dio_channels = 8,
469 .ai_fifo_depth = 512,
479 .num_p0_dio_channels = 8,
488 .ai_fifo_depth = 512,
495 .ao_fifo_depth = 2048,
496 .ao_range_table = &range_ni_E_ao_ext,
498 .num_p0_dio_channels = 8,
501 {.device_id = 0x14e0,
505 .ai_fifo_depth = 8192,
514 .ao_fifo_depth = 2048,
516 .num_p0_dio_channels = 8,
524 .ai_fifo_depth = 8192,
533 .ao_fifo_depth = 2048,
535 .num_p0_dio_channels = 8,
545 .ai_fifo_depth = 8192,
553 .ao_fifo_depth = 2048,
555 .num_p0_dio_channels = 8,
566 .ai_fifo_depth = 8192,
574 .ao_fifo_depth = 2048,
577 .num_p0_dio_channels = 8,
588 .ao_fifo_depth = 16384,
592 .num_p0_dio_channels = 8,
603 .ao_fifo_depth = 16384,
606 .num_p0_dio_channels = 8,
617 .ao_fifo_depth = 16384,
620 .num_p0_dio_channels = 8,
631 .ao_fifo_depth = 16384,
634 .num_p0_dio_channels = 8,
645 .ao_fifo_depth = 8192,
648 .num_p0_dio_channels = 8,
660 .ao_fifo_depth = 8192,
662 .num_p0_dio_channels = 8,
674 .ao_fifo_depth = 16384,
677 .num_p0_dio_channels = 8,
688 .ao_fifo_depth = 16384,
691 .num_p0_dio_channels = 8,
700 .ai_fifo_depth = 512,
706 .ao_fifo_depth = 2048,
707 .ao_range_table = &range_ni_E_ao_ext,
710 .num_p0_dio_channels = 8,
719 .ai_fifo_depth = 512,
725 .ao_fifo_depth = 2048,
726 .ao_range_table = &range_ni_E_ao_ext,
729 .num_p0_dio_channels = 8,
738 .ai_fifo_depth = 512,
745 .ao_fifo_depth = 2048,
746 .ao_range_table = &range_ni_E_ao_ext,
748 .num_p0_dio_channels = 8,
756 .ai_fifo_depth = 512,
762 .ao_fifo_depth = 2048,
763 .ao_range_table = &range_ni_E_ao_ext,
766 .num_p0_dio_channels = 8,
774 .ai_fifo_depth = 512,
784 .num_p0_dio_channels = 8,
793 .ai_fifo_depth = 512,
800 .num_p0_dio_channels = 8,
811 .ai_fifo_depth = 4095,
816 .ao_fifo_depth = 8191,
817 .ao_range_table = &range_ni_M_622x_ao,
821 .num_p0_dio_channels = 8,
827 .name =
"pci-6221_37pin",
830 .ai_fifo_depth = 4095,
835 .ao_fifo_depth = 8191,
836 .ao_range_table = &range_ni_M_622x_ao,
840 .num_p0_dio_channels = 8,
849 .ai_fifo_depth = 4095,
857 .num_p0_dio_channels = 32,
866 .ai_fifo_depth = 4095,
874 .num_p0_dio_channels = 32,
883 .ai_fifo_depth = 4095,
888 .ao_fifo_depth = 8191,
889 .ao_range_table = &range_ni_M_622x_ao,
893 .num_p0_dio_channels = 32,
902 .ai_fifo_depth = 4095,
907 .ao_fifo_depth = 8191,
908 .ao_range_table = &range_ni_M_622x_ao,
912 .num_p0_dio_channels = 32,
921 .ai_fifo_depth = 4095,
926 .ao_fifo_depth = 8191,
927 .ao_range_table = &range_ni_M_622x_ao,
931 .num_p0_dio_channels = 32,
940 .ai_fifo_depth = 4095,
948 .num_p0_dio_channels = 8,
957 .ai_fifo_depth = 4095,
962 .ao_fifo_depth = 8191,
963 .ao_range_table = &range_ni_M_625x_ao,
967 .num_p0_dio_channels = 8,
976 .ai_fifo_depth = 4095,
981 .ao_fifo_depth = 8191,
982 .ao_range_table = &range_ni_M_625x_ao,
986 .num_p0_dio_channels = 8,
995 .ai_fifo_depth = 4095,
1000 .ao_fifo_depth = 8191,
1001 .ao_range_table = &range_ni_M_625x_ao,
1005 .num_p0_dio_channels = 8,
1010 .device_id = 0x70b7,
1014 .ai_fifo_depth = 4095,
1022 .num_p0_dio_channels = 32,
1027 .device_id = 0x70ab,
1031 .ai_fifo_depth = 4095,
1036 .ao_fifo_depth = 8191,
1037 .ao_range_table = &range_ni_M_625x_ao,
1041 .num_p0_dio_channels = 32,
1046 .device_id = 0x717f,
1047 .name =
"pcie-6259",
1050 .ai_fifo_depth = 4095,
1055 .ao_fifo_depth = 8191,
1056 .ao_range_table = &range_ni_M_625x_ao,
1060 .num_p0_dio_channels = 32,
1065 .device_id = 0x70b6,
1069 .ai_fifo_depth = 2047,
1074 .ao_fifo_depth = 8191,
1077 .num_p0_dio_channels = 8,
1082 .device_id = 0x70bd,
1086 .ai_fifo_depth = 2047,
1091 .ao_fifo_depth = 8191,
1092 .ao_range_table = &range_ni_M_628x_ao,
1096 .num_p0_dio_channels = 8,
1101 .device_id = 0x70bf,
1105 .ai_fifo_depth = 2047,
1110 .ao_fifo_depth = 8191,
1111 .ao_range_table = &range_ni_M_628x_ao,
1115 .num_p0_dio_channels = 8,
1120 .device_id = 0x70bc,
1124 .ai_fifo_depth = 2047,
1132 .num_p0_dio_channels = 32,
1137 .device_id = 0x70ac,
1141 .ai_fifo_depth = 2047,
1146 .ao_fifo_depth = 8191,
1147 .ao_range_table = &range_ni_M_628x_ao,
1151 .num_p0_dio_channels = 32,
1156 .device_id = 0x70C0,
1160 .ai_fifo_depth = 1024,
1169 .num_p0_dio_channels = 8,
1173 .device_id = 0x710D,
1177 .ai_fifo_depth = 1024,
1186 .num_p0_dio_channels = 8,
1193 #define devpriv ((struct ni_private *)dev->private)
1197 #define ni_writel(a, b) (writel((a), devpriv->mite->daq_io_addr + (b)))
1198 #define ni_readl(a) (readl(devpriv->mite->daq_io_addr + (a)))
1199 #define ni_writew(a, b) (writew((a), devpriv->mite->daq_io_addr + (b)))
1200 #define ni_readw(a) (readw(devpriv->mite->daq_io_addr + (a)))
1201 #define ni_writeb(a, b) (writeb((a), devpriv->mite->daq_io_addr + (b)))
1202 #define ni_readb(a) (readb(devpriv->mite->daq_io_addr + (a)))
1216 unsigned long flags;
1221 spin_unlock_irqrestore(&
devpriv->window_lock, flags);
1226 unsigned long flags;
1232 spin_unlock_irqrestore(&
devpriv->window_lock, flags);
1323 (
"%s: FIXME: register 0x%x does not map cleanly on to m-series boards.\n",
1496 #define interrupt_pin(a) 0
1497 #define IRQ_POLARITY 1
1499 #define NI_E_IRQ_FLAGS IRQF_SHARED
1509 unsigned long new_size);
1512 unsigned long new_size);
1515 unsigned long new_size);
1517 static void m_series_init_eeprom_buffer(
struct comedi_device *dev)
1519 static const int Start_Cal_EEPROM = 0x400;
1520 static const unsigned window_size = 10;
1521 static const int serial_number_eeprom_offset = 0x4;
1522 static const int serial_number_eeprom_length = 0x4;
1523 unsigned old_iodwbsr_bits;
1524 unsigned old_iodwbsr1_bits;
1525 unsigned old_iodwcr1_bits;
1532 writel(((0x80 | window_size) |
devpriv->mite->daq_phys_addr),
1534 writel(0x1 | old_iodwcr1_bits,
1538 BUG_ON(serial_number_eeprom_length >
sizeof(
devpriv->serial_number));
1539 for (i = 0; i < serial_number_eeprom_length; ++
i) {
1540 char *byte_ptr = (
char *)&
devpriv->serial_number + i;
1541 *byte_ptr =
ni_readb(serial_number_eeprom_offset + i);
1567 devpriv->ai_calib_source_enabled = 0;
1575 mio_common_detach(dev);
1597 for (n = 0; n <
ARRAY_SIZE(ni_boards); n++) {
1612 ret = ni_alloc_private(dev);
1616 dev->
board_ptr = pcimio_find_boardinfo(pcidev);
1628 devpriv->stc_writew = &m_series_stc_writew;
1629 devpriv->stc_readw = &m_series_stc_readw;
1630 devpriv->stc_writel = &m_series_stc_writel;
1631 devpriv->stc_readl = &m_series_stc_readl;
1633 devpriv->stc_writew = &e_series_win_out;
1634 devpriv->stc_readw = &e_series_win_in;
1635 devpriv->stc_writel = &win_out2;
1636 devpriv->stc_readl = &win_in2;
1641 pr_warn(
"error setting up mite\n");
1644 comedi_set_hw_dev(dev, &
devpriv->mite->pcidev->dev);
1662 m_series_init_eeprom_buffer(dev);
1668 if (dev->
irq == 0) {
1669 pr_warn(
"unknown irq (bad)\n");
1675 pr_warn(
"irq not available\n");
1680 ret = ni_E_init(dev);
1686 dev->
subdevices[NI_GPCT_SUBDEV(0)].buf_change = &pcimio_gpct0_change;
1687 dev->
subdevices[NI_GPCT_SUBDEV(1)].buf_change = &pcimio_gpct1_change;
1719 unsigned long new_size)
1732 unsigned long new_size)
1756 .driver_name =
"ni_pcimio",
1758 .attach_pci = pcimio_attach_pci,
1759 .detach = pcimio_detach,
1831 static struct pci_driver ni_pcimio_pci_driver = {
1832 .name =
"ni_pcimio",
1833 .id_table = ni_pcimio_pci_table,
1834 .probe = ni_pcimio_pci_probe,