Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / comedi / drivers / ni_daq_700.c
CommitLineData
1f9bbbe2
FB
1/*
2 * comedi/drivers/ni_daq_700.c
3 * Driver for DAQCard-700 DIO only
4 * copied from 8255
5 *
6 * COMEDI - Linux Control and Measurement Device Interface
7 * Copyright (C) 1998 David A. Schleef <ds@schleef.org>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 *
23 */
24
25/*
26Driver: ni_daq_700
27Description: National Instruments PCMCIA DAQCard-700 DIO only
28Author: Fred Brooks <nsaspook@nsaspook.com>,
29 based on ni_daq_dio24 by Daniel Vecino Castel <dvecino@able.es>
30Devices: [National Instruments] PCMCIA DAQ-Card-700 (ni_daq_700)
31Status: works
32Updated: Thu, 21 Feb 2008 12:07:20 +0000
33
34The daqcard-700 appears in Comedi as a single digital I/O subdevice with
3516 channels. The channel 0 corresponds to the daqcard-700's output
36port, bit 0; channel 8 corresponds to the input port, bit 0.
37
38Direction configuration: channels 0-7 output, 8-15 input (8225 device
39emu as port A output, port B input, port C N/A).
40
41IRQ is assigned but not used.
42*/
43
25436dc9 44#include <linux/interrupt.h>
5a0e3ad6 45#include <linux/slab.h>
1f9bbbe2
FB
46#include "../comedidev.h"
47
48#include <linux/ioport.h>
1f9bbbe2 49
1f9bbbe2
FB
50#include <pcmcia/cs.h>
51#include <pcmcia/cistpl.h>
52#include <pcmcia/cisreg.h>
53#include <pcmcia/ds.h>
54
55static struct pcmcia_device *pcmcia_cur_dev = NULL;
56
2696fb57 57#define DIO700_SIZE 8 /* size of io region used by board */
1f9bbbe2 58
0a85b6f0
MT
59static int dio700_attach(struct comedi_device *dev,
60 struct comedi_devconfig *it);
da91b269 61static int dio700_detach(struct comedi_device *dev);
1f9bbbe2
FB
62
63enum dio700_bustype { pcmcia_bustype };
64
4cab3740 65struct dio700_board {
1f9bbbe2 66 const char *name;
2696fb57
BP
67 int device_id; /* device id for pcmcia board */
68 enum dio700_bustype bustype; /* PCMCIA */
69 int have_dio; /* have daqcard-700 dio */
70 /* function pointers so we can use inb/outb or readb/writeb */
71 /* as appropriate */
1f9bbbe2
FB
72 unsigned int (*read_byte) (unsigned int address);
73 void (*write_byte) (unsigned int byte, unsigned int address);
4cab3740 74};
1f9bbbe2 75
4cab3740 76static const struct dio700_board dio700_boards[] = {
1f9bbbe2 77 {
0a85b6f0 78 .name = "daqcard-700",
9a16a92c
GH
79 /* 0x10b is manufacturer id, 0x4743 is device id */
80 .device_id = 0x4743,
0a85b6f0
MT
81 .bustype = pcmcia_bustype,
82 .have_dio = 1,
83 },
1f9bbbe2 84 {
0a85b6f0 85 .name = "ni_daq_700",
9a16a92c
GH
86 /* 0x10b is manufacturer id, 0x4743 is device id */
87 .device_id = 0x4743,
0a85b6f0
MT
88 .bustype = pcmcia_bustype,
89 .have_dio = 1,
90 },
1f9bbbe2
FB
91};
92
93/*
94 * Useful for shorthand access to the particular board structure
95 */
4cab3740 96#define thisboard ((const struct dio700_board *)dev->board_ptr)
1f9bbbe2 97
adf32843
BP
98struct dio700_private {
99
1f9bbbe2 100 int data; /* number of data points left to be taken */
adf32843
BP
101};
102
adf32843 103#define devpriv ((struct dio700_private *)dev->private)
1f9bbbe2 104
139dfbdf 105static struct comedi_driver driver_dio700 = {
68c3dbff
BP
106 .driver_name = "ni_daq_700",
107 .module = THIS_MODULE,
108 .attach = dio700_attach,
109 .detach = dio700_detach,
8629efa4 110 .num_names = ARRAY_SIZE(dio700_boards),
68c3dbff
BP
111 .board_name = &dio700_boards[0].name,
112 .offset = sizeof(struct dio700_board),
1f9bbbe2
FB
113};
114
115/* the real driver routines */
116
117#define _700_SIZE 8
118
119#define _700_DATA 0
120
121#define DIO_W 0x04
122#define DIO_R 0x05
123
124struct subdev_700_struct {
125 unsigned long cb_arg;
126 int (*cb_func) (int, int, int, unsigned long);
127 int have_irq;
128};
129
130#define CALLBACK_ARG (((struct subdev_700_struct *)s->private)->cb_arg)
131#define CALLBACK_FUNC (((struct subdev_700_struct *)s->private)->cb_func)
132#define subdevpriv ((struct subdev_700_struct *)s->private)
133
da91b269 134static void do_config(struct comedi_device *dev, struct comedi_subdevice *s);
1f9bbbe2 135
da91b269 136void subdev_700_interrupt(struct comedi_device *dev, struct comedi_subdevice *s)
1f9bbbe2 137{
790c5541 138 short d;
1f9bbbe2
FB
139
140 d = CALLBACK_FUNC(0, _700_DATA, 0, CALLBACK_ARG);
141
142 comedi_buf_put(s->async, d);
143 s->async->events |= COMEDI_CB_EOS;
144
145 comedi_event(dev, s);
146}
ee21350f 147EXPORT_SYMBOL(subdev_700_interrupt);
1f9bbbe2
FB
148
149static int subdev_700_cb(int dir, int port, int data, unsigned long arg)
150{
151 /* port is always A for output and B for input (8255 emu) */
152 unsigned long iobase = arg;
153
154 if (dir) {
155 outb(data, iobase + DIO_W);
156 return 0;
157 } else {
158 return inb(iobase + DIO_R);
159 }
160}
161
0a85b6f0
MT
162static int subdev_700_insn(struct comedi_device *dev,
163 struct comedi_subdevice *s, struct comedi_insn *insn,
164 unsigned int *data)
1f9bbbe2
FB
165{
166 if (data[0]) {
167 s->state &= ~data[0];
168 s->state |= (data[0] & data[1]);
169
170 if (data[0] & 0xff)
171 CALLBACK_FUNC(1, _700_DATA, s->state & 0xff,
0a85b6f0 172 CALLBACK_ARG);
1f9bbbe2
FB
173 }
174
175 data[1] = s->state & 0xff;
176 data[1] |= CALLBACK_FUNC(0, _700_DATA, 0, CALLBACK_ARG) << 8;
177
178 return 2;
179}
180
0a85b6f0
MT
181static int subdev_700_insn_config(struct comedi_device *dev,
182 struct comedi_subdevice *s,
183 struct comedi_insn *insn, unsigned int *data)
1f9bbbe2
FB
184{
185
186 switch (data[0]) {
187 case INSN_CONFIG_DIO_INPUT:
188 break;
189 case INSN_CONFIG_DIO_OUTPUT:
190 break;
191 case INSN_CONFIG_DIO_QUERY:
192 data[1] =
0a85b6f0
MT
193 (s->
194 io_bits & (1 << CR_CHAN(insn->chanspec))) ? COMEDI_OUTPUT :
195 COMEDI_INPUT;
1f9bbbe2
FB
196 return insn->n;
197 break;
198 default:
199 return -EINVAL;
200 }
201
202 return 1;
203}
204
da91b269 205static void do_config(struct comedi_device *dev, struct comedi_subdevice *s)
1f9bbbe2
FB
206{ /* use powerup defaults */
207 return;
208}
209
0a85b6f0
MT
210static int subdev_700_cmdtest(struct comedi_device *dev,
211 struct comedi_subdevice *s,
212 struct comedi_cmd *cmd)
1f9bbbe2
FB
213{
214 int err = 0;
215 unsigned int tmp;
216
217 /* step 1 */
218
219 tmp = cmd->start_src;
220 cmd->start_src &= TRIG_NOW;
221 if (!cmd->start_src || tmp != cmd->start_src)
222 err++;
223
224 tmp = cmd->scan_begin_src;
225 cmd->scan_begin_src &= TRIG_EXT;
226 if (!cmd->scan_begin_src || tmp != cmd->scan_begin_src)
227 err++;
228
229 tmp = cmd->convert_src;
230 cmd->convert_src &= TRIG_FOLLOW;
231 if (!cmd->convert_src || tmp != cmd->convert_src)
232 err++;
233
234 tmp = cmd->scan_end_src;
235 cmd->scan_end_src &= TRIG_COUNT;
236 if (!cmd->scan_end_src || tmp != cmd->scan_end_src)
237 err++;
238
239 tmp = cmd->stop_src;
240 cmd->stop_src &= TRIG_NONE;
241 if (!cmd->stop_src || tmp != cmd->stop_src)
242 err++;
243
244 if (err)
245 return 1;
246
247 /* step 2 */
248
249 if (err)
250 return 2;
251
252 /* step 3 */
253
254 if (cmd->start_arg != 0) {
255 cmd->start_arg = 0;
256 err++;
257 }
258 if (cmd->scan_begin_arg != 0) {
259 cmd->scan_begin_arg = 0;
260 err++;
261 }
262 if (cmd->convert_arg != 0) {
263 cmd->convert_arg = 0;
264 err++;
265 }
266 if (cmd->scan_end_arg != 1) {
267 cmd->scan_end_arg = 1;
268 err++;
269 }
270 if (cmd->stop_arg != 0) {
271 cmd->stop_arg = 0;
272 err++;
273 }
274
275 if (err)
276 return 3;
277
278 /* step 4 */
279
280 if (err)
281 return 4;
282
283 return 0;
284}
285
da91b269 286static int subdev_700_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
1f9bbbe2
FB
287{
288 /* FIXME */
289
290 return 0;
291}
292
0a85b6f0
MT
293static int subdev_700_cancel(struct comedi_device *dev,
294 struct comedi_subdevice *s)
1f9bbbe2
FB
295{
296 /* FIXME */
297
298 return 0;
299}
300
0a85b6f0
MT
301int subdev_700_init(struct comedi_device *dev, struct comedi_subdevice *s,
302 int (*cb) (int, int, int, unsigned long), unsigned long arg)
1f9bbbe2
FB
303{
304 s->type = COMEDI_SUBD_DIO;
305 s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
306 s->n_chan = 16;
307 s->range_table = &range_digital;
308 s->maxdata = 1;
309
310 s->private = kmalloc(sizeof(struct subdev_700_struct), GFP_KERNEL);
311 if (!s->private)
312 return -ENOMEM;
313
314 CALLBACK_ARG = arg;
9a16a92c 315 if (cb == NULL)
1f9bbbe2 316 CALLBACK_FUNC = subdev_700_cb;
9a16a92c 317 else
1f9bbbe2 318 CALLBACK_FUNC = cb;
9a16a92c 319
1f9bbbe2
FB
320 s->insn_bits = subdev_700_insn;
321 s->insn_config = subdev_700_insn_config;
322
323 s->state = 0;
324 s->io_bits = 0x00ff;
325 do_config(dev, s);
326
327 return 0;
328}
ee21350f 329EXPORT_SYMBOL(subdev_700_init);
1f9bbbe2 330
da91b269 331int subdev_700_init_irq(struct comedi_device *dev, struct comedi_subdevice *s,
0a85b6f0
MT
332 int (*cb) (int, int, int, unsigned long),
333 unsigned long arg)
1f9bbbe2
FB
334{
335 int ret;
336
337 ret = subdev_700_init(dev, s, cb, arg);
338 if (ret < 0)
339 return ret;
340
341 s->do_cmdtest = subdev_700_cmdtest;
342 s->do_cmd = subdev_700_cmd;
343 s->cancel = subdev_700_cancel;
344
345 subdevpriv->have_irq = 1;
346
347 return 0;
348}
ee21350f 349EXPORT_SYMBOL(subdev_700_init_irq);
1f9bbbe2 350
da91b269 351void subdev_700_cleanup(struct comedi_device *dev, struct comedi_subdevice *s)
1f9bbbe2 352{
9a16a92c
GH
353 if (s->private)
354 if (subdevpriv->have_irq)
1f9bbbe2 355
9a16a92c 356 kfree(s->private);
1f9bbbe2 357}
1f9bbbe2 358EXPORT_SYMBOL(subdev_700_cleanup);
1f9bbbe2 359
da91b269 360static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it)
1f9bbbe2 361{
34c43922 362 struct comedi_subdevice *s;
1f9bbbe2
FB
363 unsigned long iobase = 0;
364#ifdef incomplete
365 unsigned int irq = 0;
366#endif
367 struct pcmcia_device *link;
368
369 /* allocate and initialize dev->private */
adf32843 370 if (alloc_private(dev, sizeof(struct dio700_private)) < 0)
1f9bbbe2
FB
371 return -ENOMEM;
372
2696fb57 373 /* get base address, irq etc. based on bustype */
1f9bbbe2
FB
374 switch (thisboard->bustype) {
375 case pcmcia_bustype:
376 link = pcmcia_cur_dev; /* XXX hack */
377 if (!link)
378 return -EIO;
9a017a91 379 iobase = link->resource[0]->start;
1f9bbbe2 380#ifdef incomplete
eb14120f 381 irq = link->irq;
1f9bbbe2
FB
382#endif
383 break;
384 default:
385 printk("bug! couldn't determine board type\n");
386 return -EINVAL;
387 break;
388 }
389 printk("comedi%d: ni_daq_700: %s, io 0x%lx", dev->minor,
0a85b6f0 390 thisboard->name, iobase);
1f9bbbe2 391#ifdef incomplete
9a16a92c 392 if (irq)
1f9bbbe2 393 printk(", irq %u", irq);
9a16a92c 394
1f9bbbe2
FB
395#endif
396
397 printk("\n");
398
399 if (iobase == 0) {
400 printk("io base address is zero!\n");
401 return -EINVAL;
402 }
403
404 dev->iobase = iobase;
405
406#ifdef incomplete
407 /* grab our IRQ */
408 dev->irq = irq;
409#endif
410
411 dev->board_name = thisboard->name;
412
413 if (alloc_subdevices(dev, 1) < 0)
414 return -ENOMEM;
415
416 /* DAQCard-700 dio */
417 s = dev->subdevices + 0;
418 subdev_700_init(dev, s, NULL, dev->iobase);
419
420 return 0;
421};
422
da91b269 423static int dio700_detach(struct comedi_device *dev)
1f9bbbe2
FB
424{
425 printk("comedi%d: ni_daq_700: cs-remove\n", dev->minor);
426
427 if (dev->subdevices)
428 subdev_700_cleanup(dev, dev->subdevices + 0);
429
430 if (thisboard->bustype != pcmcia_bustype && dev->iobase)
431 release_region(dev->iobase, DIO700_SIZE);
432 if (dev->irq)
5f74ea14 433 free_irq(dev->irq, dev);
1f9bbbe2
FB
434
435 return 0;
436};
437
55a19b39 438/* PCMCIA crap -- watch your words, please! */
1f9bbbe2
FB
439
440static void dio700_config(struct pcmcia_device *link);
441static void dio700_release(struct pcmcia_device *link);
442static int dio700_cs_suspend(struct pcmcia_device *p_dev);
443static int dio700_cs_resume(struct pcmcia_device *p_dev);
444
445/*
446 The attach() and detach() entry points are used to create and destroy
447 "instances" of the driver, where each instance represents everything
448 needed to manage one actual PCMCIA card.
449*/
450
451static int dio700_cs_attach(struct pcmcia_device *);
452static void dio700_cs_detach(struct pcmcia_device *);
453
454/*
455 You'll also need to prototype all the functions that will actually
456 be used to talk to your device. See 'memory_cs' for a good example
457 of a fully self-sufficient driver; the other drivers rely more or
458 less on other parts of the kernel.
459*/
460
30570f0d 461struct local_info_t {
1f9bbbe2 462 struct pcmcia_device *link;
1f9bbbe2
FB
463 int stop;
464 struct bus_operations *bus;
30570f0d 465};
1f9bbbe2
FB
466
467/*======================================================================
468
469 dio700_cs_attach() creates an "instance" of the driver, allocating
470 local data structures for one device. The device is registered
471 with Card Services.
472
473 The dev_link structure is initialized, but we don't actually
474 configure the card at this point -- we wait until we receive a
475 card insertion event.
476
477======================================================================*/
478
479static int dio700_cs_attach(struct pcmcia_device *link)
480{
30570f0d 481 struct local_info_t *local;
1f9bbbe2
FB
482
483 printk(KERN_INFO "ni_daq_700: cs-attach\n");
484
55a19b39 485 dev_dbg(&link->dev, "dio700_cs_attach()\n");
1f9bbbe2
FB
486
487 /* Allocate space for private device-specific data */
30570f0d 488 local = kzalloc(sizeof(struct local_info_t), GFP_KERNEL);
1f9bbbe2
FB
489 if (!local)
490 return -ENOMEM;
491 local->link = link;
492 link->priv = local;
493
1f9bbbe2
FB
494 /*
495 General socket configuration defaults can go here. In this
496 client, we assume very little, and rely on the CIS for almost
497 everything. In most clients, many details (i.e., number, sizes,
498 and attributes of IO windows) are fixed by the nature of the
499 device, and can be hard-wired here.
500 */
501 link->conf.Attributes = 0;
502 link->conf.IntType = INT_MEMORY_AND_IO;
503
504 pcmcia_cur_dev = link;
505
506 dio700_config(link);
507
508 return 0;
509} /* dio700_cs_attach */
510
511/*======================================================================
512
513 This deletes a driver "instance". The device is de-registered
514 with Card Services. If it has been released, all local data
515 structures are freed. Otherwise, the structures will be freed
516 when the device is released.
517
518======================================================================*/
519
520static void dio700_cs_detach(struct pcmcia_device *link)
521{
522
523 printk(KERN_INFO "ni_daq_700: cs-detach!\n");
524
55a19b39 525 dev_dbg(&link->dev, "dio700_cs_detach\n");
1f9bbbe2 526
cdc268b4
JMC
527 ((struct local_info_t *)link->priv)->stop = 1;
528 dio700_release(link);
1f9bbbe2 529
30570f0d 530 /* This points to the parent struct local_info_t struct */
f25bd6bf 531 kfree(link->priv);
1f9bbbe2
FB
532
533} /* dio700_cs_detach */
534
535/*======================================================================
536
537 dio700_config() is scheduled to run after a CARD_INSERTION event
538 is received, to configure the PCMCIA socket, and to make the
539 device available to the system.
540
541======================================================================*/
542
55a19b39
DB
543static int dio700_pcmcia_config_loop(struct pcmcia_device *p_dev,
544 cistpl_cftable_entry_t *cfg,
545 cistpl_cftable_entry_t *dflt,
546 unsigned int vcc,
547 void *priv_data)
1f9bbbe2 548{
55a19b39
DB
549 if (cfg->index == 0)
550 return -ENODEV;
1f9bbbe2 551
55a19b39
DB
552 /* Does this card need audio output? */
553 if (cfg->flags & CISTPL_CFTABLE_AUDIO) {
554 p_dev->conf.Attributes |= CONF_ENABLE_SPKR;
555 p_dev->conf.Status = CCSR_AUDIO_ENA;
1f9bbbe2 556 }
c3744138 557
55a19b39 558 /* Do we need to allocate an interrupt? */
eb14120f 559 p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
55a19b39
DB
560
561 /* IO window settings */
90abdc3b 562 p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
55a19b39
DB
563 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
564 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
90abdc3b
DB
565 p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
566 p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
567 p_dev->resource[0]->flags |=
568 pcmcia_io_cfg_data_width(io->flags);
569 p_dev->resource[0]->start = io->win[0].base;
570 p_dev->resource[0]->end = io->win[0].len;
55a19b39 571 if (io->nwin > 1) {
90abdc3b
DB
572 p_dev->resource[1]->flags = p_dev->resource[0]->flags;
573 p_dev->resource[1]->start = io->win[1].base;
574 p_dev->resource[1]->end = io->win[1].len;
55a19b39
DB
575 }
576 /* This reserves IO space but doesn't actually enable it */
90abdc3b 577 if (pcmcia_request_io(p_dev) != 0)
55a19b39 578 return -ENODEV;
1f9bbbe2 579 }
c3744138 580
55a19b39
DB
581 /* If we got this far, we're cool! */
582 return 0;
583}
1f9bbbe2 584
55a19b39
DB
585static void dio700_config(struct pcmcia_device *link)
586{
55a19b39
DB
587 win_req_t req;
588 int ret;
1f9bbbe2 589
55a19b39 590 printk(KERN_INFO "ni_daq_700: cs-config\n");
1f9bbbe2 591
55a19b39 592 dev_dbg(&link->dev, "dio700_config\n");
c3744138 593
0f52e86d 594 ret = pcmcia_loop_config(link, dio700_pcmcia_config_loop, NULL);
55a19b39
DB
595 if (ret) {
596 dev_warn(&link->dev, "no configuration found\n");
597 goto failed;
1f9bbbe2
FB
598 }
599
eb14120f
DB
600 if (!link->irq)
601 goto failed;
1f9bbbe2
FB
602
603 /*
604 This actually configures the PCMCIA socket -- setting up
605 the I/O windows and the interrupt mapping, and putting the
606 card and host interface into "Memory and IO" mode.
607 */
55a19b39
DB
608 ret = pcmcia_request_configuration(link, &link->conf);
609 if (ret != 0)
610 goto failed;
1f9bbbe2 611
1f9bbbe2 612 /* Finally, report what we've done */
cdc268b4 613 dev_info(&link->dev, "index 0x%02x", link->conf.ConfigIndex);
1f9bbbe2 614 if (link->conf.Attributes & CONF_ENABLE_IRQ)
eb14120f 615 printk(", irq %d", link->irq);
9a017a91
DB
616 if (link->resource[0])
617 printk(", io %pR", link->resource[0]);
618 if (link->resource[1])
619 printk(" & %pR", link->resource[1]);
1f9bbbe2
FB
620 printk("\n");
621
622 return;
623
55a19b39 624failed:
1f9bbbe2
FB
625 printk(KERN_INFO "ni_daq_700 cs failed");
626 dio700_release(link);
627
628} /* dio700_config */
629
630static void dio700_release(struct pcmcia_device *link)
631{
55a19b39 632 dev_dbg(&link->dev, "dio700_release\n");
1f9bbbe2
FB
633
634 pcmcia_disable_device(link);
635} /* dio700_release */
636
637/*======================================================================
638
639 The card status event handler. Mostly, this schedules other
640 stuff to run after an event is received.
641
642 When a CARD_REMOVAL event is received, we immediately set a
643 private flag to block future accesses to this device. All the
644 functions that actually access the device should check this flag
645 to make sure the card is still present.
646
647======================================================================*/
648
649static int dio700_cs_suspend(struct pcmcia_device *link)
650{
30570f0d 651 struct local_info_t *local = link->priv;
1f9bbbe2
FB
652
653 /* Mark the device as stopped, to block IO until later */
654 local->stop = 1;
655 return 0;
656} /* dio700_cs_suspend */
657
658static int dio700_cs_resume(struct pcmcia_device *link)
659{
30570f0d 660 struct local_info_t *local = link->priv;
1f9bbbe2
FB
661
662 local->stop = 0;
663 return 0;
664} /* dio700_cs_resume */
665
666/*====================================================================*/
667
668static struct pcmcia_device_id dio700_cs_ids[] = {
669 /* N.B. These IDs should match those in dio700_boards */
670 PCMCIA_DEVICE_MANF_CARD(0x010b, 0x4743), /* daqcard-700 */
671 PCMCIA_DEVICE_NULL
672};
673
6c7f8196 674
1f9bbbe2 675MODULE_DEVICE_TABLE(pcmcia, dio700_cs_ids);
6c7f8196
AK
676MODULE_AUTHOR("Fred Brooks <nsaspook@nsaspook.com>");
677MODULE_DESCRIPTION("Comedi driver for National Instruments "
678 "PCMCIA DAQCard-700 DIO");
679MODULE_LICENSE("GPL");
1f9bbbe2
FB
680
681struct pcmcia_driver dio700_cs_driver = {
682 .probe = dio700_cs_attach,
683 .remove = dio700_cs_detach,
684 .suspend = dio700_cs_suspend,
685 .resume = dio700_cs_resume,
686 .id_table = dio700_cs_ids,
687 .owner = THIS_MODULE,
688 .drv = {
1685e633 689 .name = "ni_daq_700",
1f9bbbe2
FB
690 },
691};
692
693static int __init init_dio700_cs(void)
694{
1f9bbbe2
FB
695 pcmcia_register_driver(&dio700_cs_driver);
696 return 0;
697}
698
699static void __exit exit_dio700_cs(void)
700{
55a19b39 701 pr_debug("ni_daq_700: unloading\n");
1f9bbbe2
FB
702 pcmcia_unregister_driver(&dio700_cs_driver);
703}
0a85b6f0 704
1f9bbbe2
FB
705int __init init_module(void)
706{
707 int ret;
708
709 ret = init_dio700_cs();
710 if (ret < 0)
711 return ret;
712
713 return comedi_driver_register(&driver_dio700);
714}
715
716void __exit cleanup_module(void)
717{
718 exit_dio700_cs();
719 comedi_driver_unregister(&driver_dio700);
720}