2 * Comedi driver for NI PCMCIA MIO E series cards
4 * COMEDI - Linux Control and Measurement Device Interface
5 * Copyright (C) 1997-2000 David A. Schleef <ds@schleef.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
20 * Description: National Instruments DAQCard E series
23 * Devices: [National Instruments] DAQCard-AI-16XE-50 (ni_mio_cs),
24 * DAQCard-AI-16E-4, DAQCard-6062E, DAQCard-6024E, DAQCard-6036E
25 * Updated: Thu Oct 23 19:43:17 CDT 2003
27 * See the notes in the ni_atmio.o driver.
31 * The real guts of the driver is in ni_mio_common.c, which is
32 * included by all the E series drivers.
34 * References for specifications:
35 * 341080a.pdf DAQCard E Series Register Level Programmer Manual
38 #include <linux/module.h>
39 #include <linux/delay.h>
41 #include "../comedi_pcmcia.h"
49 static const struct ni_board_struct ni_boards[] = {
51 .name = "DAQCard-ai-16xe-50",
55 .ai_fifo_depth = 1024,
56 .gainlkup = ai_gain_8,
58 .caldac = { dac8800, dac8043 },
60 .name = "DAQCard-ai-16e-4",
64 .ai_fifo_depth = 1024,
65 .gainlkup = ai_gain_16,
67 .caldac = { mb88341 }, /* verified */
69 .name = "DAQCard-6062E",
73 .ai_fifo_depth = 8192,
74 .gainlkup = ai_gain_16,
78 .ao_fifo_depth = 2048,
79 .ao_range_table = &range_bipolar10,
81 .caldac = { ad8804_debug }, /* verified */
83 /* specs incorrect! */
84 .name = "DAQCard-6024E",
88 .ai_fifo_depth = 1024,
89 .gainlkup = ai_gain_4,
93 .ao_range_table = &range_bipolar10,
95 .caldac = { ad8804_debug },
97 /* specs incorrect! */
98 .name = "DAQCard-6036E",
101 .ai_maxdata = 0xffff,
102 .ai_fifo_depth = 1024,
104 .gainlkup = ai_gain_4,
107 .ao_maxdata = 0xffff,
108 .ao_range_table = &range_bipolar10,
110 .caldac = { ad8804_debug },
114 .name = "DAQCard-6715",
115 .device_id = 0x0000, /* unknown */
117 .ao_maxdata = 0x0fff,
119 .caldac = { mb88341, mb88341 },
124 #include "ni_mio_common.c"
126 static const void *ni_getboardtype(struct comedi_device *dev,
127 struct pcmcia_device *link)
129 static const struct ni_board_struct *board;
132 for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
133 board = &ni_boards[i];
134 if (board->device_id == link->card_id)
140 static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data)
144 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
145 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
147 for (base = 0x000; base < 0x400; base += 0x20) {
148 p_dev->resource[0]->start = base;
149 ret = pcmcia_request_io(p_dev);
156 static int mio_cs_auto_attach(struct comedi_device *dev,
157 unsigned long context)
159 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
160 static const struct ni_board_struct *board;
163 board = ni_getboardtype(dev, link);
166 dev->board_ptr = board;
167 dev->board_name = board->name;
169 link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
170 ret = comedi_pcmcia_enable(dev, mio_pcmcia_config_loop);
173 dev->iobase = link->resource[0]->start;
176 ret = pcmcia_request_irq(link, ni_E_interrupt);
179 dev->irq = link->irq;
181 ret = ni_alloc_private(dev);
185 return ni_E_init(dev, 0, 1);
188 static void mio_cs_detach(struct comedi_device *dev)
190 mio_common_detach(dev);
191 comedi_pcmcia_disable(dev);
194 static struct comedi_driver driver_ni_mio_cs = {
195 .driver_name = "ni_mio_cs",
196 .module = THIS_MODULE,
197 .auto_attach = mio_cs_auto_attach,
198 .detach = mio_cs_detach,
201 static int cs_attach(struct pcmcia_device *link)
203 return comedi_pcmcia_auto_config(link, &driver_ni_mio_cs);
206 static const struct pcmcia_device_id ni_mio_cs_ids[] = {
207 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010d), /* DAQCard-ai-16xe-50 */
208 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010c), /* DAQCard-ai-16e-4 */
209 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x02c4), /* DAQCard-6062E */
210 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x075e), /* DAQCard-6024E */
211 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0245), /* DAQCard-6036E */
214 MODULE_DEVICE_TABLE(pcmcia, ni_mio_cs_ids);
216 static struct pcmcia_driver ni_mio_cs_driver = {
218 .owner = THIS_MODULE,
219 .id_table = ni_mio_cs_ids,
221 .remove = comedi_pcmcia_auto_unconfig,
223 module_comedi_pcmcia_driver(driver_ni_mio_cs, ni_mio_cs_driver);
225 MODULE_DESCRIPTION("Comedi driver for National Instruments DAQCard E series");
226 MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
227 MODULE_LICENSE("GPL");