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), PCL-722 (pcl722), PCL-731 (pcl731),
12 * [ADLink] ACL-7122 (acl7122), ACL-7124 (acl7124), PET-48DIO (pet48dio),
13 * [WinSystems] PCM-IO48 (pcmio48),
14 * [Diamond Systems] ONYX-MM-DIO (onyx-mm-dio)
15 * Author: Michal Dobes <dobes@tesnet.cz>
18 * Configuration options:
20 * [1] - IRQ (not supported)
21 * [2] - number of DIO (pcl722 and acl7122 boards)
22 * 0, 144: 144 DIO configuration
23 * 1, 96: 96 DIO configuration
26 #include <linux/module.h>
27 #include "../comedidev.h"
33 unsigned int io_range;
34 unsigned int can_have96:1;
35 unsigned int is_pet48:1;
39 static const struct pcl724_board boardtypes[] = {
43 .numofports = 1, /* 24 DIO channels */
48 .numofports = 6, /* 144 (or 96) DIO channels */
52 .numofports = 2, /* 48 DIO channels */
57 .numofports = 6, /* 144 (or 96) DIO channels */
61 .numofports = 1, /* 24 DIO channels */
66 .numofports = 2, /* 48 DIO channels */
70 .numofports = 2, /* 48 DIO channels */
72 .name = "onyx-mm-dio",
74 .numofports = 2, /* 48 DIO channels */
78 static int pcl724_8255mapped_io(struct comedi_device *dev,
79 int dir, int port, int data,
82 int movport = I8255_SIZE * (iobase >> 12);
86 outb(port + movport, iobase);
88 outb(data, iobase + 1);
91 return inb(iobase + 1);
94 static int pcl724_attach(struct comedi_device *dev,
95 struct comedi_devconfig *it)
97 const struct pcl724_board *board = dev->board_ptr;
98 struct comedi_subdevice *s;
100 unsigned int iorange;
105 iorange = board->io_range;
106 n_subdevices = board->numofports;
108 /* Handle PCL-724 in 96 DIO configuration */
109 if (board->can_have96 &&
110 (it->options[2] == 1 || it->options[2] == 96)) {
115 ret = comedi_request_region(dev, it->options[0], iorange);
119 ret = comedi_alloc_subdevices(dev, n_subdevices);
123 for (i = 0; i < dev->n_subdevices; i++) {
124 s = &dev->subdevices[i];
125 if (board->is_pet48) {
126 iobase = dev->iobase + (i * 0x1000);
127 ret = subdev_8255_init(dev, s, pcl724_8255mapped_io,
130 ret = subdev_8255_init(dev, s, NULL, i * I8255_SIZE);
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 and PC/104 DIO boards");
152 MODULE_LICENSE("GPL");