]>
Commit | Line | Data |
---|---|---|
e184e2be | 1 | // SPDX-License-Identifier: GPL-2.0+ |
0882eaa6 | 2 | /* |
66774ce6 IA |
3 | * comedi/drivers/das08.c |
4 | * comedi module for common DAS08 support (used by ISA/PCI/PCMCIA drivers) | |
b4ae23ce | 5 | * |
66774ce6 IA |
6 | * COMEDI - Linux Control and Measurement Device Interface |
7 | * Copyright (C) 2000 David A. Schleef <ds@schleef.org> | |
8 | * Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net> | |
9 | * Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org> | |
b4ae23ce | 10 | */ |
0882eaa6 | 11 | |
ce157f80 | 12 | #include <linux/module.h> |
0882eaa6 | 13 | |
33782dd5 HS |
14 | #include "../comedidev.h" |
15 | ||
0882eaa6 | 16 | #include "8255.h" |
9a16a017 | 17 | #include "comedi_8254.h" |
0882eaa6 DS |
18 | #include "das08.h" |
19 | ||
5826d99a IA |
20 | /* |
21 | * Data format of DAS08_AI_LSB_REG and DAS08_AI_MSB_REG depends on | |
22 | * 'ai_encoding' member of board structure: | |
23 | * | |
24 | * das08_encode12 : DATA[11..4] = MSB[7..0], DATA[3..0] = LSB[7..4]. | |
25 | * das08_pcm_encode12 : DATA[11..8] = MSB[3..0], DATA[7..9] = LSB[7..0]. | |
26 | * das08_encode16 : SIGN = MSB[7], MAGNITUDE[14..8] = MSB[6..0], | |
27 | * MAGNITUDE[7..0] = LSB[7..0]. | |
28 | * SIGN==0 for negative input, SIGN==1 for positive input. | |
29 | * Note: when read a second time after conversion | |
30 | * complete, MSB[7] is an "over-range" bit. | |
31 | */ | |
32 | #define DAS08_AI_LSB_REG 0x00 /* (R) AI least significant bits */ | |
33 | #define DAS08_AI_MSB_REG 0x01 /* (R) AI most significant bits */ | |
c2ba9e96 | 34 | #define DAS08_AI_TRIG_REG 0x01 /* (W) AI software trigger */ |
b00b3f76 | 35 | #define DAS08_STATUS_REG 0x02 /* (R) status */ |
851e5d54 | 36 | #define DAS08_STATUS_AI_BUSY BIT(7) /* AI conversion in progress */ |
23983910 IA |
37 | /* |
38 | * The IRQ status bit is set to 1 by a rising edge on the external interrupt | |
39 | * input (which may be jumpered to the pacer output). It is cleared by | |
40 | * setting the INTE control bit to 0. Not present on "JR" boards. | |
41 | */ | |
42 | #define DAS08_STATUS_IRQ BIT(3) /* latched interrupt input */ | |
4d14ac8a IA |
43 | /* digital inputs (not "JR" boards) */ |
44 | #define DAS08_STATUS_DI(x) (((x) & 0x70) >> 4) | |
c800e513 | 45 | #define DAS08_CONTROL_REG 0x02 /* (W) control */ |
ac81df60 IA |
46 | /* |
47 | * Note: The AI multiplexor channel can also be read from status register using | |
48 | * the same mask. | |
49 | */ | |
50 | #define DAS08_CONTROL_MUX_MASK 0x7 /* multiplexor channel mask */ | |
51 | #define DAS08_CONTROL_MUX(x) ((x) & DAS08_CONTROL_MUX_MASK) /* mux channel */ | |
6a3a22bc | 52 | #define DAS08_CONTROL_INTE BIT(3) /* interrupt enable (not "JR" boards) */ |
11e8457f IA |
53 | #define DAS08_CONTROL_DO_MASK 0xf0 /* digital outputs mask (not "JR") */ |
54 | /* digital outputs (not "JR" boards) */ | |
55 | #define DAS08_CONTROL_DO(x) (((x) << 4) & DAS08_CONTROL_DO_MASK) | |
f1c04fd4 IA |
56 | /* |
57 | * (R/W) programmable AI gain ("PGx" and "AOx" boards): | |
58 | * + bits 3..0 (R/W) show/set the gain for the current AI mux channel | |
59 | * + bits 6..4 (R) show the current AI mux channel | |
60 | * + bit 7 (R) not unused | |
61 | */ | |
62 | #define DAS08_GAIN_REG 0x03 | |
0882eaa6 | 63 | |
c47c0ed2 IA |
64 | #define DAS08JR_DI_REG 0x03 /* (R) digital inputs ("JR" boards) */ |
65 | #define DAS08JR_DO_REG 0x03 /* (W) digital outputs ("JR" boards) */ | |
7b2098f6 IA |
66 | /* (W) analog output l.s.b. registers for 2 channels ("JR" boards) */ |
67 | #define DAS08JR_AO_LSB_REG(x) ((x) ? 0x06 : 0x04) | |
68 | /* (W) analog output m.s.b. registers for 2 channels ("JR" boards) */ | |
69 | #define DAS08JR_AO_MSB_REG(x) ((x) ? 0x07 : 0x05) | |
09ed1b72 IA |
70 | /* |
71 | * (R) update analog outputs ("JR" boards set for simultaneous output) | |
72 | * (same register as digital inputs) | |
73 | */ | |
74 | #define DAS08JR_AO_UPDATE_REG 0x03 | |
0882eaa6 | 75 | |
3c98c1d3 IA |
76 | /* (W) analog output l.s.b. registers for 2 channels ("AOx" boards) */ |
77 | #define DAS08AOX_AO_LSB_REG(x) ((x) ? 0x0a : 0x08) | |
78 | /* (W) analog output m.s.b. registers for 2 channels ("AOx" boards) */ | |
79 | #define DAS08AOX_AO_MSB_REG(x) ((x) ? 0x0b : 0x09) | |
6814b4a3 IA |
80 | /* |
81 | * (R) update analog outputs ("AOx" boards set for simultaneous output) | |
82 | * (any of the analog output registers could be used for this) | |
83 | */ | |
84 | #define DAS08AOX_AO_UPDATE_REG 0x08 | |
0882eaa6 DS |
85 | |
86 | /* gainlist same as _pgx_ below */ | |
87 | ||
a76ccfa8 | 88 | static const struct comedi_lrange das08_pgl_ai_range = { |
be5bf027 HS |
89 | 9, { |
90 | BIP_RANGE(10), | |
91 | BIP_RANGE(5), | |
92 | BIP_RANGE(2.5), | |
93 | BIP_RANGE(1.25), | |
94 | BIP_RANGE(0.625), | |
95 | UNI_RANGE(10), | |
96 | UNI_RANGE(5), | |
97 | UNI_RANGE(2.5), | |
98 | UNI_RANGE(1.25) | |
99 | } | |
0882eaa6 | 100 | }; |
0a85b6f0 | 101 | |
a76ccfa8 | 102 | static const struct comedi_lrange das08_pgh_ai_range = { |
be5bf027 HS |
103 | 12, { |
104 | BIP_RANGE(10), | |
105 | BIP_RANGE(5), | |
106 | BIP_RANGE(1), | |
107 | BIP_RANGE(0.5), | |
108 | BIP_RANGE(0.1), | |
109 | BIP_RANGE(0.05), | |
110 | BIP_RANGE(0.01), | |
111 | BIP_RANGE(0.005), | |
112 | UNI_RANGE(10), | |
113 | UNI_RANGE(1), | |
114 | UNI_RANGE(0.1), | |
115 | UNI_RANGE(0.01) | |
116 | } | |
0882eaa6 | 117 | }; |
0a85b6f0 | 118 | |
a76ccfa8 | 119 | static const struct comedi_lrange das08_pgm_ai_range = { |
be5bf027 HS |
120 | 9, { |
121 | BIP_RANGE(10), | |
122 | BIP_RANGE(5), | |
123 | BIP_RANGE(0.5), | |
124 | BIP_RANGE(0.05), | |
125 | BIP_RANGE(0.01), | |
126 | UNI_RANGE(10), | |
127 | UNI_RANGE(1), | |
128 | UNI_RANGE(0.1), | |
129 | UNI_RANGE(0.01) | |
130 | } | |
646e70c5 | 131 | }; |
0882eaa6 | 132 | |
9ced1de6 | 133 | static const struct comedi_lrange *const das08_ai_lranges[] = { |
fba5963c IA |
134 | [das08_pg_none] = &range_unknown, |
135 | [das08_bipolar5] = &range_bipolar5, | |
a76ccfa8 IA |
136 | [das08_pgh] = &das08_pgh_ai_range, |
137 | [das08_pgl] = &das08_pgl_ai_range, | |
138 | [das08_pgm] = &das08_pgm_ai_range, | |
0882eaa6 DS |
139 | }; |
140 | ||
fcd63ec8 | 141 | static const int das08_pgh_ai_gainlist[] = { |
b4ae23ce GS |
142 | 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 |
143 | }; | |
fcd63ec8 IA |
144 | static const int das08_pgl_ai_gainlist[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 }; |
145 | static const int das08_pgm_ai_gainlist[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 }; | |
0882eaa6 | 146 | |
fcd63ec8 | 147 | static const int *const das08_ai_gainlists[] = { |
fba5963c IA |
148 | [das08_pg_none] = NULL, |
149 | [das08_bipolar5] = NULL, | |
fcd63ec8 IA |
150 | [das08_pgh] = das08_pgh_ai_gainlist, |
151 | [das08_pgl] = das08_pgl_ai_gainlist, | |
152 | [das08_pgm] = das08_pgm_ai_gainlist, | |
0882eaa6 DS |
153 | }; |
154 | ||
c3ce086e HS |
155 | static int das08_ai_eoc(struct comedi_device *dev, |
156 | struct comedi_subdevice *s, | |
157 | struct comedi_insn *insn, | |
158 | unsigned long context) | |
159 | { | |
160 | unsigned int status; | |
161 | ||
b00b3f76 | 162 | status = inb(dev->iobase + DAS08_STATUS_REG); |
851e5d54 | 163 | if ((status & DAS08_STATUS_AI_BUSY) == 0) |
c3ce086e HS |
164 | return 0; |
165 | return -EBUSY; | |
166 | } | |
0882eaa6 | 167 | |
c224a919 IA |
168 | static int das08_ai_insn_read(struct comedi_device *dev, |
169 | struct comedi_subdevice *s, | |
170 | struct comedi_insn *insn, unsigned int *data) | |
0882eaa6 | 171 | { |
cf2f9224 | 172 | const struct das08_board_struct *board = dev->board_ptr; |
282f3528 | 173 | struct das08_private_struct *devpriv = dev->private; |
c3ce086e | 174 | int n; |
0882eaa6 DS |
175 | int chan; |
176 | int range; | |
177 | int lsb, msb; | |
c3ce086e | 178 | int ret; |
0882eaa6 DS |
179 | |
180 | chan = CR_CHAN(insn->chanspec); | |
181 | range = CR_RANGE(insn->chanspec); | |
182 | ||
183 | /* clear crap */ | |
5826d99a IA |
184 | inb(dev->iobase + DAS08_AI_LSB_REG); |
185 | inb(dev->iobase + DAS08_AI_MSB_REG); | |
0882eaa6 DS |
186 | |
187 | /* set multiplexer */ | |
194869db | 188 | /* lock to prevent race with digital output */ |
b4ae23ce | 189 | spin_lock(&dev->spinlock); |
ac81df60 IA |
190 | devpriv->do_mux_bits &= ~DAS08_CONTROL_MUX_MASK; |
191 | devpriv->do_mux_bits |= DAS08_CONTROL_MUX(chan); | |
c800e513 | 192 | outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); |
0882eaa6 DS |
193 | spin_unlock(&dev->spinlock); |
194 | ||
2b56b358 | 195 | if (devpriv->pg_gainlist) { |
0882eaa6 DS |
196 | /* set gain/range */ |
197 | range = CR_RANGE(insn->chanspec); | |
198 | outb(devpriv->pg_gainlist[range], | |
f1c04fd4 | 199 | dev->iobase + DAS08_GAIN_REG); |
0882eaa6 DS |
200 | } |
201 | ||
202 | for (n = 0; n < insn->n; n++) { | |
203 | /* clear over-range bits for 16-bit boards */ | |
cf2f9224 | 204 | if (board->ai_nbits == 16) |
5826d99a | 205 | if (inb(dev->iobase + DAS08_AI_MSB_REG) & 0x80) |
33fba3b7 | 206 | dev_info(dev->class_dev, "over-range\n"); |
0882eaa6 DS |
207 | |
208 | /* trigger conversion */ | |
c2ba9e96 | 209 | outb_p(0, dev->iobase + DAS08_AI_TRIG_REG); |
0882eaa6 | 210 | |
c3ce086e | 211 | ret = comedi_timeout(dev, s, insn, das08_ai_eoc, 0); |
22ca19d9 | 212 | if (ret) |
c3ce086e | 213 | return ret; |
c3ce086e | 214 | |
5826d99a IA |
215 | msb = inb(dev->iobase + DAS08_AI_MSB_REG); |
216 | lsb = inb(dev->iobase + DAS08_AI_LSB_REG); | |
cf2f9224 | 217 | if (board->ai_encoding == das08_encode12) { |
0882eaa6 | 218 | data[n] = (lsb >> 4) | (msb << 4); |
cf2f9224 | 219 | } else if (board->ai_encoding == das08_pcm_encode12) { |
0882eaa6 | 220 | data[n] = (msb << 8) + lsb; |
cf2f9224 | 221 | } else if (board->ai_encoding == das08_encode16) { |
34cce462 IA |
222 | /* |
223 | * "JR" 16-bit boards are sign-magnitude. | |
224 | * | |
225 | * XXX The manual seems to imply that 0 is full-scale | |
226 | * negative and 65535 is full-scale positive, but the | |
227 | * original COMEDI patch to add support for the | |
228 | * DAS08/JR/16 and DAS08/JR/16-AO boards have it | |
229 | * encoded as sign-magnitude. Assume the original | |
230 | * COMEDI code is correct for now. | |
231 | */ | |
232 | unsigned int magnitude = lsb | ((msb & 0x7f) << 8); | |
233 | ||
234 | /* | |
235 | * MSB bit 7 is 0 for negative, 1 for positive voltage. | |
236 | * COMEDI 16-bit bipolar data value for 0V is 0x8000. | |
237 | */ | |
0882eaa6 | 238 | if (msb & 0x80) |
557e3619 | 239 | data[n] = BIT(15) + magnitude; |
0882eaa6 | 240 | else |
557e3619 | 241 | data[n] = BIT(15) - magnitude; |
0882eaa6 | 242 | } else { |
85f3f14e | 243 | dev_err(dev->class_dev, "bug! unknown ai encoding\n"); |
0882eaa6 DS |
244 | return -1; |
245 | } | |
246 | } | |
247 | ||
248 | return n; | |
249 | } | |
250 | ||
9f05914d IA |
251 | static int das08_di_insn_bits(struct comedi_device *dev, |
252 | struct comedi_subdevice *s, | |
253 | struct comedi_insn *insn, unsigned int *data) | |
0882eaa6 DS |
254 | { |
255 | data[0] = 0; | |
4d14ac8a | 256 | data[1] = DAS08_STATUS_DI(inb(dev->iobase + DAS08_STATUS_REG)); |
0882eaa6 | 257 | |
a2714e3e | 258 | return insn->n; |
0882eaa6 DS |
259 | } |
260 | ||
3919c3d5 IA |
261 | static int das08_do_insn_bits(struct comedi_device *dev, |
262 | struct comedi_subdevice *s, | |
263 | struct comedi_insn *insn, unsigned int *data) | |
0882eaa6 | 264 | { |
282f3528 | 265 | struct das08_private_struct *devpriv = dev->private; |
0882eaa6 | 266 | |
4800fee7 HS |
267 | if (comedi_dio_update_state(s, data)) { |
268 | /* prevent race with setting of analog input mux */ | |
269 | spin_lock(&dev->spinlock); | |
11e8457f IA |
270 | devpriv->do_mux_bits &= ~DAS08_CONTROL_DO_MASK; |
271 | devpriv->do_mux_bits |= DAS08_CONTROL_DO(s->state); | |
c800e513 | 272 | outb(devpriv->do_mux_bits, dev->iobase + DAS08_CONTROL_REG); |
4800fee7 HS |
273 | spin_unlock(&dev->spinlock); |
274 | } | |
275 | ||
276 | data[1] = s->state; | |
0882eaa6 | 277 | |
a2714e3e | 278 | return insn->n; |
0882eaa6 DS |
279 | } |
280 | ||
9f05914d IA |
281 | static int das08jr_di_insn_bits(struct comedi_device *dev, |
282 | struct comedi_subdevice *s, | |
283 | struct comedi_insn *insn, unsigned int *data) | |
0882eaa6 DS |
284 | { |
285 | data[0] = 0; | |
c47c0ed2 | 286 | data[1] = inb(dev->iobase + DAS08JR_DI_REG); |
0882eaa6 | 287 | |
a2714e3e | 288 | return insn->n; |
0882eaa6 DS |
289 | } |
290 | ||
3919c3d5 IA |
291 | static int das08jr_do_insn_bits(struct comedi_device *dev, |
292 | struct comedi_subdevice *s, | |
293 | struct comedi_insn *insn, unsigned int *data) | |
0882eaa6 | 294 | { |
ebf33d04 | 295 | if (comedi_dio_update_state(s, data)) |
c47c0ed2 | 296 | outb(s->state, dev->iobase + DAS08JR_DO_REG); |
0882eaa6 | 297 | |
ebf33d04 | 298 | data[1] = s->state; |
0882eaa6 | 299 | |
a2714e3e | 300 | return insn->n; |
0882eaa6 DS |
301 | } |
302 | ||
3b85aa63 IA |
303 | static void das08_ao_set_data(struct comedi_device *dev, |
304 | unsigned int chan, unsigned int data) | |
0882eaa6 | 305 | { |
cf2f9224 | 306 | const struct das08_board_struct *board = dev->board_ptr; |
3b85aa63 IA |
307 | unsigned char lsb; |
308 | unsigned char msb; | |
0882eaa6 | 309 | |
3b85aa63 IA |
310 | lsb = data & 0xff; |
311 | msb = (data >> 8) & 0xff; | |
cf2f9224 | 312 | if (board->is_jr) { |
7b2098f6 IA |
313 | outb(lsb, dev->iobase + DAS08JR_AO_LSB_REG(chan)); |
314 | outb(msb, dev->iobase + DAS08JR_AO_MSB_REG(chan)); | |
0882eaa6 | 315 | /* load DACs */ |
09ed1b72 | 316 | inb(dev->iobase + DAS08JR_AO_UPDATE_REG); |
3b85aa63 | 317 | } else { |
3c98c1d3 IA |
318 | outb(lsb, dev->iobase + DAS08AOX_AO_LSB_REG(chan)); |
319 | outb(msb, dev->iobase + DAS08AOX_AO_MSB_REG(chan)); | |
3b85aa63 | 320 | /* load DACs */ |
6814b4a3 | 321 | inb(dev->iobase + DAS08AOX_AO_UPDATE_REG); |
0882eaa6 | 322 | } |
8432eb35 IA |
323 | } |
324 | ||
862f7736 HS |
325 | static int das08_ao_insn_write(struct comedi_device *dev, |
326 | struct comedi_subdevice *s, | |
327 | struct comedi_insn *insn, | |
328 | unsigned int *data) | |
0882eaa6 | 329 | { |
862f7736 | 330 | unsigned int chan = CR_CHAN(insn->chanspec); |
c2dfc3a5 | 331 | unsigned int val = s->readback[chan]; |
862f7736 | 332 | int i; |
0882eaa6 | 333 | |
c2dfc3a5 HS |
334 | for (i = 0; i < insn->n; i++) { |
335 | val = data[i]; | |
336 | das08_ao_set_data(dev, chan, val); | |
337 | } | |
338 | s->readback[chan] = val; | |
0882eaa6 | 339 | |
862f7736 | 340 | return insn->n; |
0882eaa6 DS |
341 | } |
342 | ||
da91b269 | 343 | int das08_common_attach(struct comedi_device *dev, unsigned long iobase) |
0882eaa6 | 344 | { |
cf2f9224 | 345 | const struct das08_board_struct *board = dev->board_ptr; |
282f3528 | 346 | struct das08_private_struct *devpriv = dev->private; |
34c43922 | 347 | struct comedi_subdevice *s; |
0882eaa6 | 348 | int ret; |
c2dfc3a5 | 349 | int i; |
0882eaa6 | 350 | |
0882eaa6 DS |
351 | dev->iobase = iobase; |
352 | ||
cf2f9224 | 353 | dev->board_name = board->name; |
0882eaa6 | 354 | |
2f0b9d08 | 355 | ret = comedi_alloc_subdevices(dev, 6); |
8b6c5694 | 356 | if (ret) |
0882eaa6 DS |
357 | return ret; |
358 | ||
2add117c | 359 | s = &dev->subdevices[0]; |
0882eaa6 | 360 | /* ai */ |
cf2f9224 | 361 | if (board->ai_nbits) { |
0882eaa6 | 362 | s->type = COMEDI_SUBD_AI; |
194869db IA |
363 | /* |
364 | * XXX some boards actually have differential | |
b4ae23ce GS |
365 | * inputs instead of single ended. |
366 | * The driver does nothing with arefs though, | |
367 | * so it's no big deal. | |
368 | */ | |
0882eaa6 DS |
369 | s->subdev_flags = SDF_READABLE | SDF_GROUND; |
370 | s->n_chan = 8; | |
cf2f9224 HS |
371 | s->maxdata = (1 << board->ai_nbits) - 1; |
372 | s->range_table = das08_ai_lranges[board->ai_pg]; | |
c224a919 | 373 | s->insn_read = das08_ai_insn_read; |
cf2f9224 | 374 | devpriv->pg_gainlist = das08_ai_gainlists[board->ai_pg]; |
0882eaa6 DS |
375 | } else { |
376 | s->type = COMEDI_SUBD_UNUSED; | |
377 | } | |
378 | ||
2add117c | 379 | s = &dev->subdevices[1]; |
0882eaa6 | 380 | /* ao */ |
cf2f9224 | 381 | if (board->ao_nbits) { |
0882eaa6 | 382 | s->type = COMEDI_SUBD_AO; |
0882eaa6 DS |
383 | s->subdev_flags = SDF_WRITABLE; |
384 | s->n_chan = 2; | |
cf2f9224 | 385 | s->maxdata = (1 << board->ao_nbits) - 1; |
0882eaa6 | 386 | s->range_table = &range_bipolar5; |
862f7736 | 387 | s->insn_write = das08_ao_insn_write; |
c2dfc3a5 HS |
388 | |
389 | ret = comedi_alloc_subdev_readback(s); | |
390 | if (ret) | |
391 | return ret; | |
392 | ||
9949595c | 393 | /* initialize all channels to 0V */ |
c2dfc3a5 HS |
394 | for (i = 0; i < s->n_chan; i++) { |
395 | s->readback[i] = s->maxdata / 2; | |
396 | das08_ao_set_data(dev, i, s->readback[i]); | |
397 | } | |
0882eaa6 DS |
398 | } else { |
399 | s->type = COMEDI_SUBD_UNUSED; | |
400 | } | |
401 | ||
2add117c | 402 | s = &dev->subdevices[2]; |
0882eaa6 | 403 | /* di */ |
cf2f9224 | 404 | if (board->di_nchan) { |
0882eaa6 DS |
405 | s->type = COMEDI_SUBD_DI; |
406 | s->subdev_flags = SDF_READABLE; | |
cf2f9224 | 407 | s->n_chan = board->di_nchan; |
0882eaa6 DS |
408 | s->maxdata = 1; |
409 | s->range_table = &range_digital; | |
cf2f9224 | 410 | s->insn_bits = board->is_jr ? das08jr_di_insn_bits : |
9f05914d | 411 | das08_di_insn_bits; |
0882eaa6 DS |
412 | } else { |
413 | s->type = COMEDI_SUBD_UNUSED; | |
414 | } | |
415 | ||
2add117c | 416 | s = &dev->subdevices[3]; |
0882eaa6 | 417 | /* do */ |
cf2f9224 | 418 | if (board->do_nchan) { |
0882eaa6 | 419 | s->type = COMEDI_SUBD_DO; |
453fd2b3 | 420 | s->subdev_flags = SDF_WRITABLE; |
cf2f9224 | 421 | s->n_chan = board->do_nchan; |
0882eaa6 DS |
422 | s->maxdata = 1; |
423 | s->range_table = &range_digital; | |
cf2f9224 | 424 | s->insn_bits = board->is_jr ? das08jr_do_insn_bits : |
3919c3d5 | 425 | das08_do_insn_bits; |
0882eaa6 DS |
426 | } else { |
427 | s->type = COMEDI_SUBD_UNUSED; | |
428 | } | |
429 | ||
2add117c | 430 | s = &dev->subdevices[4]; |
0882eaa6 | 431 | /* 8255 */ |
cf2f9224 HS |
432 | if (board->i8255_offset != 0) { |
433 | ret = subdev_8255_init(dev, s, NULL, board->i8255_offset); | |
e6439a45 HS |
434 | if (ret) |
435 | return ret; | |
0882eaa6 DS |
436 | } else { |
437 | s->type = COMEDI_SUBD_UNUSED; | |
438 | } | |
439 | ||
9a16a017 | 440 | /* Counter subdevice (8254) */ |
2add117c | 441 | s = &dev->subdevices[5]; |
cf2f9224 HS |
442 | if (board->i8254_offset) { |
443 | dev->pacer = comedi_8254_init(dev->iobase + board->i8254_offset, | |
9a16a017 HS |
444 | 0, I8254_IO8, 0); |
445 | if (!dev->pacer) | |
446 | return -ENOMEM; | |
447 | ||
448 | comedi_8254_subdevice_init(s, dev->pacer); | |
0882eaa6 DS |
449 | } else { |
450 | s->type = COMEDI_SUBD_UNUSED; | |
451 | } | |
452 | ||
453 | return 0; | |
454 | } | |
b4ae23ce | 455 | EXPORT_SYMBOL_GPL(das08_common_attach); |
0882eaa6 | 456 | |
1e576a57 IA |
457 | static int __init das08_init(void) |
458 | { | |
459 | return 0; | |
727b286b | 460 | } |
f91f9bea | 461 | module_init(das08_init); |
727b286b | 462 | |
1e576a57 | 463 | static void __exit das08_exit(void) |
727b286b | 464 | { |
727b286b | 465 | } |
1e576a57 | 466 | module_exit(das08_exit); |
0882eaa6 | 467 | |
90f703d3 | 468 | MODULE_AUTHOR("Comedi http://www.comedi.org"); |
57334a30 | 469 | MODULE_DESCRIPTION("Comedi common DAS08 support module"); |
90f703d3 | 470 | MODULE_LICENSE("GPL"); |