2 comedi/drivers/ni_mio_cs.c
3 Hardware 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>
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.
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.
30 The real guts of the driver is in ni_mio_common.c, which is
31 included by all the E series drivers.
33 References for specifications:
35 341080a.pdf DAQCard E Series Register Level Programmer Manual
39 #include <linux/module.h>
40 #include "../comedidev.h"
42 #include <linux/delay.h>
47 #include <pcmcia/cistpl.h>
48 #include <pcmcia/ds.h>
54 static const struct ni_board_struct ni_boards[] = {
56 .name = "DAQCard-ai-16xe-50",
60 .ai_fifo_depth = 1024,
61 .gainlkup = ai_gain_8,
63 .caldac = { dac8800, dac8043 },
65 .name = "DAQCard-ai-16e-4",
69 .ai_fifo_depth = 1024,
70 .gainlkup = ai_gain_16,
72 .caldac = { mb88341 }, /* verified */
74 .name = "DAQCard-6062E",
78 .ai_fifo_depth = 8192,
79 .gainlkup = ai_gain_16,
83 .ao_fifo_depth = 2048,
84 .ao_range_table = &range_bipolar10,
86 .caldac = { ad8804_debug }, /* verified */
88 /* specs incorrect! */
89 .name = "DAQCard-6024E",
93 .ai_fifo_depth = 1024,
94 .gainlkup = ai_gain_4,
98 .ao_range_table = &range_bipolar10,
100 .caldac = { ad8804_debug },
102 /* specs incorrect! */
103 .name = "DAQCard-6036E",
106 .ai_maxdata = 0xffff,
107 .ai_fifo_depth = 1024,
109 .gainlkup = ai_gain_4,
112 .ao_maxdata = 0xffff,
113 .ao_range_table = &range_bipolar10,
115 .caldac = { ad8804_debug },
119 .name = "DAQCard-6715",
120 .device_id = 0x0000, /* unknown */
122 .ao_maxdata = 0x0fff,
124 .caldac = { mb88341, mb88341 },
129 #include "ni_mio_common.c"
131 static const void *ni_getboardtype(struct comedi_device *dev,
132 struct pcmcia_device *link)
134 static const struct ni_board_struct *board;
137 for (i = 0; i < ARRAY_SIZE(ni_boards); i++) {
138 board = &ni_boards[i];
139 if (board->device_id == link->card_id)
145 static int mio_pcmcia_config_loop(struct pcmcia_device *p_dev, void *priv_data)
149 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
150 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
152 for (base = 0x000; base < 0x400; base += 0x20) {
153 p_dev->resource[0]->start = base;
154 ret = pcmcia_request_io(p_dev);
161 static int mio_cs_auto_attach(struct comedi_device *dev,
162 unsigned long context)
164 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
165 static const struct ni_board_struct *board;
166 struct ni_private *devpriv;
169 board = ni_getboardtype(dev, link);
172 dev->board_ptr = board;
173 dev->board_name = board->name;
175 link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
176 ret = comedi_pcmcia_enable(dev, mio_pcmcia_config_loop);
179 dev->iobase = link->resource[0]->start;
182 ret = pcmcia_request_irq(link, ni_E_interrupt);
185 dev->irq = link->irq;
187 ret = ni_alloc_private(dev);
191 devpriv = dev->private;
193 return ni_E_init(dev, 0, 1);
196 static void mio_cs_detach(struct comedi_device *dev)
198 mio_common_detach(dev);
199 comedi_pcmcia_disable(dev);
202 static struct comedi_driver driver_ni_mio_cs = {
203 .driver_name = "ni_mio_cs",
204 .module = THIS_MODULE,
205 .auto_attach = mio_cs_auto_attach,
206 .detach = mio_cs_detach,
209 static int cs_attach(struct pcmcia_device *link)
211 return comedi_pcmcia_auto_config(link, &driver_ni_mio_cs);
214 static const struct pcmcia_device_id ni_mio_cs_ids[] = {
215 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010d), /* DAQCard-ai-16xe-50 */
216 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x010c), /* DAQCard-ai-16e-4 */
217 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x02c4), /* DAQCard-6062E */
218 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x075e), /* DAQCard-6024E */
219 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0245), /* DAQCard-6036E */
222 MODULE_DEVICE_TABLE(pcmcia, ni_mio_cs_ids);
224 static struct pcmcia_driver ni_mio_cs_driver = {
226 .owner = THIS_MODULE,
227 .id_table = ni_mio_cs_ids,
229 .remove = comedi_pcmcia_auto_unconfig,
231 module_comedi_pcmcia_driver(driver_ni_mio_cs, ni_mio_cs_driver);
233 MODULE_DESCRIPTION("Comedi driver for National Instruments DAQCard E series");
234 MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
235 MODULE_LICENSE("GPL");