linux/drivers/staging/comedi/drivers/amplc_pc236.c
<<
>>
Prefs
   1/*
   2 * comedi/drivers/amplc_pc236.c
   3 * Driver for Amplicon PC36AT DIO boards.
   4 *
   5 * Copyright (C) 2002 MEV Ltd. <http://www.mev.co.uk/>
   6 *
   7 * COMEDI - Linux Control and Measurement Device Interface
   8 * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
   9 *
  10 * This program is free software; you can redistribute it and/or modify
  11 * it under the terms of the GNU General Public License as published by
  12 * the Free Software Foundation; either version 2 of the License, or
  13 * (at your option) any later version.
  14 *
  15 * This program is distributed in the hope that it will be useful,
  16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18 * GNU General Public License for more details.
  19 */
  20/*
  21 * Driver: amplc_pc236
  22 * Description: Amplicon PC36AT
  23 * Author: Ian Abbott <abbotti@mev.co.uk>
  24 * Devices: [Amplicon] PC36AT (pc36at)
  25 * Updated: Fri, 25 Jul 2014 15:32:40 +0000
  26 * Status: works
  27 *
  28 * Configuration options - PC36AT:
  29 *   [0] - I/O port base address
  30 *   [1] - IRQ (optional)
  31 *
  32 * The PC36AT board has a single 8255 appearing as subdevice 0.
  33 *
  34 * Subdevice 1 pretends to be a digital input device, but it always returns
  35 * 0 when read. However, if you run a command with scan_begin_src=TRIG_EXT,
  36 * a rising edge on port C bit 3 acts as an external trigger, which can be
  37 * used to wake up tasks.  This is like the comedi_parport device, but the
  38 * only way to physically disable the interrupt on the PC36AT is to remove
  39 * the IRQ jumper.  If no interrupt is connected, then subdevice 1 is
  40 * unused.
  41 */
  42
  43#include <linux/module.h>
  44
  45#include "../comedidev.h"
  46
  47#include "amplc_pc236.h"
  48
  49static int pc236_attach(struct comedi_device *dev, struct comedi_devconfig *it)
  50{
  51        struct pc236_private *devpriv;
  52        int ret;
  53
  54        devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
  55        if (!devpriv)
  56                return -ENOMEM;
  57
  58        ret = comedi_request_region(dev, it->options[0], 0x4);
  59        if (ret)
  60                return ret;
  61
  62        return amplc_pc236_common_attach(dev, dev->iobase, it->options[1], 0);
  63}
  64
  65static const struct pc236_board pc236_boards[] = {
  66        {
  67                .name = "pc36at",
  68        },
  69};
  70
  71static struct comedi_driver amplc_pc236_driver = {
  72        .driver_name = "amplc_pc236",
  73        .module = THIS_MODULE,
  74        .attach = pc236_attach,
  75        .detach = comedi_legacy_detach,
  76        .board_name = &pc236_boards[0].name,
  77        .offset = sizeof(struct pc236_board),
  78        .num_names = ARRAY_SIZE(pc236_boards),
  79};
  80
  81module_comedi_driver(amplc_pc236_driver);
  82
  83MODULE_AUTHOR("Comedi http://www.comedi.org");
  84MODULE_DESCRIPTION("Comedi driver for Amplicon PC36AT DIO boards");
  85MODULE_LICENSE("GPL");
  86