2 * comedi/drivers/acl7225b.c
3 * Driver for Adlink NuDAQ ACL-7225b and clones
8 Description: Adlink NuDAQ ACL-7225b & compatibles
9 Author: José Luis Sánchez (jsanchezv@teleline.es)
11 Devices: [Adlink] ACL-7225b (acl7225b), [ICP] P16R16DIO (p16r16dio)
14 #include "../comedidev.h"
16 #include <linux/ioport.h>
18 #define ACL7225_SIZE 8 /* Requires 8 ioports, but only 4 are used */
19 #define P16R16DIO_SIZE 4
20 #define ACL7225_RIO_LO 0 /* Relays input/output low byte (R0-R7) */
21 #define ACL7225_RIO_HI 1 /* Relays input/output high byte (R8-R15) */
22 #define ACL7225_DI_LO 2 /* Digital input low byte (DI0-DI7) */
23 #define ACL7225_DI_HI 3 /* Digital input high byte (DI8-DI15) */
26 const char *name; /* driver name */
27 int io_range; /* len of I/O space */
30 static int acl7225b_do_insn(struct comedi_device *dev,
31 struct comedi_subdevice *s,
32 struct comedi_insn *insn, unsigned int *data)
36 s->state |= (data[0] & data[1]);
39 outb(s->state & 0xff, dev->iobase + (unsigned long)s->private);
42 dev->iobase + (unsigned long)s->private + 1);
49 static int acl7225b_di_insn(struct comedi_device *dev,
50 struct comedi_subdevice *s,
51 struct comedi_insn *insn, unsigned int *data)
53 data[1] = inb(dev->iobase + (unsigned long)s->private) |
54 (inb(dev->iobase + (unsigned long)s->private + 1) << 8);
59 static int acl7225b_attach(struct comedi_device *dev,
60 struct comedi_devconfig *it)
62 const struct boardtype *board = comedi_board(dev);
63 struct comedi_subdevice *s;
67 iobase = it->options[0];
68 iorange = board->io_range;
69 printk(KERN_INFO "comedi%d: acl7225b: board=%s 0x%04x\n", dev->minor,
71 if (!request_region(iobase, iorange, "acl7225b")) {
72 printk(KERN_ERR "comedi%d: request_region failed - I/O port conflict\n",
76 dev->board_name = board->name;
80 ret = comedi_alloc_subdevices(dev, 3);
84 s = &dev->subdevices[0];
86 s->type = COMEDI_SUBD_DO;
87 s->subdev_flags = SDF_WRITABLE;
90 s->insn_bits = acl7225b_do_insn;
91 s->range_table = &range_digital;
92 s->private = (void *)ACL7225_RIO_LO;
94 s = &dev->subdevices[1];
96 s->type = COMEDI_SUBD_DI;
97 s->subdev_flags = SDF_READABLE;
100 s->insn_bits = acl7225b_di_insn;
101 s->range_table = &range_digital;
102 s->private = (void *)ACL7225_RIO_LO;
104 s = &dev->subdevices[2];
105 /* Isolated digital inputs */
106 s->type = COMEDI_SUBD_DI;
107 s->subdev_flags = SDF_READABLE;
110 s->insn_bits = acl7225b_di_insn;
111 s->range_table = &range_digital;
112 s->private = (void *)ACL7225_DI_LO;
117 static void acl7225b_detach(struct comedi_device *dev)
119 const struct boardtype *board = comedi_board(dev);
122 release_region(dev->iobase, board->io_range);
125 static const struct boardtype boardtypes[] = {
126 { "acl7225b", ACL7225_SIZE, },
127 { "p16r16dio", P16R16DIO_SIZE, },
130 static struct comedi_driver acl7225b_driver = {
131 .driver_name = "acl7225b",
132 .module = THIS_MODULE,
133 .attach = acl7225b_attach,
134 .detach = acl7225b_detach,
135 .board_name = &boardtypes[0].name,
136 .num_names = ARRAY_SIZE(boardtypes),
137 .offset = sizeof(struct boardtype),
139 module_comedi_driver(acl7225b_driver);
141 MODULE_AUTHOR("Comedi http://www.comedi.org");
142 MODULE_DESCRIPTION("Comedi low-level driver");
143 MODULE_LICENSE("GPL");