ii_pci20kc.c revision 0a85b6f0ab0d2edb0d41b32697111ce0e4f43496
1/*
2 *	comedi/drivers/ii_pci20kc.c
3 *	Driver for Intelligent Instruments PCI-20001C carrier board
4 *	and modules.
5 *
6 *	Copyright (C) 2000 Markus Kempf <kempf@matsci.uni-sb.de>
7 *	with suggestions from David Schleef
8 *			16.06.2000
9 *
10 *	Linux device driver for COMEDI
11 *	Intelligent Instrumentation
12 *	PCI-20001 C-2A Carrier Board
13 *	PCI-20341 M-1A 16-Bit analog input module
14 *				- differential
15 *				- range (-5V - +5V)
16 *				- 16 bit
17 *	PCI-20006 M-2 16-Bit analog output module
18 *				- ranges (-10V - +10V) (0V - +10V) (-5V - +5V)
19 *				- 16 bit
20 *
21 *	only ONE PCI-20341 module possible
22 * 	only ONE PCI-20006 module possible
23 *	no extern trigger implemented
24 *
25 *	NOT WORKING (but soon) only 4 on-board differential channels supported
26 *	NOT WORKING (but soon) only ONE di-port and ONE do-port supported instead of 4 digital ports
27 *	di-port == Port 0
28 *	do-port == Port 1
29 *
30 *	The state of this driver is only a starting point for a complete
31 *	COMEDI-driver. The final driver should support all features of the
32 *	carrier board and modules.
33 *
34 *	The test configuration:
35 *
36 *	kernel 2.2.14 with RTAI v1.2  and patch-2.2.14rthal2
37 *	COMEDI 0.7.45
38 *	COMEDILIB 0.7.9
39 *
40 */
41/*
42Driver: ii_pci20kc
43Description: Intelligent Instruments PCI-20001C carrier board
44Author: Markus Kempf <kempf@matsci.uni-sb.de>
45Devices: [Intelligent Instrumentation] PCI-20001C (ii_pci20kc)
46Status: works
47
48Supports the PCI-20001 C-2a Carrier board, and could probably support
49the other carrier boards with small modifications.  Modules supported
50are:
51	PCI-20006 M-2 16-bit analog output module
52	PCI-20341 M-1A 16-bit analog input module
53
54Options:
55  0   Board base address
56  1   IRQ
57  2   first option for module 1
58  3   second option for module 1
59  4   first option for module 2
60  5   second option for module 2
61  6   first option for module 3
62  7   second option for module 3
63
64options for PCI-20006M:
65  first:   Analog output channel 0 range configuration
66             0  bipolar 10  (-10V -- +10V)
67             1  unipolar 10  (0V -- +10V)
68             2  bipolar 5  (-5V -- 5V)
69  second:  Analog output channel 1 range configuration
70
71options for PCI-20341M:
72  first:   Analog input gain configuration
73             0  1
74             1  10
75             2  100
76             3  200
77*/
78
79/* XXX needs to use ioremap() for compatibility with 2.4 kernels.  Should also
80 * check_mem_region() etc. - fmhess */
81
82#include "../comedidev.h"
83
84#define PCI20000_ID			0x1d
85#define PCI20341_ID    			0x77
86#define PCI20006_ID      		0xe3
87#define PCI20xxx_EMPTY_ID		0xff
88
89#define PCI20000_OFFSET 		0x100
90#define PCI20000_MODULES		3
91
92#define PCI20000_DIO_0			0x80
93#define PCI20000_DIO_1			0x81
94#define PCI20000_DIO_2			0xc0
95#define PCI20000_DIO_3			0xc1
96#define PCI20000_DIO_CONTROL_01		0x83	/* port 0, 1 control */
97#define PCI20000_DIO_CONTROL_23		0xc3	/* port 2, 3 control */
98#define PCI20000_DIO_BUFFER		0x82	/* buffer direction and enable */
99#define PCI20000_DIO_EOC		0xef	/* even port, control output */
100#define PCI20000_DIO_OOC		0xfd	/* odd port, control output */
101#define PCI20000_DIO_EIC		0x90	/* even port, control input */
102#define PCI20000_DIO_OIC		0x82	/* odd port, control input */
103#define DIO_CAND			0x12	/* and bit 1, bit 4 of control */
104#define DIO_BE				0x01	/* buffer: port enable */
105#define DIO_BO				0x04	/* buffer: output */
106#define DIO_BI				0x05	/* buffer: input */
107#define DIO_PS_0			0x00	/* buffer: port shift 0 */
108#define DIO_PS_1			0x01	/* buffer: port shift 1 */
109#define DIO_PS_2			0x04	/* buffer: port shift 2 */
110#define DIO_PS_3			0x05	/* buffer: port shift 3 */
111
112#define PCI20006_LCHAN0			0x0d
113#define PCI20006_STROBE0		0x0b
114#define PCI20006_LCHAN1			0x15
115#define PCI20006_STROBE1		0x13
116
117#define PCI20341_INIT			0x04
118#define PCI20341_REPMODE		0x00	/* single shot mode */
119#define PCI20341_PACER			0x00	/* Hardware Pacer disabled */
120#define PCI20341_CHAN_NR		0x04	/* number of input channels */
121#define PCI20341_CONFIG_REG		0x10
122#define PCI20341_MOD_STATUS		0x01
123#define PCI20341_OPT_REG		0x11
124#define PCI20341_SET_TIME_REG		0x15
125#define PCI20341_LCHAN_ADDR_REG		0x13
126#define PCI20341_CHAN_LIST		0x80
127#define PCI20341_CC_RESET		0x1b
128#define PCI20341_CHAN_RESET		0x19
129#define PCI20341_SOFT_PACER		0x04
130#define PCI20341_STATUS_REG		0x12
131#define PCI20341_LDATA			0x02
132#define PCI20341_DAISY_CHAIN		0x20	/* On-board inputs only */
133#define PCI20341_MUX			0x04	/* Enable on-board MUX */
134#define PCI20341_SCANLIST		0x80	/* Channel/Gain Scan List */
135
136union pci20xxx_subdev_private {
137	void *iobase;
138	struct {
139		void *iobase;
140		const struct comedi_lrange *ao_range_list[2];	/* range of channels of ao module */
141		unsigned int last_data[2];
142	} pci20006;
143	struct {
144		void *iobase;
145		int timebase;
146		int settling_time;
147		int ai_gain;
148	} pci20341;
149};
150
151struct pci20xxx_private {
152
153	void *ioaddr;
154	union pci20xxx_subdev_private subdev_private[PCI20000_MODULES];
155};
156
157#define devpriv ((struct pci20xxx_private *)dev->private)
158#define CHAN (CR_CHAN(it->chanlist[0]))
159
160static int pci20xxx_attach(struct comedi_device *dev,
161			   struct comedi_devconfig *it);
162static int pci20xxx_detach(struct comedi_device *dev);
163
164static struct comedi_driver driver_pci20xxx = {
165	.driver_name = "ii_pci20kc",
166	.module = THIS_MODULE,
167	.attach = pci20xxx_attach,
168	.detach = pci20xxx_detach,
169};
170
171static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
172			 int opt0, int opt1);
173static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
174			 int opt0, int opt1);
175static int pci20xxx_dio_init(struct comedi_device *dev,
176			     struct comedi_subdevice *s);
177
178/*
179  options[0]	Board base address
180  options[1]	IRQ
181  options[2]	first option for module 1
182  options[3]	second option for module 1
183  options[4]	first option for module 2
184  options[5]	second option for module 2
185  options[6]	first option for module 3
186  options[7]	second option for module 3
187
188  options for PCI-20341M:
189  first		Analog input gain configuration
190		0 == 1
191		1 == 10
192		2 == 100
193		3 == 200
194
195  options for PCI-20006M:
196  first		Analog output channel 0 range configuration
197		0 == bipolar 10  (-10V -- +10V)
198		1 == unipolar 10V  (0V -- +10V)
199		2 == bipolar 5V  (-5V -- +5V)
200  second	Analog output channel 1 range configuration
201		0 == bipolar 10  (-10V -- +10V)
202		1 == unipolar 10V  (0V -- +10V)
203		2 == bipolar 5V  (-5V -- +5V)
204*/
205static int pci20xxx_attach(struct comedi_device *dev,
206			   struct comedi_devconfig *it)
207{
208	unsigned char i;
209	int ret;
210	int id;
211	struct comedi_subdevice *s;
212	union pci20xxx_subdev_private *sdp;
213
214	ret = alloc_subdevices(dev, 1 + PCI20000_MODULES);
215	if (ret < 0)
216		return ret;
217
218	ret = alloc_private(dev, sizeof(struct pci20xxx_private));
219	if (ret < 0)
220		return ret;
221
222	devpriv->ioaddr = (void *)(unsigned long)it->options[0];
223	dev->board_name = "pci20kc";
224
225	/* Check PCI-20001 C-2A Carrier Board ID */
226	if ((readb(devpriv->ioaddr) & PCI20000_ID) != PCI20000_ID) {
227		printk("comedi%d: ii_pci20kc", dev->minor);
228		printk
229		    (" PCI-20001 C-2A Carrier Board at base=0x%p not found !\n",
230		     devpriv->ioaddr);
231		return -EINVAL;
232	}
233	printk("comedi%d:\n", dev->minor);
234	printk("ii_pci20kc: PCI-20001 C-2A at base=0x%p\n", devpriv->ioaddr);
235
236	for (i = 0; i < PCI20000_MODULES; i++) {
237		s = dev->subdevices + i;
238		id = readb(devpriv->ioaddr + (i + 1) * PCI20000_OFFSET);
239		s->private = devpriv->subdev_private + i;
240		sdp = s->private;
241		switch (id) {
242		case PCI20006_ID:
243			sdp->pci20006.iobase =
244			    devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
245			pci20006_init(dev, s, it->options[2 * i + 2],
246				      it->options[2 * i + 3]);
247			printk("comedi%d: ii_pci20kc", dev->minor);
248			printk(" PCI-20006 module in slot %d \n", i + 1);
249			break;
250		case PCI20341_ID:
251			sdp->pci20341.iobase =
252			    devpriv->ioaddr + (i + 1) * PCI20000_OFFSET;
253			pci20341_init(dev, s, it->options[2 * i + 2],
254				      it->options[2 * i + 3]);
255			printk("comedi%d: ii_pci20kc", dev->minor);
256			printk(" PCI-20341 module in slot %d \n", i + 1);
257			break;
258		default:
259			printk
260			    ("ii_pci20kc: unknown module code 0x%02x in slot %d: module disabled\n",
261			     id, i);
262			/* fall through */
263		case PCI20xxx_EMPTY_ID:
264			s->type = COMEDI_SUBD_UNUSED;
265			break;
266		}
267	}
268
269	/* initialize struct pci20xxx_private */
270	pci20xxx_dio_init(dev, dev->subdevices + PCI20000_MODULES);
271
272	return 1;
273}
274
275static int pci20xxx_detach(struct comedi_device *dev)
276{
277	printk("comedi%d: pci20xxx: remove\n", dev->minor);
278
279	return 0;
280}
281
282/* pci20006m */
283
284static int pci20006_insn_read(struct comedi_device *dev,
285			      struct comedi_subdevice *s,
286			      struct comedi_insn *insn, unsigned int *data);
287static int pci20006_insn_write(struct comedi_device *dev,
288			       struct comedi_subdevice *s,
289			       struct comedi_insn *insn, unsigned int *data);
290
291static const struct comedi_lrange *pci20006_range_list[] = {
292	&range_bipolar10,
293	&range_unipolar10,
294	&range_bipolar5,
295};
296
297static int pci20006_init(struct comedi_device *dev, struct comedi_subdevice *s,
298			 int opt0, int opt1)
299{
300	union pci20xxx_subdev_private *sdp = s->private;
301
302	if (opt0 < 0 || opt0 > 2)
303		opt0 = 0;
304	if (opt1 < 0 || opt1 > 2)
305		opt1 = 0;
306
307	sdp->pci20006.ao_range_list[0] = pci20006_range_list[opt0];
308	sdp->pci20006.ao_range_list[1] = pci20006_range_list[opt1];
309
310	/* ao subdevice */
311	s->type = COMEDI_SUBD_AO;
312	s->subdev_flags = SDF_WRITABLE;
313	s->n_chan = 2;
314	s->len_chanlist = 2;
315	s->insn_read = pci20006_insn_read;
316	s->insn_write = pci20006_insn_write;
317	s->maxdata = 0xffff;
318	s->range_table_list = sdp->pci20006.ao_range_list;
319	return 0;
320}
321
322static int pci20006_insn_read(struct comedi_device *dev,
323			      struct comedi_subdevice *s,
324			      struct comedi_insn *insn, unsigned int *data)
325{
326	union pci20xxx_subdev_private *sdp = s->private;
327
328	data[0] = sdp->pci20006.last_data[CR_CHAN(insn->chanspec)];
329
330	return 1;
331}
332
333static int pci20006_insn_write(struct comedi_device *dev,
334			       struct comedi_subdevice *s,
335			       struct comedi_insn *insn, unsigned int *data)
336{
337	union pci20xxx_subdev_private *sdp = s->private;
338	int hi, lo;
339	unsigned int boarddata;
340
341	sdp->pci20006.last_data[CR_CHAN(insn->chanspec)] = data[0];
342	boarddata = (((unsigned int)data[0] + 0x8000) & 0xffff);	/* comedi-data -> board-data */
343	lo = (boarddata & 0xff);
344	hi = ((boarddata >> 8) & 0xff);
345
346	switch (CR_CHAN(insn->chanspec)) {
347	case 0:
348		writeb(lo, sdp->iobase + PCI20006_LCHAN0);
349		writeb(hi, sdp->iobase + PCI20006_LCHAN0 + 1);
350		writeb(0x00, sdp->iobase + PCI20006_STROBE0);
351		break;
352	case 1:
353		writeb(lo, sdp->iobase + PCI20006_LCHAN1);
354		writeb(hi, sdp->iobase + PCI20006_LCHAN1 + 1);
355		writeb(0x00, sdp->iobase + PCI20006_STROBE1);
356		break;
357	default:
358		printk(" comedi%d: pci20xxx: ao channel Error!\n", dev->minor);
359		return -EINVAL;
360	}
361
362	return 1;
363}
364
365/* PCI20341M */
366
367static int pci20341_insn_read(struct comedi_device *dev,
368			      struct comedi_subdevice *s,
369			      struct comedi_insn *insn, unsigned int *data);
370
371static const int pci20341_timebase[] = { 0x00, 0x00, 0x00, 0x04 };
372static const int pci20341_settling_time[] = { 0x58, 0x58, 0x93, 0x99 };
373
374static const struct comedi_lrange range_bipolar0_5 = { 1, {BIP_RANGE(0.5)} };
375static const struct comedi_lrange range_bipolar0_05 = { 1, {BIP_RANGE(0.05)} };
376static const struct comedi_lrange range_bipolar0_025 =
377    { 1, {BIP_RANGE(0.025)} };
378
379static const struct comedi_lrange *const pci20341_ranges[] = {
380	&range_bipolar5,
381	&range_bipolar0_5,
382	&range_bipolar0_05,
383	&range_bipolar0_025,
384};
385
386static int pci20341_init(struct comedi_device *dev, struct comedi_subdevice *s,
387			 int opt0, int opt1)
388{
389	union pci20xxx_subdev_private *sdp = s->private;
390	int option;
391
392	/* options handling */
393	if (opt0 < 0 || opt0 > 3)
394		opt0 = 0;
395	sdp->pci20341.timebase = pci20341_timebase[opt0];
396	sdp->pci20341.settling_time = pci20341_settling_time[opt0];
397
398	/* ai subdevice */
399	s->type = COMEDI_SUBD_AI;
400	s->subdev_flags = SDF_READABLE;
401	s->n_chan = PCI20341_CHAN_NR;
402	s->len_chanlist = PCI20341_SCANLIST;
403	s->insn_read = pci20341_insn_read;
404	s->maxdata = 0xffff;
405	s->range_table = pci20341_ranges[opt0];
406
407	option = sdp->pci20341.timebase | PCI20341_REPMODE;	/* depends on gain, trigger, repetition mode */
408
409	writeb(PCI20341_INIT, sdp->iobase + PCI20341_CONFIG_REG);	/* initialize Module */
410	writeb(PCI20341_PACER, sdp->iobase + PCI20341_MOD_STATUS);	/* set Pacer */
411	writeb(option, sdp->iobase + PCI20341_OPT_REG);	/* option register */
412	writeb(sdp->pci20341.settling_time, sdp->iobase + PCI20341_SET_TIME_REG);	/* settling time counter */
413	/* trigger not implemented */
414	return 0;
415}
416
417static int pci20341_insn_read(struct comedi_device *dev,
418			      struct comedi_subdevice *s,
419			      struct comedi_insn *insn, unsigned int *data)
420{
421	union pci20xxx_subdev_private *sdp = s->private;
422	unsigned int i = 0, j = 0;
423	int lo, hi;
424	unsigned char eoc;	/* end of conversion */
425	unsigned int clb;	/* channel list byte */
426	unsigned int boarddata;
427
428	writeb(1, sdp->iobase + PCI20341_LCHAN_ADDR_REG);	/* write number of input channels */
429	clb = PCI20341_DAISY_CHAIN | PCI20341_MUX | (sdp->pci20341.ai_gain << 3)
430	    | CR_CHAN(insn->chanspec);
431	writeb(clb, sdp->iobase + PCI20341_CHAN_LIST);
432	writeb(0x00, sdp->iobase + PCI20341_CC_RESET);	/* reset settling time counter and trigger delay counter */
433	writeb(0x00, sdp->iobase + PCI20341_CHAN_RESET);
434
435	/* generate Pacer */
436
437	for (i = 0; i < insn->n; i++) {
438		/* data polling isn't the niciest way to get the data, I know,
439		 * but there are only 6 cycles (mean) and it is easier than
440		 * the whole interrupt stuff
441		 */
442		j = 0;
443		readb(sdp->iobase + PCI20341_SOFT_PACER);	/* generate Pacer */
444		eoc = readb(sdp->iobase + PCI20341_STATUS_REG);
445		while ((eoc < 0x80) && j < 100) {	/* poll Interrupt Flag */
446			j++;
447			eoc = readb(sdp->iobase + PCI20341_STATUS_REG);
448		}
449		if (j >= 100) {
450			printk
451			    ("comedi%d:  pci20xxx: AI interrupt channel %i polling exit !\n",
452			     dev->minor, i);
453			return -EINVAL;
454		}
455		lo = readb(sdp->iobase + PCI20341_LDATA);
456		hi = readb(sdp->iobase + PCI20341_LDATA + 1);
457		boarddata = lo + 0x100 * hi;
458		data[i] = (short)((boarddata + 0x8000) & 0xffff);	/* board-data -> comedi-data */
459	}
460
461	return i;
462}
463
464/* native DIO */
465
466static void pci20xxx_dio_config(struct comedi_device *dev,
467				struct comedi_subdevice *s);
468static int pci20xxx_dio_insn_bits(struct comedi_device *dev,
469				  struct comedi_subdevice *s,
470				  struct comedi_insn *insn, unsigned int *data);
471static int pci20xxx_dio_insn_config(struct comedi_device *dev,
472				    struct comedi_subdevice *s,
473				    struct comedi_insn *insn,
474				    unsigned int *data);
475
476/* initialize struct pci20xxx_private */
477static int pci20xxx_dio_init(struct comedi_device *dev,
478			     struct comedi_subdevice *s)
479{
480
481	s->type = COMEDI_SUBD_DIO;
482	s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
483	s->n_chan = 32;
484	s->insn_bits = pci20xxx_dio_insn_bits;
485	s->insn_config = pci20xxx_dio_insn_config;
486	s->maxdata = 1;
487	s->len_chanlist = 32;
488	s->range_table = &range_digital;
489	s->io_bits = 0;
490
491	/* digital I/O lines default to input on board reset. */
492	pci20xxx_dio_config(dev, s);
493
494	return 0;
495}
496
497static int pci20xxx_dio_insn_config(struct comedi_device *dev,
498				    struct comedi_subdevice *s,
499				    struct comedi_insn *insn,
500				    unsigned int *data)
501{
502	int mask, bits;
503
504	mask = 1 << CR_CHAN(insn->chanspec);
505	if (mask & 0x000000ff) {
506		bits = 0x000000ff;
507	} else if (mask & 0x0000ff00) {
508		bits = 0x0000ff00;
509	} else if (mask & 0x00ff0000) {
510		bits = 0x00ff0000;
511	} else {
512		bits = 0xff000000;
513	}
514	if (data[0]) {
515		s->io_bits |= bits;
516	} else {
517		s->io_bits &= ~bits;
518	}
519	pci20xxx_dio_config(dev, s);
520
521	return 1;
522}
523
524static int pci20xxx_dio_insn_bits(struct comedi_device *dev,
525				  struct comedi_subdevice *s,
526				  struct comedi_insn *insn, unsigned int *data)
527{
528	unsigned int mask = data[0];
529
530	s->state &= ~mask;
531	s->state |= (mask & data[1]);
532
533	mask &= s->io_bits;
534	if (mask & 0x000000ff)
535		writeb((s->state >> 0) & 0xff,
536		       devpriv->ioaddr + PCI20000_DIO_0);
537	if (mask & 0x0000ff00)
538		writeb((s->state >> 8) & 0xff,
539		       devpriv->ioaddr + PCI20000_DIO_1);
540	if (mask & 0x00ff0000)
541		writeb((s->state >> 16) & 0xff,
542		       devpriv->ioaddr + PCI20000_DIO_2);
543	if (mask & 0xff000000)
544		writeb((s->state >> 24) & 0xff,
545		       devpriv->ioaddr + PCI20000_DIO_3);
546
547	data[1] = readb(devpriv->ioaddr + PCI20000_DIO_0);
548	data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
549	data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16;
550	data[1] |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24;
551
552	return 2;
553}
554
555static void pci20xxx_dio_config(struct comedi_device *dev,
556				struct comedi_subdevice *s)
557{
558	unsigned char control_01;
559	unsigned char control_23;
560	unsigned char buffer;
561
562	control_01 = readb(devpriv->ioaddr + PCI20000_DIO_CONTROL_01);
563	control_23 = readb(devpriv->ioaddr + PCI20000_DIO_CONTROL_23);
564	buffer = readb(devpriv->ioaddr + PCI20000_DIO_BUFFER);
565
566	if (s->io_bits & 0x000000ff) {
567		/* output port 0 */
568		control_01 &= PCI20000_DIO_EOC;
569		buffer = (buffer & (~(DIO_BE << DIO_PS_0))) | (DIO_BO <<
570							       DIO_PS_0);
571	} else {
572		/* input port 0 */
573		control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_EIC;
574		buffer = (buffer & (~(DIO_BI << DIO_PS_0)));
575	}
576	if (s->io_bits & 0x0000ff00) {
577		/* output port 1 */
578		control_01 &= PCI20000_DIO_OOC;
579		buffer = (buffer & (~(DIO_BE << DIO_PS_1))) | (DIO_BO <<
580							       DIO_PS_1);
581	} else {
582		/* input port 1 */
583		control_01 = (control_01 & DIO_CAND) | PCI20000_DIO_OIC;
584		buffer = (buffer & (~(DIO_BI << DIO_PS_1)));
585	}
586	if (s->io_bits & 0x00ff0000) {
587		/* output port 2 */
588		control_23 &= PCI20000_DIO_EOC;
589		buffer = (buffer & (~(DIO_BE << DIO_PS_2))) | (DIO_BO <<
590							       DIO_PS_2);
591	} else {
592		/* input port 2 */
593		control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_EIC;
594		buffer = (buffer & (~(DIO_BI << DIO_PS_2)));
595	}
596	if (s->io_bits & 0xff000000) {
597		/* output port 3 */
598		control_23 &= PCI20000_DIO_OOC;
599		buffer = (buffer & (~(DIO_BE << DIO_PS_3))) | (DIO_BO <<
600							       DIO_PS_3);
601	} else {
602		/* input port 3 */
603		control_23 = (control_23 & DIO_CAND) | PCI20000_DIO_OIC;
604		buffer = (buffer & (~(DIO_BI << DIO_PS_3)));
605	}
606	writeb(control_01, devpriv->ioaddr + PCI20000_DIO_CONTROL_01);
607	writeb(control_23, devpriv->ioaddr + PCI20000_DIO_CONTROL_23);
608	writeb(buffer, devpriv->ioaddr + PCI20000_DIO_BUFFER);
609}
610
611#if 0
612static void pci20xxx_do(struct comedi_device *dev, struct comedi_subdevice *s)
613{
614	/* XXX if the channel is configured for input, does this
615	   do bad things? */
616	/* XXX it would be a good idea to only update the registers
617	   that _need_ to be updated.  This requires changes to
618	   comedi, however. */
619	writeb((s->state >> 0) & 0xff, devpriv->ioaddr + PCI20000_DIO_0);
620	writeb((s->state >> 8) & 0xff, devpriv->ioaddr + PCI20000_DIO_1);
621	writeb((s->state >> 16) & 0xff, devpriv->ioaddr + PCI20000_DIO_2);
622	writeb((s->state >> 24) & 0xff, devpriv->ioaddr + PCI20000_DIO_3);
623}
624
625static unsigned int pci20xxx_di(struct comedi_device *dev,
626				struct comedi_subdevice *s)
627{
628	/* XXX same note as above */
629	unsigned int bits;
630
631	bits = readb(devpriv->ioaddr + PCI20000_DIO_0);
632	bits |= readb(devpriv->ioaddr + PCI20000_DIO_1) << 8;
633	bits |= readb(devpriv->ioaddr + PCI20000_DIO_2) << 16;
634	bits |= readb(devpriv->ioaddr + PCI20000_DIO_3) << 24;
635
636	return bits;
637}
638#endif
639
640COMEDI_INITCLEANUP(driver_pci20xxx);
641