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,
32 struct comedi_devconfig *it);
33 static int pcm3730_detach(struct comedi_device *dev);
34 static struct comedi_driver driver_pcm3730 = {
35 .driver_name = "pcm3730",
36 .module = THIS_MODULE,
37 .attach = pcm3730_attach,
38 .detach = pcm3730_detach,
41 COMEDI_INITCLEANUP(driver_pcm3730);
43 static int pcm3730_do_insn_bits(struct comedi_device *dev,
44 struct comedi_subdevice *s,
45 struct comedi_insn *insn, unsigned int *data)
51 s->state |= (data[0] & data[1]);
52 outb(s->state, dev->iobase + (unsigned long)(s->private));
59 static int pcm3730_di_insn_bits(struct comedi_device *dev,
60 struct comedi_subdevice *s,
61 struct comedi_insn *insn, unsigned int *data)
65 data[1] = inb(dev->iobase + (unsigned long)(s->private));
69 static int pcm3730_attach(struct comedi_device *dev,
70 struct comedi_devconfig *it)
72 struct comedi_subdevice *s;
75 iobase = it->options[0];
76 printk("comedi%d: pcm3730: 0x%04lx ", dev->minor, iobase);
77 if (!request_region(iobase, PCM3730_SIZE, "pcm3730")) {
78 printk("I/O port conflict\n");
82 dev->board_name = "pcm3730";
83 dev->iobase = dev->iobase;
86 if (alloc_subdevices(dev, 6) < 0)
89 s = dev->subdevices + 0;
90 s->type = COMEDI_SUBD_DO;
91 s->subdev_flags = SDF_WRITABLE;
94 s->insn_bits = pcm3730_do_insn_bits;
95 s->range_table = &range_digital;
96 s->private = (void *)PCM3730_DOA;
98 s = dev->subdevices + 1;
99 s->type = COMEDI_SUBD_DO;
100 s->subdev_flags = SDF_WRITABLE;
103 s->insn_bits = pcm3730_do_insn_bits;
104 s->range_table = &range_digital;
105 s->private = (void *)PCM3730_DOB;
107 s = dev->subdevices + 2;
108 s->type = COMEDI_SUBD_DO;
109 s->subdev_flags = SDF_WRITABLE;
112 s->insn_bits = pcm3730_do_insn_bits;
113 s->range_table = &range_digital;
114 s->private = (void *)PCM3730_DOC;
116 s = dev->subdevices + 3;
117 s->type = COMEDI_SUBD_DI;
118 s->subdev_flags = SDF_READABLE;
121 s->insn_bits = pcm3730_di_insn_bits;
122 s->range_table = &range_digital;
123 s->private = (void *)PCM3730_DIA;
125 s = dev->subdevices + 4;
126 s->type = COMEDI_SUBD_DI;
127 s->subdev_flags = SDF_READABLE;
130 s->insn_bits = pcm3730_di_insn_bits;
131 s->range_table = &range_digital;
132 s->private = (void *)PCM3730_DIB;
134 s = dev->subdevices + 5;
135 s->type = COMEDI_SUBD_DI;
136 s->subdev_flags = SDF_READABLE;
139 s->insn_bits = pcm3730_di_insn_bits;
140 s->range_table = &range_digital;
141 s->private = (void *)PCM3730_DIC;
148 static int pcm3730_detach(struct comedi_device *dev)
150 printk("comedi%d: pcm3730: remove\n", dev->minor);
153 release_region(dev->iobase, PCM3730_SIZE);