Version:  2.0.40 2.2.26 2.4.37 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19

Linux/drivers/staging/comedi/drivers/addi_apci_1500.c

  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 
 10 struct 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 
 21 static 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 
 95 static void apci1500_detach(struct comedi_device *dev)
 96 {
 97         if (dev->iobase)
 98                 apci1500_reset(dev);
 99         comedi_pci_detach(dev);
100 }
101 
102 static 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 
109 static 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 
115 static const struct pci_device_id apci1500_pci_table[] = {
116         { PCI_DEVICE(PCI_VENDOR_ID_AMCC, 0x80fc) },
117         { 0 }
118 };
119 MODULE_DEVICE_TABLE(pci, apci1500_pci_table);
120 
121 static 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 };
127 module_comedi_pci_driver(apci1500_driver, apci1500_pci_driver);
128 
129 MODULE_AUTHOR("Comedi http://www.comedi.org");
130 MODULE_DESCRIPTION("ADDI-DATA APCI-1500, 16 channel DI / 16 channel DO boards");
131 MODULE_LICENSE("GPL");
132 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us