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,
30 struct comedi_devconfig *it);
31 static int pcl730_detach(struct comedi_device *dev);
35 const char *name; /* board name */
36 unsigned int io_range; /* len of I/O space */
39 static const struct pcl730_board boardtypes[] = {
40 {"pcl730", PCL730_SIZE,},
41 {"iso730", PCL730_SIZE,},
42 {"acl7130", ACL7130_SIZE,},
45 #define n_boardtypes (sizeof(boardtypes)/sizeof(struct pcl730_board))
46 #define this_board ((const struct pcl730_board *)dev->board_ptr)
48 static struct comedi_driver driver_pcl730 = {
49 .driver_name = "pcl730",
50 .module = THIS_MODULE,
51 .attach = pcl730_attach,
52 .detach = pcl730_detach,
53 .board_name = &boardtypes[0].name,
54 .num_names = n_boardtypes,
55 .offset = sizeof(struct pcl730_board),
58 static int __init driver_pcl730_init_module(void)
60 return comedi_driver_register(&driver_pcl730);
63 static void __exit driver_pcl730_cleanup_module(void)
65 comedi_driver_unregister(&driver_pcl730);
68 module_init(driver_pcl730_init_module);
69 module_exit(driver_pcl730_cleanup_module);
71 static int pcl730_do_insn(struct comedi_device *dev, struct comedi_subdevice *s,
72 struct comedi_insn *insn, unsigned int *data)
79 s->state |= (data[0] & data[1]);
83 dev->iobase + ((unsigned long)s->private));
86 dev->iobase + ((unsigned long)s->private) + 1);
93 static int pcl730_di_insn(struct comedi_device *dev, struct comedi_subdevice *s,
94 struct comedi_insn *insn, unsigned int *data)
99 data[1] = inb(dev->iobase + ((unsigned long)s->private)) |
100 (inb(dev->iobase + ((unsigned long)s->private) + 1) << 8);
105 static int pcl730_attach(struct comedi_device *dev, struct comedi_devconfig *it)
107 struct comedi_subdevice *s;
108 unsigned long iobase;
109 unsigned int iorange;
111 iobase = it->options[0];
112 iorange = this_board->io_range;
113 printk(KERN_INFO "comedi%d: pcl730: board=%s 0x%04lx ", dev->minor,
114 this_board->name, iobase);
115 if (!request_region(iobase, iorange, "pcl730")) {
116 printk("I/O port conflict\n");
119 dev->board_name = this_board->name;
120 dev->iobase = iobase;
123 if (alloc_subdevices(dev, 4) < 0)
126 s = dev->subdevices + 0;
128 s->type = COMEDI_SUBD_DO;
129 s->subdev_flags = SDF_WRITABLE;
132 s->insn_bits = pcl730_do_insn;
133 s->range_table = &range_digital;
134 s->private = (void *)PCL730_IDIO_LO;
136 s = dev->subdevices + 1;
138 s->type = COMEDI_SUBD_DI;
139 s->subdev_flags = SDF_READABLE;
142 s->insn_bits = pcl730_di_insn;
143 s->range_table = &range_digital;
144 s->private = (void *)PCL730_IDIO_LO;
146 s = dev->subdevices + 2;
148 s->type = COMEDI_SUBD_DO;
149 s->subdev_flags = SDF_WRITABLE;
152 s->insn_bits = pcl730_do_insn;
153 s->range_table = &range_digital;
154 s->private = (void *)PCL730_DIO_LO;
156 s = dev->subdevices + 3;
158 s->type = COMEDI_SUBD_DI;
159 s->subdev_flags = SDF_READABLE;
162 s->insn_bits = pcl730_di_insn;
163 s->range_table = &range_digital;
164 s->private = (void *)PCL730_DIO_LO;
166 printk(KERN_INFO "\n");
171 static int pcl730_detach(struct comedi_device *dev)
173 printk(KERN_INFO "comedi%d: pcl730: remove\n", dev->minor);
176 release_region(dev->iobase, this_board->io_range);
181 MODULE_AUTHOR("Comedi http://www.comedi.org");
182 MODULE_DESCRIPTION("Comedi low-level driver");
183 MODULE_LICENSE("GPL");