1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Comedi driver for DAS008 PCMCIA boards
4 *
5 * COMEDI - Linux Control and Measurement Device Interface
6 * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
7 * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net>
8 *
9 * PCMCIA support code for this driver is adapted from the dummy_cs.c
10 * driver of the Linux PCMCIA Card Services package.
11 *
12 * The initial developer of the original code is David A. Hinds
13 * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
14 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
15 */
16
17/*
18 * Driver: das08_cs
19 * Description: DAS-08 PCMCIA boards
20 * Author: Warren Jasper, ds, Frank Hess
21 * Devices: [ComputerBoards] PCM-DAS08 (pcm-das08)
22 * Status: works
23 *
24 * This is the PCMCIA-specific support split off from the
25 * das08 driver.
26 *
27 * Configuration Options: none, uses PCMCIA auto config
28 *
29 * Command support does not exist, but could be added for this board.
30 */
31
32#include <linux/module.h>
33#include <linux/comedi/comedi_pcmcia.h>
34
35#include "das08.h"
36
37static const struct das08_board_struct das08_cs_boards[] = {
38	{
39		.name		= "pcm-das08",
40		.ai_nbits	= 12,
41		.ai_pg		= das08_bipolar5,
42		.ai_encoding	= das08_pcm_encode12,
43		.di_nchan	= 3,
44		.do_nchan	= 3,
45		.iosize		= 16,
46	},
47};
48
49static int das08_cs_auto_attach(struct comedi_device *dev,
50				unsigned long context)
51{
52	struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
53	struct das08_private_struct *devpriv;
54	unsigned long iobase;
55	int ret;
56
57	/* The das08 driver needs the board_ptr */
58	dev->board_ptr = &das08_cs_boards[0];
59
60	link->config_flags |= CONF_AUTO_SET_IO;
61	ret = comedi_pcmcia_enable(dev, NULL);
62	if (ret)
63		return ret;
64	iobase = link->resource[0]->start;
65
66	devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
67	if (!devpriv)
68		return -ENOMEM;
69
70	return das08_common_attach(dev, iobase);
71}
72
73static struct comedi_driver driver_das08_cs = {
74	.driver_name	= "das08_cs",
75	.module		= THIS_MODULE,
76	.auto_attach	= das08_cs_auto_attach,
77	.detach		= comedi_pcmcia_disable,
78};
79
80static int das08_pcmcia_attach(struct pcmcia_device *link)
81{
82	return comedi_pcmcia_auto_config(link, &driver_das08_cs);
83}
84
85static const struct pcmcia_device_id das08_cs_id_table[] = {
86	PCMCIA_DEVICE_MANF_CARD(0x01c5, 0x4001),
87	PCMCIA_DEVICE_NULL
88};
89MODULE_DEVICE_TABLE(pcmcia, das08_cs_id_table);
90
91static struct pcmcia_driver das08_cs_driver = {
92	.name		= "pcm-das08",
93	.owner		= THIS_MODULE,
94	.id_table	= das08_cs_id_table,
95	.probe		= das08_pcmcia_attach,
96	.remove		= comedi_pcmcia_auto_unconfig,
97};
98module_comedi_pcmcia_driver(driver_das08_cs, das08_cs_driver);
99
100MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
101MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");
102MODULE_DESCRIPTION("Comedi driver for ComputerBoards DAS-08 PCMCIA boards");
103MODULE_LICENSE("GPL");
104