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