]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/comedi/drivers/das08_cs.c
Merge tag 'late-omap' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[karo-tx-linux.git] / drivers / staging / comedi / drivers / das08_cs.c
1 /*
2     comedi/drivers/das08_cs.c
3     DAS08 driver
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     This program is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with this program; if not, write to the Free Software
21     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
23     PCMCIA support code for this driver is adapted from the dummy_cs.c
24     driver of the Linux PCMCIA Card Services package.
25
26     The initial developer of the original code is David A. Hinds
27     <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
28     are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
29
30 *****************************************************************
31
32 */
33 /*
34 Driver: das08_cs
35 Description: DAS-08 PCMCIA boards
36 Author: Warren Jasper, ds, Frank Hess
37 Devices: [ComputerBoards] PCM-DAS08 (pcm-das08)
38 Status: works
39
40 This is the PCMCIA-specific support split off from the
41 das08 driver.
42
43 Options (for pcm-das08):
44         NONE
45
46 Command support does not exist, but could be added for this board.
47 */
48
49 #include <linux/delay.h>
50 #include <linux/slab.h>
51
52 #include "../comedidev.h"
53
54 #include <pcmcia/cistpl.h>
55 #include <pcmcia/ds.h>
56
57 #include "das08.h"
58
59 static const struct das08_board_struct das08_cs_boards[] = {
60         {
61                 .name           = "pcm-das08",
62                 .id             = 0x0,  /*  XXX */
63                 .ai_nbits       = 12,
64                 .ai_pg          = das08_bipolar5,
65                 .ai_encoding    = das08_pcm_encode12,
66                 .di_nchan       = 3,
67                 .do_nchan       = 3,
68                 .iosize         = 16,
69         },
70 };
71
72 static int das08_cs_auto_attach(struct comedi_device *dev,
73                                 unsigned long context)
74 {
75         struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
76         struct das08_private_struct *devpriv;
77         unsigned long iobase;
78         int ret;
79
80         /* The das08 driver needs the board_ptr */
81         dev->board_ptr = &das08_cs_boards[0];
82
83         link->config_flags |= CONF_AUTO_SET_IO;
84         ret = comedi_pcmcia_enable(dev, NULL);
85         if (ret)
86                 return ret;
87         iobase = link->resource[0]->start;
88
89         devpriv = kzalloc(sizeof(*devpriv), GFP_KERNEL);
90         if (!devpriv)
91                 return -ENOMEM;
92         dev->private = devpriv;
93
94         return das08_common_attach(dev, iobase);
95 }
96
97 static void das08_cs_detach(struct comedi_device *dev)
98 {
99         das08_common_detach(dev);
100         comedi_pcmcia_disable(dev);
101 }
102
103 static struct comedi_driver driver_das08_cs = {
104         .driver_name    = "das08_cs",
105         .module         = THIS_MODULE,
106         .auto_attach    = das08_cs_auto_attach,
107         .detach         = das08_cs_detach,
108 };
109
110 static int das08_pcmcia_attach(struct pcmcia_device *link)
111 {
112         return comedi_pcmcia_auto_config(link, &driver_das08_cs);
113 }
114
115 static const struct pcmcia_device_id das08_cs_id_table[] = {
116         PCMCIA_DEVICE_MANF_CARD(0x01c5, 0x4001),
117         PCMCIA_DEVICE_NULL
118 };
119 MODULE_DEVICE_TABLE(pcmcia, das08_cs_id_table);
120
121 static struct pcmcia_driver das08_cs_driver = {
122         .name           = "pcm-das08",
123         .owner          = THIS_MODULE,
124         .id_table       = das08_cs_id_table,
125         .probe          = das08_pcmcia_attach,
126         .remove         = comedi_pcmcia_auto_unconfig,
127 };
128 module_comedi_pcmcia_driver(driver_das08_cs, das08_cs_driver);
129
130 MODULE_AUTHOR("David A. Schleef <ds@schleef.org>, "
131               "Frank Mori Hess <fmhess@users.sourceforge.net>");
132 MODULE_DESCRIPTION("Comedi driver for ComputerBoards DAS-08 PCMCIA boards");
133 MODULE_LICENSE("GPL");