2 * comedi/drivers/pcl730.c
3 * Driver for Advantech PCL-730 and clones
8 Description: Advantech PCL-730 (& compatibles)
9 Author: José Luis Sánchez (jsanchezv@teleline.es)
11 Devices: [Advantech] PCL-730 (pcl730), [ICP] ISO-730 (iso730),
12 [Adlink] ACL-7130 (acl7130)
14 Interrupts are not supported.
15 The ACL-7130 card have an 8254 timer/counter not supported by this driver.
18 #include "../comedidev.h"
20 #include <linux/ioport.h>
23 #define ACL7130_SIZE 8
24 #define PCL730_IDIO_LO 0 /* Isolated Digital I/O low byte (ID0-ID7) */
25 #define PCL730_IDIO_HI 1 /* Isolated Digital I/O high byte (ID8-ID15) */
26 #define PCL730_DIO_LO 2 /* TTL Digital I/O low byte (D0-D7) */
27 #define PCL730_DIO_HI 3 /* TTL Digital I/O high byte (D8-D15) */
29 static int pcl730_attach(struct comedi_device * dev, comedi_devconfig * it);
30 static int pcl730_detach(struct comedi_device * dev);
33 const char *name; // board name
34 unsigned int io_range; // len of I/O space
37 static const boardtype boardtypes[] = {
38 {"pcl730", PCL730_SIZE,},
39 {"iso730", PCL730_SIZE,},
40 {"acl7130", ACL7130_SIZE,},
43 #define n_boardtypes (sizeof(boardtypes)/sizeof(boardtype))
44 #define this_board ((const boardtype *)dev->board_ptr)
46 static comedi_driver driver_pcl730 = {
51 board_name:&boardtypes[0].name,
52 num_names:n_boardtypes,
53 offset:sizeof(boardtype),
56 COMEDI_INITCLEANUP(driver_pcl730);
58 static int pcl730_do_insn(struct comedi_device * dev, struct comedi_subdevice * s,
59 comedi_insn * insn, unsigned int * data)
66 s->state |= (data[0] & data[1]);
70 dev->iobase + ((unsigned long)s->private));
73 dev->iobase + ((unsigned long)s->private) + 1);
80 static int pcl730_di_insn(struct comedi_device * dev, struct comedi_subdevice * s,
81 comedi_insn * insn, unsigned int * data)
86 data[1] = inb(dev->iobase + ((unsigned long)s->private)) |
87 (inb(dev->iobase + ((unsigned long)s->private) + 1) << 8);
92 static int pcl730_attach(struct comedi_device * dev, comedi_devconfig * it)
94 struct comedi_subdevice *s;
98 iobase = it->options[0];
99 iorange = this_board->io_range;
100 printk("comedi%d: pcl730: board=%s 0x%04lx ", dev->minor,
101 this_board->name, iobase);
102 if (!request_region(iobase, iorange, "pcl730")) {
103 printk("I/O port conflict\n");
106 dev->board_name = this_board->name;
107 dev->iobase = iobase;
110 if (alloc_subdevices(dev, 4) < 0)
113 s = dev->subdevices + 0;
115 s->type = COMEDI_SUBD_DO;
116 s->subdev_flags = SDF_WRITABLE;
119 s->insn_bits = pcl730_do_insn;
120 s->range_table = &range_digital;
121 s->private = (void *)PCL730_IDIO_LO;
123 s = dev->subdevices + 1;
125 s->type = COMEDI_SUBD_DI;
126 s->subdev_flags = SDF_READABLE;
129 s->insn_bits = pcl730_di_insn;
130 s->range_table = &range_digital;
131 s->private = (void *)PCL730_IDIO_LO;
133 s = dev->subdevices + 2;
135 s->type = COMEDI_SUBD_DO;
136 s->subdev_flags = SDF_WRITABLE;
139 s->insn_bits = pcl730_do_insn;
140 s->range_table = &range_digital;
141 s->private = (void *)PCL730_DIO_LO;
143 s = dev->subdevices + 3;
145 s->type = COMEDI_SUBD_DI;
146 s->subdev_flags = SDF_READABLE;
149 s->insn_bits = pcl730_di_insn;
150 s->range_table = &range_digital;
151 s->private = (void *)PCL730_DIO_LO;
158 static int pcl730_detach(struct comedi_device * dev)
160 printk("comedi%d: pcl730: remove\n", dev->minor);
163 release_region(dev->iobase, this_board->io_range);