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) */
31 const char *name
; /* board name */
32 unsigned int io_range
; /* len of I/O space */
35 static int pcl730_do_insn(struct comedi_device
*dev
, struct comedi_subdevice
*s
,
36 struct comedi_insn
*insn
, unsigned int *data
)
40 s
->state
|= (data
[0] & data
[1]);
44 dev
->iobase
+ ((unsigned long)s
->private));
47 dev
->iobase
+ ((unsigned long)s
->private) + 1);
54 static int pcl730_di_insn(struct comedi_device
*dev
, struct comedi_subdevice
*s
,
55 struct comedi_insn
*insn
, unsigned int *data
)
57 data
[1] = inb(dev
->iobase
+ ((unsigned long)s
->private)) |
58 (inb(dev
->iobase
+ ((unsigned long)s
->private) + 1) << 8);
63 static int pcl730_attach(struct comedi_device
*dev
, struct comedi_devconfig
*it
)
65 const struct pcl730_board
*board
= comedi_board(dev
);
66 struct comedi_subdevice
*s
;
71 iobase
= it
->options
[0];
72 iorange
= board
->io_range
;
73 printk(KERN_INFO
"comedi%d: pcl730: board=%s 0x%04lx ", dev
->minor
,
75 if (!request_region(iobase
, iorange
, "pcl730")) {
76 printk("I/O port conflict\n");
79 dev
->board_name
= board
->name
;
83 ret
= comedi_alloc_subdevices(dev
, 4);
87 s
= dev
->subdevices
+ 0;
89 s
->type
= COMEDI_SUBD_DO
;
90 s
->subdev_flags
= SDF_WRITABLE
;
93 s
->insn_bits
= pcl730_do_insn
;
94 s
->range_table
= &range_digital
;
95 s
->private = (void *)PCL730_IDIO_LO
;
97 s
= dev
->subdevices
+ 1;
99 s
->type
= COMEDI_SUBD_DI
;
100 s
->subdev_flags
= SDF_READABLE
;
103 s
->insn_bits
= pcl730_di_insn
;
104 s
->range_table
= &range_digital
;
105 s
->private = (void *)PCL730_IDIO_LO
;
107 s
= dev
->subdevices
+ 2;
109 s
->type
= COMEDI_SUBD_DO
;
110 s
->subdev_flags
= SDF_WRITABLE
;
113 s
->insn_bits
= pcl730_do_insn
;
114 s
->range_table
= &range_digital
;
115 s
->private = (void *)PCL730_DIO_LO
;
117 s
= dev
->subdevices
+ 3;
119 s
->type
= COMEDI_SUBD_DI
;
120 s
->subdev_flags
= SDF_READABLE
;
123 s
->insn_bits
= pcl730_di_insn
;
124 s
->range_table
= &range_digital
;
125 s
->private = (void *)PCL730_DIO_LO
;
127 printk(KERN_INFO
"\n");
132 static void pcl730_detach(struct comedi_device
*dev
)
134 const struct pcl730_board
*board
= comedi_board(dev
);
137 release_region(dev
->iobase
, board
->io_range
);
140 static const struct pcl730_board boardtypes
[] = {
141 { "pcl730", PCL730_SIZE
, },
142 { "iso730", PCL730_SIZE
, },
143 { "acl7130", ACL7130_SIZE
, },
146 static struct comedi_driver pcl730_driver
= {
147 .driver_name
= "pcl730",
148 .module
= THIS_MODULE
,
149 .attach
= pcl730_attach
,
150 .detach
= pcl730_detach
,
151 .board_name
= &boardtypes
[0].name
,
152 .num_names
= ARRAY_SIZE(boardtypes
),
153 .offset
= sizeof(struct pcl730_board
),
155 module_comedi_driver(pcl730_driver
);
157 MODULE_AUTHOR("Comedi http://www.comedi.org");
158 MODULE_DESCRIPTION("Comedi low-level driver");
159 MODULE_LICENSE("GPL");