3 comedi/drivers/aio_iiro_16.c
5 Driver for Access I/O Products PC-104 AIO-IIRO-16 Digital I/O board
6 Copyright (C) 2006 C&C Technologies, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
22 Description: Access I/O Products PC-104 IIRO16 Relay And Isolated Input Board
23 Author: Zachary Ware <zach.ware@cctechnol.com>
25 [Access I/O] PC-104 AIO12-8
28 Configuration Options:
29 [0] - I/O port base address
33 #include <linux/module.h>
34 #include "../comedidev.h"
36 #define AIO_IIRO_16_SIZE 0x08
37 #define AIO_IIRO_16_RELAY_0_7 0x00
38 #define AIO_IIRO_16_INPUT_0_7 0x01
39 #define AIO_IIRO_16_IRQ 0x02
40 #define AIO_IIRO_16_RELAY_8_15 0x04
41 #define AIO_IIRO_16_INPUT_8_15 0x05
43 static int aio_iiro_16_dio_insn_bits_write(struct comedi_device *dev,
44 struct comedi_subdevice *s,
45 struct comedi_insn *insn,
50 s->state |= data[0] & data[1];
51 outb(s->state & 0xff, dev->iobase + AIO_IIRO_16_RELAY_0_7);
52 outb((s->state >> 8) & 0xff,
53 dev->iobase + AIO_IIRO_16_RELAY_8_15);
61 static int aio_iiro_16_dio_insn_bits_read(struct comedi_device *dev,
62 struct comedi_subdevice *s,
63 struct comedi_insn *insn,
67 data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_0_7);
68 data[1] |= inb(dev->iobase + AIO_IIRO_16_INPUT_8_15) << 8;
73 static int aio_iiro_16_attach(struct comedi_device *dev,
74 struct comedi_devconfig *it)
76 struct comedi_subdevice *s;
79 ret = comedi_request_region(dev, it->options[0], AIO_IIRO_16_SIZE);
83 ret = comedi_alloc_subdevices(dev, 2);
87 s = &dev->subdevices[0];
88 s->type = COMEDI_SUBD_DIO;
89 s->subdev_flags = SDF_WRITABLE;
92 s->range_table = &range_digital;
93 s->insn_bits = aio_iiro_16_dio_insn_bits_write;
95 s = &dev->subdevices[1];
96 s->type = COMEDI_SUBD_DIO;
97 s->subdev_flags = SDF_READABLE;
100 s->range_table = &range_digital;
101 s->insn_bits = aio_iiro_16_dio_insn_bits_read;
106 static struct comedi_driver aio_iiro_16_driver = {
107 .driver_name = "aio_iiro_16",
108 .module = THIS_MODULE,
109 .attach = aio_iiro_16_attach,
110 .detach = comedi_legacy_detach,
112 module_comedi_driver(aio_iiro_16_driver);
114 MODULE_AUTHOR("Comedi http://www.comedi.org");
115 MODULE_DESCRIPTION("Comedi low-level driver");
116 MODULE_LICENSE("GPL");