3 * Comedi driver for 8255 based ISA and PC/104 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 * (WinSystems) PCM-IO48 [pcmio48]
18 * (Diamond Systems) ONYX-MM-DIO [onyx-mm-dio]
19 * Author: Michal Dobes <dobes@tesnet.cz>
22 * Configuration options:
24 * [1] - IRQ (not supported)
25 * [2] - number of DIO (pcl722 and acl7122 boards)
26 * 0, 144: 144 DIO configuration
27 * 1, 96: 96 DIO configuration
30 #include <linux/module.h>
31 #include "../comedidev.h"
37 unsigned int io_range
;
38 unsigned int can_have96
:1;
39 unsigned int is_pet48
:1;
43 static const struct pcl724_board boardtypes
[] = {
47 .numofports
= 1, /* 24 DIO channels */
52 .numofports
= 6, /* 144 (or 96) DIO channels */
56 .numofports
= 2, /* 48 DIO channels */
61 .numofports
= 6, /* 144 (or 96) DIO channels */
65 .numofports
= 1, /* 24 DIO channels */
70 .numofports
= 2, /* 48 DIO channels */
74 .numofports
= 2, /* 48 DIO channels */
76 .name
= "onyx-mm-dio",
78 .numofports
= 2, /* 48 DIO channels */
82 static int pcl724_8255mapped_io(struct comedi_device
*dev
,
83 int dir
, int port
, int data
,
86 int movport
= I8255_SIZE
* (iobase
>> 12);
90 outb(port
+ movport
, iobase
);
92 outb(data
, iobase
+ 1);
95 return inb(iobase
+ 1);
98 static int pcl724_attach(struct comedi_device
*dev
,
99 struct comedi_devconfig
*it
)
101 const struct pcl724_board
*board
= dev
->board_ptr
;
102 struct comedi_subdevice
*s
;
103 unsigned long iobase
;
104 unsigned int iorange
;
109 iorange
= board
->io_range
;
110 n_subdevices
= board
->numofports
;
112 /* Handle PCL-724 in 96 DIO configuration */
113 if (board
->can_have96
&&
114 (it
->options
[2] == 1 || it
->options
[2] == 96)) {
119 ret
= comedi_request_region(dev
, it
->options
[0], iorange
);
123 ret
= comedi_alloc_subdevices(dev
, n_subdevices
);
127 for (i
= 0; i
< dev
->n_subdevices
; i
++) {
128 s
= &dev
->subdevices
[i
];
129 if (board
->is_pet48
) {
130 iobase
= dev
->iobase
+ (i
* 0x1000);
131 ret
= subdev_8255_init(dev
, s
, pcl724_8255mapped_io
,
134 ret
= subdev_8255_init(dev
, s
, NULL
, i
* I8255_SIZE
);
143 static struct comedi_driver pcl724_driver
= {
144 .driver_name
= "pcl724",
145 .module
= THIS_MODULE
,
146 .attach
= pcl724_attach
,
147 .detach
= comedi_legacy_detach
,
148 .board_name
= &boardtypes
[0].name
,
149 .num_names
= ARRAY_SIZE(boardtypes
),
150 .offset
= sizeof(struct pcl724_board
),
152 module_comedi_driver(pcl724_driver
);
154 MODULE_AUTHOR("Comedi http://www.comedi.org");
155 MODULE_DESCRIPTION("Comedi driver for 8255 based ISA and PC/104 DIO boards");
156 MODULE_LICENSE("GPL");