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 * Author: Michal Dobes <dobes@tesnet.cz>
21 * Configuration options:
23 * [1] - IRQ (not supported)
24 * [2] - number of DIO (pcl722 and acl7122 boards)
25 * 0, 144: 144 DIO configuration
26 * 1, 96: 96 DIO configuration
29 #include <linux/module.h>
30 #include "../comedidev.h"
38 unsigned int io_range;
39 unsigned int can_have96:1;
40 unsigned int is_pet48:1;
44 static const struct pcl724_board boardtypes[] = {
48 .numofports = 1, /* 24 DIO channels */
53 .numofports = 6, /* 144 (or 96) DIO channels */
57 .numofports = 2, /* 48 DIO channels */
62 .numofports = 6, /* 144 (or 96) DIO channels */
66 .numofports = 1, /* 24 DIO channels */
71 .numofports = 2, /* 48 DIO channels */
75 .numofports = 2, /* 48 DIO channels */
79 static int pcl724_8255mapped_io(int dir, int port, int data,
82 int movport = SIZE_8255 * (iobase >> 12);
87 outb(port + movport, iobase);
88 outb(data, iobase + 1);
91 outb(port + movport, iobase);
92 return inb(iobase + 1);
96 static int pcl724_attach(struct comedi_device *dev,
97 struct comedi_devconfig *it)
99 const struct pcl724_board *board = comedi_board(dev);
100 struct comedi_subdevice *s;
101 unsigned long iobase;
102 unsigned int iorange;
107 iorange = board->io_range;
108 n_subdevices = board->numofports;
110 /* Handle PCL-724 in 96 DIO configuration */
111 if (board->can_have96 &&
112 (it->options[2] == 1 || it->options[2] == 96)) {
117 ret = comedi_request_region(dev, it->options[0], iorange);
121 ret = comedi_alloc_subdevices(dev, n_subdevices);
125 for (i = 0; i < dev->n_subdevices; i++) {
126 s = &dev->subdevices[i];
127 if (board->is_pet48) {
128 iobase = dev->iobase + (i * 0x1000);
129 ret = subdev_8255_init(dev, s, pcl724_8255mapped_io,
132 iobase = dev->iobase + (i * SIZE_8255);
133 ret = subdev_8255_init(dev, s, NULL, iobase);
142 static struct comedi_driver pcl724_driver = {
143 .driver_name = "pcl724",
144 .module = THIS_MODULE,
145 .attach = pcl724_attach,
146 .detach = comedi_legacy_detach,
147 .board_name = &boardtypes[0].name,
148 .num_names = ARRAY_SIZE(boardtypes),
149 .offset = sizeof(struct pcl724_board),
151 module_comedi_driver(pcl724_driver);
153 MODULE_AUTHOR("Comedi http://www.comedi.org");
154 MODULE_DESCRIPTION("Comedi driver for 8255 based ISA and PC/104 DIO boards");
155 MODULE_LICENSE("GPL");