1 // SPDX-License-Identifier: GPL-2.0+
3 * comedi/drivers/ni_labpc.c
4 * Driver for National Instruments Lab-PC series boards and compatibles
5 * Copyright (C) 2001-2003 Frank Mori Hess <fmhess@users.sourceforge.net>
10 * Description: National Instruments Lab-PC (& compatibles)
11 * Devices: [National Instruments] Lab-PC-1200 (lab-pc-1200),
12 * Lab-PC-1200AI (lab-pc-1200ai), Lab-PC+ (lab-pc+)
13 * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
16 * Configuration options - ISA boards:
17 * [0] - I/O port base address
18 * [1] - IRQ (optional, required for timed or externally triggered
20 * [2] - DMA channel (optional)
22 * Tested with lab-pc-1200. For the older Lab-PC+, not all input
23 * ranges and analog references will work, the available ranges/arefs
24 * will depend on how you have configured the jumpers on your board
25 * (see your owner's manual).
27 * Kernel-level ISA plug-and-play support for the lab-pc-1200 boards
28 * has not yet been added to the driver, mainly due to the fact that
29 * I don't know the device id numbers. If you have one of these boards,
30 * please file a bug report at https://comedi.org/ so I can get the
31 * necessary information from you.
33 * The 1200 series boards have onboard calibration dacs for correcting
34 * analog input/output offsets and gains. The proper settings for these
35 * caldacs are stored on the board's eeprom. To read the caldac values
36 * from the eeprom and store them into a file that can be then be used
37 * by comedilib, use the comedi_calibrate program.
39 * The Lab-pc+ has quirky chanlist requirements when scanning multiple
40 * channels. Multiple channel scan sequence must start at highest channel,
41 * then decrement down to channel 0. The rest of the cards can scan down
42 * like lab-pc+ or scan up from channel zero. Chanlists consisting of all
43 * one channel are also legal, and allow you to pace conversions in bursts.
46 * 341309a (labpc-1200 register manual)
50 #include <linux/module.h>
51 #include <linux/comedi/comedidev.h>
54 #include "ni_labpc_isadma.h"
56 static const struct labpc_boardinfo labpc_boards[] = {
58 .name = "lab-pc-1200",
64 .name = "lab-pc-1200ai",
75 static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
77 unsigned int irq = it->options[1];
78 unsigned int dma_chan = it->options[2];
81 ret = comedi_request_region(dev, it->options[0], 0x20);
85 ret = labpc_common_attach(dev, irq, 0);
90 labpc_init_dma_chan(dev, dma_chan);
95 static void labpc_detach(struct comedi_device *dev)
97 labpc_free_dma_chan(dev);
98 labpc_common_detach(dev);
99 comedi_legacy_detach(dev);
102 static struct comedi_driver labpc_driver = {
103 .driver_name = "ni_labpc",
104 .module = THIS_MODULE,
105 .attach = labpc_attach,
106 .detach = labpc_detach,
107 .num_names = ARRAY_SIZE(labpc_boards),
108 .board_name = &labpc_boards[0].name,
109 .offset = sizeof(struct labpc_boardinfo),
111 module_comedi_driver(labpc_driver);
113 MODULE_AUTHOR("Comedi https://www.comedi.org");
114 MODULE_DESCRIPTION("Comedi driver for NI Lab-PC ISA boards");
115 MODULE_LICENSE("GPL");