1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Comedi driver for National Instruments PCMCIA DAQ-Card DIO-24
4 * Copyright (C) 2002 Daniel Vecino Castel <dvecino@able.es>
5 *
6 * PCMCIA crap at end of file is adapted from dummy_cs.c 1.31
7 * 2001/08/24 12:13:13 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. All Rights Reserved.
11 */
12
13/*
14 * Driver: ni_daq_dio24
15 * Description: National Instruments PCMCIA DAQ-Card DIO-24
16 * Author: Daniel Vecino Castel <dvecino@able.es>
17 * Devices: [National Instruments] PCMCIA DAQ-Card DIO-24 (ni_daq_dio24)
18 * Status: ?
19 * Updated: Thu, 07 Nov 2002 21:53:06 -0800
20 *
21 * This is just a wrapper around the 8255.o driver to properly handle
22 * the PCMCIA interface.
23 */
24
25#include <linux/module.h>
26#include <linux/comedi/comedi_pcmcia.h>
27#include <linux/comedi/comedi_8255.h>
28
29static int dio24_auto_attach(struct comedi_device *dev,
30 unsigned long context)
31{
32 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
33 struct comedi_subdevice *s;
34 int ret;
35
36 link->config_flags |= CONF_AUTO_SET_IO;
37 ret = comedi_pcmcia_enable(dev, NULL);
38 if (ret)
39 return ret;
40 dev->iobase = link->resource[0]->start;
41
42 ret = comedi_alloc_subdevices(dev, num_subdevices: 1);
43 if (ret)
44 return ret;
45
46 /* 8255 dio */
47 s = &dev->subdevices[0];
48 return subdev_8255_io_init(dev, s, regbase: 0x00);
49}
50
51static struct comedi_driver driver_dio24 = {
52 .driver_name = "ni_daq_dio24",
53 .module = THIS_MODULE,
54 .auto_attach = dio24_auto_attach,
55 .detach = comedi_pcmcia_disable,
56};
57
58static int dio24_cs_attach(struct pcmcia_device *link)
59{
60 return comedi_pcmcia_auto_config(link, driver: &driver_dio24);
61}
62
63static const struct pcmcia_device_id dio24_cs_ids[] = {
64 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x475c), /* daqcard-dio24 */
65 PCMCIA_DEVICE_NULL
66};
67MODULE_DEVICE_TABLE(pcmcia, dio24_cs_ids);
68
69static struct pcmcia_driver dio24_cs_driver = {
70 .name = "ni_daq_dio24",
71 .owner = THIS_MODULE,
72 .id_table = dio24_cs_ids,
73 .probe = dio24_cs_attach,
74 .remove = comedi_pcmcia_auto_unconfig,
75};
76module_comedi_pcmcia_driver(driver_dio24, dio24_cs_driver);
77
78MODULE_AUTHOR("Daniel Vecino Castel <dvecino@able.es>");
79MODULE_DESCRIPTION(
80 "Comedi driver for National Instruments PCMCIA DAQ-Card DIO-24");
81MODULE_LICENSE("GPL");
82

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