1 /*======================================================================
3 comedi/drivers/quatech_daqp_cs.c
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.
9 COMEDI - Linux Control and Measurement Device Interface
10 Copyright (C) 1998 David A. Schleef <ds@schleef.org>
11 http://www.comedi.org/
13 quatech_daqp_cs.c 1.10
15 Documentation for the DAQP PCMCIA cards can be found on Quatech's site:
17 ftp://ftp.quatech.com/Manuals/daqp-208.pdf
19 This manual is for both the DAQP-208 and the DAQP-308.
26 - ground ref or differential
27 - single-shot and timed both supported
28 - D/A conversion, single-shot
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
40 ======================================================================*/
43 Driver: quatech_daqp_cs
44 Description: Quatech DAQP PCMCIA data capture cards
45 Author: Brent Baccala <baccala@freesoft.org>
47 Devices: [Quatech] DAQP-208 (daqp), DAQP-308
50 #include <linux/module.h>
51 #include <linux/semaphore.h>
52 #include <linux/completion.h>
54 #include "../comedi_pcmcia.h"
59 enum { semaphore, buffer } interrupt_mode;
61 struct completion eos;
64 /* The DAQP communicates with the system through a 16 byte I/O window. */
66 #define DAQP_FIFO_SIZE 4096
69 #define DAQP_SCANLIST 1
70 #define DAQP_CONTROL 2
72 #define DAQP_DIGITAL_IO 3
73 #define DAQP_PACER_LOW 4
74 #define DAQP_PACER_MID 5
75 #define DAQP_PACER_HIGH 6
76 #define DAQP_COMMAND 7
81 #define DAQP_SCANLIST_DIFFERENTIAL 0x4000
82 #define DAQP_SCANLIST_GAIN(x) ((x)<<12)
83 #define DAQP_SCANLIST_CHANNEL(x) ((x)<<8)
84 #define DAQP_SCANLIST_START 0x0080
85 #define DAQP_SCANLIST_EXT_GAIN(x) ((x)<<4)
86 #define DAQP_SCANLIST_EXT_CHANNEL(x) (x)
88 #define DAQP_CONTROL_PACER_100kHz 0xc0
89 #define DAQP_CONTROL_PACER_1MHz 0x80
90 #define DAQP_CONTROL_PACER_5MHz 0x40
91 #define DAQP_CONTROL_PACER_EXTERNAL 0x00
92 #define DAQP_CONTORL_EXPANSION 0x20
93 #define DAQP_CONTROL_EOS_INT_ENABLE 0x10
94 #define DAQP_CONTROL_FIFO_INT_ENABLE 0x08
95 #define DAQP_CONTROL_TRIGGER_ONESHOT 0x00
96 #define DAQP_CONTROL_TRIGGER_CONTINUOUS 0x04
97 #define DAQP_CONTROL_TRIGGER_INTERNAL 0x00
98 #define DAQP_CONTROL_TRIGGER_EXTERNAL 0x02
99 #define DAQP_CONTROL_TRIGGER_RISING 0x00
100 #define DAQP_CONTROL_TRIGGER_FALLING 0x01
102 #define DAQP_STATUS_IDLE 0x80
103 #define DAQP_STATUS_RUNNING 0x40
104 #define DAQP_STATUS_EVENTS 0x38
105 #define DAQP_STATUS_DATA_LOST 0x20
106 #define DAQP_STATUS_END_OF_SCAN 0x10
107 #define DAQP_STATUS_FIFO_THRESHOLD 0x08
108 #define DAQP_STATUS_FIFO_FULL 0x04
109 #define DAQP_STATUS_FIFO_NEARFULL 0x02
110 #define DAQP_STATUS_FIFO_EMPTY 0x01
112 #define DAQP_COMMAND_ARM 0x80
113 #define DAQP_COMMAND_RSTF 0x40
114 #define DAQP_COMMAND_RSTQ 0x20
115 #define DAQP_COMMAND_STOP 0x10
116 #define DAQP_COMMAND_LATCH 0x08
117 #define DAQP_COMMAND_100kHz 0x00
118 #define DAQP_COMMAND_50kHz 0x02
119 #define DAQP_COMMAND_25kHz 0x04
120 #define DAQP_COMMAND_FIFO_DATA 0x01
121 #define DAQP_COMMAND_FIFO_PROGRAM 0x00
123 #define DAQP_AUX_TRIGGER_TTL 0x00
124 #define DAQP_AUX_TRIGGER_ANALOG 0x80
125 #define DAQP_AUX_TRIGGER_PRETRIGGER 0x40
126 #define DAQP_AUX_TIMER_INT_ENABLE 0x20
127 #define DAQP_AUX_TIMER_RELOAD 0x00
128 #define DAQP_AUX_TIMER_PAUSE 0x08
129 #define DAQP_AUX_TIMER_GO 0x10
130 #define DAQP_AUX_TIMER_GO_EXTERNAL 0x18
131 #define DAQP_AUX_TIMER_EXTERNAL_SRC 0x04
132 #define DAQP_AUX_TIMER_INTERNAL_SRC 0x00
133 #define DAQP_AUX_DA_DIRECT 0x00
134 #define DAQP_AUX_DA_OVERFLOW 0x01
135 #define DAQP_AUX_DA_EXTERNAL 0x02
136 #define DAQP_AUX_DA_PACER 0x03
138 #define DAQP_AUX_RUNNING 0x80
139 #define DAQP_AUX_TRIGGERED 0x40
140 #define DAQP_AUX_DA_BUFFER 0x20
141 #define DAQP_AUX_TIMER_OVERFLOW 0x10
142 #define DAQP_AUX_CONVERSION 0x08
143 #define DAQP_AUX_DATA_LOST 0x04
144 #define DAQP_AUX_FIFO_NEARFULL 0x02
145 #define DAQP_AUX_FIFO_EMPTY 0x01
147 static const struct comedi_lrange range_daqp_ai = {
156 /* Cancel a running acquisition */
158 static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
160 struct daqp_private *devpriv = dev->private;
165 outb(DAQP_COMMAND_STOP, dev->iobase + DAQP_COMMAND);
167 /* flush any linguring data in FIFO - superfluous here */
168 /* outb(DAQP_COMMAND_RSTF, dev->iobase+DAQP_COMMAND); */
170 devpriv->interrupt_mode = semaphore;
177 * Operates in one of two modes. If devpriv->interrupt_mode is
178 * 'semaphore', just signal the devpriv->eos completion and return
179 * (one-shot mode). Otherwise (continuous mode), read data in from
180 * the card, transfer it to the buffer provided by the higher-level
181 * comedi kernel module, and signal various comedi callback routines,
182 * which run pretty quick.
184 static enum irqreturn daqp_interrupt(int irq, void *dev_id)
186 struct comedi_device *dev = dev_id;
187 struct daqp_private *devpriv = dev->private;
188 struct comedi_subdevice *s = dev->read_subdev;
189 struct comedi_cmd *cmd = &s->async->cmd;
190 int loop_limit = 10000;
196 switch (devpriv->interrupt_mode) {
198 complete(&devpriv->eos);
202 while (!((status = inb(dev->iobase + DAQP_STATUS))
203 & DAQP_STATUS_FIFO_EMPTY)) {
206 if (status & DAQP_STATUS_DATA_LOST) {
207 s->async->events |= COMEDI_CB_OVERFLOW;
208 dev_warn(dev->class_dev, "data lost\n");
212 data = inb(dev->iobase + DAQP_FIFO);
213 data |= inb(dev->iobase + DAQP_FIFO) << 8;
216 comedi_buf_write_samples(s, &data, 1);
218 /* If there's a limit, decrement it
219 * and stop conversion if zero
222 if (cmd->stop_src == TRIG_COUNT &&
223 s->async->scans_done >= cmd->stop_arg) {
224 s->async->events |= COMEDI_CB_EOA;
228 if ((loop_limit--) <= 0)
232 if (loop_limit <= 0) {
233 dev_warn(dev->class_dev,
234 "loop_limit reached in daqp_interrupt()\n");
235 s->async->events |= COMEDI_CB_ERROR;
238 comedi_handle_events(dev, s);
243 static void daqp_ai_set_one_scanlist_entry(struct comedi_device *dev,
244 unsigned int chanspec,
247 unsigned int chan = CR_CHAN(chanspec);
248 unsigned int range = CR_RANGE(chanspec);
249 unsigned int aref = CR_AREF(chanspec);
252 val = DAQP_SCANLIST_CHANNEL(chan) | DAQP_SCANLIST_GAIN(range);
254 if (aref == AREF_DIFF)
255 val |= DAQP_SCANLIST_DIFFERENTIAL;
258 val |= DAQP_SCANLIST_START;
260 outb(val & 0xff, dev->iobase + DAQP_SCANLIST);
261 outb((val >> 8) & 0xff, dev->iobase + DAQP_SCANLIST);
264 /* One-shot analog data acquisition routine */
266 static int daqp_ai_insn_read(struct comedi_device *dev,
267 struct comedi_subdevice *s,
268 struct comedi_insn *insn, unsigned int *data)
270 struct daqp_private *devpriv = dev->private;
278 /* Stop any running conversion */
279 daqp_ai_cancel(dev, s);
281 outb(0, dev->iobase + DAQP_AUX);
283 /* Reset scan list queue */
284 outb(DAQP_COMMAND_RSTQ, dev->iobase + DAQP_COMMAND);
286 /* Program one scan list entry */
287 daqp_ai_set_one_scanlist_entry(dev, insn->chanspec, 1);
289 /* Reset data FIFO (see page 28 of DAQP User's Manual) */
291 outb(DAQP_COMMAND_RSTF, dev->iobase + DAQP_COMMAND);
295 v = DAQP_CONTROL_TRIGGER_ONESHOT | DAQP_CONTROL_TRIGGER_INTERNAL
296 | DAQP_CONTROL_PACER_100kHz | DAQP_CONTROL_EOS_INT_ENABLE;
298 outb(v, dev->iobase + DAQP_CONTROL);
300 /* Reset any pending interrupts (my card has a tendency to require
301 * require multiple reads on the status register to achieve this)
305 && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS))
308 dev_err(dev->class_dev,
309 "couldn't clear interrupts in status register\n");
313 init_completion(&devpriv->eos);
314 devpriv->interrupt_mode = semaphore;
316 for (i = 0; i < insn->n; i++) {
317 /* Start conversion */
318 outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
319 dev->iobase + DAQP_COMMAND);
321 /* Wait for interrupt service routine to unblock completion */
322 /* Maybe could use a timeout here, but it's interruptible */
323 if (wait_for_completion_interruptible(&devpriv->eos))
326 data[i] = inb(dev->iobase + DAQP_FIFO);
327 data[i] |= inb(dev->iobase + DAQP_FIFO) << 8;
334 /* This function converts ns nanoseconds to a counter value suitable
335 * for programming the device. We always use the DAQP's 5 MHz clock,
336 * which with its 24-bit counter, allows values up to 84 seconds.
337 * Also, the function adjusts ns so that it cooresponds to the actual
338 * time that the device will use.
341 static int daqp_ns_to_timer(unsigned int *ns, unsigned int flags)
351 /* cmdtest tests a particular command to see if it is valid.
352 * Using the cmdtest ioctl, a user can create a valid cmd
353 * and then have it executed by the cmd ioctl.
355 * cmdtest returns 1,2,3,4 or 0, depending on which tests
356 * the command passes.
359 static int daqp_ai_cmdtest(struct comedi_device *dev,
360 struct comedi_subdevice *s, struct comedi_cmd *cmd)
365 /* Step 1 : check if triggers are trivially valid */
367 err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW);
368 err |= comedi_check_trigger_src(&cmd->scan_begin_src,
369 TRIG_TIMER | TRIG_FOLLOW);
370 err |= comedi_check_trigger_src(&cmd->convert_src,
371 TRIG_TIMER | TRIG_NOW);
372 err |= comedi_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
373 err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
378 /* Step 2a : make sure trigger sources are unique */
380 err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
381 err |= comedi_check_trigger_is_unique(cmd->convert_src);
382 err |= comedi_check_trigger_is_unique(cmd->stop_src);
384 /* Step 2b : and mutually compatible */
389 /* Step 3: check if arguments are trivially valid */
391 err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
393 #define MAX_SPEED 10000 /* 100 kHz - in nanoseconds */
395 if (cmd->scan_begin_src == TRIG_TIMER) {
396 err |= comedi_check_trigger_arg_min(&cmd->scan_begin_arg,
400 /* If both scan_begin and convert are both timer values, the only
401 * way that can make sense is if the scan time is the number of
402 * conversions times the convert time
405 if (cmd->scan_begin_src == TRIG_TIMER && cmd->convert_src == TRIG_TIMER
406 && cmd->scan_begin_arg != cmd->convert_arg * cmd->scan_end_arg) {
410 if (cmd->convert_src == TRIG_TIMER) {
411 err |= comedi_check_trigger_arg_min(&cmd->convert_arg,
415 err |= comedi_check_trigger_arg_is(&cmd->scan_end_arg,
418 if (cmd->stop_src == TRIG_COUNT)
419 err |= comedi_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
421 err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
426 /* step 4: fix up any arguments */
428 if (cmd->scan_begin_src == TRIG_TIMER) {
429 arg = cmd->scan_begin_arg;
430 daqp_ns_to_timer(&arg, cmd->flags);
431 err |= comedi_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
434 if (cmd->convert_src == TRIG_TIMER) {
435 arg = cmd->convert_arg;
436 daqp_ns_to_timer(&arg, cmd->flags);
437 err |= comedi_check_trigger_arg_is(&cmd->convert_arg, arg);
446 static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
448 struct daqp_private *devpriv = dev->private;
449 struct comedi_cmd *cmd = &s->async->cmd;
451 int scanlist_start_on_every_entry;
460 /* Stop any running conversion */
461 daqp_ai_cancel(dev, s);
463 outb(0, dev->iobase + DAQP_AUX);
465 /* Reset scan list queue */
466 outb(DAQP_COMMAND_RSTQ, dev->iobase + DAQP_COMMAND);
468 /* Program pacer clock
470 * There's two modes we can operate in. If convert_src is
471 * TRIG_TIMER, then convert_arg specifies the time between
472 * each conversion, so we program the pacer clock to that
473 * frequency and set the SCANLIST_START bit on every scanlist
474 * entry. Otherwise, convert_src is TRIG_NOW, which means
475 * we want the fastest possible conversions, scan_begin_src
476 * is TRIG_TIMER, and scan_begin_arg specifies the time between
477 * each scan, so we program the pacer clock to this frequency
478 * and only set the SCANLIST_START bit on the first entry.
481 if (cmd->convert_src == TRIG_TIMER) {
482 counter = daqp_ns_to_timer(&cmd->convert_arg, cmd->flags);
483 outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
484 outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
485 outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
486 scanlist_start_on_every_entry = 1;
488 counter = daqp_ns_to_timer(&cmd->scan_begin_arg, cmd->flags);
489 outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
490 outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
491 outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
492 scanlist_start_on_every_entry = 0;
495 /* Program scan list */
496 for (i = 0; i < cmd->chanlist_len; i++) {
497 int start = (i == 0 || scanlist_start_on_every_entry);
499 daqp_ai_set_one_scanlist_entry(dev, cmd->chanlist[i], start);
502 /* Now it's time to program the FIFO threshold, basically the
503 * number of samples the card will buffer before it interrupts
506 * If we don't have a stop count, then use half the size of
507 * the FIFO (the manufacturer's recommendation). Consider
508 * that the FIFO can hold 2K samples (4K bytes). With the
509 * threshold set at half the FIFO size, we have a margin of
510 * error of 1024 samples. At the chip's maximum sample rate
511 * of 100,000 Hz, the CPU would have to delay interrupt
512 * service for a full 10 milliseconds in order to lose data
513 * here (as opposed to higher up in the kernel). I've never
514 * seen it happen. However, for slow sample rates it may
515 * buffer too much data and introduce too much delay for the
518 * If we have a stop count, then things get more interesting.
519 * If the stop count is less than the FIFO size (actually
520 * three-quarters of the FIFO size - see below), we just use
521 * the stop count itself as the threshold, the card interrupts
522 * us when that many samples have been taken, and we kill the
523 * acquisition at that point and are done. If the stop count
524 * is larger than that, then we divide it by 2 until it's less
525 * than three quarters of the FIFO size (we always leave the
526 * top quarter of the FIFO as protection against sluggish CPU
527 * interrupt response) and use that as the threshold. So, if
528 * the stop count is 4000 samples, we divide by two twice to
529 * get 1000 samples, use that as the threshold, take four
530 * interrupts to get our 4000 samples and are done.
532 * The algorithm could be more clever. For example, if 81000
533 * samples are requested, we could set the threshold to 1500
534 * samples and take 54 interrupts to get 81000. But 54 isn't
535 * a power of two, so this algorithm won't find that option.
536 * Instead, it'll set the threshold at 1266 and take 64
537 * interrupts to get 81024 samples, of which the last 24 will
538 * be discarded... but we won't get the last interrupt until
539 * they've been collected. To find the first option, the
540 * computer could look at the prime decomposition of the
541 * sample count (81000 = 3^4 * 5^3 * 2^3) and factor it into a
542 * threshold (1500 = 3 * 5^3 * 2^2) and an interrupt count (54
543 * = 3^3 * 2). Hmmm... a one-line while loop or prime
544 * decomposition of integers... I'll leave it the way it is.
546 * I'll also note a mini-race condition before ignoring it in
547 * the code. Let's say we're taking 4000 samples, as before.
548 * After 1000 samples, we get an interrupt. But before that
549 * interrupt is completely serviced, another sample is taken
550 * and loaded into the FIFO. Since the interrupt handler
551 * empties the FIFO before returning, it will read 1001 samples.
552 * If that happens four times, we'll end up taking 4004 samples,
553 * not 4000. The interrupt handler will discard the extra four
554 * samples (by halting the acquisition with four samples still
555 * in the FIFO), but we will have to wait for them.
557 * In short, this code works pretty well, but for either of
558 * the two reasons noted, might end up waiting for a few more
559 * samples than actually requested. Shouldn't make too much
563 /* Save away the number of conversions we should perform, and
564 * compute the FIFO threshold (in bytes, not samples - that's
565 * why we multiple devpriv->count by 2 = sizeof(sample))
568 if (cmd->stop_src == TRIG_COUNT) {
569 unsigned long long nsamples;
570 unsigned long long nbytes;
572 nsamples = (unsigned long long)cmd->stop_arg *
574 nbytes = nsamples * comedi_bytes_per_sample(s);
575 while (nbytes > DAQP_FIFO_SIZE * 3 / 4)
579 threshold = DAQP_FIFO_SIZE / 2;
582 /* Reset data FIFO (see page 28 of DAQP User's Manual) */
584 outb(DAQP_COMMAND_RSTF, dev->iobase + DAQP_COMMAND);
586 /* Set FIFO threshold. First two bytes are near-empty
587 * threshold, which is unused; next two bytes are near-full
588 * threshold. We computed the number of bytes we want in the
589 * FIFO when the interrupt is generated, what the card wants
590 * is actually the number of available bytes left in the FIFO
591 * when the interrupt is to happen.
594 outb(0x00, dev->iobase + DAQP_FIFO);
595 outb(0x00, dev->iobase + DAQP_FIFO);
597 outb((DAQP_FIFO_SIZE - threshold) & 0xff, dev->iobase + DAQP_FIFO);
598 outb((DAQP_FIFO_SIZE - threshold) >> 8, dev->iobase + DAQP_FIFO);
602 v = DAQP_CONTROL_TRIGGER_CONTINUOUS | DAQP_CONTROL_TRIGGER_INTERNAL
603 | DAQP_CONTROL_PACER_5MHz | DAQP_CONTROL_FIFO_INT_ENABLE;
605 outb(v, dev->iobase + DAQP_CONTROL);
607 /* Reset any pending interrupts (my card has a tendency to require
608 * require multiple reads on the status register to achieve this)
612 && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS))
615 dev_err(dev->class_dev,
616 "couldn't clear interrupts in status register\n");
620 devpriv->interrupt_mode = buffer;
622 /* Start conversion */
623 outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
624 dev->iobase + DAQP_COMMAND);
629 static int daqp_ao_insn_write(struct comedi_device *dev,
630 struct comedi_subdevice *s,
631 struct comedi_insn *insn,
634 struct daqp_private *devpriv = dev->private;
635 unsigned int chan = CR_CHAN(insn->chanspec);
641 /* Make sure D/A update mode is direct update */
642 outb(0, dev->iobase + DAQP_AUX);
644 for (i = 0; i > insn->n; i++) {
645 unsigned val = data[i];
647 s->readback[chan] = val;
650 val ^= 0x0800; /* Flip the sign */
653 outw(val, dev->iobase + DAQP_DA);
659 static int daqp_di_insn_bits(struct comedi_device *dev,
660 struct comedi_subdevice *s,
661 struct comedi_insn *insn,
664 struct daqp_private *devpriv = dev->private;
669 data[0] = inb(dev->iobase + DAQP_DIGITAL_IO);
674 static int daqp_do_insn_bits(struct comedi_device *dev,
675 struct comedi_subdevice *s,
676 struct comedi_insn *insn,
679 struct daqp_private *devpriv = dev->private;
684 if (comedi_dio_update_state(s, data))
685 outb(s->state, dev->iobase + DAQP_DIGITAL_IO);
692 static int daqp_auto_attach(struct comedi_device *dev,
693 unsigned long context)
695 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
696 struct daqp_private *devpriv;
697 struct comedi_subdevice *s;
700 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
704 link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
705 ret = comedi_pcmcia_enable(dev, NULL);
708 dev->iobase = link->resource[0]->start;
711 ret = pcmcia_request_irq(link, daqp_interrupt);
715 ret = comedi_alloc_subdevices(dev, 4);
719 s = &dev->subdevices[0];
720 dev->read_subdev = s;
721 s->type = COMEDI_SUBD_AI;
722 s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
724 s->len_chanlist = 2048;
726 s->range_table = &range_daqp_ai;
727 s->insn_read = daqp_ai_insn_read;
728 s->do_cmdtest = daqp_ai_cmdtest;
729 s->do_cmd = daqp_ai_cmd;
730 s->cancel = daqp_ai_cancel;
732 s = &dev->subdevices[1];
733 s->type = COMEDI_SUBD_AO;
734 s->subdev_flags = SDF_WRITABLE;
737 s->range_table = &range_bipolar5;
738 s->insn_write = daqp_ao_insn_write;
740 ret = comedi_alloc_subdev_readback(s);
744 s = &dev->subdevices[2];
745 s->type = COMEDI_SUBD_DI;
746 s->subdev_flags = SDF_READABLE;
749 s->insn_bits = daqp_di_insn_bits;
751 s = &dev->subdevices[3];
752 s->type = COMEDI_SUBD_DO;
753 s->subdev_flags = SDF_WRITABLE;
756 s->insn_bits = daqp_do_insn_bits;
761 static struct comedi_driver driver_daqp = {
762 .driver_name = "quatech_daqp_cs",
763 .module = THIS_MODULE,
764 .auto_attach = daqp_auto_attach,
765 .detach = comedi_pcmcia_disable,
768 static int daqp_cs_suspend(struct pcmcia_device *link)
770 struct comedi_device *dev = link->priv;
771 struct daqp_private *devpriv = dev ? dev->private : NULL;
773 /* Mark the device as stopped, to block IO until later */
780 static int daqp_cs_resume(struct pcmcia_device *link)
782 struct comedi_device *dev = link->priv;
783 struct daqp_private *devpriv = dev ? dev->private : NULL;
791 static int daqp_cs_attach(struct pcmcia_device *link)
793 return comedi_pcmcia_auto_config(link, &driver_daqp);
796 static const struct pcmcia_device_id daqp_cs_id_table[] = {
797 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0027),
800 MODULE_DEVICE_TABLE(pcmcia, daqp_cs_id_table);
802 static struct pcmcia_driver daqp_cs_driver = {
803 .name = "quatech_daqp_cs",
804 .owner = THIS_MODULE,
805 .id_table = daqp_cs_id_table,
806 .probe = daqp_cs_attach,
807 .remove = comedi_pcmcia_auto_unconfig,
808 .suspend = daqp_cs_suspend,
809 .resume = daqp_cs_resume,
811 module_comedi_pcmcia_driver(driver_daqp, daqp_cs_driver);
813 MODULE_DESCRIPTION("Comedi driver for Quatech DAQP PCMCIA data capture cards");
814 MODULE_AUTHOR("Brent Baccala <baccala@freesoft.org>");
815 MODULE_LICENSE("GPL");