3 * Comedi driver for 8255 based ISA DIO boards
5 * Michal Dobes <dobes@tesnet.cz>
10 * Description: Comedi driver for 8255 based ISA DIO boards
11 * Devices: (Advantech) PCL-724 [pcl724]
12 * (Advantech) PCL-722 [pcl722]
13 * (Advantech) PCL-731 [pcl731]
14 * (ADLink) ACL-7122 [acl7122]
15 * (ADLink) ACL-7124 [acl7124]
16 * (ADLink) PET-48DIO [pet48dio]
17 * Author: Michal Dobes <dobes@tesnet.cz>
20 * Configuration options:
22 * [1] - IRQ (not supported)
23 * [2] - number of DIO (pcl722 and acl7122 boards)
24 * 0, 144: 144 DIO configuration
25 * 1, 96: 96 DIO configuration
28 #include "../comedidev.h"
30 #include <linux/ioport.h>
31 #include <linux/delay.h>
39 unsigned int io_range
;
40 unsigned int can_have96
:1;
41 unsigned int is_pet48
:1;
45 static const struct pcl724_board boardtypes
[] = {
49 .numofports
= 1, /* 24 DIO channels */
54 .numofports
= 6, /* 144 (or 96) DIO channels */
58 .numofports
= 2, /* 48 DIO channels */
63 .numofports
= 6, /* 144 (or 96) DIO channels */
67 .numofports
= 1, /* 24 DIO channels */
72 .numofports
= 2, /* 48 DIO channels */
76 static int pcl724_8255mapped_io(int dir
, int port
, int data
,
79 int movport
= SIZE_8255
* (iobase
>> 12);
84 outb(port
+ movport
, iobase
);
85 outb(data
, iobase
+ 1);
88 outb(port
+ movport
, iobase
);
89 return inb(iobase
+ 1);
93 static int pcl724_attach(struct comedi_device
*dev
,
94 struct comedi_devconfig
*it
)
96 const struct pcl724_board
*board
= comedi_board(dev
);
97 struct comedi_subdevice
*s
;
104 iorange
= board
->io_range
;
105 n_subdevices
= board
->numofports
;
107 /* Handle PCL-724 in 96 DIO configuration */
108 if (board
->can_have96
&&
109 (it
->options
[2] == 1 || it
->options
[2] == 96)) {
114 ret
= comedi_request_region(dev
, it
->options
[0], iorange
);
118 ret
= comedi_alloc_subdevices(dev
, n_subdevices
);
122 for (i
= 0; i
< dev
->n_subdevices
; i
++) {
123 s
= &dev
->subdevices
[i
];
124 if (board
->is_pet48
) {
125 iobase
= dev
->iobase
+ (i
* 0x1000);
126 ret
= subdev_8255_init(dev
, s
, pcl724_8255mapped_io
,
129 iobase
= dev
->iobase
+ (i
* SIZE_8255
);
130 ret
= subdev_8255_init(dev
, s
, NULL
, iobase
);
139 static struct comedi_driver pcl724_driver
= {
140 .driver_name
= "pcl724",
141 .module
= THIS_MODULE
,
142 .attach
= pcl724_attach
,
143 .detach
= comedi_legacy_detach
,
144 .board_name
= &boardtypes
[0].name
,
145 .num_names
= ARRAY_SIZE(boardtypes
),
146 .offset
= sizeof(struct pcl724_board
),
148 module_comedi_driver(pcl724_driver
);
150 MODULE_AUTHOR("Comedi http://www.comedi.org");
151 MODULE_DESCRIPTION("Comedi driver for 8255 based ISA DIO boards");
152 MODULE_LICENSE("GPL");