root/drivers/staging/comedi/drivers/ni_labpc_cs.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. labpc_cs_auto_attach
  2. labpc_cs_detach
  3. labpc_cs_attach

   1 // SPDX-License-Identifier: GPL-2.0+
   2 /*
   3  * Driver for National Instruments daqcard-1200 boards
   4  * Copyright (C) 2001, 2002, 2003 Frank Mori Hess <fmhess@users.sourceforge.net>
   5  *
   6  * PCMCIA crap is adapted from dummy_cs.c 1.31 2001/08/24 12:13:13
   7  * from the pcmcia package.
   8  * The initial developer of the pcmcia dummy_cs.c code is David A. Hinds
   9  * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
  10  * are Copyright (C) 1999 David A. Hinds.
  11  */
  12 
  13 /*
  14  * Driver: ni_labpc_cs
  15  * Description: National Instruments Lab-PC (& compatibles)
  16  * Author: Frank Mori Hess <fmhess@users.sourceforge.net>
  17  * Devices: [National Instruments] DAQCard-1200 (daqcard-1200)
  18  * Status: works
  19  *
  20  * Thanks go to Fredrik Lingvall for much testing and perseverance in
  21  * helping to debug daqcard-1200 support.
  22  *
  23  * The 1200 series boards have onboard calibration dacs for correcting
  24  * analog input/output offsets and gains. The proper settings for these
  25  * caldacs are stored on the board's eeprom. To read the caldac values
  26  * from the eeprom and store them into a file that can be then be used by
  27  * comedilib, use the comedi_calibrate program.
  28  *
  29  * Configuration options: none
  30  *
  31  * The daqcard-1200 has quirky chanlist requirements when scanning multiple
  32  * channels. Multiple channel scan sequence must start at highest channel,
  33  * then decrement down to channel 0.  Chanlists consisting of all one channel
  34  * are also legal, and allow you to pace conversions in bursts.
  35  *
  36  * NI manuals:
  37  *   340988a (daqcard-1200)
  38  */
  39 
  40 #include <linux/module.h>
  41 
  42 #include "../comedi_pcmcia.h"
  43 
  44 #include "ni_labpc.h"
  45 
  46 static const struct labpc_boardinfo labpc_cs_boards[] = {
  47         {
  48                 .name                   = "daqcard-1200",
  49                 .ai_speed               = 10000,
  50                 .has_ao                 = 1,
  51                 .is_labpc1200           = 1,
  52         },
  53 };
  54 
  55 static int labpc_cs_auto_attach(struct comedi_device *dev,
  56                                 unsigned long context)
  57 {
  58         struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
  59         int ret;
  60 
  61         /* The ni_labpc driver needs the board_ptr */
  62         dev->board_ptr = &labpc_cs_boards[0];
  63 
  64         link->config_flags |= CONF_AUTO_SET_IO |
  65                               CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
  66         ret = comedi_pcmcia_enable(dev, NULL);
  67         if (ret)
  68                 return ret;
  69         dev->iobase = link->resource[0]->start;
  70 
  71         if (!link->irq)
  72                 return -EINVAL;
  73 
  74         return labpc_common_attach(dev, link->irq, IRQF_SHARED);
  75 }
  76 
  77 static void labpc_cs_detach(struct comedi_device *dev)
  78 {
  79         labpc_common_detach(dev);
  80         comedi_pcmcia_disable(dev);
  81 }
  82 
  83 static struct comedi_driver driver_labpc_cs = {
  84         .driver_name    = "ni_labpc_cs",
  85         .module         = THIS_MODULE,
  86         .auto_attach    = labpc_cs_auto_attach,
  87         .detach         = labpc_cs_detach,
  88 };
  89 
  90 static int labpc_cs_attach(struct pcmcia_device *link)
  91 {
  92         return comedi_pcmcia_auto_config(link, &driver_labpc_cs);
  93 }
  94 
  95 static const struct pcmcia_device_id labpc_cs_ids[] = {
  96         PCMCIA_DEVICE_MANF_CARD(0x010b, 0x0103),        /* daqcard-1200 */
  97         PCMCIA_DEVICE_NULL
  98 };
  99 MODULE_DEVICE_TABLE(pcmcia, labpc_cs_ids);
 100 
 101 static struct pcmcia_driver labpc_cs_driver = {
 102         .name           = "daqcard-1200",
 103         .owner          = THIS_MODULE,
 104         .id_table       = labpc_cs_ids,
 105         .probe          = labpc_cs_attach,
 106         .remove         = comedi_pcmcia_auto_unconfig,
 107 };
 108 module_comedi_pcmcia_driver(driver_labpc_cs, labpc_cs_driver);
 109 
 110 MODULE_DESCRIPTION("Comedi driver for National Instruments Lab-PC");
 111 MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");
 112 MODULE_LICENSE("GPL");

/* [<][>][^][v][top][bottom][index][help] */