• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * das16.c
3  * DAS16 driver
4  *
5  * COMEDI - Linux Control and Measurement Device Interface
6  * Copyright (C) 2000 David A. Schleef <ds@schleef.org>
7  * Copyright (C) 2000 Chris R. Baugher <baugher@enteract.com>
8  * Copyright (C) 2001,2002 Frank Mori Hess <fmhess@users.sourceforge.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  */
20 
21 /*
22  * Driver: das16
23  * Description: DAS16 compatible boards
24  * Author: Sam Moore, Warren Jasper, ds, Chris Baugher, Frank Hess, Roman Fietze
25  * Devices: [Keithley Metrabyte] DAS-16 (das-16), DAS-16G (das-16g),
26  *   DAS-16F (das-16f), DAS-1201 (das-1201), DAS-1202 (das-1202),
27  *   DAS-1401 (das-1401), DAS-1402 (das-1402), DAS-1601 (das-1601),
28  *   DAS-1602 (das-1602),
29  *   [ComputerBoards] PC104-DAS16/JR (pc104-das16jr),
30  *   PC104-DAS16JR/16 (pc104-das16jr/16), CIO-DAS16 (cio-das16),
31  *   CIO-DAS16F (cio-das16/f), CIO-DAS16/JR (cio-das16/jr),
32  *   CIO-DAS16JR/16 (cio-das16jr/16), CIO-DAS1401/12 (cio-das1401/12),
33  *   CIO-DAS1402/12 (cio-das1402/12), CIO-DAS1402/16 (cio-das1402/16),
34  *   CIO-DAS1601/12 (cio-das1601/12), CIO-DAS1602/12 (cio-das1602/12),
35  *   CIO-DAS1602/16 (cio-das1602/16), CIO-DAS16/330 (cio-das16/330)
36  * Status: works
37  * Updated: 2003-10-12
38  *
39  * A rewrite of the das16 and das1600 drivers.
40  *
41  * Options:
42  *	[0] - base io address
43  *	[1] - irq (does nothing, irq is not used anymore)
44  *	[2] - dma channel (optional, required for comedi_command support)
45  *	[3] - master clock speed in MHz (optional, 1 or 10, ignored if
46  *		board can probe clock, defaults to 1)
47  *	[4] - analog input range lowest voltage in microvolts (optional,
48  *		only useful if your board does not have software
49  *		programmable gain)
50  *	[5] - analog input range highest voltage in microvolts (optional,
51  *		only useful if board does not have software programmable
52  *		gain)
53  *	[6] - analog output range lowest voltage in microvolts (optional)
54  *	[7] - analog output range highest voltage in microvolts (optional)
55  *
56  * Passing a zero for an option is the same as leaving it unspecified.
57  */
58 
59 /*
60  * Testing and debugging help provided by Daniel Koch.
61  *
62  * Keithley Manuals:
63  *	2309.PDF (das16)
64  *	4919.PDF (das1400, 1600)
65  *	4922.PDF (das-1400)
66  *	4923.PDF (das1200, 1400, 1600)
67  *
68  * Computer boards manuals also available from their website
69  * www.measurementcomputing.com
70  */
71 
72 #include <linux/module.h>
73 #include <linux/slab.h>
74 #include <linux/interrupt.h>
75 
76 #include "../comedidev.h"
77 
78 #include "comedi_isadma.h"
79 #include "comedi_8254.h"
80 #include "8255.h"
81 
82 #define DAS16_DMA_SIZE 0xff00	/*  size in bytes of allocated dma buffer */
83 
84 /*
85  * Register I/O map
86  */
87 #define DAS16_TRIG_REG			0x00
88 #define DAS16_AI_LSB_REG		0x00
89 #define DAS16_AI_MSB_REG		0x01
90 #define DAS16_MUX_REG			0x02
91 #define DAS16_DIO_REG			0x03
92 #define DAS16_AO_LSB_REG(x)		((x) ? 0x06 : 0x04)
93 #define DAS16_AO_MSB_REG(x)		((x) ? 0x07 : 0x05)
94 #define DAS16_STATUS_REG		0x08
95 #define DAS16_STATUS_BUSY		(1 << 7)
96 #define DAS16_STATUS_UNIPOLAR		(1 << 6)
97 #define DAS16_STATUS_MUXBIT		(1 << 5)
98 #define DAS16_STATUS_INT		(1 << 4)
99 #define DAS16_CTRL_REG			0x09
100 #define DAS16_CTRL_INTE			(1 << 7)
101 #define DAS16_CTRL_IRQ(x)		(((x) & 0x7) << 4)
102 #define DAS16_CTRL_DMAE			(1 << 2)
103 #define DAS16_CTRL_PACING_MASK		(3 << 0)
104 #define DAS16_CTRL_INT_PACER		(3 << 0)
105 #define DAS16_CTRL_EXT_PACER		(2 << 0)
106 #define DAS16_CTRL_SOFT_PACER		(0 << 0)
107 #define DAS16_PACER_REG			0x0a
108 #define DAS16_PACER_BURST_LEN(x)	(((x) & 0xf) << 4)
109 #define DAS16_PACER_CTR0		(1 << 1)
110 #define DAS16_PACER_TRIG0		(1 << 0)
111 #define DAS16_GAIN_REG			0x0b
112 #define DAS16_TIMER_BASE_REG		0x0c	/* to 0x0f */
113 
114 #define DAS1600_CONV_REG		0x404
115 #define DAS1600_CONV_DISABLE		(1 << 6)
116 #define DAS1600_BURST_REG		0x405
117 #define DAS1600_BURST_VAL		(1 << 6)
118 #define DAS1600_ENABLE_REG		0x406
119 #define DAS1600_ENABLE_VAL		(1 << 6)
120 #define DAS1600_STATUS_REG		0x407
121 #define DAS1600_STATUS_BME		(1 << 6)
122 #define DAS1600_STATUS_ME		(1 << 5)
123 #define DAS1600_STATUS_CD		(1 << 4)
124 #define DAS1600_STATUS_WS		(1 << 1)
125 #define DAS1600_STATUS_CLK_10MHZ	(1 << 0)
126 
127 static const struct comedi_lrange range_das1x01_bip = {
128 	4, {
129 		BIP_RANGE(10),
130 		BIP_RANGE(1),
131 		BIP_RANGE(0.1),
132 		BIP_RANGE(0.01)
133 	}
134 };
135 
136 static const struct comedi_lrange range_das1x01_unip = {
137 	4, {
138 		UNI_RANGE(10),
139 		UNI_RANGE(1),
140 		UNI_RANGE(0.1),
141 		UNI_RANGE(0.01)
142 	}
143 };
144 
145 static const struct comedi_lrange range_das1x02_bip = {
146 	4, {
147 		BIP_RANGE(10),
148 		BIP_RANGE(5),
149 		BIP_RANGE(2.5),
150 		BIP_RANGE(1.25)
151 	}
152 };
153 
154 static const struct comedi_lrange range_das1x02_unip = {
155 	4, {
156 		UNI_RANGE(10),
157 		UNI_RANGE(5),
158 		UNI_RANGE(2.5),
159 		UNI_RANGE(1.25)
160 	}
161 };
162 
163 static const struct comedi_lrange range_das16jr = {
164 	9, {
165 		BIP_RANGE(10),
166 		BIP_RANGE(5),
167 		BIP_RANGE(2.5),
168 		BIP_RANGE(1.25),
169 		BIP_RANGE(0.625),
170 		UNI_RANGE(10),
171 		UNI_RANGE(5),
172 		UNI_RANGE(2.5),
173 		UNI_RANGE(1.25)
174 	}
175 };
176 
177 static const struct comedi_lrange range_das16jr_16 = {
178 	8, {
179 		BIP_RANGE(10),
180 		BIP_RANGE(5),
181 		BIP_RANGE(2.5),
182 		BIP_RANGE(1.25),
183 		UNI_RANGE(10),
184 		UNI_RANGE(5),
185 		UNI_RANGE(2.5),
186 		UNI_RANGE(1.25)
187 	}
188 };
189 
190 static const int das16jr_gainlist[] = { 8, 0, 1, 2, 3, 4, 5, 6, 7 };
191 static const int das16jr_16_gainlist[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
192 static const int das1600_gainlist[] = { 0, 1, 2, 3 };
193 
194 enum {
195 	das16_pg_none = 0,
196 	das16_pg_16jr,
197 	das16_pg_16jr_16,
198 	das16_pg_1601,
199 	das16_pg_1602,
200 };
201 static const int *const das16_gainlists[] = {
202 	NULL,
203 	das16jr_gainlist,
204 	das16jr_16_gainlist,
205 	das1600_gainlist,
206 	das1600_gainlist,
207 };
208 
209 static const struct comedi_lrange *const das16_ai_uni_lranges[] = {
210 	&range_unknown,
211 	&range_das16jr,
212 	&range_das16jr_16,
213 	&range_das1x01_unip,
214 	&range_das1x02_unip,
215 };
216 
217 static const struct comedi_lrange *const das16_ai_bip_lranges[] = {
218 	&range_unknown,
219 	&range_das16jr,
220 	&range_das16jr_16,
221 	&range_das1x01_bip,
222 	&range_das1x02_bip,
223 };
224 
225 struct das16_board {
226 	const char *name;
227 	unsigned int ai_maxdata;
228 	unsigned int ai_speed;	/*  max conversion speed in nanosec */
229 	unsigned int ai_pg;
230 	unsigned int has_ao:1;
231 	unsigned int has_8255:1;
232 
233 	unsigned int i8255_offset;
234 
235 	unsigned int size;
236 	unsigned int id;
237 };
238 
239 static const struct das16_board das16_boards[] = {
240 	{
241 		.name		= "das-16",
242 		.ai_maxdata	= 0x0fff,
243 		.ai_speed	= 15000,
244 		.ai_pg		= das16_pg_none,
245 		.has_ao		= 1,
246 		.has_8255	= 1,
247 		.i8255_offset	= 0x10,
248 		.size		= 0x14,
249 		.id		= 0x00,
250 	}, {
251 		.name		= "das-16g",
252 		.ai_maxdata	= 0x0fff,
253 		.ai_speed	= 15000,
254 		.ai_pg		= das16_pg_none,
255 		.has_ao		= 1,
256 		.has_8255	= 1,
257 		.i8255_offset	= 0x10,
258 		.size		= 0x14,
259 		.id		= 0x00,
260 	}, {
261 		.name		= "das-16f",
262 		.ai_maxdata	= 0x0fff,
263 		.ai_speed	= 8500,
264 		.ai_pg		= das16_pg_none,
265 		.has_ao		= 1,
266 		.has_8255	= 1,
267 		.i8255_offset	= 0x10,
268 		.size		= 0x14,
269 		.id		= 0x00,
270 	}, {
271 		.name		= "cio-das16",
272 		.ai_maxdata	= 0x0fff,
273 		.ai_speed	= 20000,
274 		.ai_pg		= das16_pg_none,
275 		.has_ao		= 1,
276 		.has_8255	= 1,
277 		.i8255_offset	= 0x10,
278 		.size		= 0x14,
279 		.id		= 0x80,
280 	}, {
281 		.name		= "cio-das16/f",
282 		.ai_maxdata	= 0x0fff,
283 		.ai_speed	= 10000,
284 		.ai_pg		= das16_pg_none,
285 		.has_ao		= 1,
286 		.has_8255	= 1,
287 		.i8255_offset	= 0x10,
288 		.size		= 0x14,
289 		.id		= 0x80,
290 	}, {
291 		.name		= "cio-das16/jr",
292 		.ai_maxdata	= 0x0fff,
293 		.ai_speed	= 7692,
294 		.ai_pg		= das16_pg_16jr,
295 		.size		= 0x10,
296 		.id		= 0x00,
297 	}, {
298 		.name		= "pc104-das16jr",
299 		.ai_maxdata	= 0x0fff,
300 		.ai_speed	= 3300,
301 		.ai_pg		= das16_pg_16jr,
302 		.size		= 0x10,
303 		.id		= 0x00,
304 	}, {
305 		.name		= "cio-das16jr/16",
306 		.ai_maxdata	= 0xffff,
307 		.ai_speed	= 10000,
308 		.ai_pg		= das16_pg_16jr_16,
309 		.size		= 0x10,
310 		.id		= 0x00,
311 	}, {
312 		.name		= "pc104-das16jr/16",
313 		.ai_maxdata	= 0xffff,
314 		.ai_speed	= 10000,
315 		.ai_pg		= das16_pg_16jr_16,
316 		.size		= 0x10,
317 		.id		= 0x00,
318 	}, {
319 		.name		= "das-1201",
320 		.ai_maxdata	= 0x0fff,
321 		.ai_speed	= 20000,
322 		.ai_pg		= das16_pg_none,
323 		.has_8255	= 1,
324 		.i8255_offset	= 0x400,
325 		.size		= 0x408,
326 		.id		= 0x20,
327 	}, {
328 		.name		= "das-1202",
329 		.ai_maxdata	= 0x0fff,
330 		.ai_speed	= 10000,
331 		.ai_pg		= das16_pg_none,
332 		.has_8255	= 1,
333 		.i8255_offset	= 0x400,
334 		.size		= 0x408,
335 		.id		= 0x20,
336 	}, {
337 		.name		= "das-1401",
338 		.ai_maxdata	= 0x0fff,
339 		.ai_speed	= 10000,
340 		.ai_pg		= das16_pg_1601,
341 		.size		= 0x408,
342 		.id		= 0xc0,
343 	}, {
344 		.name		= "das-1402",
345 		.ai_maxdata	= 0x0fff,
346 		.ai_speed	= 10000,
347 		.ai_pg		= das16_pg_1602,
348 		.size		= 0x408,
349 		.id		= 0xc0,
350 	}, {
351 		.name		= "das-1601",
352 		.ai_maxdata	= 0x0fff,
353 		.ai_speed	= 10000,
354 		.ai_pg		= das16_pg_1601,
355 		.has_ao		= 1,
356 		.has_8255	= 1,
357 		.i8255_offset	= 0x400,
358 		.size		= 0x408,
359 		.id		= 0xc0,
360 	}, {
361 		.name		= "das-1602",
362 		.ai_maxdata	= 0x0fff,
363 		.ai_speed	= 10000,
364 		.ai_pg		= das16_pg_1602,
365 		.has_ao		= 1,
366 		.has_8255	= 1,
367 		.i8255_offset	= 0x400,
368 		.size		= 0x408,
369 		.id		= 0xc0,
370 	}, {
371 		.name		= "cio-das1401/12",
372 		.ai_maxdata	= 0x0fff,
373 		.ai_speed	= 6250,
374 		.ai_pg		= das16_pg_1601,
375 		.size		= 0x408,
376 		.id		= 0xc0,
377 	}, {
378 		.name		= "cio-das1402/12",
379 		.ai_maxdata	= 0x0fff,
380 		.ai_speed	= 6250,
381 		.ai_pg		= das16_pg_1602,
382 		.size		= 0x408,
383 		.id		= 0xc0,
384 	}, {
385 		.name		= "cio-das1402/16",
386 		.ai_maxdata	= 0xffff,
387 		.ai_speed	= 10000,
388 		.ai_pg		= das16_pg_1602,
389 		.size		= 0x408,
390 		.id		= 0xc0,
391 	}, {
392 		.name		= "cio-das1601/12",
393 		.ai_maxdata	= 0x0fff,
394 		.ai_speed	= 6250,
395 		.ai_pg		= das16_pg_1601,
396 		.has_ao		= 1,
397 		.has_8255	= 1,
398 		.i8255_offset	= 0x400,
399 		.size		= 0x408,
400 		.id		= 0xc0,
401 	}, {
402 		.name		= "cio-das1602/12",
403 		.ai_maxdata	= 0x0fff,
404 		.ai_speed	= 10000,
405 		.ai_pg		= das16_pg_1602,
406 		.has_ao		= 1,
407 		.has_8255	= 1,
408 		.i8255_offset	= 0x400,
409 		.size		= 0x408,
410 		.id		= 0xc0,
411 	}, {
412 		.name		= "cio-das1602/16",
413 		.ai_maxdata	= 0xffff,
414 		.ai_speed	= 10000,
415 		.ai_pg		= das16_pg_1602,
416 		.has_ao		= 1,
417 		.has_8255	= 1,
418 		.i8255_offset	= 0x400,
419 		.size		= 0x408,
420 		.id		= 0xc0,
421 	}, {
422 		.name		= "cio-das16/330",
423 		.ai_maxdata	= 0x0fff,
424 		.ai_speed	= 3030,
425 		.ai_pg		= das16_pg_16jr,
426 		.size		= 0x14,
427 		.id		= 0xf0,
428 	},
429 };
430 
431 /* Period for timer interrupt in jiffies.  It's a function
432  * to deal with possibility of dynamic HZ patches  */
timer_period(void)433 static inline int timer_period(void)
434 {
435 	return HZ / 20;
436 }
437 
438 struct das16_private_struct {
439 	struct comedi_isadma	*dma;
440 	unsigned int		clockbase;
441 	unsigned int		ctrl_reg;
442 	unsigned int		divisor1;
443 	unsigned int		divisor2;
444 	struct timer_list	timer;
445 	unsigned long		extra_iobase;
446 	unsigned int		can_burst:1;
447 	unsigned int		timer_running:1;
448 };
449 
das16_ai_setup_dma(struct comedi_device * dev,struct comedi_subdevice * s,unsigned int unread_samples)450 static void das16_ai_setup_dma(struct comedi_device *dev,
451 			       struct comedi_subdevice *s,
452 			       unsigned int unread_samples)
453 {
454 	struct das16_private_struct *devpriv = dev->private;
455 	struct comedi_isadma *dma = devpriv->dma;
456 	struct comedi_isadma_desc *desc = &dma->desc[dma->cur_dma];
457 	unsigned int max_samples = comedi_bytes_to_samples(s, desc->maxsize);
458 	unsigned int nsamples;
459 
460 	/*
461 	 * Determine dma size based on the buffer size plus the number of
462 	 * unread samples and the number of samples remaining in the command.
463 	 */
464 	nsamples = comedi_nsamples_left(s, max_samples + unread_samples);
465 	if (nsamples > unread_samples) {
466 		nsamples -= unread_samples;
467 		desc->size = comedi_samples_to_bytes(s, nsamples);
468 		comedi_isadma_program(desc);
469 	}
470 }
471 
das16_interrupt(struct comedi_device * dev)472 static void das16_interrupt(struct comedi_device *dev)
473 {
474 	struct das16_private_struct *devpriv = dev->private;
475 	struct comedi_subdevice *s = dev->read_subdev;
476 	struct comedi_async *async = s->async;
477 	struct comedi_cmd *cmd = &async->cmd;
478 	struct comedi_isadma *dma = devpriv->dma;
479 	struct comedi_isadma_desc *desc = &dma->desc[dma->cur_dma];
480 	unsigned long spin_flags;
481 	unsigned int residue;
482 	unsigned int nbytes;
483 	unsigned int nsamples;
484 
485 	spin_lock_irqsave(&dev->spinlock, spin_flags);
486 	if (!(devpriv->ctrl_reg & DAS16_CTRL_DMAE)) {
487 		spin_unlock_irqrestore(&dev->spinlock, spin_flags);
488 		return;
489 	}
490 
491 	/*
492 	 * The pc104-das16jr (at least) has problems if the dma
493 	 * transfer is interrupted in the middle of transferring
494 	 * a 16 bit sample.
495 	 */
496 	residue = comedi_isadma_disable_on_sample(desc->chan,
497 						  comedi_bytes_per_sample(s));
498 
499 	/* figure out how many samples to read */
500 	if (residue > desc->size) {
501 		dev_err(dev->class_dev, "residue > transfer size!\n");
502 		async->events |= COMEDI_CB_ERROR;
503 		nbytes = 0;
504 	} else {
505 		nbytes = desc->size - residue;
506 	}
507 	nsamples = comedi_bytes_to_samples(s, nbytes);
508 
509 	/* restart DMA if more samples are needed */
510 	if (nsamples) {
511 		dma->cur_dma = 1 - dma->cur_dma;
512 		das16_ai_setup_dma(dev, s, nsamples);
513 	}
514 
515 	spin_unlock_irqrestore(&dev->spinlock, spin_flags);
516 
517 	comedi_buf_write_samples(s, desc->virt_addr, nsamples);
518 
519 	if (cmd->stop_src == TRIG_COUNT && async->scans_done >= cmd->stop_arg)
520 		async->events |= COMEDI_CB_EOA;
521 
522 	comedi_handle_events(dev, s);
523 }
524 
das16_timer_interrupt(unsigned long arg)525 static void das16_timer_interrupt(unsigned long arg)
526 {
527 	struct comedi_device *dev = (struct comedi_device *)arg;
528 	struct das16_private_struct *devpriv = dev->private;
529 	unsigned long flags;
530 
531 	das16_interrupt(dev);
532 
533 	spin_lock_irqsave(&dev->spinlock, flags);
534 	if (devpriv->timer_running)
535 		mod_timer(&devpriv->timer, jiffies + timer_period());
536 	spin_unlock_irqrestore(&dev->spinlock, flags);
537 }
538 
das16_ai_set_mux_range(struct comedi_device * dev,unsigned int first_chan,unsigned int last_chan,unsigned int range)539 static void das16_ai_set_mux_range(struct comedi_device *dev,
540 				   unsigned int first_chan,
541 				   unsigned int last_chan,
542 				   unsigned int range)
543 {
544 	const struct das16_board *board = dev->board_ptr;
545 
546 	/* set multiplexer */
547 	outb(first_chan | (last_chan << 4), dev->iobase + DAS16_MUX_REG);
548 
549 	/* some boards do not have programmable gain */
550 	if (board->ai_pg == das16_pg_none)
551 		return;
552 
553 	/*
554 	 * Set gain (this is also burst rate register but according to
555 	 * computer boards manual, burst rate does nothing, even on
556 	 * keithley cards).
557 	 */
558 	outb((das16_gainlists[board->ai_pg])[range],
559 	     dev->iobase + DAS16_GAIN_REG);
560 }
561 
das16_ai_check_chanlist(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_cmd * cmd)562 static int das16_ai_check_chanlist(struct comedi_device *dev,
563 				   struct comedi_subdevice *s,
564 				   struct comedi_cmd *cmd)
565 {
566 	unsigned int chan0 = CR_CHAN(cmd->chanlist[0]);
567 	unsigned int range0 = CR_RANGE(cmd->chanlist[0]);
568 	int i;
569 
570 	for (i = 1; i < cmd->chanlist_len; i++) {
571 		unsigned int chan = CR_CHAN(cmd->chanlist[i]);
572 		unsigned int range = CR_RANGE(cmd->chanlist[i]);
573 
574 		if (chan != ((chan0 + i) % s->n_chan)) {
575 			dev_dbg(dev->class_dev,
576 				"entries in chanlist must be consecutive channels, counting upwards\n");
577 			return -EINVAL;
578 		}
579 
580 		if (range != range0) {
581 			dev_dbg(dev->class_dev,
582 				"entries in chanlist must all have the same gain\n");
583 			return -EINVAL;
584 		}
585 	}
586 
587 	return 0;
588 }
589 
das16_cmd_test(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_cmd * cmd)590 static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
591 			  struct comedi_cmd *cmd)
592 {
593 	const struct das16_board *board = dev->board_ptr;
594 	struct das16_private_struct *devpriv = dev->private;
595 	int err = 0;
596 	unsigned int trig_mask;
597 	unsigned int arg;
598 
599 	/* Step 1 : check if triggers are trivially valid */
600 
601 	err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
602 
603 	trig_mask = TRIG_FOLLOW;
604 	if (devpriv->can_burst)
605 		trig_mask |= TRIG_TIMER | TRIG_EXT;
606 	err |= comedi_check_trigger_src(&cmd->scan_begin_src, trig_mask);
607 
608 	trig_mask = TRIG_TIMER | TRIG_EXT;
609 	if (devpriv->can_burst)
610 		trig_mask |= TRIG_NOW;
611 	err |= comedi_check_trigger_src(&cmd->convert_src, trig_mask);
612 
613 	err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
614 	err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
615 
616 	if (err)
617 		return 1;
618 
619 	/* Step 2a : make sure trigger sources are unique */
620 
621 	err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
622 	err |= comedi_check_trigger_is_unique(cmd->convert_src);
623 	err |= comedi_check_trigger_is_unique(cmd->stop_src);
624 
625 	/* Step 2b : and mutually compatible */
626 
627 	/*  make sure scan_begin_src and convert_src dont conflict */
628 	if (cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_NOW)
629 		err |= -EINVAL;
630 	if (cmd->scan_begin_src != TRIG_FOLLOW && cmd->convert_src != TRIG_NOW)
631 		err |= -EINVAL;
632 
633 	if (err)
634 		return 2;
635 
636 	/* Step 3: check if arguments are trivially valid */
637 
638 	err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
639 
640 	if (cmd->scan_begin_src == TRIG_FOLLOW)	/* internal trigger */
641 		err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, 0);
642 
643 	err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
644 					   cmd->chanlist_len);
645 
646 	/* check against maximum frequency */
647 	if (cmd->scan_begin_src == TRIG_TIMER) {
648 		err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
649 						    board->ai_speed *
650 						    cmd->chanlist_len);
651 	}
652 
653 	if (cmd->convert_src == TRIG_TIMER) {
654 		err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
655 						    board->ai_speed);
656 	}
657 
658 	if (cmd->stop_src == TRIG_COUNT)
659 		err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
660 	else	/* TRIG_NONE */
661 		err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
662 
663 	if (err)
664 		return 3;
665 
666 	/*  step 4: fix up arguments */
667 	if (cmd->scan_begin_src == TRIG_TIMER) {
668 		arg = cmd->scan_begin_arg;
669 		comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
670 		err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
671 	}
672 	if (cmd->convert_src == TRIG_TIMER) {
673 		arg = cmd->convert_arg;
674 		comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
675 		err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
676 	}
677 	if (err)
678 		return 4;
679 
680 	/* Step 5: check channel list if it exists */
681 	if (cmd->chanlist && cmd->chanlist_len > 0)
682 		err |= das16_ai_check_chanlist(dev, s, cmd);
683 
684 	if (err)
685 		return 5;
686 
687 	return 0;
688 }
689 
das16_set_pacer(struct comedi_device * dev,unsigned int ns,unsigned int flags)690 static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
691 				    unsigned int flags)
692 {
693 	comedi_8254_cascade_ns_to_timer(dev->pacer, &ns, flags);
694 	comedi_8254_update_divisors(dev->pacer);
695 	comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
696 
697 	return ns;
698 }
699 
das16_cmd_exec(struct comedi_device * dev,struct comedi_subdevice * s)700 static int das16_cmd_exec(struct comedi_device *dev, struct comedi_subdevice *s)
701 {
702 	struct das16_private_struct *devpriv = dev->private;
703 	struct comedi_isadma *dma = devpriv->dma;
704 	struct comedi_async *async = s->async;
705 	struct comedi_cmd *cmd = &async->cmd;
706 	unsigned int first_chan = CR_CHAN(cmd->chanlist[0]);
707 	unsigned int last_chan = CR_CHAN(cmd->chanlist[cmd->chanlist_len - 1]);
708 	unsigned int range = CR_RANGE(cmd->chanlist[0]);
709 	unsigned int byte;
710 	unsigned long flags;
711 
712 	if (cmd->flags & CMDF_PRIORITY) {
713 		dev_err(dev->class_dev,
714 			"isa dma transfers cannot be performed with CMDF_PRIORITY, aborting\n");
715 		return -1;
716 	}
717 
718 	if (devpriv->can_burst)
719 		outb(DAS1600_CONV_DISABLE, dev->iobase + DAS1600_CONV_REG);
720 
721 	/* set mux and range for chanlist scan */
722 	das16_ai_set_mux_range(dev, first_chan, last_chan, range);
723 
724 	/* set counter mode and counts */
725 	cmd->convert_arg = das16_set_pacer(dev, cmd->convert_arg, cmd->flags);
726 
727 	/* enable counters */
728 	byte = 0;
729 	if (devpriv->can_burst) {
730 		if (cmd->convert_src == TRIG_NOW) {
731 			outb(DAS1600_BURST_VAL,
732 			     dev->iobase + DAS1600_BURST_REG);
733 			/*  set burst length */
734 			byte |= DAS16_PACER_BURST_LEN(cmd->chanlist_len - 1);
735 		} else {
736 			outb(0, dev->iobase + DAS1600_BURST_REG);
737 		}
738 	}
739 	outb(byte, dev->iobase + DAS16_PACER_REG);
740 
741 	/* set up dma transfer */
742 	dma->cur_dma = 0;
743 	das16_ai_setup_dma(dev, s, 0);
744 
745 	/*  set up timer */
746 	spin_lock_irqsave(&dev->spinlock, flags);
747 	devpriv->timer_running = 1;
748 	devpriv->timer.expires = jiffies + timer_period();
749 	add_timer(&devpriv->timer);
750 
751 	/* enable DMA interrupt with external or internal pacing */
752 	devpriv->ctrl_reg &= ~(DAS16_CTRL_INTE | DAS16_CTRL_PACING_MASK);
753 	devpriv->ctrl_reg |= DAS16_CTRL_DMAE;
754 	if (cmd->convert_src == TRIG_EXT)
755 		devpriv->ctrl_reg |= DAS16_CTRL_EXT_PACER;
756 	else
757 		devpriv->ctrl_reg |= DAS16_CTRL_INT_PACER;
758 	outb(devpriv->ctrl_reg, dev->iobase + DAS16_CTRL_REG);
759 
760 	if (devpriv->can_burst)
761 		outb(0, dev->iobase + DAS1600_CONV_REG);
762 	spin_unlock_irqrestore(&dev->spinlock, flags);
763 
764 	return 0;
765 }
766 
das16_cancel(struct comedi_device * dev,struct comedi_subdevice * s)767 static int das16_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
768 {
769 	struct das16_private_struct *devpriv = dev->private;
770 	struct comedi_isadma *dma = devpriv->dma;
771 	unsigned long flags;
772 
773 	spin_lock_irqsave(&dev->spinlock, flags);
774 
775 	/* disable interrupts, dma and pacer clocked conversions */
776 	devpriv->ctrl_reg &= ~(DAS16_CTRL_INTE | DAS16_CTRL_DMAE |
777 			       DAS16_CTRL_PACING_MASK);
778 	outb(devpriv->ctrl_reg, dev->iobase + DAS16_CTRL_REG);
779 
780 	comedi_isadma_disable(dma->chan);
781 
782 	/*  disable SW timer */
783 	if (devpriv->timer_running) {
784 		devpriv->timer_running = 0;
785 		del_timer(&devpriv->timer);
786 	}
787 
788 	if (devpriv->can_burst)
789 		outb(0, dev->iobase + DAS1600_BURST_REG);
790 
791 	spin_unlock_irqrestore(&dev->spinlock, flags);
792 
793 	return 0;
794 }
795 
das16_ai_munge(struct comedi_device * dev,struct comedi_subdevice * s,void * array,unsigned int num_bytes,unsigned int start_chan_index)796 static void das16_ai_munge(struct comedi_device *dev,
797 			   struct comedi_subdevice *s, void *array,
798 			   unsigned int num_bytes,
799 			   unsigned int start_chan_index)
800 {
801 	unsigned short *data = array;
802 	unsigned int num_samples = comedi_bytes_to_samples(s, num_bytes);
803 	unsigned int i;
804 
805 	for (i = 0; i < num_samples; i++) {
806 		data[i] = le16_to_cpu(data[i]);
807 		if (s->maxdata == 0x0fff)
808 			data[i] >>= 4;
809 		data[i] &= s->maxdata;
810 	}
811 }
812 
das16_ai_eoc(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_insn * insn,unsigned long context)813 static int das16_ai_eoc(struct comedi_device *dev,
814 			struct comedi_subdevice *s,
815 			struct comedi_insn *insn,
816 			unsigned long context)
817 {
818 	unsigned int status;
819 
820 	status = inb(dev->iobase + DAS16_STATUS_REG);
821 	if ((status & DAS16_STATUS_BUSY) == 0)
822 		return 0;
823 	return -EBUSY;
824 }
825 
das16_ai_insn_read(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_insn * insn,unsigned int * data)826 static int das16_ai_insn_read(struct comedi_device *dev,
827 			      struct comedi_subdevice *s,
828 			      struct comedi_insn *insn,
829 			      unsigned int *data)
830 {
831 	unsigned int chan = CR_CHAN(insn->chanspec);
832 	unsigned int range = CR_RANGE(insn->chanspec);
833 	unsigned int val;
834 	int ret;
835 	int i;
836 
837 	/* set mux and range for single channel */
838 	das16_ai_set_mux_range(dev, chan, chan, range);
839 
840 	for (i = 0; i < insn->n; i++) {
841 		/* trigger conversion */
842 		outb_p(0, dev->iobase + DAS16_TRIG_REG);
843 
844 		ret = comedi_timeout(dev, s, insn, das16_ai_eoc, 0);
845 		if (ret)
846 			return ret;
847 
848 		val = inb(dev->iobase + DAS16_AI_MSB_REG) << 8;
849 		val |= inb(dev->iobase + DAS16_AI_LSB_REG);
850 		if (s->maxdata == 0x0fff)
851 			val >>= 4;
852 		val &= s->maxdata;
853 
854 		data[i] = val;
855 	}
856 
857 	return insn->n;
858 }
859 
das16_ao_insn_write(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_insn * insn,unsigned int * data)860 static int das16_ao_insn_write(struct comedi_device *dev,
861 			       struct comedi_subdevice *s,
862 			       struct comedi_insn *insn,
863 			       unsigned int *data)
864 {
865 	unsigned int chan = CR_CHAN(insn->chanspec);
866 	int i;
867 
868 	for (i = 0; i < insn->n; i++) {
869 		unsigned int val = data[i];
870 
871 		s->readback[chan] = val;
872 
873 		val <<= 4;
874 
875 		outb(val & 0xff, dev->iobase + DAS16_AO_LSB_REG(chan));
876 		outb((val >> 8) & 0xff, dev->iobase + DAS16_AO_MSB_REG(chan));
877 	}
878 
879 	return insn->n;
880 }
881 
das16_di_insn_bits(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_insn * insn,unsigned int * data)882 static int das16_di_insn_bits(struct comedi_device *dev,
883 			      struct comedi_subdevice *s,
884 			      struct comedi_insn *insn,
885 			      unsigned int *data)
886 {
887 	data[1] = inb(dev->iobase + DAS16_DIO_REG) & 0xf;
888 
889 	return insn->n;
890 }
891 
das16_do_insn_bits(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_insn * insn,unsigned int * data)892 static int das16_do_insn_bits(struct comedi_device *dev,
893 			      struct comedi_subdevice *s,
894 			      struct comedi_insn *insn,
895 			      unsigned int *data)
896 {
897 	if (comedi_dio_update_state(s, data))
898 		outb(s->state, dev->iobase + DAS16_DIO_REG);
899 
900 	data[1] = s->state;
901 
902 	return insn->n;
903 }
904 
das16_probe(struct comedi_device * dev,struct comedi_devconfig * it)905 static int das16_probe(struct comedi_device *dev, struct comedi_devconfig *it)
906 {
907 	const struct das16_board *board = dev->board_ptr;
908 	int diobits;
909 
910 	/* diobits indicates boards */
911 	diobits = inb(dev->iobase + DAS16_DIO_REG) & 0xf0;
912 	if (board->id != diobits) {
913 		dev_err(dev->class_dev,
914 			"requested board's id bits are incorrect (0x%x != 0x%x)\n",
915 			board->id, diobits);
916 		return -EINVAL;
917 	}
918 
919 	return 0;
920 }
921 
das16_reset(struct comedi_device * dev)922 static void das16_reset(struct comedi_device *dev)
923 {
924 	outb(0, dev->iobase + DAS16_STATUS_REG);
925 	outb(0, dev->iobase + DAS16_CTRL_REG);
926 	outb(0, dev->iobase + DAS16_PACER_REG);
927 }
928 
das16_alloc_dma(struct comedi_device * dev,unsigned int dma_chan)929 static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
930 {
931 	struct das16_private_struct *devpriv = dev->private;
932 
933 	/* only DMA channels 3 and 1 are valid */
934 	if (!(dma_chan == 1 || dma_chan == 3))
935 		return;
936 
937 	/* DMA uses two buffers */
938 	devpriv->dma = comedi_isadma_alloc(dev, 2, dma_chan, dma_chan,
939 					   DAS16_DMA_SIZE, COMEDI_ISADMA_READ);
940 	if (devpriv->dma) {
941 		setup_timer(&devpriv->timer, das16_timer_interrupt,
942 			    (unsigned long)dev);
943 	}
944 }
945 
das16_free_dma(struct comedi_device * dev)946 static void das16_free_dma(struct comedi_device *dev)
947 {
948 	struct das16_private_struct *devpriv = dev->private;
949 
950 	if (devpriv) {
951 		if (devpriv->timer.data)
952 			del_timer_sync(&devpriv->timer);
953 		comedi_isadma_free(devpriv->dma);
954 	}
955 }
956 
das16_ai_range(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_devconfig * it,unsigned int pg_type,unsigned int status)957 static const struct comedi_lrange *das16_ai_range(struct comedi_device *dev,
958 						  struct comedi_subdevice *s,
959 						  struct comedi_devconfig *it,
960 						  unsigned int pg_type,
961 						  unsigned int status)
962 {
963 	unsigned int min = it->options[4];
964 	unsigned int max = it->options[5];
965 
966 	/* get any user-defined input range */
967 	if (pg_type == das16_pg_none && (min || max)) {
968 		struct comedi_lrange *lrange;
969 		struct comedi_krange *krange;
970 
971 		/* allocate single-range range table */
972 		lrange = comedi_alloc_spriv(s,
973 					    sizeof(*lrange) + sizeof(*krange));
974 		if (!lrange)
975 			return &range_unknown;
976 
977 		/* initialize ai range */
978 		lrange->length = 1;
979 		krange = lrange->range;
980 		krange->min = min;
981 		krange->max = max;
982 		krange->flags = UNIT_volt;
983 
984 		return lrange;
985 	}
986 
987 	/* use software programmable range */
988 	if (status & DAS16_STATUS_UNIPOLAR)
989 		return das16_ai_uni_lranges[pg_type];
990 	return das16_ai_bip_lranges[pg_type];
991 }
992 
das16_ao_range(struct comedi_device * dev,struct comedi_subdevice * s,struct comedi_devconfig * it)993 static const struct comedi_lrange *das16_ao_range(struct comedi_device *dev,
994 						  struct comedi_subdevice *s,
995 						  struct comedi_devconfig *it)
996 {
997 	unsigned int min = it->options[6];
998 	unsigned int max = it->options[7];
999 
1000 	/* get any user-defined output range */
1001 	if (min || max) {
1002 		struct comedi_lrange *lrange;
1003 		struct comedi_krange *krange;
1004 
1005 		/* allocate single-range range table */
1006 		lrange = comedi_alloc_spriv(s,
1007 					    sizeof(*lrange) + sizeof(*krange));
1008 		if (!lrange)
1009 			return &range_unknown;
1010 
1011 		/* initialize ao range */
1012 		lrange->length = 1;
1013 		krange = lrange->range;
1014 		krange->min = min;
1015 		krange->max = max;
1016 		krange->flags = UNIT_volt;
1017 
1018 		return lrange;
1019 	}
1020 
1021 	return &range_unknown;
1022 }
1023 
das16_attach(struct comedi_device * dev,struct comedi_devconfig * it)1024 static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
1025 {
1026 	const struct das16_board *board = dev->board_ptr;
1027 	struct das16_private_struct *devpriv;
1028 	struct comedi_subdevice *s;
1029 	unsigned int osc_base;
1030 	unsigned int status;
1031 	int ret;
1032 
1033 	/*  check that clock setting is valid */
1034 	if (it->options[3]) {
1035 		if (it->options[3] != 1 && it->options[3] != 10) {
1036 			dev_err(dev->class_dev,
1037 				"Invalid option. Master clock must be set to 1 or 10 (MHz)\n");
1038 			return -EINVAL;
1039 		}
1040 	}
1041 
1042 	devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
1043 	if (!devpriv)
1044 		return -ENOMEM;
1045 
1046 	if (board->size < 0x400) {
1047 		ret = comedi_request_region(dev, it->options[0], board->size);
1048 		if (ret)
1049 			return ret;
1050 	} else {
1051 		ret = comedi_request_region(dev, it->options[0], 0x10);
1052 		if (ret)
1053 			return ret;
1054 		/* Request an additional region for the 8255 */
1055 		ret = __comedi_request_region(dev, dev->iobase + 0x400,
1056 					      board->size & 0x3ff);
1057 		if (ret)
1058 			return ret;
1059 		devpriv->extra_iobase = dev->iobase + 0x400;
1060 		devpriv->can_burst = 1;
1061 	}
1062 
1063 	/*  probe id bits to make sure they are consistent */
1064 	if (das16_probe(dev, it))
1065 		return -EINVAL;
1066 
1067 	/*  get master clock speed */
1068 	osc_base = I8254_OSC_BASE_1MHZ;
1069 	if (devpriv->can_burst) {
1070 		status = inb(dev->iobase + DAS1600_STATUS_REG);
1071 		if (status & DAS1600_STATUS_CLK_10MHZ)
1072 			osc_base = I8254_OSC_BASE_10MHZ;
1073 	} else {
1074 		if (it->options[3])
1075 			osc_base = I8254_OSC_BASE_1MHZ / it->options[3];
1076 	}
1077 
1078 	dev->pacer = comedi_8254_init(dev->iobase + DAS16_TIMER_BASE_REG,
1079 				      osc_base, I8254_IO8, 0);
1080 	if (!dev->pacer)
1081 		return -ENOMEM;
1082 
1083 	das16_alloc_dma(dev, it->options[2]);
1084 
1085 	ret = comedi_alloc_subdevices(dev, 4 + board->has_8255);
1086 	if (ret)
1087 		return ret;
1088 
1089 	status = inb(dev->iobase + DAS16_STATUS_REG);
1090 
1091 	/* Analog Input subdevice */
1092 	s = &dev->subdevices[0];
1093 	s->type		= COMEDI_SUBD_AI;
1094 	s->subdev_flags	= SDF_READABLE;
1095 	if (status & DAS16_STATUS_MUXBIT) {
1096 		s->subdev_flags	|= SDF_GROUND;
1097 		s->n_chan	= 16;
1098 	} else {
1099 		s->subdev_flags	|= SDF_DIFF;
1100 		s->n_chan	= 8;
1101 	}
1102 	s->len_chanlist	= s->n_chan;
1103 	s->maxdata	= board->ai_maxdata;
1104 	s->range_table	= das16_ai_range(dev, s, it, board->ai_pg, status);
1105 	s->insn_read	= das16_ai_insn_read;
1106 	if (devpriv->dma) {
1107 		dev->read_subdev = s;
1108 		s->subdev_flags	|= SDF_CMD_READ;
1109 		s->do_cmdtest	= das16_cmd_test;
1110 		s->do_cmd	= das16_cmd_exec;
1111 		s->cancel	= das16_cancel;
1112 		s->munge	= das16_ai_munge;
1113 	}
1114 
1115 	/* Analog Output subdevice */
1116 	s = &dev->subdevices[1];
1117 	if (board->has_ao) {
1118 		s->type		= COMEDI_SUBD_AO;
1119 		s->subdev_flags	= SDF_WRITABLE;
1120 		s->n_chan	= 2;
1121 		s->maxdata	= 0x0fff;
1122 		s->range_table	= das16_ao_range(dev, s, it);
1123 		s->insn_write	= das16_ao_insn_write;
1124 
1125 		ret = comedi_alloc_subdev_readback(s);
1126 		if (ret)
1127 			return ret;
1128 	} else {
1129 		s->type		= COMEDI_SUBD_UNUSED;
1130 	}
1131 
1132 	/* Digital Input subdevice */
1133 	s = &dev->subdevices[2];
1134 	s->type		= COMEDI_SUBD_DI;
1135 	s->subdev_flags	= SDF_READABLE;
1136 	s->n_chan	= 4;
1137 	s->maxdata	= 1;
1138 	s->range_table	= &range_digital;
1139 	s->insn_bits	= das16_di_insn_bits;
1140 
1141 	/* Digital Output subdevice */
1142 	s = &dev->subdevices[3];
1143 	s->type		= COMEDI_SUBD_DO;
1144 	s->subdev_flags	= SDF_WRITABLE;
1145 	s->n_chan	= 4;
1146 	s->maxdata	= 1;
1147 	s->range_table	= &range_digital;
1148 	s->insn_bits	= das16_do_insn_bits;
1149 
1150 	/* initialize digital output lines */
1151 	outb(s->state, dev->iobase + DAS16_DIO_REG);
1152 
1153 	/* 8255 Digital I/O subdevice */
1154 	if (board->has_8255) {
1155 		s = &dev->subdevices[4];
1156 		ret = subdev_8255_init(dev, s, NULL, board->i8255_offset);
1157 		if (ret)
1158 			return ret;
1159 	}
1160 
1161 	das16_reset(dev);
1162 	/* set the interrupt level */
1163 	devpriv->ctrl_reg = DAS16_CTRL_IRQ(dev->irq);
1164 	outb(devpriv->ctrl_reg, dev->iobase + DAS16_CTRL_REG);
1165 
1166 	if (devpriv->can_burst) {
1167 		outb(DAS1600_ENABLE_VAL, dev->iobase + DAS1600_ENABLE_REG);
1168 		outb(0, dev->iobase + DAS1600_CONV_REG);
1169 		outb(0, dev->iobase + DAS1600_BURST_REG);
1170 	}
1171 
1172 	return 0;
1173 }
1174 
das16_detach(struct comedi_device * dev)1175 static void das16_detach(struct comedi_device *dev)
1176 {
1177 	const struct das16_board *board = dev->board_ptr;
1178 	struct das16_private_struct *devpriv = dev->private;
1179 
1180 	if (devpriv) {
1181 		if (dev->iobase)
1182 			das16_reset(dev);
1183 		das16_free_dma(dev);
1184 
1185 		if (devpriv->extra_iobase)
1186 			release_region(devpriv->extra_iobase,
1187 				       board->size & 0x3ff);
1188 	}
1189 
1190 	comedi_legacy_detach(dev);
1191 }
1192 
1193 static struct comedi_driver das16_driver = {
1194 	.driver_name	= "das16",
1195 	.module		= THIS_MODULE,
1196 	.attach		= das16_attach,
1197 	.detach		= das16_detach,
1198 	.board_name	= &das16_boards[0].name,
1199 	.num_names	= ARRAY_SIZE(das16_boards),
1200 	.offset		= sizeof(das16_boards[0]),
1201 };
1202 module_comedi_driver(das16_driver);
1203 
1204 MODULE_AUTHOR("Comedi http://www.comedi.org");
1205 MODULE_DESCRIPTION("Comedi driver for DAS16 compatible boards");
1206 MODULE_LICENSE("GPL");
1207