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) */
25 static int acl7225b_attach(comedi_device * dev, comedi_devconfig * it);
26 static int acl7225b_detach(comedi_device * dev);
29 const char *name; // driver name
30 int io_range; // len of I/O space
33 static const boardtype boardtypes[] = {
34 {"acl7225b", ACL7225_SIZE,},
35 {"p16r16dio", P16R16DIO_SIZE,},
38 #define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
39 #define this_board ((const boardtype *)dev->board_ptr)
41 static comedi_driver driver_acl7225b = {
42 driver_name:"acl7225b",
44 attach:acl7225b_attach,
45 detach:acl7225b_detach,
46 board_name:&boardtypes[0].name,
47 num_names:n_boardtypes,
48 offset:sizeof(boardtype),
51 COMEDI_INITCLEANUP(driver_acl7225b);
53 static int acl7225b_do_insn(comedi_device * dev, comedi_subdevice * s,
54 comedi_insn * insn, lsampl_t * data)
61 s->state |= (data[0] & data[1]);
64 outb(s->state & 0xff, dev->iobase + (unsigned long)s->private);
67 dev->iobase + (unsigned long)s->private + 1);
74 static int acl7225b_di_insn(comedi_device * dev, comedi_subdevice * s,
75 comedi_insn * insn, lsampl_t * data)
80 data[1] = inb(dev->iobase + (unsigned long)s->private) |
81 (inb(dev->iobase + (unsigned long)s->private + 1) << 8);
86 static int acl7225b_attach(comedi_device * dev, comedi_devconfig * it)
91 iobase = it->options[0];
92 iorange = this_board->io_range;
93 printk("comedi%d: acl7225b: board=%s 0x%04x ", dev->minor,
94 this_board->name, iobase);
95 if (!request_region(iobase, iorange, "acl7225b")) {
96 printk("I/O port conflict\n");
99 dev->board_name = this_board->name;
100 dev->iobase = iobase;
103 if (alloc_subdevices(dev, 3) < 0)
106 s = dev->subdevices + 0;
108 s->type = COMEDI_SUBD_DO;
109 s->subdev_flags = SDF_WRITABLE;
112 s->insn_bits = acl7225b_do_insn;
113 s->range_table = &range_digital;
114 s->private = (void *)ACL7225_RIO_LO;
116 s = dev->subdevices + 1;
118 s->type = COMEDI_SUBD_DI;
119 s->subdev_flags = SDF_READABLE;
122 s->insn_bits = acl7225b_di_insn;
123 s->range_table = &range_digital;
124 s->private = (void *)ACL7225_RIO_LO;
126 s = dev->subdevices + 2;
127 /* Isolated digital inputs */
128 s->type = COMEDI_SUBD_DI;
129 s->subdev_flags = SDF_READABLE;
132 s->insn_bits = acl7225b_di_insn;
133 s->range_table = &range_digital;
134 s->private = (void *)ACL7225_DI_LO;
141 static int acl7225b_detach(comedi_device * dev)
143 printk("comedi%d: acl7225b: remove\n", dev->minor);
146 release_region(dev->iobase, this_board->io_range);