2 * Driver for Amplicon PCI263 relay board.
4 * Copyright (C) 2002 MEV Ltd. <http://www.mev.co.uk/>
6 * COMEDI - Linux Control and Measurement Device Interface
7 * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
21 * Driver: amplc_pci263
22 * Description: Amplicon PCI263
23 * Author: Ian Abbott <abbotti@mev.co.uk>
24 * Devices: [Amplicon] PCI263 (amplc_pci263)
25 * Updated: Fri, 12 Apr 2013 15:19:36 +0100
28 * Configuration options: not applicable, uses PCI auto config
30 * The board appears as one subdevice, with 16 digital outputs, each
31 * connected to a reed-relay. Relay contacts are closed when output is 1.
32 * The state of the outputs can be read.
35 #include <linux/module.h>
37 #include "../comedi_pci.h"
39 /* PCI263 registers */
40 #define PCI263_DO_0_7_REG 0x00
41 #define PCI263_DO_8_15_REG 0x01
43 static int pci263_do_insn_bits(struct comedi_device *dev,
44 struct comedi_subdevice *s,
45 struct comedi_insn *insn,
48 if (comedi_dio_update_state(s, data)) {
49 outb(s->state & 0xff, dev->iobase + PCI263_DO_0_7_REG);
50 outb((s->state >> 8) & 0xff, dev->iobase + PCI263_DO_8_15_REG);
58 static int pci263_auto_attach(struct comedi_device *dev,
59 unsigned long context_unused)
61 struct pci_dev *pci_dev = comedi_to_pci_dev(dev);
62 struct comedi_subdevice *s;
65 ret = comedi_pci_enable(dev);
69 dev->iobase = pci_resource_start(pci_dev, 2);
70 ret = comedi_alloc_subdevices(dev, 1);
74 /* Digital Output subdevice */
75 s = &dev->subdevices[0];
76 s->type = COMEDI_SUBD_DO;
77 s->subdev_flags = SDF_WRITABLE;
80 s->range_table = &range_digital;
81 s->insn_bits = pci263_do_insn_bits;
83 /* read initial relay state */
84 s->state = inb(dev->iobase + PCI263_DO_0_7_REG) |
85 (inb(dev->iobase + PCI263_DO_8_15_REG) << 8);
90 static struct comedi_driver amplc_pci263_driver = {
91 .driver_name = "amplc_pci263",
92 .module = THIS_MODULE,
93 .auto_attach = pci263_auto_attach,
94 .detach = comedi_pci_detach,
97 static const struct pci_device_id pci263_pci_table[] = {
98 { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, 0x000c) },
101 MODULE_DEVICE_TABLE(pci, pci263_pci_table);
103 static int amplc_pci263_pci_probe(struct pci_dev *dev,
104 const struct pci_device_id *id)
106 return comedi_pci_auto_config(dev, &lc_pci263_driver,
110 static struct pci_driver amplc_pci263_pci_driver = {
111 .name = "amplc_pci263",
112 .id_table = pci263_pci_table,
113 .probe = &lc_pci263_pci_probe,
114 .remove = comedi_pci_auto_unconfig,
116 module_comedi_pci_driver(amplc_pci263_driver, amplc_pci263_pci_driver);
118 MODULE_AUTHOR("Comedi http://www.comedi.org");
119 MODULE_DESCRIPTION("Comedi driver for Amplicon PCI263 relay board");
120 MODULE_LICENSE("GPL");