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
;
69 ret
= comedi_request_region(dev
, it
->options
[0], board
->io_range
);
73 ret
= comedi_alloc_subdevices(dev
, 4);
77 s
= &dev
->subdevices
[0];
79 s
->type
= COMEDI_SUBD_DO
;
80 s
->subdev_flags
= SDF_WRITABLE
;
83 s
->insn_bits
= pcl730_do_insn
;
84 s
->range_table
= &range_digital
;
85 s
->private = (void *)PCL730_IDIO_LO
;
87 s
= &dev
->subdevices
[1];
89 s
->type
= COMEDI_SUBD_DI
;
90 s
->subdev_flags
= SDF_READABLE
;
93 s
->insn_bits
= pcl730_di_insn
;
94 s
->range_table
= &range_digital
;
95 s
->private = (void *)PCL730_IDIO_LO
;
97 s
= &dev
->subdevices
[2];
99 s
->type
= COMEDI_SUBD_DO
;
100 s
->subdev_flags
= SDF_WRITABLE
;
103 s
->insn_bits
= pcl730_do_insn
;
104 s
->range_table
= &range_digital
;
105 s
->private = (void *)PCL730_DIO_LO
;
107 s
= &dev
->subdevices
[3];
109 s
->type
= COMEDI_SUBD_DI
;
110 s
->subdev_flags
= SDF_READABLE
;
113 s
->insn_bits
= pcl730_di_insn
;
114 s
->range_table
= &range_digital
;
115 s
->private = (void *)PCL730_DIO_LO
;
117 printk(KERN_INFO
"\n");
122 static const struct pcl730_board boardtypes
[] = {
123 { "pcl730", PCL730_SIZE
, },
124 { "iso730", PCL730_SIZE
, },
125 { "acl7130", ACL7130_SIZE
, },
128 static struct comedi_driver pcl730_driver
= {
129 .driver_name
= "pcl730",
130 .module
= THIS_MODULE
,
131 .attach
= pcl730_attach
,
132 .detach
= comedi_legacy_detach
,
133 .board_name
= &boardtypes
[0].name
,
134 .num_names
= ARRAY_SIZE(boardtypes
),
135 .offset
= sizeof(struct pcl730_board
),
137 module_comedi_driver(pcl730_driver
);
139 MODULE_AUTHOR("Comedi http://www.comedi.org");
140 MODULE_DESCRIPTION("Comedi low-level driver");
141 MODULE_LICENSE("GPL");