2 * comedi/drivers/pcm3730.c
3 * Driver for PCM3730 and clones
5 * from pcl725 by David S.
11 Devices: [Advantech] PCM-3730 (pcm3730)
14 Configuration options:
18 #include "../comedidev.h"
20 #include <linux/ioport.h>
22 #define PCM3730_SIZE 4 /* consecutive io port addresses */
24 #define PCM3730_DOA 0 /* offsets for each port */
31 static int pcm3730_attach(struct comedi_device *dev, struct comedi_devconfig *it);
32 static int pcm3730_detach(struct comedi_device *dev);
33 static struct comedi_driver driver_pcm3730 = {
34 .driver_name = "pcm3730",
35 .module = THIS_MODULE,
36 .attach = pcm3730_attach,
37 .detach = pcm3730_detach,
40 COMEDI_INITCLEANUP(driver_pcm3730);
42 static int pcm3730_do_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
43 struct comedi_insn *insn, unsigned int *data)
49 s->state |= (data[0] & data[1]);
50 outb(s->state, dev->iobase + (unsigned long)(s->private));
57 static int pcm3730_di_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s,
58 struct comedi_insn *insn, unsigned int *data)
62 data[1] = inb(dev->iobase + (unsigned long)(s->private));
66 static int pcm3730_attach(struct comedi_device *dev, struct comedi_devconfig *it)
68 struct comedi_subdevice *s;
71 iobase = it->options[0];
72 printk("comedi%d: pcm3730: 0x%04lx ", dev->minor, iobase);
73 if (!request_region(iobase, PCM3730_SIZE, "pcm3730")) {
74 printk("I/O port conflict\n");
78 dev->board_name = "pcm3730";
79 dev->iobase = dev->iobase;
82 if (alloc_subdevices(dev, 6) < 0)
85 s = dev->subdevices + 0;
86 s->type = COMEDI_SUBD_DO;
87 s->subdev_flags = SDF_WRITABLE;
90 s->insn_bits = pcm3730_do_insn_bits;
91 s->range_table = &range_digital;
92 s->private = (void *)PCM3730_DOA;
94 s = dev->subdevices + 1;
95 s->type = COMEDI_SUBD_DO;
96 s->subdev_flags = SDF_WRITABLE;
99 s->insn_bits = pcm3730_do_insn_bits;
100 s->range_table = &range_digital;
101 s->private = (void *)PCM3730_DOB;
103 s = dev->subdevices + 2;
104 s->type = COMEDI_SUBD_DO;
105 s->subdev_flags = SDF_WRITABLE;
108 s->insn_bits = pcm3730_do_insn_bits;
109 s->range_table = &range_digital;
110 s->private = (void *)PCM3730_DOC;
112 s = dev->subdevices + 3;
113 s->type = COMEDI_SUBD_DI;
114 s->subdev_flags = SDF_READABLE;
117 s->insn_bits = pcm3730_di_insn_bits;
118 s->range_table = &range_digital;
119 s->private = (void *)PCM3730_DIA;
121 s = dev->subdevices + 4;
122 s->type = COMEDI_SUBD_DI;
123 s->subdev_flags = SDF_READABLE;
126 s->insn_bits = pcm3730_di_insn_bits;
127 s->range_table = &range_digital;
128 s->private = (void *)PCM3730_DIB;
130 s = dev->subdevices + 5;
131 s->type = COMEDI_SUBD_DI;
132 s->subdev_flags = SDF_READABLE;
135 s->insn_bits = pcm3730_di_insn_bits;
136 s->range_table = &range_digital;
137 s->private = (void *)PCM3730_DIC;
144 static int pcm3730_detach(struct comedi_device *dev)
146 printk("comedi%d: pcm3730: remove\n", dev->minor);
149 release_region(dev->iobase, PCM3730_SIZE);