2 * Driver for Amplicon PC263 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.
22 * Description: Amplicon PC263
23 * Author: Ian Abbott <abbotti@mev.co.uk>
24 * Devices: [Amplicon] PC263 (pc263)
25 * Updated: Fri, 12 Apr 2013 15:19:36 +0100
28 * Configuration options:
29 * [0] - I/O port base address
31 * The board appears as one subdevice, with 16 digital outputs, each
32 * connected to a reed-relay. Relay contacts are closed when output is 1.
33 * The state of the outputs can be read.
36 #include <linux/module.h>
37 #include "../comedidev.h"
40 #define PC263_DO_0_7_REG 0x00
41 #define PC263_DO_8_15_REG 0x01
47 static const struct pc263_board pc263_boards[] = {
53 static int pc263_do_insn_bits(struct comedi_device *dev,
54 struct comedi_subdevice *s,
55 struct comedi_insn *insn,
58 if (comedi_dio_update_state(s, data)) {
59 outb(s->state & 0xff, dev->iobase + PC263_DO_0_7_REG);
60 outb((s->state >> 8) & 0xff, dev->iobase + PC263_DO_8_15_REG);
68 static int pc263_attach(struct comedi_device *dev, struct comedi_devconfig *it)
70 struct comedi_subdevice *s;
73 ret = comedi_request_region(dev, it->options[0], 0x2);
77 ret = comedi_alloc_subdevices(dev, 1);
81 /* Digital Output subdevice */
82 s = &dev->subdevices[0];
83 s->type = COMEDI_SUBD_DO;
84 s->subdev_flags = SDF_WRITABLE;
87 s->range_table = &range_digital;
88 s->insn_bits = pc263_do_insn_bits;
90 /* read initial relay state */
91 s->state = inb(dev->iobase + PC263_DO_0_7_REG) |
92 (inb(dev->iobase + PC263_DO_8_15_REG) << 8);
97 static struct comedi_driver amplc_pc263_driver = {
98 .driver_name = "amplc_pc263",
99 .module = THIS_MODULE,
100 .attach = pc263_attach,
101 .detach = comedi_legacy_detach,
102 .board_name = &pc263_boards[0].name,
103 .offset = sizeof(struct pc263_board),
104 .num_names = ARRAY_SIZE(pc263_boards),
107 module_comedi_driver(amplc_pc263_driver);
109 MODULE_AUTHOR("Comedi http://www.comedi.org");
110 MODULE_DESCRIPTION("Comedi driver for Amplicon PC263 relay board");
111 MODULE_LICENSE("GPL");