1 // SPDX-License-Identifier: GPL-2.0+
3 * Driver for Amplicon PC263 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>
13 * Description: Amplicon PC263
14 * Author: Ian Abbott <abbotti@mev.co.uk>
15 * Devices: [Amplicon] PC263 (pc263)
16 * Updated: Fri, 12 Apr 2013 15:19:36 +0100
19 * Configuration options:
20 * [0] - I/O port base address
22 * The board appears as one subdevice, with 16 digital outputs, each
23 * connected to a reed-relay. Relay contacts are closed when output is 1.
24 * The state of the outputs can be read.
27 #include <linux/module.h>
28 #include <linux/comedi/comedidev.h>
31 #define PC263_DO_0_7_REG 0x00
32 #define PC263_DO_8_15_REG 0x01
38 static const struct pc263_board pc263_boards[] = {
44 static int pc263_do_insn_bits(struct comedi_device *dev,
45 struct comedi_subdevice *s,
46 struct comedi_insn *insn,
49 if (comedi_dio_update_state(s, data)) {
50 outb(s->state & 0xff, dev->iobase + PC263_DO_0_7_REG);
51 outb((s->state >> 8) & 0xff, dev->iobase + PC263_DO_8_15_REG);
59 static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
61 struct comedi_subdevice *s;
64 ret = comedi_request_region(dev, it->options[0], 0x2);
68 ret = comedi_alloc_subdevices(dev, 1);
72 /* Digital Output subdevice */
73 s = &dev->subdevices[0];
74 s->type = COMEDI_SUBD_DO;
75 s->subdev_flags = SDF_WRITABLE;
78 s->range_table = &range_digital;
79 s->insn_bits = pc263_do_insn_bits;
81 /* read initial relay state */
82 s->state = inb(dev->iobase + PC263_DO_0_7_REG) |
83 (inb(dev->iobase + PC263_DO_8_15_REG) << 8);
88 static struct comedi_driver amplc_pc263_driver = {
89 .driver_name = "amplc_pc263",
90 .module = THIS_MODULE,
91 .attach = pc263_attach,
92 .detach = comedi_legacy_detach,
93 .board_name = &pc263_boards[0].name,
94 .offset = sizeof(struct pc263_board),
95 .num_names = ARRAY_SIZE(pc263_boards),
98 module_comedi_driver(amplc_pc263_driver);
100 MODULE_AUTHOR("Comedi https://www.comedi.org");
101 MODULE_DESCRIPTION("Comedi driver for Amplicon PC263 relay board");
102 MODULE_LICENSE("GPL");