staging: comedi: comedi_test: use unsigned int for waveform timing
[linux-2.6-block.git] / drivers / staging / comedi / drivers / ni_labpc.c
CommitLineData
124b13b2 1/*
31922394
HS
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.
31922394 15 */
124b13b2
FMH
16
17/*
31922394
HS
18 * Driver: ni_labpc
19 * Description: National Instruments Lab-PC (& compatibles)
d49ebefe
IA
20 * Devices: [National Instruments] Lab-PC-1200 (lab-pc-1200),
21 * Lab-PC-1200AI (lab-pc-1200ai), Lab-PC+ (lab-pc+)
31922394
HS
22 * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
23 * Status: works
24 *
25 * Configuration options - ISA boards:
26 * [0] - I/O port base address
27 * [1] - IRQ (optional, required for timed or externally triggered
28 * conversions)
29 * [2] - DMA channel (optional)
30 *
31922394
HS
31 * Tested with lab-pc-1200. For the older Lab-PC+, not all input
32 * ranges and analog references will work, the available ranges/arefs
33 * will depend on how you have configured the jumpers on your board
34 * (see your owner's manual).
35 *
36 * Kernel-level ISA plug-and-play support for the lab-pc-1200 boards
37 * has not yet been added to the driver, mainly due to the fact that
38 * I don't know the device id numbers. If you have one of these boards,
39 * please file a bug report at http://comedi.org/ so I can get the
40 * necessary information from you.
41 *
42 * The 1200 series boards have onboard calibration dacs for correcting
43 * analog input/output offsets and gains. The proper settings for these
44 * caldacs are stored on the board's eeprom. To read the caldac values
45 * from the eeprom and store them into a file that can be then be used
46 * by comedilib, use the comedi_calibrate program.
47 *
48 * The Lab-pc+ has quirky chanlist requirements when scanning multiple
49 * channels. Multiple channel scan sequence must start at highest channel,
50 * then decrement down to channel 0. The rest of the cards can scan down
51 * like lab-pc+ or scan up from channel zero. Chanlists consisting of all
52 * one channel are also legal, and allow you to pace conversions in bursts.
53 *
54 * NI manuals:
55 * 341309a (labpc-1200 register manual)
31922394
HS
56 * 320502b (lab-pc+)
57 */
124b13b2 58
ce157f80 59#include <linux/module.h>
33782dd5 60
124b13b2
FMH
61#include "../comedidev.h"
62
124b13b2 63#include "ni_labpc.h"
9a638662 64#include "ni_labpc_isadma.h"
124b13b2 65
f65d971d 66static const struct labpc_boardinfo labpc_boards[] = {
124b13b2 67 {
f2c447ca 68 .name = "lab-pc-1200",
63d6ba20 69 .ai_speed = 10000,
f2c447ca 70 .ai_scan_up = 1,
63d6ba20
HS
71 .has_ao = 1,
72 .is_labpc1200 = 1,
f2c447ca
HS
73 }, {
74 .name = "lab-pc-1200ai",
63d6ba20 75 .ai_speed = 10000,
f2c447ca 76 .ai_scan_up = 1,
63d6ba20 77 .is_labpc1200 = 1,
f2c447ca
HS
78 }, {
79 .name = "lab-pc+",
63d6ba20
HS
80 .ai_speed = 12000,
81 .has_ao = 1,
f2c447ca 82 },
124b13b2 83};
124b13b2 84
dd2aef64
HS
85static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
86{
fa3cb219
HS
87 unsigned int irq = it->options[1];
88 unsigned int dma_chan = it->options[2];
5b365a8a 89 int ret;
dd2aef64 90
862755ec 91 ret = comedi_request_region(dev, it->options[0], 0x20);
dd2aef64
HS
92 if (ret)
93 return ret;
94
3e034797 95 ret = labpc_common_attach(dev, irq, 0);
76730884
HS
96 if (ret)
97 return ret;
98
86aff4bb
IA
99 if (dev->irq)
100 labpc_init_dma_chan(dev, dma_chan);
76730884
HS
101
102 return 0;
dd2aef64
HS
103}
104
a0eeed40 105static void labpc_detach(struct comedi_device *dev)
dd2aef64 106{
aae59483 107 labpc_free_dma_chan(dev);
c0cfeca1 108 labpc_common_detach(dev);
fa3cb219 109 comedi_legacy_detach(dev);
dd2aef64 110}
dd2aef64 111
5e51f0db 112static struct comedi_driver labpc_driver = {
147a85d7 113 .driver_name = "ni_labpc",
6e8bddf2
HS
114 .module = THIS_MODULE,
115 .attach = labpc_attach,
fa3cb219 116 .detach = labpc_detach,
6e8bddf2
HS
117 .num_names = ARRAY_SIZE(labpc_boards),
118 .board_name = &labpc_boards[0].name,
119 .offset = sizeof(struct labpc_boardinfo),
5e51f0db 120};
fa3cb219 121module_comedi_driver(labpc_driver);
124b13b2 122
90f703d3 123MODULE_AUTHOR("Comedi http://www.comedi.org");
1b419769 124MODULE_DESCRIPTION("Comedi driver for NI Lab-PC ISA boards");
90f703d3 125MODULE_LICENSE("GPL");