linux/drivers/staging/comedi/drivers/addi_apci_1500.c
<<
>>
Prefs
   1#include <linux/module.h>
   2#include <linux/pci.h>
   3#include <linux/sched.h>
   4#include <linux/interrupt.h>
   5
   6#include "../comedidev.h"
   7#include "comedi_fc.h"
   8#include "amcc_s5933.h"
   9
  10struct apci1500_private {
  11        int iobase;
  12        int i_IobaseAmcc;
  13        int i_IobaseAddon;
  14        int i_IobaseReserved;
  15        unsigned char b_OutputMemoryStatus;
  16        struct task_struct *tsk_Current;
  17};
  18
  19#include "addi-data/hwdrv_apci1500.c"
  20
  21static int apci1500_auto_attach(struct comedi_device *dev,
  22                                unsigned long context)
  23{
  24        struct pci_dev *pcidev = comedi_to_pci_dev(dev);
  25        struct apci1500_private *devpriv;
  26        struct comedi_subdevice *s;
  27        int ret;
  28
  29        devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
  30        if (!devpriv)
  31                return -ENOMEM;
  32
  33        ret = comedi_pci_enable(dev);
  34        if (ret)
  35                return ret;
  36
  37        dev->iobase = pci_resource_start(pcidev, 1);
  38        devpriv->iobase = dev->iobase;
  39        devpriv->i_IobaseAmcc = pci_resource_start(pcidev, 0);
  40        devpriv->i_IobaseAddon = pci_resource_start(pcidev, 2);
  41        devpriv->i_IobaseReserved = pci_resource_start(pcidev, 3);
  42
  43        if (pcidev->irq > 0) {
  44                ret = request_irq(pcidev->irq, apci1500_interrupt, IRQF_SHARED,
  45                                  dev->board_name, dev);
  46                if (ret == 0)
  47                        dev->irq = pcidev->irq;
  48        }
  49
  50        ret = comedi_alloc_subdevices(dev, 3);
  51        if (ret)
  52                return ret;
  53
  54        /*  Allocate and Initialise DI Subdevice Structures */
  55        s = &dev->subdevices[0];
  56        s->type = COMEDI_SUBD_DI;
  57        s->subdev_flags = SDF_READABLE;
  58        s->n_chan = 16;
  59        s->maxdata = 1;
  60        s->range_table = &range_digital;
  61        s->insn_config = apci1500_di_config;
  62        s->insn_read = apci1500_di_read;
  63        s->insn_write = apci1500_di_write;
  64        s->insn_bits = apci1500_di_insn_bits;
  65
  66        /*  Allocate and Initialise DO Subdevice Structures */
  67        s = &dev->subdevices[1];
  68        s->type = COMEDI_SUBD_DO;
  69        s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
  70        s->n_chan = 16;
  71        s->maxdata = 1;
  72        s->range_table = &range_digital;
  73        s->insn_config = apci1500_do_config;
  74        s->insn_write = apci1500_do_write;
  75        s->insn_bits = apci1500_do_bits;
  76
  77        /*  Allocate and Initialise Timer Subdevice Structures */
  78        s = &dev->subdevices[2];
  79        s->type = COMEDI_SUBD_TIMER;
  80        s->subdev_flags = SDF_WRITABLE;
  81        s->n_chan = 1;
  82        s->maxdata = 0;
  83        s->len_chanlist = 1;
  84        s->range_table = &range_digital;
  85        s->insn_write = apci1500_timer_write;
  86        s->insn_read = apci1500_timer_read;
  87        s->insn_config = apci1500_timer_config;
  88        s->insn_bits = apci1500_timer_bits;
  89
  90        apci1500_reset(dev);
  91
  92        return 0;
  93}
  94
  95static void apci1500_detach(struct comedi_device *dev)
  96{
  97        if (dev->iobase)
  98                apci1500_reset(dev);
  99        comedi_pci_detach(dev);
 100}
 101
 102static struct comedi_driver apci1500_driver = {
 103        .driver_name    = "addi_apci_1500",
 104        .module         = THIS_MODULE,
 105        .auto_attach    = apci1500_auto_attach,
 106        .detach         = apci1500_detach,
 107};
 108
 109static int apci1500_pci_probe(struct pci_dev *dev,
 110                              const struct pci_device_id *id)
 111{
 112        return comedi_pci_auto_config(dev, &apci1500_driver, id->driver_data);
 113}
 114
 115static const struct pci_device_id apci1500_pci_table[] = {
 116        { PCI_DEVICE(PCI_VENDOR_ID_AMCC, 0x80fc) },
 117        { 0 }
 118};
 119MODULE_DEVICE_TABLE(pci, apci1500_pci_table);
 120
 121static struct pci_driver apci1500_pci_driver = {
 122        .name           = "addi_apci_1500",
 123        .id_table       = apci1500_pci_table,
 124        .probe          = apci1500_pci_probe,
 125        .remove         = comedi_pci_auto_unconfig,
 126};
 127module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver);
 128
 129MODULE_AUTHOR("Comedi http://www.comedi.org");
 130MODULE_DESCRIPTION("ADDI-DATA APCI-1500, 16 channel DI / 16 channel DO boards");
 131MODULE_LICENSE("GPL");
 132
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.