1 // SPDX-License-Identifier: GPL-2.0+
3 * Comedi driver for NI PCMCIA MIO E series cards
5 * COMEDI - Linux Control and Measurement Device Interface
6 * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
11 * Description: National Instruments DAQCard E series
14 * Devices: [National Instruments] DAQCard-AI-16XE-50 (ni_mio_cs),
15 * DAQCard-AI-16E-4, DAQCard-6062E, DAQCard-6024E, DAQCard-6036E
16 * Updated: Thu Oct 23 19:43:17 CDT 2003
18 * See the notes in the ni_atmio.o driver.
22 * The real guts of the driver is in ni_mio_common.c, which is
23 * included by all the E series drivers.
25 * References for specifications:
26 * 341080a.pdf DAQCard E Series Register Level Programmer Manual
29 #include <linux/module.h>
30 #include <linux/delay.h>
32 #include "../comedi_pcmcia.h"
40 static const struct ni_board_struct ni_boards[] = {
42 .name = "DAQCard-ai-16xe-50",
46 .ai_fifo_depth = 1024,
47 .gainlkup = ai_gain_8,
49 .caldac = { dac8800, dac8043 },
51 .name = "DAQCard-ai-16e-4",
55 .ai_fifo_depth = 1024,
56 .gainlkup = ai_gain_16,
58 .caldac = { mb88341 }, /* verified */
60 .name = "DAQCard-6062E",
64 .ai_fifo_depth = 8192,
65 .gainlkup = ai_gain_16,
69 .ao_fifo_depth = 2048,
70 .ao_range_table = &range_bipolar10,
72 .caldac = { ad8804_debug }, /* verified */
74 /* specs incorrect! */
75 .name = "DAQCard-6024E",
79 .ai_fifo_depth = 1024,
80 .gainlkup = ai_gain_4,
84 .ao_range_table = &range_bipolar10,
86 .caldac = { ad8804_debug },
88 /* specs incorrect! */
89 .name = "DAQCard-6036E",
93 .ai_fifo_depth = 1024,
95 .gainlkup = ai_gain_4,
99 .ao_range_table = &range_bipolar10,
101 .caldac = { ad8804_debug },
105 .name = "DAQCard-6715",
106 .device_id = 0x0000, /* unknown */
108 .ao_maxdata = 0x0fff,
110 .caldac = { mb88341, mb88341 },
115 #include "ni_mio_common.c"
117 static const void *ni_getboardtype(struct comedi_device *dev,
118 struct pcmcia_device *link)
120 static const struct ni_board_struct *board;
123 for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
124 board = &ni_boards[i];
125 if (board->device_id == link->card_id)
131 static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data)
135 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
136 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
138 for (base = 0x000; base < 0x400; base += 0x20) {
139 p_dev->resource[0]->start = base;
140 ret = pcmcia_request_io(p_dev);
147 static int mio_cs_auto_attach(struct comedi_device *dev,
148 unsigned long context)
150 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
151 static const struct ni_board_struct *board;
154 board = ni_getboardtype(dev, link);
157 dev->board_ptr = board;
158 dev->board_name = board->name;
160 link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
161 ret = comedi_pcmcia_enable(dev, mio_pcmcia_config_loop);
164 dev->iobase = link->resource[0]->start;
167 ret = pcmcia_request_irq(link, ni_E_interrupt);
170 dev->irq = link->irq;
172 ret = ni_alloc_private(dev);
176 return ni_E_init(dev, 0, 1);
179 static void mio_cs_detach(struct comedi_device *dev)
181 mio_common_detach(dev);
182 comedi_pcmcia_disable(dev);
185 static struct comedi_driver driver_ni_mio_cs = {
186 .driver_name = "ni_mio_cs",
187 .module = THIS_MODULE,
188 .auto_attach = mio_cs_auto_attach,
189 .detach = mio_cs_detach,
192 static int cs_attach(struct pcmcia_device *link)
194 return comedi_pcmcia_auto_config(link, &driver_ni_mio_cs);
197 static const struct pcmcia_device_id ni_mio_cs_ids[] = {
198 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010d), /* DAQCard-ai-16xe-50 */
199 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010c), /* DAQCard-ai-16e-4 */
200 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x02c4), /* DAQCard-6062E */
201 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x075e), /* DAQCard-6024E */
202 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0245), /* DAQCard-6036E */
205 MODULE_DEVICE_TABLE(pcmcia, ni_mio_cs_ids);
207 static struct pcmcia_driver ni_mio_cs_driver = {
209 .owner = THIS_MODULE,
210 .id_table = ni_mio_cs_ids,
212 .remove = comedi_pcmcia_auto_unconfig,
214 module_comedi_pcmcia_driver(driver_ni_mio_cs, ni_mio_cs_driver);
216 MODULE_DESCRIPTION("Comedi driver for National Instruments DAQCard E series");
217 MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
218 MODULE_LICENSE("GPL");