Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / comedi / drivers / quatech_daqp_cs.c
CommitLineData
62ed6662
BB
1/*======================================================================
2
3 comedi/drivers/quatech_daqp_cs.c
4
5 Quatech DAQP PCMCIA data capture cards COMEDI client driver
6 Copyright (C) 2000, 2003 Brent Baccala <baccala@freesoft.org>
7 The DAQP interface code in this file is released into the public domain.
8
9 COMEDI - Linux Control and Measurement Device Interface
10 Copyright (C) 1998 David A. Schleef <ds@schleef.org>
11 http://www.comedi.org/
12
13 quatech_daqp_cs.c 1.10
14
15 Documentation for the DAQP PCMCIA cards can be found on Quatech's site:
16
3420f6b4 17 ftp://ftp.quatech.com/Manuals/daqp-208.pdf
62ed6662
BB
18
19 This manual is for both the DAQP-208 and the DAQP-308.
20
21 What works:
22
23 - A/D conversion
24 - 8 channels
25 - 4 gain ranges
26 - ground ref or differential
27 - single-shot and timed both supported
28 - D/A conversion, single-shot
29 - digital I/O
30
31 What doesn't:
32
33 - any kind of triggering - external or D/A channel 1
34 - the card's optional expansion board
35 - the card's timer (for anything other than A/D conversion)
36 - D/A update modes other than immediate (i.e, timed)
37 - fancier timing modes
38 - setting card's FIFO buffer thresholds to anything but default
39
40======================================================================*/
41
42/*
43Driver: quatech_daqp_cs
44Description: Quatech DAQP PCMCIA data capture cards
45Author: Brent Baccala <baccala@freesoft.org>
46Status: works
47Devices: [Quatech] DAQP-208 (daqp), DAQP-308
48*/
49
50#include "../comedidev.h"
3142788b 51#include <linux/semaphore.h>
62ed6662 52
62ed6662
BB
53#include <pcmcia/cs.h>
54#include <pcmcia/cistpl.h>
55#include <pcmcia/cisreg.h>
56#include <pcmcia/ds.h>
57
7ec52ed2
AIB
58#include <linux/completion.h>
59
62ed6662
BB
60/* Maximum number of separate DAQP devices we'll allow */
61#define MAX_DEV 4
62
ab64f663 63struct local_info_t {
62ed6662 64 struct pcmcia_device *link;
62ed6662
BB
65 int stop;
66 int table_index;
67 char board_name[32];
68
69 enum { semaphore, buffer } interrupt_mode;
70
7ec52ed2 71 struct completion eos;
62ed6662 72
71b5f4f1 73 struct comedi_device *dev;
34c43922 74 struct comedi_subdevice *s;
62ed6662 75 int count;
ab64f663 76};
62ed6662
BB
77
78/* A list of "instances" of the device. */
79
ab64f663 80static struct local_info_t *dev_table[MAX_DEV] = { NULL, /* ... */ };
62ed6662
BB
81
82/* The DAQP communicates with the system through a 16 byte I/O window. */
83
84#define DAQP_FIFO_SIZE 4096
85
86#define DAQP_FIFO 0
87#define DAQP_SCANLIST 1
88#define DAQP_CONTROL 2
89#define DAQP_STATUS 2
90#define DAQP_DIGITAL_IO 3
91#define DAQP_PACER_LOW 4
92#define DAQP_PACER_MID 5
93#define DAQP_PACER_HIGH 6
94#define DAQP_COMMAND 7
95#define DAQP_DA 8
96#define DAQP_TIMER 10
97#define DAQP_AUX 15
98
99#define DAQP_SCANLIST_DIFFERENTIAL 0x4000
100#define DAQP_SCANLIST_GAIN(x) ((x)<<12)
101#define DAQP_SCANLIST_CHANNEL(x) ((x)<<8)
102#define DAQP_SCANLIST_START 0x0080
103#define DAQP_SCANLIST_EXT_GAIN(x) ((x)<<4)
104#define DAQP_SCANLIST_EXT_CHANNEL(x) (x)
105
106#define DAQP_CONTROL_PACER_100kHz 0xc0
107#define DAQP_CONTROL_PACER_1MHz 0x80
108#define DAQP_CONTROL_PACER_5MHz 0x40
109#define DAQP_CONTROL_PACER_EXTERNAL 0x00
110#define DAQP_CONTORL_EXPANSION 0x20
111#define DAQP_CONTROL_EOS_INT_ENABLE 0x10
112#define DAQP_CONTROL_FIFO_INT_ENABLE 0x08
113#define DAQP_CONTROL_TRIGGER_ONESHOT 0x00
114#define DAQP_CONTROL_TRIGGER_CONTINUOUS 0x04
115#define DAQP_CONTROL_TRIGGER_INTERNAL 0x00
116#define DAQP_CONTROL_TRIGGER_EXTERNAL 0x02
117#define DAQP_CONTROL_TRIGGER_RISING 0x00
118#define DAQP_CONTROL_TRIGGER_FALLING 0x01
119
120#define DAQP_STATUS_IDLE 0x80
121#define DAQP_STATUS_RUNNING 0x40
122#define DAQP_STATUS_EVENTS 0x38
123#define DAQP_STATUS_DATA_LOST 0x20
124#define DAQP_STATUS_END_OF_SCAN 0x10
125#define DAQP_STATUS_FIFO_THRESHOLD 0x08
126#define DAQP_STATUS_FIFO_FULL 0x04
127#define DAQP_STATUS_FIFO_NEARFULL 0x02
128#define DAQP_STATUS_FIFO_EMPTY 0x01
129
130#define DAQP_COMMAND_ARM 0x80
131#define DAQP_COMMAND_RSTF 0x40
132#define DAQP_COMMAND_RSTQ 0x20
133#define DAQP_COMMAND_STOP 0x10
134#define DAQP_COMMAND_LATCH 0x08
135#define DAQP_COMMAND_100kHz 0x00
136#define DAQP_COMMAND_50kHz 0x02
137#define DAQP_COMMAND_25kHz 0x04
138#define DAQP_COMMAND_FIFO_DATA 0x01
139#define DAQP_COMMAND_FIFO_PROGRAM 0x00
140
141#define DAQP_AUX_TRIGGER_TTL 0x00
142#define DAQP_AUX_TRIGGER_ANALOG 0x80
143#define DAQP_AUX_TRIGGER_PRETRIGGER 0x40
144#define DAQP_AUX_TIMER_INT_ENABLE 0x20
145#define DAQP_AUX_TIMER_RELOAD 0x00
146#define DAQP_AUX_TIMER_PAUSE 0x08
147#define DAQP_AUX_TIMER_GO 0x10
148#define DAQP_AUX_TIMER_GO_EXTERNAL 0x18
149#define DAQP_AUX_TIMER_EXTERNAL_SRC 0x04
150#define DAQP_AUX_TIMER_INTERNAL_SRC 0x00
151#define DAQP_AUX_DA_DIRECT 0x00
152#define DAQP_AUX_DA_OVERFLOW 0x01
153#define DAQP_AUX_DA_EXTERNAL 0x02
154#define DAQP_AUX_DA_PACER 0x03
155
156#define DAQP_AUX_RUNNING 0x80
157#define DAQP_AUX_TRIGGERED 0x40
158#define DAQP_AUX_DA_BUFFER 0x20
159#define DAQP_AUX_TIMER_OVERFLOW 0x10
160#define DAQP_AUX_CONVERSION 0x08
161#define DAQP_AUX_DATA_LOST 0x04
162#define DAQP_AUX_FIFO_NEARFULL 0x02
163#define DAQP_AUX_FIFO_EMPTY 0x01
164
165/* These range structures tell COMEDI how the sample values map to
68c3dbff
BP
166 * voltages. The A/D converter has four .ranges = +/- 10V through
167 * +/- 1.25V, and the D/A converter has only .one = +/- 5V.
62ed6662
BB
168 */
169
9ced1de6 170static const struct comedi_lrange range_daqp_ai = { 4, {
0a85b6f0
MT
171 BIP_RANGE(10),
172 BIP_RANGE(5),
173 BIP_RANGE(2.5),
174 BIP_RANGE(1.25)
175 }
62ed6662
BB
176};
177
9ced1de6 178static const struct comedi_lrange range_daqp_ao = { 1, {BIP_RANGE(5)} };
62ed6662
BB
179
180/*====================================================================*/
181
182/* comedi interface code */
183
da91b269
BP
184static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it);
185static int daqp_detach(struct comedi_device *dev);
139dfbdf 186static struct comedi_driver driver_daqp = {
68c3dbff
BP
187 .driver_name = "quatech_daqp_cs",
188 .module = THIS_MODULE,
189 .attach = daqp_attach,
190 .detach = daqp_detach,
62ed6662
BB
191};
192
193#ifdef DAQP_DEBUG
194
da91b269 195static void daqp_dump(struct comedi_device *dev)
62ed6662 196{
3420f6b4 197 printk(KERN_INFO "DAQP: status %02x; aux status %02x\n",
0a85b6f0 198 inb(dev->iobase + DAQP_STATUS), inb(dev->iobase + DAQP_AUX));
62ed6662
BB
199}
200
201static void hex_dump(char *str, void *ptr, int len)
202{
203 unsigned char *cptr = ptr;
204 int i;
205
206 printk(str);
207
208 for (i = 0; i < len; i++) {
3420f6b4 209 if (i % 16 == 0)
5fc9e4d5 210 printk("\n%p:", cptr);
3420f6b4 211
62ed6662
BB
212 printk(" %02x", *(cptr++));
213 }
214 printk("\n");
215}
216
217#endif
218
219/* Cancel a running acquisition */
220
da91b269 221static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
62ed6662 222{
0a85b6f0 223 struct local_info_t *local = (struct local_info_t *)s->private;
62ed6662 224
3420f6b4 225 if (local->stop)
62ed6662 226 return -EIO;
3420f6b4 227
62ed6662
BB
228
229 outb(DAQP_COMMAND_STOP, dev->iobase + DAQP_COMMAND);
230
231 /* flush any linguring data in FIFO - superfluous here */
232 /* outb(DAQP_COMMAND_RSTF, dev->iobase+DAQP_COMMAND); */
233
234 local->interrupt_mode = semaphore;
235
236 return 0;
237}
238
239/* Interrupt handler
240 *
241 * Operates in one of two modes. If local->interrupt_mode is
7ec52ed2 242 * 'semaphore', just signal the local->eos completion and return
62ed6662
BB
243 * (one-shot mode). Otherwise (continuous mode), read data in from
244 * the card, transfer it to the buffer provided by the higher-level
245 * comedi kernel module, and signal various comedi callback routines,
246 * which run pretty quick.
247 */
e3752a1d 248static enum irqreturn daqp_interrupt(int irq, void *dev_id)
62ed6662 249{
0a85b6f0 250 struct local_info_t *local = (struct local_info_t *)dev_id;
71b5f4f1 251 struct comedi_device *dev;
34c43922 252 struct comedi_subdevice *s;
62ed6662
BB
253 int loop_limit = 10000;
254 int status;
255
256 if (local == NULL) {
257 printk(KERN_WARNING
0a85b6f0 258 "daqp_interrupt(): irq %d for unknown device.\n", irq);
e3752a1d 259 return IRQ_NONE;
62ed6662
BB
260 }
261
262 dev = local->dev;
263 if (dev == NULL) {
264 printk(KERN_WARNING "daqp_interrupt(): NULL comedi_device.\n");
e3752a1d 265 return IRQ_NONE;
62ed6662
BB
266 }
267
268 if (!dev->attached) {
269 printk(KERN_WARNING
0a85b6f0 270 "daqp_interrupt(): struct comedi_device not yet attached.\n");
e3752a1d 271 return IRQ_NONE;
62ed6662
BB
272 }
273
274 s = local->s;
275 if (s == NULL) {
276 printk(KERN_WARNING
0a85b6f0 277 "daqp_interrupt(): NULL comedi_subdevice.\n");
e3752a1d 278 return IRQ_NONE;
62ed6662
BB
279 }
280
0a85b6f0 281 if ((struct local_info_t *)s->private != local) {
62ed6662 282 printk(KERN_WARNING
0a85b6f0 283 "daqp_interrupt(): invalid comedi_subdevice.\n");
e3752a1d 284 return IRQ_NONE;
62ed6662
BB
285 }
286
287 switch (local->interrupt_mode) {
288
289 case semaphore:
290
7ec52ed2 291 complete(&local->eos);
62ed6662
BB
292 break;
293
294 case buffer:
295
296 while (!((status = inb(dev->iobase + DAQP_STATUS))
0a85b6f0 297 & DAQP_STATUS_FIFO_EMPTY)) {
62ed6662 298
790c5541 299 short data;
62ed6662
BB
300
301 if (status & DAQP_STATUS_DATA_LOST) {
302 s->async->events |=
0a85b6f0 303 COMEDI_CB_EOA | COMEDI_CB_OVERFLOW;
62ed6662
BB
304 printk("daqp: data lost\n");
305 daqp_ai_cancel(dev, s);
306 break;
307 }
308
309 data = inb(dev->iobase + DAQP_FIFO);
310 data |= inb(dev->iobase + DAQP_FIFO) << 8;
311 data ^= 0x8000;
312
313 comedi_buf_put(s->async, data);
314
315 /* If there's a limit, decrement it
316 * and stop conversion if zero
317 */
318
319 if (local->count > 0) {
320 local->count--;
321 if (local->count == 0) {
322 daqp_ai_cancel(dev, s);
323 s->async->events |= COMEDI_CB_EOA;
324 break;
325 }
326 }
327
328 if ((loop_limit--) <= 0)
329 break;
330 }
331
332 if (loop_limit <= 0) {
333 printk(KERN_WARNING
0a85b6f0 334 "loop_limit reached in daqp_interrupt()\n");
62ed6662
BB
335 daqp_ai_cancel(dev, s);
336 s->async->events |= COMEDI_CB_EOA | COMEDI_CB_ERROR;
337 }
338
339 s->async->events |= COMEDI_CB_BLOCK;
340
341 comedi_event(dev, s);
342 }
e3752a1d 343 return IRQ_HANDLED;
62ed6662
BB
344}
345
346/* One-shot analog data acquisition routine */
347
0a85b6f0
MT
348static int daqp_ai_insn_read(struct comedi_device *dev,
349 struct comedi_subdevice *s,
350 struct comedi_insn *insn, unsigned int *data)
62ed6662 351{
0a85b6f0 352 struct local_info_t *local = (struct local_info_t *)s->private;
62ed6662
BB
353 int i;
354 int v;
355 int counter = 10000;
356
3420f6b4 357 if (local->stop)
62ed6662 358 return -EIO;
3420f6b4 359
62ed6662
BB
360
361 /* Stop any running conversion */
362 daqp_ai_cancel(dev, s);
363
364 outb(0, dev->iobase + DAQP_AUX);
365
366 /* Reset scan list queue */
367 outb(DAQP_COMMAND_RSTQ, dev->iobase + DAQP_COMMAND);
368
369 /* Program one scan list entry */
370
371 v = DAQP_SCANLIST_CHANNEL(CR_CHAN(insn->chanspec))
0a85b6f0 372 | DAQP_SCANLIST_GAIN(CR_RANGE(insn->chanspec));
62ed6662 373
3420f6b4 374 if (CR_AREF(insn->chanspec) == AREF_DIFF)
62ed6662 375 v |= DAQP_SCANLIST_DIFFERENTIAL;
3420f6b4 376
62ed6662
BB
377
378 v |= DAQP_SCANLIST_START;
379
380 outb(v & 0xff, dev->iobase + DAQP_SCANLIST);
381 outb(v >> 8, dev->iobase + DAQP_SCANLIST);
382
383 /* Reset data FIFO (see page 28 of DAQP User's Manual) */
384
385 outb(DAQP_COMMAND_RSTF, dev->iobase + DAQP_COMMAND);
386
387 /* Set trigger */
388
389 v = DAQP_CONTROL_TRIGGER_ONESHOT | DAQP_CONTROL_TRIGGER_INTERNAL
0a85b6f0 390 | DAQP_CONTROL_PACER_100kHz | DAQP_CONTROL_EOS_INT_ENABLE;
62ed6662
BB
391
392 outb(v, dev->iobase + DAQP_CONTROL);
393
394 /* Reset any pending interrupts (my card has a tendancy to require
395 * require multiple reads on the status register to achieve this)
396 */
397
398 while (--counter
0a85b6f0 399 && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
62ed6662
BB
400 if (!counter) {
401 printk("daqp: couldn't clear interrupts in status register\n");
402 return -1;
403 }
404
7ec52ed2 405 init_completion(&local->eos);
62ed6662
BB
406 local->interrupt_mode = semaphore;
407 local->dev = dev;
408 local->s = s;
409
410 for (i = 0; i < insn->n; i++) {
411
412 /* Start conversion */
413 outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
0a85b6f0 414 dev->iobase + DAQP_COMMAND);
62ed6662 415
7ec52ed2 416 /* Wait for interrupt service routine to unblock completion */
62ed6662 417 /* Maybe could use a timeout here, but it's interruptible */
7ec52ed2 418 if (wait_for_completion_interruptible(&local->eos))
62ed6662
BB
419 return -EINTR;
420
421 data[i] = inb(dev->iobase + DAQP_FIFO);
422 data[i] |= inb(dev->iobase + DAQP_FIFO) << 8;
423 data[i] ^= 0x8000;
424 }
425
426 return insn->n;
427}
428
429/* This function converts ns nanoseconds to a counter value suitable
430 * for programming the device. We always use the DAQP's 5 MHz clock,
431 * which with its 24-bit counter, allows values up to 84 seconds.
432 * Also, the function adjusts ns so that it cooresponds to the actual
433 * time that the device will use.
434 */
435
436static int daqp_ns_to_timer(unsigned int *ns, int round)
437{
438 int timer;
439
440 timer = *ns / 200;
441 *ns = timer * 200;
442
443 return timer;
444}
445
446/* cmdtest tests a particular command to see if it is valid.
447 * Using the cmdtest ioctl, a user can create a valid cmd
448 * and then have it executed by the cmd ioctl.
449 *
450 * cmdtest returns 1,2,3,4 or 0, depending on which tests
451 * the command passes.
452 */
453
0a85b6f0
MT
454static int daqp_ai_cmdtest(struct comedi_device *dev,
455 struct comedi_subdevice *s, struct comedi_cmd *cmd)
62ed6662
BB
456{
457 int err = 0;
458 int tmp;
459
460 /* step 1: make sure trigger sources are trivially valid */
461
462 tmp = cmd->start_src;
463 cmd->start_src &= TRIG_NOW;
464 if (!cmd->start_src || tmp != cmd->start_src)
465 err++;
466
467 tmp = cmd->scan_begin_src;
468 cmd->scan_begin_src &= TRIG_TIMER | TRIG_FOLLOW;
469 if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
470 err++;
471
472 tmp = cmd->convert_src;
473 cmd->convert_src &= TRIG_TIMER | TRIG_NOW;
474 if (!cmd->convert_src || tmp != cmd->convert_src)
475 err++;
476
477 tmp = cmd->scan_end_src;
478 cmd->scan_end_src &= TRIG_COUNT;
479 if (!cmd->scan_end_src || tmp != cmd->scan_end_src)
480 err++;
481
482 tmp = cmd->stop_src;
483 cmd->stop_src &= TRIG_COUNT | TRIG_NONE;
484 if (!cmd->stop_src || tmp != cmd->stop_src)
485 err++;
486
487 if (err)
488 return 1;
489
3420f6b4
GS
490 /*
491 * step 2: make sure trigger sources
492 * are unique and mutually compatible
493 */
62ed6662 494
828684f9 495 /* note that mutual compatibility is not an issue here */
62ed6662 496 if (cmd->scan_begin_src != TRIG_TIMER &&
0a85b6f0 497 cmd->scan_begin_src != TRIG_FOLLOW)
62ed6662
BB
498 err++;
499 if (cmd->convert_src != TRIG_NOW && cmd->convert_src != TRIG_TIMER)
500 err++;
501 if (cmd->scan_begin_src == TRIG_FOLLOW && cmd->convert_src == TRIG_NOW)
502 err++;
503 if (cmd->stop_src != TRIG_COUNT && cmd->stop_src != TRIG_NONE)
504 err++;
505
506 if (err)
507 return 2;
508
509 /* step 3: make sure arguments are trivially compatible */
510
511 if (cmd->start_arg != 0) {
512 cmd->start_arg = 0;
513 err++;
514 }
515#define MAX_SPEED 10000 /* 100 kHz - in nanoseconds */
516
517 if (cmd->scan_begin_src == TRIG_TIMER
0a85b6f0 518 && cmd->scan_begin_arg < MAX_SPEED) {
62ed6662
BB
519 cmd->scan_begin_arg = MAX_SPEED;
520 err++;
521 }
522
523 /* If both scan_begin and convert are both timer values, the only
524 * way that can make sense is if the scan time is the number of
525 * conversions times the convert time
526 */
527
528 if (cmd->scan_begin_src == TRIG_TIMER && cmd->convert_src == TRIG_TIMER
0a85b6f0 529 && cmd->scan_begin_arg != cmd->convert_arg * cmd->scan_end_arg) {
62ed6662
BB
530 err++;
531 }
532
533 if (cmd->convert_src == TRIG_TIMER && cmd->convert_arg < MAX_SPEED) {
534 cmd->convert_arg = MAX_SPEED;
535 err++;
536 }
537
538 if (cmd->scan_end_arg != cmd->chanlist_len) {
539 cmd->scan_end_arg = cmd->chanlist_len;
540 err++;
541 }
542 if (cmd->stop_src == TRIG_COUNT) {
543 if (cmd->stop_arg > 0x00ffffff) {
544 cmd->stop_arg = 0x00ffffff;
545 err++;
546 }
547 } else {
548 /* TRIG_NONE */
549 if (cmd->stop_arg != 0) {
550 cmd->stop_arg = 0;
551 err++;
552 }
553 }
554
555 if (err)
556 return 3;
557
558 /* step 4: fix up any arguments */
559
560 if (cmd->scan_begin_src == TRIG_TIMER) {
561 tmp = cmd->scan_begin_arg;
562 daqp_ns_to_timer(&cmd->scan_begin_arg,
0a85b6f0 563 cmd->flags & TRIG_ROUND_MASK);
62ed6662
BB
564 if (tmp != cmd->scan_begin_arg)
565 err++;
566 }
567
568 if (cmd->convert_src == TRIG_TIMER) {
569 tmp = cmd->convert_arg;
570 daqp_ns_to_timer(&cmd->convert_arg,
0a85b6f0 571 cmd->flags & TRIG_ROUND_MASK);
62ed6662
BB
572 if (tmp != cmd->convert_arg)
573 err++;
574 }
575
576 if (err)
577 return 4;
578
579 return 0;
580}
581
da91b269 582static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
62ed6662 583{
0a85b6f0 584 struct local_info_t *local = (struct local_info_t *)s->private;
ea6d0d4c 585 struct comedi_cmd *cmd = &s->async->cmd;
e3752a1d 586 int counter;
62ed6662
BB
587 int scanlist_start_on_every_entry;
588 int threshold;
589
590 int i;
591 int v;
592
3420f6b4 593 if (local->stop)
62ed6662 594 return -EIO;
3420f6b4 595
62ed6662
BB
596
597 /* Stop any running conversion */
598 daqp_ai_cancel(dev, s);
599
600 outb(0, dev->iobase + DAQP_AUX);
601
602 /* Reset scan list queue */
603 outb(DAQP_COMMAND_RSTQ, dev->iobase + DAQP_COMMAND);
604
605 /* Program pacer clock
606 *
607 * There's two modes we can operate in. If convert_src is
608 * TRIG_TIMER, then convert_arg specifies the time between
609 * each conversion, so we program the pacer clock to that
610 * frequency and set the SCANLIST_START bit on every scanlist
611 * entry. Otherwise, convert_src is TRIG_NOW, which means
612 * we want the fastest possible conversions, scan_begin_src
613 * is TRIG_TIMER, and scan_begin_arg specifies the time between
614 * each scan, so we program the pacer clock to this frequency
615 * and only set the SCANLIST_START bit on the first entry.
616 */
617
618 if (cmd->convert_src == TRIG_TIMER) {
e3752a1d 619 counter = daqp_ns_to_timer(&cmd->convert_arg,
0a85b6f0 620 cmd->flags & TRIG_ROUND_MASK);
62ed6662
BB
621 outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
622 outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
623 outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
624 scanlist_start_on_every_entry = 1;
625 } else {
e3752a1d 626 counter = daqp_ns_to_timer(&cmd->scan_begin_arg,
0a85b6f0 627 cmd->flags & TRIG_ROUND_MASK);
62ed6662
BB
628 outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
629 outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
630 outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
631 scanlist_start_on_every_entry = 0;
632 }
633
634 /* Program scan list */
635
636 for (i = 0; i < cmd->chanlist_len; i++) {
637
638 int chanspec = cmd->chanlist[i];
639
640 /* Program one scan list entry */
641
642 v = DAQP_SCANLIST_CHANNEL(CR_CHAN(chanspec))
0a85b6f0 643 | DAQP_SCANLIST_GAIN(CR_RANGE(chanspec));
62ed6662 644
3420f6b4 645 if (CR_AREF(chanspec) == AREF_DIFF)
62ed6662 646 v |= DAQP_SCANLIST_DIFFERENTIAL;
62ed6662 647
3420f6b4 648 if (i == 0 || scanlist_start_on_every_entry)
62ed6662 649 v |= DAQP_SCANLIST_START;
62ed6662
BB
650
651 outb(v & 0xff, dev->iobase + DAQP_SCANLIST);
652 outb(v >> 8, dev->iobase + DAQP_SCANLIST);
653 }
654
655 /* Now it's time to program the FIFO threshold, basically the
656 * number of samples the card will buffer before it interrupts
657 * the CPU.
658 *
659 * If we don't have a stop count, then use half the size of
660 * the FIFO (the manufacturer's recommendation). Consider
661 * that the FIFO can hold 2K samples (4K bytes). With the
662 * threshold set at half the FIFO size, we have a margin of
663 * error of 1024 samples. At the chip's maximum sample rate
664 * of 100,000 Hz, the CPU would have to delay interrupt
665 * service for a full 10 milliseconds in order to lose data
666 * here (as opposed to higher up in the kernel). I've never
667 * seen it happen. However, for slow sample rates it may
668 * buffer too much data and introduce too much delay for the
669 * user application.
670 *
671 * If we have a stop count, then things get more interesting.
672 * If the stop count is less than the FIFO size (actually
673 * three-quarters of the FIFO size - see below), we just use
674 * the stop count itself as the threshold, the card interrupts
675 * us when that many samples have been taken, and we kill the
676 * acquisition at that point and are done. If the stop count
677 * is larger than that, then we divide it by 2 until it's less
678 * than three quarters of the FIFO size (we always leave the
679 * top quarter of the FIFO as protection against sluggish CPU
680 * interrupt response) and use that as the threshold. So, if
681 * the stop count is 4000 samples, we divide by two twice to
682 * get 1000 samples, use that as the threshold, take four
683 * interrupts to get our 4000 samples and are done.
684 *
685 * The algorithm could be more clever. For example, if 81000
686 * samples are requested, we could set the threshold to 1500
687 * samples and take 54 interrupts to get 81000. But 54 isn't
688 * a power of two, so this algorithm won't find that option.
689 * Instead, it'll set the threshold at 1266 and take 64
690 * interrupts to get 81024 samples, of which the last 24 will
691 * be discarded... but we won't get the last interrupt until
692 * they've been collected. To find the first option, the
693 * computer could look at the prime decomposition of the
694 * sample count (81000 = 3^4 * 5^3 * 2^3) and factor it into a
695 * threshold (1500 = 3 * 5^3 * 2^2) and an interrupt count (54
696 * = 3^3 * 2). Hmmm... a one-line while loop or prime
697 * decomposition of integers... I'll leave it the way it is.
698 *
699 * I'll also note a mini-race condition before ignoring it in
700 * the code. Let's say we're taking 4000 samples, as before.
701 * After 1000 samples, we get an interrupt. But before that
702 * interrupt is completely serviced, another sample is taken
703 * and loaded into the FIFO. Since the interrupt handler
704 * empties the FIFO before returning, it will read 1001 samples.
705 * If that happens four times, we'll end up taking 4004 samples,
706 * not 4000. The interrupt handler will discard the extra four
707 * samples (by halting the acquisition with four samples still
708 * in the FIFO), but we will have to wait for them.
709 *
710 * In short, this code works pretty well, but for either of
711 * the two reasons noted, might end up waiting for a few more
712 * samples than actually requested. Shouldn't make too much
713 * of a difference.
714 */
715
716 /* Save away the number of conversions we should perform, and
717 * compute the FIFO threshold (in bytes, not samples - that's
718 * why we multiple local->count by 2 = sizeof(sample))
719 */
720
721 if (cmd->stop_src == TRIG_COUNT) {
722 local->count = cmd->stop_arg * cmd->scan_end_arg;
723 threshold = 2 * local->count;
724 while (threshold > DAQP_FIFO_SIZE * 3 / 4)
725 threshold /= 2;
726 } else {
727 local->count = -1;
728 threshold = DAQP_FIFO_SIZE / 2;
729 }
730
731 /* Reset data FIFO (see page 28 of DAQP User's Manual) */
732
733 outb(DAQP_COMMAND_RSTF, dev->iobase + DAQP_COMMAND);
734
735 /* Set FIFO threshold. First two bytes are near-empty
736 * threshold, which is unused; next two bytes are near-full
737 * threshold. We computed the number of bytes we want in the
738 * FIFO when the interrupt is generated, what the card wants
739 * is actually the number of available bytes left in the FIFO
740 * when the interrupt is to happen.
741 */
742
743 outb(0x00, dev->iobase + DAQP_FIFO);
744 outb(0x00, dev->iobase + DAQP_FIFO);
745
746 outb((DAQP_FIFO_SIZE - threshold) & 0xff, dev->iobase + DAQP_FIFO);
747 outb((DAQP_FIFO_SIZE - threshold) >> 8, dev->iobase + DAQP_FIFO);
748
749 /* Set trigger */
750
751 v = DAQP_CONTROL_TRIGGER_CONTINUOUS | DAQP_CONTROL_TRIGGER_INTERNAL
0a85b6f0 752 | DAQP_CONTROL_PACER_5MHz | DAQP_CONTROL_FIFO_INT_ENABLE;
62ed6662
BB
753
754 outb(v, dev->iobase + DAQP_CONTROL);
755
756 /* Reset any pending interrupts (my card has a tendancy to require
757 * require multiple reads on the status register to achieve this)
758 */
e3752a1d 759 counter = 100;
62ed6662 760 while (--counter
0a85b6f0 761 && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS)) ;
62ed6662 762 if (!counter) {
3420f6b4
GS
763 printk(KERN_ERR
764 "daqp: couldn't clear interrupts in status register\n");
62ed6662
BB
765 return -1;
766 }
767
768 local->interrupt_mode = buffer;
769 local->dev = dev;
770 local->s = s;
771
772 /* Start conversion */
773 outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
0a85b6f0 774 dev->iobase + DAQP_COMMAND);
62ed6662
BB
775
776 return 0;
777}
778
779/* Single-shot analog output routine */
780
0a85b6f0
MT
781static int daqp_ao_insn_write(struct comedi_device *dev,
782 struct comedi_subdevice *s,
783 struct comedi_insn *insn, unsigned int *data)
62ed6662 784{
0a85b6f0 785 struct local_info_t *local = (struct local_info_t *)s->private;
62ed6662
BB
786 int d;
787 unsigned int chan;
788
3420f6b4 789 if (local->stop)
62ed6662 790 return -EIO;
62ed6662
BB
791
792 chan = CR_CHAN(insn->chanspec);
793 d = data[0];
794 d &= 0x0fff;
795 d ^= 0x0800; /* Flip the sign */
796 d |= chan << 12;
797
798 /* Make sure D/A update mode is direct update */
799 outb(0, dev->iobase + DAQP_AUX);
800
801 outw(d, dev->iobase + DAQP_DA);
802
803 return 1;
804}
805
806/* Digital input routine */
807
0a85b6f0
MT
808static int daqp_di_insn_read(struct comedi_device *dev,
809 struct comedi_subdevice *s,
810 struct comedi_insn *insn, unsigned int *data)
62ed6662 811{
0a85b6f0 812 struct local_info_t *local = (struct local_info_t *)s->private;
62ed6662 813
3420f6b4 814 if (local->stop)
62ed6662 815 return -EIO;
62ed6662
BB
816
817 data[0] = inb(dev->iobase + DAQP_DIGITAL_IO);
818
819 return 1;
820}
821
822/* Digital output routine */
823
0a85b6f0
MT
824static int daqp_do_insn_write(struct comedi_device *dev,
825 struct comedi_subdevice *s,
826 struct comedi_insn *insn, unsigned int *data)
62ed6662 827{
0a85b6f0 828 struct local_info_t *local = (struct local_info_t *)s->private;
62ed6662 829
3420f6b4 830 if (local->stop)
62ed6662 831 return -EIO;
62ed6662
BB
832
833 outw(data[0] & 0xf, dev->iobase + DAQP_DIGITAL_IO);
834
835 return 1;
836}
837
838/* daqp_attach is called via comedi_config to attach a comedi device
839 * to a /dev/comedi*. Note that this is different from daqp_cs_attach()
840 * which is called by the pcmcia subsystem to attach the PCMCIA card
841 * when it is inserted.
842 */
843
da91b269 844static int daqp_attach(struct comedi_device *dev, struct comedi_devconfig *it)
62ed6662
BB
845{
846 int ret;
ab64f663 847 struct local_info_t *local = dev_table[it->options[0]];
34c43922 848 struct comedi_subdevice *s;
62ed6662
BB
849
850 if (it->options[0] < 0 || it->options[0] >= MAX_DEV || !local) {
851 printk("comedi%d: No such daqp device %d\n",
0a85b6f0 852 dev->minor, it->options[0]);
62ed6662
BB
853 return -EIO;
854 }
855
856 /* Typically brittle code that I don't completely understand,
857 * but "it works on my card". The intent is to pull the model
858 * number of the card out the PCMCIA CIS and stash it away as
859 * the COMEDI board_name. Looks like the third field in
860 * CISTPL_VERS_1 (offset 2) holds what we're looking for. If
861 * it doesn't work, who cares, just leave it as "DAQP".
862 */
863
864 strcpy(local->board_name, "DAQP");
865 dev->board_name = local->board_name;
55a19b39
DB
866 if (local->link->prod_id[2]) {
867 if (strncmp(local->link->prod_id[2], "DAQP", 4) == 0) {
868 strncpy(local->board_name, local->link->prod_id[2],
869 sizeof(local->board_name));
62ed6662
BB
870 }
871 }
872
9a017a91 873 dev->iobase = local->link->resource[0]->start;
62ed6662 874
c3744138
BP
875 ret = alloc_subdevices(dev, 4);
876 if (ret < 0)
62ed6662
BB
877 return ret;
878
3420f6b4 879 printk(KERN_INFO "comedi%d: attaching daqp%d (io 0x%04lx)\n",
0a85b6f0 880 dev->minor, it->options[0], dev->iobase);
62ed6662
BB
881
882 s = dev->subdevices + 0;
883 dev->read_subdev = s;
884 s->private = local;
885 s->type = COMEDI_SUBD_AI;
886 s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
887 s->n_chan = 8;
888 s->len_chanlist = 2048;
889 s->maxdata = 0xffff;
890 s->range_table = &range_daqp_ai;
891 s->insn_read = daqp_ai_insn_read;
892 s->do_cmdtest = daqp_ai_cmdtest;
893 s->do_cmd = daqp_ai_cmd;
894 s->cancel = daqp_ai_cancel;
895
896 s = dev->subdevices + 1;
897 dev->write_subdev = s;
898 s->private = local;
899 s->type = COMEDI_SUBD_AO;
900 s->subdev_flags = SDF_WRITEABLE;
901 s->n_chan = 2;
902 s->len_chanlist = 1;
903 s->maxdata = 0x0fff;
904 s->range_table = &range_daqp_ao;
905 s->insn_write = daqp_ao_insn_write;
906
907 s = dev->subdevices + 2;
908 s->private = local;
909 s->type = COMEDI_SUBD_DI;
910 s->subdev_flags = SDF_READABLE;
911 s->n_chan = 1;
912 s->len_chanlist = 1;
913 s->insn_read = daqp_di_insn_read;
914
915 s = dev->subdevices + 3;
916 s->private = local;
917 s->type = COMEDI_SUBD_DO;
918 s->subdev_flags = SDF_WRITEABLE;
919 s->n_chan = 1;
920 s->len_chanlist = 1;
921 s->insn_write = daqp_do_insn_write;
922
923 return 1;
924}
925
926/* daqp_detach (called from comedi_comdig) does nothing. If the PCMCIA
927 * card is removed, daqp_cs_detach() is called by the pcmcia subsystem.
928 */
929
da91b269 930static int daqp_detach(struct comedi_device *dev)
62ed6662 931{
3420f6b4 932 printk(KERN_INFO "comedi%d: detaching daqp\n", dev->minor);
62ed6662
BB
933
934 return 0;
935}
936
937/*====================================================================
938
939 PCMCIA interface code
940
941 The rest of the code in this file is based on dummy_cs.c v1.24
942 from the Linux pcmcia_cs distribution v3.1.8 and is subject
943 to the following license agreement.
944
945 The remaining contents of this file are subject to the Mozilla Public
946 License Version 1.1 (the "License"); you may not use this file
947 except in compliance with the License. You may obtain a copy of
948 the License at http://www.mozilla.org/MPL/
949
950 Software distributed under the License is distributed on an "AS
951 IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
952 implied. See the License for the specific language governing
953 rights and limitations under the License.
954
955 The initial developer of the original code is David A. Hinds
956 <dhinds@pcmcia.sourceforge.org>. Portions created by David A. Hinds
957 are Copyright (C) 1999 David A. Hinds. All Rights Reserved.
958
959 Alternatively, the contents of this file may be used under the
960 terms of the GNU Public License version 2 (the "GPL"), in which
961 case the provisions of the GPL are applicable instead of the
962 above. If you wish to allow the use of your version of this file
963 only under the terms of the GPL and not to allow others to use
964 your version of this file under the MPL, indicate your decision
965 by deleting the provisions above and replace them with the notice
966 and other provisions required by the GPL. If you do not delete
967 the provisions above, a recipient may use your version of this
968 file under either the MPL or the GPL.
969
970======================================================================*/
971
972/*
973 The event() function is this driver's Card Services event handler.
974 It will be called by Card Services when an appropriate card status
975 event is received. The config() and release() entry points are
976 used to configure or release a socket, in response to card
977 insertion and ejection events.
978
979 Kernel version 2.6.16 upwards uses suspend() and resume() functions
980 instead of an event() function.
981*/
982
983static void daqp_cs_config(struct pcmcia_device *link);
984static void daqp_cs_release(struct pcmcia_device *link);
985static int daqp_cs_suspend(struct pcmcia_device *p_dev);
986static int daqp_cs_resume(struct pcmcia_device *p_dev);
987
988/*
989 The attach() and detach() entry points are used to create and destroy
990 "instances" of the driver, where each instance represents everything
991 needed to manage one actual PCMCIA card.
992*/
993
994static int daqp_cs_attach(struct pcmcia_device *);
995static void daqp_cs_detach(struct pcmcia_device *);
996
62ed6662
BB
997/*======================================================================
998
999 daqp_cs_attach() creates an "instance" of the driver, allocating
1000 local data structures for one device. The device is registered
1001 with Card Services.
1002
1003 The dev_link structure is initialized, but we don't actually
1004 configure the card at this point -- we wait until we receive a
1005 card insertion event.
1006
1007======================================================================*/
1008
1009static int daqp_cs_attach(struct pcmcia_device *link)
1010{
ab64f663 1011 struct local_info_t *local;
62ed6662
BB
1012 int i;
1013
55a19b39 1014 dev_dbg(&link->dev, "daqp_cs_attach()\n");
62ed6662
BB
1015
1016 for (i = 0; i < MAX_DEV; i++)
1017 if (dev_table[i] == NULL)
1018 break;
1019 if (i == MAX_DEV) {
1020 printk(KERN_NOTICE "daqp_cs: no devices available\n");
1021 return -ENODEV;
1022 }
1023
1024 /* Allocate space for private device-specific data */
ab64f663 1025 local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
62ed6662
BB
1026 if (!local)
1027 return -ENOMEM;
1028
1029 local->table_index = i;
1030 dev_table[i] = local;
1031 local->link = link;
1032 link->priv = local;
1033
62ed6662
BB
1034 /*
1035 General socket configuration defaults can go here. In this
1036 client, we assume very little, and rely on the CIS for almost
1037 everything. In most clients, many details (i.e., number, sizes,
1038 and attributes of IO windows) are fixed by the nature of the
1039 device, and can be hard-wired here.
1040 */
1041 link->conf.Attributes = 0;
1042 link->conf.IntType = INT_MEMORY_AND_IO;
1043
1044 daqp_cs_config(link);
1045
1046 return 0;
1047} /* daqp_cs_attach */
1048
1049/*======================================================================
1050
1051 This deletes a driver "instance". The device is de-registered
1052 with Card Services. If it has been released, all local data
1053 structures are freed. Otherwise, the structures will be freed
1054 when the device is released.
1055
1056======================================================================*/
1057
1058static void daqp_cs_detach(struct pcmcia_device *link)
1059{
ab64f663 1060 struct local_info_t *dev = link->priv;
62ed6662 1061
55a19b39 1062 dev_dbg(&link->dev, "daqp_cs_detach\n");
62ed6662 1063
7622802e
JMC
1064 dev->stop = 1;
1065 daqp_cs_release(link);
62ed6662
BB
1066
1067 /* Unlink device structure, and free it */
1068 dev_table[dev->table_index] = NULL;
f25bd6bf 1069 kfree(dev);
62ed6662
BB
1070
1071} /* daqp_cs_detach */
1072
1073/*======================================================================
1074
1075 daqp_cs_config() is scheduled to run after a CARD_INSERTION event
1076 is received, to configure the PCMCIA socket, and to make the
1077 device available to the system.
1078
1079======================================================================*/
1080
c3744138 1081
55a19b39
DB
1082static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev,
1083 cistpl_cftable_entry_t *cfg,
1084 cistpl_cftable_entry_t *dflt,
1085 unsigned int vcc,
1086 void *priv_data)
1087{
1088 if (cfg->index == 0)
1089 return -ENODEV;
62ed6662 1090
55a19b39 1091 /* Do we need to allocate an interrupt? */
eb14120f 1092 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
55a19b39
DB
1093
1094 /* IO window settings */
90abdc3b 1095 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
55a19b39
DB
1096 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
1097 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
90abdc3b
DB
1098 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
1099 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
1100 p_dev->resource[0]->flags |=
1101 pcmcia_io_cfg_data_width(io->flags);
1102 p_dev->resource[0]->start = io->win[0].base;
1103 p_dev->resource[0]->end = io->win[0].len;
55a19b39 1104 if (io->nwin > 1) {
90abdc3b
DB
1105 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
1106 p_dev->resource[1]->start = io->win[1].base;
1107 p_dev->resource[1]->end = io->win[1].len;
55a19b39 1108 }
62ed6662 1109 }
c3744138 1110
55a19b39 1111 /* This reserves IO space but doesn't actually enable it */
90abdc3b 1112 return pcmcia_request_io(p_dev);
55a19b39 1113}
62ed6662 1114
55a19b39
DB
1115static void daqp_cs_config(struct pcmcia_device *link)
1116{
55a19b39 1117 int ret;
62ed6662 1118
55a19b39 1119 dev_dbg(&link->dev, "daqp_cs_config\n");
62ed6662 1120
55a19b39
DB
1121 ret = pcmcia_loop_config(link, daqp_pcmcia_config_loop, NULL);
1122 if (ret) {
1123 dev_warn(&link->dev, "no configuration found\n");
1124 goto failed;
62ed6662
BB
1125 }
1126
eb14120f
DB
1127 ret = pcmcia_request_irq(link, daqp_interrupt);
1128 if (ret)
1129 goto failed;
62ed6662
BB
1130
1131 /*
1132 This actually configures the PCMCIA socket -- setting up
1133 the I/O windows and the interrupt mapping, and putting the
1134 card and host interface into "Memory and IO" mode.
1135 */
55a19b39
DB
1136 ret = pcmcia_request_configuration(link, &link->conf);
1137 if (ret)
1138 goto failed;
62ed6662 1139
62ed6662 1140 /* Finally, report what we've done */
7622802e 1141 dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
62ed6662 1142 if (link->conf.Attributes & CONF_ENABLE_IRQ)
eb14120f 1143 printk(", irq %u", link->irq);
9a017a91
DB
1144 if (link->resource[0])
1145 printk(" & %pR", link->resource[0]);
1146 if (link->resource[1])
1147 printk(" & %pR", link->resource[1]);
62ed6662
BB
1148 printk("\n");
1149
1150 return;
1151
55a19b39 1152failed:
62ed6662
BB
1153 daqp_cs_release(link);
1154
1155} /* daqp_cs_config */
1156
1157static void daqp_cs_release(struct pcmcia_device *link)
1158{
55a19b39 1159 dev_dbg(&link->dev, "daqp_cs_release\n");
62ed6662
BB
1160
1161 pcmcia_disable_device(link);
1162} /* daqp_cs_release */
1163
1164/*======================================================================
1165
1166 The card status event handler. Mostly, this schedules other
1167 stuff to run after an event is received.
1168
1169 When a CARD_REMOVAL event is received, we immediately set a
1170 private flag to block future accesses to this device. All the
1171 functions that actually access the device should check this flag
1172 to make sure the card is still present.
1173
1174======================================================================*/
1175
1176static int daqp_cs_suspend(struct pcmcia_device *link)
1177{
ab64f663 1178 struct local_info_t *local = link->priv;
62ed6662
BB
1179
1180 /* Mark the device as stopped, to block IO until later */
1181 local->stop = 1;
1182 return 0;
1183}
1184
1185static int daqp_cs_resume(struct pcmcia_device *link)
1186{
ab64f663 1187 struct local_info_t *local = link->priv;
62ed6662
BB
1188
1189 local->stop = 0;
1190
1191 return 0;
1192}
1193
1194/*====================================================================*/
1195
1196#ifdef MODULE
1197
1198static struct pcmcia_device_id daqp_cs_id_table[] = {
1199 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0027),
1200 PCMCIA_DEVICE_NULL
1201};
1202
1203MODULE_DEVICE_TABLE(pcmcia, daqp_cs_id_table);
6c7f8196
AK
1204MODULE_AUTHOR("Brent Baccala <baccala@freesoft.org>");
1205MODULE_DESCRIPTION("Comedi driver for Quatech DAQP PCMCIA data capture cards");
1206MODULE_LICENSE("GPL");
62ed6662 1207
e3752a1d 1208static struct pcmcia_driver daqp_cs_driver = {
62ed6662
BB
1209 .probe = daqp_cs_attach,
1210 .remove = daqp_cs_detach,
1211 .suspend = daqp_cs_suspend,
1212 .resume = daqp_cs_resume,
1213 .id_table = daqp_cs_id_table,
1214 .owner = THIS_MODULE,
1215 .drv = {
1685e633 1216 .name = "quatech_daqp_cs",
62ed6662
BB
1217 },
1218};
1219
1220int __init init_module(void)
1221{
62ed6662
BB
1222 pcmcia_register_driver(&daqp_cs_driver);
1223 comedi_driver_register(&driver_daqp);
1224 return 0;
1225}
1226
1227void __exit cleanup_module(void)
1228{
62ed6662
BB
1229 comedi_driver_unregister(&driver_daqp);
1230 pcmcia_unregister_driver(&daqp_cs_driver);
1231}
1232
1233#endif