linux/drivers/staging/comedi/drivers/das08_cs.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0+
   2/*
   3 * Comedi driver for DAS008 PCMCIA boards
   4 *
   5 * COMEDI - Linux Control and Measurement Device Interface
   6 * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
   7 * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net>
   8 *
   9 * PCMCIA support code for this driver is adapted from the dummy_cs.c
  10 * driver of the Linux PCMCIA Card Services package.
  11 *
  12 * The initial developer of the original code is David A. Hinds
  13 * <dahinds@users.sourceforge.net>.  Portions created by David A. Hinds
  14 * are Copyright (C) 1999 David A. Hinds.  All Rights Reserved.
  15 */
  16
  17/*
  18 * Driver: das08_cs
  19 * Description: DAS-08 PCMCIA boards
  20 * Author: Warren Jasper, ds, Frank Hess
  21 * Devices: [ComputerBoards] PCM-DAS08 (pcm-das08)
  22 * Status: works
  23 *
  24 * This is the PCMCIA-specific support split off from the
  25 * das08 driver.
  26 *
  27 * Configuration Options: none, uses PCMCIA auto config
  28 *
  29 * Command support does not exist, but could be added for this board.
  30 */
  31
  32#include <linux/module.h>
  33
  34#include "../comedi_pcmcia.h"
  35
  36#include "das08.h"
  37
  38static const struct das08_board_struct das08_cs_boards[] = {
  39        {
  40                .name           = "pcm-das08",
  41                .ai_nbits       = 12,
  42                .ai_pg          = das08_bipolar5,
  43                .ai_encoding    = das08_pcm_encode12,
  44                .di_nchan       = 3,
  45                .do_nchan       = 3,
  46                .iosize         = 16,
  47        },
  48};
  49
  50static int das08_cs_auto_attach(struct comedi_device *dev,
  51                                unsigned long context)
  52{
  53        struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
  54        struct das08_private_struct *devpriv;
  55        unsigned long iobase;
  56        int ret;
  57
  58        /* The das08 driver needs the board_ptr */
  59        dev->board_ptr = &das08_cs_boards[0];
  60
  61        link->config_flags |= CONF_AUTO_SET_IO;
  62        ret = comedi_pcmcia_enable(dev, NULL);
  63        if (ret)
  64                return ret;
  65        iobase = link->resource[0]->start;
  66
  67        devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
  68        if (!devpriv)
  69                return -ENOMEM;
  70
  71        return das08_common_attach(dev, iobase);
  72}
  73
  74static struct comedi_driver driver_das08_cs = {
  75        .driver_name    = "das08_cs",
  76        .module         = THIS_MODULE,
  77        .auto_attach    = das08_cs_auto_attach,
  78        .detach         = comedi_pcmcia_disable,
  79};
  80
  81static int das08_pcmcia_attach(struct pcmcia_device *link)
  82{
  83        return comedi_pcmcia_auto_config(link, &driver_das08_cs);
  84}
  85
  86static const struct pcmcia_device_id das08_cs_id_table[] = {
  87        PCMCIA_DEVICE_MANF_CARD(0x01c5, 0x4001),
  88        PCMCIA_DEVICE_NULL
  89};
  90MODULE_DEVICE_TABLE(pcmcia, das08_cs_id_table);
  91
  92static struct pcmcia_driver das08_cs_driver = {
  93        .name           = "pcm-das08",
  94        .owner          = THIS_MODULE,
  95        .id_table       = das08_cs_id_table,
  96        .probe          = das08_pcmcia_attach,
  97        .remove         = comedi_pcmcia_auto_unconfig,
  98};
  99module_comedi_pcmcia_driver(driver_das08_cs, das08_cs_driver);
 100
 101MODULE_AUTHOR("David A. Schleef <ds@schleef.org>");
 102MODULE_AUTHOR("Frank Mori Hess <fmhess@users.sourceforge.net>");
 103MODULE_DESCRIPTION("Comedi driver for ComputerBoards DAS-08 PCMCIA boards");
 104MODULE_LICENSE("GPL");
 105