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"
55 #include "comedi_fc.h"
60 enum { semaphore, buffer } interrupt_mode;
62 struct completion eos;
65 /* The DAQP communicates with the system through a 16 byte I/O window. */
67 #define DAQP_FIFO_SIZE 4096
70 #define DAQP_SCANLIST 1
71 #define DAQP_CONTROL 2
73 #define DAQP_DIGITAL_IO 3
74 #define DAQP_PACER_LOW 4
75 #define DAQP_PACER_MID 5
76 #define DAQP_PACER_HIGH 6
77 #define DAQP_COMMAND 7
82 #define DAQP_SCANLIST_DIFFERENTIAL 0x4000
83 #define DAQP_SCANLIST_GAIN(x) ((x)<<12)
84 #define DAQP_SCANLIST_CHANNEL(x) ((x)<<8)
85 #define DAQP_SCANLIST_START 0x0080
86 #define DAQP_SCANLIST_EXT_GAIN(x) ((x)<<4)
87 #define DAQP_SCANLIST_EXT_CHANNEL(x) (x)
89 #define DAQP_CONTROL_PACER_100kHz 0xc0
90 #define DAQP_CONTROL_PACER_1MHz 0x80
91 #define DAQP_CONTROL_PACER_5MHz 0x40
92 #define DAQP_CONTROL_PACER_EXTERNAL 0x00
93 #define DAQP_CONTORL_EXPANSION 0x20
94 #define DAQP_CONTROL_EOS_INT_ENABLE 0x10
95 #define DAQP_CONTROL_FIFO_INT_ENABLE 0x08
96 #define DAQP_CONTROL_TRIGGER_ONESHOT 0x00
97 #define DAQP_CONTROL_TRIGGER_CONTINUOUS 0x04
98 #define DAQP_CONTROL_TRIGGER_INTERNAL 0x00
99 #define DAQP_CONTROL_TRIGGER_EXTERNAL 0x02
100 #define DAQP_CONTROL_TRIGGER_RISING 0x00
101 #define DAQP_CONTROL_TRIGGER_FALLING 0x01
103 #define DAQP_STATUS_IDLE 0x80
104 #define DAQP_STATUS_RUNNING 0x40
105 #define DAQP_STATUS_EVENTS 0x38
106 #define DAQP_STATUS_DATA_LOST 0x20
107 #define DAQP_STATUS_END_OF_SCAN 0x10
108 #define DAQP_STATUS_FIFO_THRESHOLD 0x08
109 #define DAQP_STATUS_FIFO_FULL 0x04
110 #define DAQP_STATUS_FIFO_NEARFULL 0x02
111 #define DAQP_STATUS_FIFO_EMPTY 0x01
113 #define DAQP_COMMAND_ARM 0x80
114 #define DAQP_COMMAND_RSTF 0x40
115 #define DAQP_COMMAND_RSTQ 0x20
116 #define DAQP_COMMAND_STOP 0x10
117 #define DAQP_COMMAND_LATCH 0x08
118 #define DAQP_COMMAND_100kHz 0x00
119 #define DAQP_COMMAND_50kHz 0x02
120 #define DAQP_COMMAND_25kHz 0x04
121 #define DAQP_COMMAND_FIFO_DATA 0x01
122 #define DAQP_COMMAND_FIFO_PROGRAM 0x00
124 #define DAQP_AUX_TRIGGER_TTL 0x00
125 #define DAQP_AUX_TRIGGER_ANALOG 0x80
126 #define DAQP_AUX_TRIGGER_PRETRIGGER 0x40
127 #define DAQP_AUX_TIMER_INT_ENABLE 0x20
128 #define DAQP_AUX_TIMER_RELOAD 0x00
129 #define DAQP_AUX_TIMER_PAUSE 0x08
130 #define DAQP_AUX_TIMER_GO 0x10
131 #define DAQP_AUX_TIMER_GO_EXTERNAL 0x18
132 #define DAQP_AUX_TIMER_EXTERNAL_SRC 0x04
133 #define DAQP_AUX_TIMER_INTERNAL_SRC 0x00
134 #define DAQP_AUX_DA_DIRECT 0x00
135 #define DAQP_AUX_DA_OVERFLOW 0x01
136 #define DAQP_AUX_DA_EXTERNAL 0x02
137 #define DAQP_AUX_DA_PACER 0x03
139 #define DAQP_AUX_RUNNING 0x80
140 #define DAQP_AUX_TRIGGERED 0x40
141 #define DAQP_AUX_DA_BUFFER 0x20
142 #define DAQP_AUX_TIMER_OVERFLOW 0x10
143 #define DAQP_AUX_CONVERSION 0x08
144 #define DAQP_AUX_DATA_LOST 0x04
145 #define DAQP_AUX_FIFO_NEARFULL 0x02
146 #define DAQP_AUX_FIFO_EMPTY 0x01
148 static const struct comedi_lrange range_daqp_ai = {
157 /* Cancel a running acquisition */
159 static int daqp_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
161 struct daqp_private *devpriv = dev->private;
166 outb(DAQP_COMMAND_STOP, dev->iobase + DAQP_COMMAND);
168 /* flush any linguring data in FIFO - superfluous here */
169 /* outb(DAQP_COMMAND_RSTF, dev->iobase+DAQP_COMMAND); */
171 devpriv->interrupt_mode = semaphore;
178 * Operates in one of two modes. If devpriv->interrupt_mode is
179 * 'semaphore', just signal the devpriv->eos completion and return
180 * (one-shot mode). Otherwise (continuous mode), read data in from
181 * the card, transfer it to the buffer provided by the higher-level
182 * comedi kernel module, and signal various comedi callback routines,
183 * which run pretty quick.
185 static enum irqreturn daqp_interrupt(int irq, void *dev_id)
187 struct comedi_device *dev = dev_id;
188 struct daqp_private *devpriv = dev->private;
189 struct comedi_subdevice *s = dev->read_subdev;
190 struct comedi_cmd *cmd = &s->async->cmd;
191 int loop_limit = 10000;
197 switch (devpriv->interrupt_mode) {
199 complete(&devpriv->eos);
203 while (!((status = inb(dev->iobase + DAQP_STATUS))
204 & DAQP_STATUS_FIFO_EMPTY)) {
207 if (status & DAQP_STATUS_DATA_LOST) {
208 s->async->events |= COMEDI_CB_OVERFLOW;
209 dev_warn(dev->class_dev, "data lost\n");
213 data = inb(dev->iobase + DAQP_FIFO);
214 data |= inb(dev->iobase + DAQP_FIFO) << 8;
217 comedi_buf_write_samples(s, &data, 1);
219 /* If there's a limit, decrement it
220 * and stop conversion if zero
223 if (cmd->stop_src == TRIG_COUNT &&
224 s->async->scans_done >= cmd->stop_arg) {
225 s->async->events |= COMEDI_CB_EOA;
229 if ((loop_limit--) <= 0)
233 if (loop_limit <= 0) {
234 dev_warn(dev->class_dev,
235 "loop_limit reached in daqp_interrupt()\n");
236 s->async->events |= COMEDI_CB_ERROR;
239 comedi_handle_events(dev, s);
244 static void daqp_ai_set_one_scanlist_entry(struct comedi_device *dev,
245 unsigned int chanspec,
248 unsigned int chan = CR_CHAN(chanspec);
249 unsigned int range = CR_RANGE(chanspec);
250 unsigned int aref = CR_AREF(chanspec);
253 val = DAQP_SCANLIST_CHANNEL(chan) | DAQP_SCANLIST_GAIN(range);
255 if (aref == AREF_DIFF)
256 val |= DAQP_SCANLIST_DIFFERENTIAL;
259 val |= DAQP_SCANLIST_START;
261 outb(val & 0xff, dev->iobase + DAQP_SCANLIST);
262 outb((val >> 8) & 0xff, dev->iobase + DAQP_SCANLIST);
265 /* One-shot analog data acquisition routine */
267 static int daqp_ai_insn_read(struct comedi_device *dev,
268 struct comedi_subdevice *s,
269 struct comedi_insn *insn, unsigned int *data)
271 struct daqp_private *devpriv = dev->private;
279 /* Stop any running conversion */
280 daqp_ai_cancel(dev, s);
282 outb(0, dev->iobase + DAQP_AUX);
284 /* Reset scan list queue */
285 outb(DAQP_COMMAND_RSTQ, dev->iobase + DAQP_COMMAND);
287 /* Program one scan list entry */
288 daqp_ai_set_one_scanlist_entry(dev, insn->chanspec, 1);
290 /* Reset data FIFO (see page 28 of DAQP User's Manual) */
292 outb(DAQP_COMMAND_RSTF, dev->iobase + DAQP_COMMAND);
296 v = DAQP_CONTROL_TRIGGER_ONESHOT | DAQP_CONTROL_TRIGGER_INTERNAL
297 | DAQP_CONTROL_PACER_100kHz | DAQP_CONTROL_EOS_INT_ENABLE;
299 outb(v, dev->iobase + DAQP_CONTROL);
301 /* Reset any pending interrupts (my card has a tendency to require
302 * require multiple reads on the status register to achieve this)
306 && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS))
309 dev_err(dev->class_dev,
310 "couldn't clear interrupts in status register\n");
314 init_completion(&devpriv->eos);
315 devpriv->interrupt_mode = semaphore;
317 for (i = 0; i < insn->n; i++) {
319 /* Start conversion */
320 outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
321 dev->iobase + DAQP_COMMAND);
323 /* Wait for interrupt service routine to unblock completion */
324 /* Maybe could use a timeout here, but it's interruptible */
325 if (wait_for_completion_interruptible(&devpriv->eos))
328 data[i] = inb(dev->iobase + DAQP_FIFO);
329 data[i] |= inb(dev->iobase + DAQP_FIFO) << 8;
336 /* This function converts ns nanoseconds to a counter value suitable
337 * for programming the device. We always use the DAQP's 5 MHz clock,
338 * which with its 24-bit counter, allows values up to 84 seconds.
339 * Also, the function adjusts ns so that it cooresponds to the actual
340 * time that the device will use.
343 static int daqp_ns_to_timer(unsigned int *ns, unsigned int flags)
353 /* cmdtest tests a particular command to see if it is valid.
354 * Using the cmdtest ioctl, a user can create a valid cmd
355 * and then have it executed by the cmd ioctl.
357 * cmdtest returns 1,2,3,4 or 0, depending on which tests
358 * the command passes.
361 static int daqp_ai_cmdtest(struct comedi_device *dev,
362 struct comedi_subdevice *s, struct comedi_cmd *cmd)
367 /* Step 1 : check if triggers are trivially valid */
369 err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
370 err |= cfc_check_trigger_src(&cmd->scan_begin_src,
371 TRIG_TIMER | TRIG_FOLLOW);
372 err |= cfc_check_trigger_src(&cmd->convert_src,
373 TRIG_TIMER | TRIG_NOW);
374 err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
375 err |= cfc_check_trigger_src(&cmd->stop_src, TRIG_COUNT | TRIG_NONE);
380 /* Step 2a : make sure trigger sources are unique */
382 err |= cfc_check_trigger_is_unique(cmd->scan_begin_src);
383 err |= cfc_check_trigger_is_unique(cmd->convert_src);
384 err |= cfc_check_trigger_is_unique(cmd->stop_src);
386 /* Step 2b : and mutually compatible */
391 /* Step 3: check if arguments are trivially valid */
393 err |= cfc_check_trigger_arg_is(&cmd->start_arg, 0);
395 #define MAX_SPEED 10000 /* 100 kHz - in nanoseconds */
397 if (cmd->scan_begin_src == TRIG_TIMER)
398 err |= cfc_check_trigger_arg_min(&cmd->scan_begin_arg,
401 /* If both scan_begin and convert are both timer values, the only
402 * way that can make sense is if the scan time is the number of
403 * conversions times the convert time
406 if (cmd->scan_begin_src == TRIG_TIMER && cmd->convert_src == TRIG_TIMER
407 && cmd->scan_begin_arg != cmd->convert_arg * cmd->scan_end_arg) {
411 if (cmd->convert_src == TRIG_TIMER)
412 err |= cfc_check_trigger_arg_min(&cmd->convert_arg, MAX_SPEED);
414 err |= cfc_check_trigger_arg_is(&cmd->scan_end_arg, cmd->chanlist_len);
416 if (cmd->stop_src == TRIG_COUNT)
417 err |= cfc_check_trigger_arg_max(&cmd->stop_arg, 0x00ffffff);
419 err |= cfc_check_trigger_arg_is(&cmd->stop_arg, 0);
424 /* step 4: fix up any arguments */
426 if (cmd->scan_begin_src == TRIG_TIMER) {
427 arg = cmd->scan_begin_arg;
428 daqp_ns_to_timer(&arg, cmd->flags);
429 err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
432 if (cmd->convert_src == TRIG_TIMER) {
433 arg = cmd->convert_arg;
434 daqp_ns_to_timer(&arg, cmd->flags);
435 err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
444 static int daqp_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
446 struct daqp_private *devpriv = dev->private;
447 struct comedi_cmd *cmd = &s->async->cmd;
449 int scanlist_start_on_every_entry;
458 /* Stop any running conversion */
459 daqp_ai_cancel(dev, s);
461 outb(0, dev->iobase + DAQP_AUX);
463 /* Reset scan list queue */
464 outb(DAQP_COMMAND_RSTQ, dev->iobase + DAQP_COMMAND);
466 /* Program pacer clock
468 * There's two modes we can operate in. If convert_src is
469 * TRIG_TIMER, then convert_arg specifies the time between
470 * each conversion, so we program the pacer clock to that
471 * frequency and set the SCANLIST_START bit on every scanlist
472 * entry. Otherwise, convert_src is TRIG_NOW, which means
473 * we want the fastest possible conversions, scan_begin_src
474 * is TRIG_TIMER, and scan_begin_arg specifies the time between
475 * each scan, so we program the pacer clock to this frequency
476 * and only set the SCANLIST_START bit on the first entry.
479 if (cmd->convert_src == TRIG_TIMER) {
480 counter = daqp_ns_to_timer(&cmd->convert_arg, cmd->flags);
481 outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
482 outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
483 outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
484 scanlist_start_on_every_entry = 1;
486 counter = daqp_ns_to_timer(&cmd->scan_begin_arg, cmd->flags);
487 outb(counter & 0xff, dev->iobase + DAQP_PACER_LOW);
488 outb((counter >> 8) & 0xff, dev->iobase + DAQP_PACER_MID);
489 outb((counter >> 16) & 0xff, dev->iobase + DAQP_PACER_HIGH);
490 scanlist_start_on_every_entry = 0;
493 /* Program scan list */
494 for (i = 0; i < cmd->chanlist_len; i++) {
495 int start = (i == 0 || scanlist_start_on_every_entry);
497 daqp_ai_set_one_scanlist_entry(dev, cmd->chanlist[i], start);
500 /* Now it's time to program the FIFO threshold, basically the
501 * number of samples the card will buffer before it interrupts
504 * If we don't have a stop count, then use half the size of
505 * the FIFO (the manufacturer's recommendation). Consider
506 * that the FIFO can hold 2K samples (4K bytes). With the
507 * threshold set at half the FIFO size, we have a margin of
508 * error of 1024 samples. At the chip's maximum sample rate
509 * of 100,000 Hz, the CPU would have to delay interrupt
510 * service for a full 10 milliseconds in order to lose data
511 * here (as opposed to higher up in the kernel). I've never
512 * seen it happen. However, for slow sample rates it may
513 * buffer too much data and introduce too much delay for the
516 * If we have a stop count, then things get more interesting.
517 * If the stop count is less than the FIFO size (actually
518 * three-quarters of the FIFO size - see below), we just use
519 * the stop count itself as the threshold, the card interrupts
520 * us when that many samples have been taken, and we kill the
521 * acquisition at that point and are done. If the stop count
522 * is larger than that, then we divide it by 2 until it's less
523 * than three quarters of the FIFO size (we always leave the
524 * top quarter of the FIFO as protection against sluggish CPU
525 * interrupt response) and use that as the threshold. So, if
526 * the stop count is 4000 samples, we divide by two twice to
527 * get 1000 samples, use that as the threshold, take four
528 * interrupts to get our 4000 samples and are done.
530 * The algorithm could be more clever. For example, if 81000
531 * samples are requested, we could set the threshold to 1500
532 * samples and take 54 interrupts to get 81000. But 54 isn't
533 * a power of two, so this algorithm won't find that option.
534 * Instead, it'll set the threshold at 1266 and take 64
535 * interrupts to get 81024 samples, of which the last 24 will
536 * be discarded... but we won't get the last interrupt until
537 * they've been collected. To find the first option, the
538 * computer could look at the prime decomposition of the
539 * sample count (81000 = 3^4 * 5^3 * 2^3) and factor it into a
540 * threshold (1500 = 3 * 5^3 * 2^2) and an interrupt count (54
541 * = 3^3 * 2). Hmmm... a one-line while loop or prime
542 * decomposition of integers... I'll leave it the way it is.
544 * I'll also note a mini-race condition before ignoring it in
545 * the code. Let's say we're taking 4000 samples, as before.
546 * After 1000 samples, we get an interrupt. But before that
547 * interrupt is completely serviced, another sample is taken
548 * and loaded into the FIFO. Since the interrupt handler
549 * empties the FIFO before returning, it will read 1001 samples.
550 * If that happens four times, we'll end up taking 4004 samples,
551 * not 4000. The interrupt handler will discard the extra four
552 * samples (by halting the acquisition with four samples still
553 * in the FIFO), but we will have to wait for them.
555 * In short, this code works pretty well, but for either of
556 * the two reasons noted, might end up waiting for a few more
557 * samples than actually requested. Shouldn't make too much
561 /* Save away the number of conversions we should perform, and
562 * compute the FIFO threshold (in bytes, not samples - that's
563 * why we multiple devpriv->count by 2 = sizeof(sample))
566 if (cmd->stop_src == TRIG_COUNT) {
567 unsigned long long nsamples;
568 unsigned long long nbytes;
570 nsamples = (unsigned long long)cmd->stop_arg *
572 nbytes = nsamples * comedi_bytes_per_sample(s);
573 while (nbytes > DAQP_FIFO_SIZE * 3 / 4)
577 threshold = DAQP_FIFO_SIZE / 2;
580 /* Reset data FIFO (see page 28 of DAQP User's Manual) */
582 outb(DAQP_COMMAND_RSTF, dev->iobase + DAQP_COMMAND);
584 /* Set FIFO threshold. First two bytes are near-empty
585 * threshold, which is unused; next two bytes are near-full
586 * threshold. We computed the number of bytes we want in the
587 * FIFO when the interrupt is generated, what the card wants
588 * is actually the number of available bytes left in the FIFO
589 * when the interrupt is to happen.
592 outb(0x00, dev->iobase + DAQP_FIFO);
593 outb(0x00, dev->iobase + DAQP_FIFO);
595 outb((DAQP_FIFO_SIZE - threshold) & 0xff, dev->iobase + DAQP_FIFO);
596 outb((DAQP_FIFO_SIZE - threshold) >> 8, dev->iobase + DAQP_FIFO);
600 v = DAQP_CONTROL_TRIGGER_CONTINUOUS | DAQP_CONTROL_TRIGGER_INTERNAL
601 | DAQP_CONTROL_PACER_5MHz | DAQP_CONTROL_FIFO_INT_ENABLE;
603 outb(v, dev->iobase + DAQP_CONTROL);
605 /* Reset any pending interrupts (my card has a tendency to require
606 * require multiple reads on the status register to achieve this)
610 && (inb(dev->iobase + DAQP_STATUS) & DAQP_STATUS_EVENTS))
613 dev_err(dev->class_dev,
614 "couldn't clear interrupts in status register\n");
618 devpriv->interrupt_mode = buffer;
620 /* Start conversion */
621 outb(DAQP_COMMAND_ARM | DAQP_COMMAND_FIFO_DATA,
622 dev->iobase + DAQP_COMMAND);
627 static int daqp_ao_insn_write(struct comedi_device *dev,
628 struct comedi_subdevice *s,
629 struct comedi_insn *insn,
632 struct daqp_private *devpriv = dev->private;
633 unsigned int chan = CR_CHAN(insn->chanspec);
639 /* Make sure D/A update mode is direct update */
640 outb(0, dev->iobase + DAQP_AUX);
642 for (i = 0; i > insn->n; i++) {
643 unsigned val = data[i];
645 s->readback[chan] = val;
648 val ^= 0x0800; /* Flip the sign */
651 outw(val, dev->iobase + DAQP_DA);
657 static int daqp_di_insn_bits(struct comedi_device *dev,
658 struct comedi_subdevice *s,
659 struct comedi_insn *insn,
662 struct daqp_private *devpriv = dev->private;
667 data[0] = inb(dev->iobase + DAQP_DIGITAL_IO);
672 static int daqp_do_insn_bits(struct comedi_device *dev,
673 struct comedi_subdevice *s,
674 struct comedi_insn *insn,
677 struct daqp_private *devpriv = dev->private;
682 if (comedi_dio_update_state(s, data))
683 outb(s->state, dev->iobase + DAQP_DIGITAL_IO);
690 static int daqp_auto_attach(struct comedi_device *dev,
691 unsigned long context)
693 struct pcmcia_device *link = comedi_to_pcmcia_dev(dev);
694 struct daqp_private *devpriv;
695 struct comedi_subdevice *s;
698 devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
702 link->config_flags |= CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
703 ret = comedi_pcmcia_enable(dev, NULL);
706 dev->iobase = link->resource[0]->start;
709 ret = pcmcia_request_irq(link, daqp_interrupt);
713 ret = comedi_alloc_subdevices(dev, 4);
717 s = &dev->subdevices[0];
718 dev->read_subdev = s;
719 s->type = COMEDI_SUBD_AI;
720 s->subdev_flags = SDF_READABLE | SDF_GROUND | SDF_DIFF | SDF_CMD_READ;
722 s->len_chanlist = 2048;
724 s->range_table = &range_daqp_ai;
725 s->insn_read = daqp_ai_insn_read;
726 s->do_cmdtest = daqp_ai_cmdtest;
727 s->do_cmd = daqp_ai_cmd;
728 s->cancel = daqp_ai_cancel;
730 s = &dev->subdevices[1];
731 s->type = COMEDI_SUBD_AO;
732 s->subdev_flags = SDF_WRITABLE;
735 s->range_table = &range_bipolar5;
736 s->insn_write = daqp_ao_insn_write;
738 ret = comedi_alloc_subdev_readback(s);
742 s = &dev->subdevices[2];
743 s->type = COMEDI_SUBD_DI;
744 s->subdev_flags = SDF_READABLE;
747 s->insn_bits = daqp_di_insn_bits;
749 s = &dev->subdevices[3];
750 s->type = COMEDI_SUBD_DO;
751 s->subdev_flags = SDF_WRITABLE;
754 s->insn_bits = daqp_do_insn_bits;
759 static struct comedi_driver driver_daqp = {
760 .driver_name = "quatech_daqp_cs",
761 .module = THIS_MODULE,
762 .auto_attach = daqp_auto_attach,
763 .detach = comedi_pcmcia_disable,
766 static int daqp_cs_suspend(struct pcmcia_device *link)
768 struct comedi_device *dev = link->priv;
769 struct daqp_private *devpriv = dev ? dev->private : NULL;
771 /* Mark the device as stopped, to block IO until later */
778 static int daqp_cs_resume(struct pcmcia_device *link)
780 struct comedi_device *dev = link->priv;
781 struct daqp_private *devpriv = dev ? dev->private : NULL;
789 static int daqp_cs_attach(struct pcmcia_device *link)
791 return comedi_pcmcia_auto_config(link, &driver_daqp);
794 static const struct pcmcia_device_id daqp_cs_id_table[] = {
795 PCMCIA_DEVICE_MANF_CARD(0x0137, 0x0027),
798 MODULE_DEVICE_TABLE(pcmcia, daqp_cs_id_table);
800 static struct pcmcia_driver daqp_cs_driver = {
801 .name = "quatech_daqp_cs",
802 .owner = THIS_MODULE,
803 .id_table = daqp_cs_id_table,
804 .probe = daqp_cs_attach,
805 .remove = comedi_pcmcia_auto_unconfig,
806 .suspend = daqp_cs_suspend,
807 .resume = daqp_cs_resume,
809 module_comedi_pcmcia_driver(driver_daqp, daqp_cs_driver);
811 MODULE_DESCRIPTION("Comedi driver for Quatech DAQP PCMCIA data capture cards");
812 MODULE_AUTHOR("Brent Baccala <baccala@freesoft.org>");
813 MODULE_LICENSE("GPL");