1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Driver for National Instruments daqcard-1200 boards
4 * Copyright (C) 2001, 2002, 2003 Frank Mori Hess <fmhess@users.sourceforge.net>
5 *
6 * PCMCIA crap is adapted from dummy_cs.c 1.31 2001/08/24 12:13:13
7 * from the pcmcia package.
8 * The initial developer of the pcmcia dummy_cs.c code is David A. Hinds
9 * <dahinds@users.sourceforge.net>. Portions created by David A. Hinds
10 * are Copyright (C) 1999 David A. Hinds.
11 */
12
13/*
14 * Driver: ni_labpc_cs
15 * Description: National Instruments Lab-PC (& compatibles)
16 * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
17 * Devices: [National Instruments] DAQCard-1200 (daqcard-1200)
18 * Status: works
19 *
20 * Thanks go to Fredrik Lingvall for much testing and perseverance in
21 * helping to debug daqcard-1200 support.
22 *
23 * The 1200 series boards have onboard calibration dacs for correcting
24 * analog input/output offsets and gains. The proper settings for these
25 * caldacs are stored on the board's eeprom. To read the caldac values
26 * from the eeprom and store them into a file that can be then be used by
27 * comedilib, use the comedi_calibrate program.
28 *
29 * Configuration options: none
30 *
31 * The daqcard-1200 has quirky chanlist requirements when scanning multiple
32 * channels. Multiple channel scan sequence must start at highest channel,
33 * then decrement down to channel 0. Chanlists consisting of all one channel
34 * are also legal, and allow you to pace conversions in bursts.
35 *
36 * NI manuals:
37 * 340988a (daqcard-1200)
38 */
39
40#include <linux/module.h>
41#include <linux/comedi/comedi_pcmcia.h>
42
43#include "ni_labpc.h"
44
45static const struct labpc_boardinfo labpc_cs_boards[] = {
46 {
47 .name = "daqcard-1200",
48 .ai_speed = 10000,
49 .has_ao = 1,
50 .is_labpc1200 = 1,
51 },
52};
53
54static int labpc_cs_auto_attach(struct comedi_device *dev,
55 unsigned long context)
56{
57 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
58 int ret;
59
60 /* The ni_labpc driver needs the board_ptr */
61 dev->board_ptr = &labpc_cs_boards[0];
62
63 link->config_flags |= CONF_AUTO_SET_IO |
64 CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
65 ret = comedi_pcmcia_enable(dev, NULL);
66 if (ret)
67 return ret;
68 dev->iobase = link->resource[0]->start;
69
70 if (!link->irq)
71 return -EINVAL;
72
73 return labpc_common_attach(dev, irq: link->irq, IRQF_SHARED);
74}
75
76static void labpc_cs_detach(struct comedi_device *dev)
77{
78 labpc_common_detach(dev);
79 comedi_pcmcia_disable(dev);
80}
81
82static struct comedi_driver driver_labpc_cs = {
83 .driver_name = "ni_labpc_cs",
84 .module = THIS_MODULE,
85 .auto_attach = labpc_cs_auto_attach,
86 .detach = labpc_cs_detach,
87};
88
89static int labpc_cs_attach(struct pcmcia_device *link)
90{
91 return comedi_pcmcia_auto_config(link, driver: &driver_labpc_cs);
92}
93
94static const struct pcmcia_device_id labpc_cs_ids[] = {
95 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0103), /* daqcard-1200 */
96 PCMCIA_DEVICE_NULL
97};
98MODULE_DEVICE_TABLE(pcmcia, labpc_cs_ids);
99
100static struct pcmcia_driver labpc_cs_driver = {
101 .name = "daqcard-1200",
102 .owner = THIS_MODULE,
103 .id_table = labpc_cs_ids,
104 .probe = labpc_cs_attach,
105 .remove = comedi_pcmcia_auto_unconfig,
106};
107module_comedi_pcmcia_driver(driver_labpc_cs, labpc_cs_driver);
108
109MODULE_DESCRIPTION("Comedi driver for National Instruments Lab-PC");
110MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");
111MODULE_LICENSE("GPL");
112

source code of linux/drivers/comedi/drivers/ni_labpc_cs.c