Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[deliverable/linux.git] / drivers / staging / comedi / drivers / ni_labpc.c
1 /*
2 * comedi/drivers/ni_labpc.c
3 * Driver for National Instruments Lab-PC series boards and compatibles
4 * Copyright (C) 2001-2003 Frank Mori Hess <fmhess@users.sourceforge.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17 /*
18 * Driver: ni_labpc
19 * Description: National Instruments Lab-PC (& compatibles)
20 * Devices: (National Instruments) Lab-PC-1200 [lab-pc-1200]
21 * (National Instruments) Lab-PC-1200AI [lab-pc-1200ai]
22 * (National Instruments) Lab-PC+ [lab-pc+]
23 * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
24 * Status: works
25 *
26 * Configuration options - ISA boards:
27 * [0] - I/O port base address
28 * [1] - IRQ (optional, required for timed or externally triggered
29 * conversions)
30 * [2] - DMA channel (optional)
31 *
32 * Tested with lab-pc-1200. For the older Lab-PC+, not all input
33 * ranges and analog references will work, the available ranges/arefs
34 * will depend on how you have configured the jumpers on your board
35 * (see your owner's manual).
36 *
37 * Kernel-level ISA plug-and-play support for the lab-pc-1200 boards
38 * has not yet been added to the driver, mainly due to the fact that
39 * I don't know the device id numbers. If you have one of these boards,
40 * please file a bug report at http://comedi.org/ so I can get the
41 * necessary information from you.
42 *
43 * The 1200 series boards have onboard calibration dacs for correcting
44 * analog input/output offsets and gains. The proper settings for these
45 * caldacs are stored on the board's eeprom. To read the caldac values
46 * from the eeprom and store them into a file that can be then be used
47 * by comedilib, use the comedi_calibrate program.
48 *
49 * The Lab-pc+ has quirky chanlist requirements when scanning multiple
50 * channels. Multiple channel scan sequence must start at highest channel,
51 * then decrement down to channel 0. The rest of the cards can scan down
52 * like lab-pc+ or scan up from channel zero. Chanlists consisting of all
53 * one channel are also legal, and allow you to pace conversions in bursts.
54 *
55 * NI manuals:
56 * 341309a (labpc-1200 register manual)
57 * 320502b (lab-pc+)
58 */
59
60 #include <linux/module.h>
61
62 #include "../comedidev.h"
63
64 #include "ni_labpc.h"
65 #include "ni_labpc_isadma.h"
66
67 static const struct labpc_boardinfo labpc_boards[] = {
68 {
69 .name = "lab-pc-1200",
70 .ai_speed = 10000,
71 .ai_scan_up = 1,
72 .has_ao = 1,
73 .is_labpc1200 = 1,
74 }, {
75 .name = "lab-pc-1200ai",
76 .ai_speed = 10000,
77 .ai_scan_up = 1,
78 .is_labpc1200 = 1,
79 }, {
80 .name = "lab-pc+",
81 .ai_speed = 12000,
82 .has_ao = 1,
83 },
84 };
85
86 static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
87 {
88 struct labpc_private *devpriv;
89 unsigned int irq = it->options[1];
90 unsigned int dma_chan = it->options[2];
91 int ret;
92
93 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
94 if (!devpriv)
95 return -ENOMEM;
96
97 ret = comedi_request_region(dev, it->options[0], 0x20);
98 if (ret)
99 return ret;
100
101 ret = labpc_common_attach(dev, irq, 0);
102 if (ret)
103 return ret;
104
105 if (dev->irq)
106 labpc_init_dma_chan(dev, dma_chan);
107
108 return 0;
109 }
110
111 static void labpc_detach(struct comedi_device *dev)
112 {
113 struct labpc_private *devpriv = dev->private;
114
115 if (devpriv)
116 labpc_free_dma_chan(dev);
117
118 comedi_legacy_detach(dev);
119 }
120
121 static struct comedi_driver labpc_driver = {
122 .driver_name = "ni_labpc",
123 .module = THIS_MODULE,
124 .attach = labpc_attach,
125 .detach = labpc_detach,
126 .num_names = ARRAY_SIZE(labpc_boards),
127 .board_name = &labpc_boards[0].name,
128 .offset = sizeof(struct labpc_boardinfo),
129 };
130 module_comedi_driver(labpc_driver);
131
132 MODULE_AUTHOR("Comedi http://www.comedi.org");
133 MODULE_DESCRIPTION("Comedi driver for NI Lab-PC ISA boards");
134 MODULE_LICENSE("GPL");
This page took 0.034729 seconds and 5 git commands to generate.