1 // SPDX-License-Identifier: GPL-2.0+
3 * Driver for Amplicon PCI263 relay board.
5 * Copyright (C) 2002 MEV Ltd. <https://www.mev.co.uk/>
7 * COMEDI - Linux Control and Measurement Device Interface
8 * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
12 * Driver: amplc_pci263
13 * Description: Amplicon PCI263
14 * Author: Ian Abbott <abbotti@mev.co.uk>
15 * Devices: [Amplicon] PCI263 (amplc_pci263)
16 * Updated: Fri, 12 Apr 2013 15:19:36 +0100
19 * Configuration options: not applicable, uses PCI auto config
21 * The board appears as one subdevice, with 16 digital outputs, each
22 * connected to a reed-relay. Relay contacts are closed when output is 1.
23 * The state of the outputs can be read.
26 #include <linux/module.h>
28 #include "../comedi_pci.h"
30 /* PCI263 registers */
31 #define PCI263_DO_0_7_REG 0x00
32 #define PCI263_DO_8_15_REG 0x01
34 static int pci263_do_insn_bits(struct comedi_device *dev,
35 struct comedi_subdevice *s,
36 struct comedi_insn *insn,
39 if (comedi_dio_update_state(s, data)) {
40 outb(s->state & 0xff, dev->iobase + PCI263_DO_0_7_REG);
41 outb((s->state >> 8) & 0xff, dev->iobase + PCI263_DO_8_15_REG);
49 static int pci263_auto_attach(struct comedi_device *dev,
50 unsigned long context_unused)
52 struct pci_dev *pci_dev = comedi_to_pci_dev(dev);
53 struct comedi_subdevice *s;
56 ret = comedi_pci_enable(dev);
60 dev->iobase = pci_resource_start(pci_dev, 2);
61 ret = comedi_alloc_subdevices(dev, 1);
65 /* Digital Output subdevice */
66 s = &dev->subdevices[0];
67 s->type = COMEDI_SUBD_DO;
68 s->subdev_flags = SDF_WRITABLE;
71 s->range_table = &range_digital;
72 s->insn_bits = pci263_do_insn_bits;
74 /* read initial relay state */
75 s->state = inb(dev->iobase + PCI263_DO_0_7_REG) |
76 (inb(dev->iobase + PCI263_DO_8_15_REG) << 8);
81 static struct comedi_driver amplc_pci263_driver = {
82 .driver_name = "amplc_pci263",
83 .module = THIS_MODULE,
84 .auto_attach = pci263_auto_attach,
85 .detach = comedi_pci_detach,
88 static const struct pci_device_id pci263_pci_table[] = {
89 { PCI_DEVICE(PCI_VENDOR_ID_AMPLICON, 0x000c) },
92 MODULE_DEVICE_TABLE(pci, pci263_pci_table);
94 static int amplc_pci263_pci_probe(struct pci_dev *dev,
95 const struct pci_device_id *id)
97 return comedi_pci_auto_config(dev, &lc_pci263_driver,
101 static struct pci_driver amplc_pci263_pci_driver = {
102 .name = "amplc_pci263",
103 .id_table = pci263_pci_table,
104 .probe = &lc_pci263_pci_probe,
105 .remove = comedi_pci_auto_unconfig,
107 module_comedi_pci_driver(amplc_pci263_driver, amplc_pci263_pci_driver);
109 MODULE_AUTHOR("Comedi https://www.comedi.org");
110 MODULE_DESCRIPTION("Comedi driver for Amplicon PCI263 relay board");
111 MODULE_LICENSE("GPL");