1// SPDX-License-Identifier: GPL-2.0+ 2/* 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> 6 */ 7 8/* 9 * Driver: ni_labpc 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> 14 * Status: works 15 * 16 * Configuration options - ISA boards: 17 * [0] - I/O port base address 18 * [1] - IRQ (optional, required for timed or externally triggered 19 * conversions) 20 * [2] - DMA channel (optional) 21 * 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). 26 * 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 http://comedi.org/ so I can get the 31 * necessary information from you. 32 * 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. 38 * 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. 44 * 45 * NI manuals: 46 * 341309a (labpc-1200 register manual) 47 * 320502b (lab-pc+) 48 */ 49 50#include <linux/module.h> 51 52#include "../comedidev.h" 53 54#include "ni_labpc.h" 55#include "ni_labpc_isadma.h" 56 57static const struct labpc_boardinfo labpc_boards[] = { 58 { 59 .name = "lab-pc-1200", 60 .ai_speed = 10000, 61 .ai_scan_up = 1, 62 .has_ao = 1, 63 .is_labpc1200 = 1, 64 }, { 65 .name = "lab-pc-1200ai", 66 .ai_speed = 10000, 67 .ai_scan_up = 1, 68 .is_labpc1200 = 1, 69 }, { 70 .name = "lab-pc+", 71 .ai_speed = 12000, 72 .has_ao = 1, 73 }, 74}; 75 76static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it) 77{ 78 unsigned int irq = it->options[1]; 79 unsigned int dma_chan = it->options[2]; 80 int ret; 81 82 ret = comedi_request_region(dev, it->options[0], 0x20); 83 if (ret) 84 return ret; 85 86 ret = labpc_common_attach(dev, irq, 0); 87 if (ret) 88 return ret; 89 90 if (dev->irq) 91 labpc_init_dma_chan(dev, dma_chan); 92 93 return 0; 94} 95 96static void labpc_detach(struct comedi_device *dev) 97{ 98 labpc_free_dma_chan(dev); 99 labpc_common_detach(dev); 100 comedi_legacy_detach(dev); 101} 102 103static struct comedi_driver labpc_driver = { 104 .driver_name = "ni_labpc", 105 .module = THIS_MODULE, 106 .attach = labpc_attach, 107 .detach = labpc_detach, 108 .num_names = ARRAY_SIZE(labpc_boards), 109 .board_name = &labpc_boards[0].name, 110 .offset = sizeof(struct labpc_boardinfo), 111}; 112module_comedi_driver(labpc_driver); 113 114MODULE_AUTHOR("Comedi http://www.comedi.org"); 115MODULE_DESCRIPTION("Comedi driver for NI Lab-PC ISA boards"); 116MODULE_LICENSE("GPL"); 117