2 comedi/drivers/me4000.c
3 Source code for the Meilhaus ME-4000 board family.
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 2000 David A. Schleef <ds@schleef.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
20 Description: Meilhaus ME-4000 series boards
21 Devices: [Meilhaus] ME-4650 (me4000), ME-4670i, ME-4680, ME-4680i, ME-4680is
22 Author: gg (Guenter Gebhardt <g.gebhardt@meilhaus.com>)
23 Updated: Mon, 18 Mar 2002 15:34:01 -0800
24 Status: broken (no support for loading firmware)
33 Configuration Options: not applicable, uses PCI auto config
35 The firmware required by these boards is available in the
36 comedi_nonfree_firmware tarball available from
37 http://www.comedi.org. However, the driver's support for
38 loading the firmware through comedi_config is currently
43 #include <linux/module.h>
44 #include <linux/delay.h>
45 #include <linux/interrupt.h>
47 #include "../comedi_pci.h"
49 #include "comedi_8254.h"
52 #define ME4000_FIRMWARE "me4000_firmware.bin"
55 * ME4000 Register map and bit defines
57 #define ME4000_AO_CHAN(x) ((x) * 0x18)
59 #define ME4000_AO_CTRL_REG(x) (0x00 + ME4000_AO_CHAN(x))
60 #define ME4000_AO_CTRL_BIT_MODE_0 (1 << 0)
61 #define ME4000_AO_CTRL_BIT_MODE_1 (1 << 1)
62 #define ME4000_AO_CTRL_MASK_MODE (3 << 0)
63 #define ME4000_AO_CTRL_BIT_STOP (1 << 2)
64 #define ME4000_AO_CTRL_BIT_ENABLE_FIFO (1 << 3)
65 #define ME4000_AO_CTRL_BIT_ENABLE_EX_TRIG (1 << 4)
66 #define ME4000_AO_CTRL_BIT_EX_TRIG_EDGE (1 << 5)
67 #define ME4000_AO_CTRL_BIT_IMMEDIATE_STOP (1 << 7)
68 #define ME4000_AO_CTRL_BIT_ENABLE_DO (1 << 8)
69 #define ME4000_AO_CTRL_BIT_ENABLE_IRQ (1 << 9)
70 #define ME4000_AO_CTRL_BIT_RESET_IRQ (1 << 10)
71 #define ME4000_AO_STATUS_REG(x) (0x04 + ME4000_AO_CHAN(x))
72 #define ME4000_AO_STATUS_BIT_FSM (1 << 0)
73 #define ME4000_AO_STATUS_BIT_FF (1 << 1)
74 #define ME4000_AO_STATUS_BIT_HF (1 << 2)
75 #define ME4000_AO_STATUS_BIT_EF (1 << 3)
76 #define ME4000_AO_FIFO_REG(x) (0x08 + ME4000_AO_CHAN(x))
77 #define ME4000_AO_SINGLE_REG(x) (0x0c + ME4000_AO_CHAN(x))
78 #define ME4000_AO_TIMER_REG(x) (0x10 + ME4000_AO_CHAN(x))
79 #define ME4000_AI_CTRL_REG 0x74
80 #define ME4000_AI_STATUS_REG 0x74
81 #define ME4000_AI_CTRL_BIT_MODE_0 (1 << 0)
82 #define ME4000_AI_CTRL_BIT_MODE_1 (1 << 1)
83 #define ME4000_AI_CTRL_BIT_MODE_2 (1 << 2)
84 #define ME4000_AI_CTRL_BIT_SAMPLE_HOLD (1 << 3)
85 #define ME4000_AI_CTRL_BIT_IMMEDIATE_STOP (1 << 4)
86 #define ME4000_AI_CTRL_BIT_STOP (1 << 5)
87 #define ME4000_AI_CTRL_BIT_CHANNEL_FIFO (1 << 6)
88 #define ME4000_AI_CTRL_BIT_DATA_FIFO (1 << 7)
89 #define ME4000_AI_CTRL_BIT_FULLSCALE (1 << 8)
90 #define ME4000_AI_CTRL_BIT_OFFSET (1 << 9)
91 #define ME4000_AI_CTRL_BIT_EX_TRIG_ANALOG (1 << 10)
92 #define ME4000_AI_CTRL_BIT_EX_TRIG (1 << 11)
93 #define ME4000_AI_CTRL_BIT_EX_TRIG_FALLING (1 << 12)
94 #define ME4000_AI_CTRL_BIT_EX_IRQ (1 << 13)
95 #define ME4000_AI_CTRL_BIT_EX_IRQ_RESET (1 << 14)
96 #define ME4000_AI_CTRL_BIT_LE_IRQ (1 << 15)
97 #define ME4000_AI_CTRL_BIT_LE_IRQ_RESET (1 << 16)
98 #define ME4000_AI_CTRL_BIT_HF_IRQ (1 << 17)
99 #define ME4000_AI_CTRL_BIT_HF_IRQ_RESET (1 << 18)
100 #define ME4000_AI_CTRL_BIT_SC_IRQ (1 << 19)
101 #define ME4000_AI_CTRL_BIT_SC_IRQ_RESET (1 << 20)
102 #define ME4000_AI_CTRL_BIT_SC_RELOAD (1 << 21)
103 #define ME4000_AI_STATUS_BIT_EF_CHANNEL (1 << 22)
104 #define ME4000_AI_STATUS_BIT_HF_CHANNEL (1 << 23)
105 #define ME4000_AI_STATUS_BIT_FF_CHANNEL (1 << 24)
106 #define ME4000_AI_STATUS_BIT_EF_DATA (1 << 25)
107 #define ME4000_AI_STATUS_BIT_HF_DATA (1 << 26)
108 #define ME4000_AI_STATUS_BIT_FF_DATA (1 << 27)
109 #define ME4000_AI_STATUS_BIT_LE (1 << 28)
110 #define ME4000_AI_STATUS_BIT_FSM (1 << 29)
111 #define ME4000_AI_CTRL_BIT_EX_TRIG_BOTH (1 << 31)
112 #define ME4000_AI_CHANNEL_LIST_REG 0x78
113 #define ME4000_AI_LIST_INPUT_SINGLE_ENDED (0 << 5)
114 #define ME4000_AI_LIST_INPUT_DIFFERENTIAL (1 << 5)
115 #define ME4000_AI_LIST_RANGE_BIPOLAR_10 (0 << 6)
116 #define ME4000_AI_LIST_RANGE_BIPOLAR_2_5 (1 << 6)
117 #define ME4000_AI_LIST_RANGE_UNIPOLAR_10 (2 << 6)
118 #define ME4000_AI_LIST_RANGE_UNIPOLAR_2_5 (3 << 6)
119 #define ME4000_AI_LIST_LAST_ENTRY (1 << 8)
120 #define ME4000_AI_DATA_REG 0x7c
121 #define ME4000_AI_CHAN_TIMER_REG 0x80
122 #define ME4000_AI_CHAN_PRE_TIMER_REG 0x84
123 #define ME4000_AI_SCAN_TIMER_LOW_REG 0x88
124 #define ME4000_AI_SCAN_TIMER_HIGH_REG 0x8c
125 #define ME4000_AI_SCAN_PRE_TIMER_LOW_REG 0x90
126 #define ME4000_AI_SCAN_PRE_TIMER_HIGH_REG 0x94
127 #define ME4000_AI_START_REG 0x98
128 #define ME4000_IRQ_STATUS_REG 0x9c
129 #define ME4000_IRQ_STATUS_BIT_EX (1 << 0)
130 #define ME4000_IRQ_STATUS_BIT_LE (1 << 1)
131 #define ME4000_IRQ_STATUS_BIT_AI_HF (1 << 2)
132 #define ME4000_IRQ_STATUS_BIT_AO_0_HF (1 << 3)
133 #define ME4000_IRQ_STATUS_BIT_AO_1_HF (1 << 4)
134 #define ME4000_IRQ_STATUS_BIT_AO_2_HF (1 << 5)
135 #define ME4000_IRQ_STATUS_BIT_AO_3_HF (1 << 6)
136 #define ME4000_IRQ_STATUS_BIT_SC (1 << 7)
137 #define ME4000_DIO_PORT_0_REG 0xa0
138 #define ME4000_DIO_PORT_1_REG 0xa4
139 #define ME4000_DIO_PORT_2_REG 0xa8
140 #define ME4000_DIO_PORT_3_REG 0xac
141 #define ME4000_DIO_DIR_REG 0xb0
142 #define ME4000_AO_LOADSETREG_XX 0xb4
143 #define ME4000_DIO_CTRL_REG 0xb8
144 #define ME4000_DIO_CTRL_BIT_MODE_0 (1 << 0)
145 #define ME4000_DIO_CTRL_BIT_MODE_1 (1 << 1)
146 #define ME4000_DIO_CTRL_BIT_MODE_2 (1 << 2)
147 #define ME4000_DIO_CTRL_BIT_MODE_3 (1 << 3)
148 #define ME4000_DIO_CTRL_BIT_MODE_4 (1 << 4)
149 #define ME4000_DIO_CTRL_BIT_MODE_5 (1 << 5)
150 #define ME4000_DIO_CTRL_BIT_MODE_6 (1 << 6)
151 #define ME4000_DIO_CTRL_BIT_MODE_7 (1 << 7)
152 #define ME4000_DIO_CTRL_BIT_FUNCTION_0 (1 << 8)
153 #define ME4000_DIO_CTRL_BIT_FUNCTION_1 (1 << 9)
154 #define ME4000_DIO_CTRL_BIT_FIFO_HIGH_0 (1 << 10)
155 #define ME4000_DIO_CTRL_BIT_FIFO_HIGH_1 (1 << 11)
156 #define ME4000_DIO_CTRL_BIT_FIFO_HIGH_2 (1 << 12)
157 #define ME4000_DIO_CTRL_BIT_FIFO_HIGH_3 (1 << 13)
158 #define ME4000_AO_DEMUX_ADJUST_REG 0xbc
159 #define ME4000_AO_DEMUX_ADJUST_VALUE 0x4c
160 #define ME4000_AI_SAMPLE_COUNTER_REG 0xc0
162 #define ME4000_AI_FIFO_COUNT 2048
164 #define ME4000_AI_MIN_TICKS 66
165 #define ME4000_AI_MIN_SAMPLE_TIME 2000
167 #define ME4000_AI_CHANNEL_LIST_COUNT 1024
170 unsigned long plx_regbase;
173 enum me4000_boardid {
189 struct me4000_board {
201 static const struct me4000_board me4000_boards[] = {
319 static const struct comedi_lrange me4000_ai_range = {
328 static int me4000_xilinx_download(struct comedi_device *dev,
329 const u8 *data, size_t size,
330 unsigned long context)
332 struct pci_dev *pcidev = comedi_to_pci_dev(dev);
333 struct me4000_info *info = dev->private;
334 unsigned long xilinx_iobase = pci_resource_start(pcidev, 5);
335 unsigned int file_length;
343 * Set PLX local interrupt 2 polarity to high.
344 * Interrupt is thrown by init pin of xilinx.
346 outl(PLX9052_INTCSR_LI2POL, info->plx_regbase + PLX9052_INTCSR);
348 /* Set /CS and /WRITE of the Xilinx */
349 val = inl(info->plx_regbase + PLX9052_CNTRL);
350 val |= PLX9052_CNTRL_UIO2_DATA;
351 outl(val, info->plx_regbase + PLX9052_CNTRL);
353 /* Init Xilinx with CS1 */
354 inb(xilinx_iobase + 0xC8);
356 /* Wait until /INIT pin is set */
358 val = inl(info->plx_regbase + PLX9052_INTCSR);
359 if (!(val & PLX9052_INTCSR_LI2STAT)) {
360 dev_err(dev->class_dev, "Can't init Xilinx\n");
364 /* Reset /CS and /WRITE of the Xilinx */
365 val = inl(info->plx_regbase + PLX9052_CNTRL);
366 val &= ~PLX9052_CNTRL_UIO2_DATA;
367 outl(val, info->plx_regbase + PLX9052_CNTRL);
369 /* Download Xilinx firmware */
370 file_length = (((unsigned int)data[0] & 0xff) << 24) +
371 (((unsigned int)data[1] & 0xff) << 16) +
372 (((unsigned int)data[2] & 0xff) << 8) +
373 ((unsigned int)data[3] & 0xff);
376 for (i = 0; i < file_length; i++) {
377 outb(data[16 + i], xilinx_iobase);
380 /* Check if BUSY flag is low */
381 val = inl(info->plx_regbase + PLX9052_CNTRL);
382 if (val & PLX9052_CNTRL_UIO1_DATA) {
383 dev_err(dev->class_dev,
384 "Xilinx is still busy (i = %d)\n", i);
389 /* If done flag is high download was successful */
390 val = inl(info->plx_regbase + PLX9052_CNTRL);
391 if (!(val & PLX9052_CNTRL_UIO0_DATA)) {
392 dev_err(dev->class_dev, "DONE flag is not set\n");
393 dev_err(dev->class_dev, "Download not successful\n");
397 /* Set /CS and /WRITE */
398 val = inl(info->plx_regbase + PLX9052_CNTRL);
399 val |= PLX9052_CNTRL_UIO2_DATA;
400 outl(val, info->plx_regbase + PLX9052_CNTRL);
405 static void me4000_reset(struct comedi_device *dev)
407 struct me4000_info *info = dev->private;
411 /* Make a hardware reset */
412 val = inl(info->plx_regbase + PLX9052_CNTRL);
413 val |= PLX9052_CNTRL_PCI_RESET;
414 outl(val, info->plx_regbase + PLX9052_CNTRL);
415 val &= ~PLX9052_CNTRL_PCI_RESET;
416 outl(val, info->plx_regbase + PLX9052_CNTRL);
418 /* 0x8000 to the DACs means an output voltage of 0V */
419 for (chan = 0; chan < 4; chan++)
420 outl(0x8000, dev->iobase + ME4000_AO_SINGLE_REG(chan));
422 /* Set both stop bits in the analog input control register */
423 outl(ME4000_AI_CTRL_BIT_IMMEDIATE_STOP | ME4000_AI_CTRL_BIT_STOP,
424 dev->iobase + ME4000_AI_CTRL_REG);
426 /* Set both stop bits in the analog output control register */
427 val = ME4000_AO_CTRL_BIT_IMMEDIATE_STOP | ME4000_AO_CTRL_BIT_STOP;
428 for (chan = 0; chan < 4; chan++)
429 outl(val, dev->iobase + ME4000_AO_CTRL_REG(chan));
431 /* Enable interrupts on the PLX */
432 outl(PLX9052_INTCSR_LI1ENAB |
433 PLX9052_INTCSR_LI1POL |
434 PLX9052_INTCSR_PCIENAB, info->plx_regbase + PLX9052_INTCSR);
436 /* Set the adustment register for AO demux */
437 outl(ME4000_AO_DEMUX_ADJUST_VALUE,
438 dev->iobase + ME4000_AO_DEMUX_ADJUST_REG);
441 * Set digital I/O direction for port 0
442 * to output on isolated versions
444 if (!(inl(dev->iobase + ME4000_DIO_DIR_REG) & 0x1))
445 outl(0x1, dev->iobase + ME4000_DIO_CTRL_REG);
448 /*=============================================================================
450 ===========================================================================*/
452 static int me4000_ai_insn_read(struct comedi_device *dev,
453 struct comedi_subdevice *subdevice,
454 struct comedi_insn *insn, unsigned int *data)
456 const struct me4000_board *thisboard = dev->board_ptr;
457 int chan = CR_CHAN(insn->chanspec);
458 int rang = CR_RANGE(insn->chanspec);
459 int aref = CR_AREF(insn->chanspec);
461 unsigned int entry = 0;
467 } else if (insn->n > 1) {
468 dev_err(dev->class_dev, "Invalid instruction length %d\n",
475 entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_2_5;
478 entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_10;
481 entry |= ME4000_AI_LIST_RANGE_BIPOLAR_2_5;
484 entry |= ME4000_AI_LIST_RANGE_BIPOLAR_10;
487 dev_err(dev->class_dev, "Invalid range specified\n");
494 if (chan >= thisboard->ai_nchan) {
495 dev_err(dev->class_dev,
496 "Analog input is not available\n");
499 entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED | chan;
503 if (rang == 0 || rang == 1) {
504 dev_err(dev->class_dev,
505 "Range must be bipolar when aref = diff\n");
509 if (chan >= thisboard->ai_diff_nchan) {
510 dev_err(dev->class_dev,
511 "Analog input is not available\n");
514 entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL | chan;
517 dev_err(dev->class_dev, "Invalid aref specified\n");
521 entry |= ME4000_AI_LIST_LAST_ENTRY;
523 /* Clear channel list, data fifo and both stop bits */
524 tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
525 tmp &= ~(ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
526 ME4000_AI_CTRL_BIT_DATA_FIFO |
527 ME4000_AI_CTRL_BIT_STOP | ME4000_AI_CTRL_BIT_IMMEDIATE_STOP);
528 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
530 /* Set the acquisition mode to single */
531 tmp &= ~(ME4000_AI_CTRL_BIT_MODE_0 | ME4000_AI_CTRL_BIT_MODE_1 |
532 ME4000_AI_CTRL_BIT_MODE_2);
533 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
535 /* Enable channel list and data fifo */
536 tmp |= ME4000_AI_CTRL_BIT_CHANNEL_FIFO | ME4000_AI_CTRL_BIT_DATA_FIFO;
537 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
539 /* Generate channel list entry */
540 outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
542 /* Set the timer to maximum sample rate */
543 outl(ME4000_AI_MIN_TICKS, dev->iobase + ME4000_AI_CHAN_TIMER_REG);
544 outl(ME4000_AI_MIN_TICKS, dev->iobase + ME4000_AI_CHAN_PRE_TIMER_REG);
546 /* Start conversion by dummy read */
547 inl(dev->iobase + ME4000_AI_START_REG);
549 /* Wait until ready */
551 if (!(inl(dev->iobase + ME4000_AI_STATUS_REG) &
552 ME4000_AI_STATUS_BIT_EF_DATA)) {
553 dev_err(dev->class_dev, "Value not available after wait\n");
557 /* Read value from data fifo */
558 lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF;
559 data[0] = lval ^ 0x8000;
564 static int me4000_ai_cancel(struct comedi_device *dev,
565 struct comedi_subdevice *s)
569 /* Stop any running conversion */
570 tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
571 tmp &= ~(ME4000_AI_CTRL_BIT_STOP | ME4000_AI_CTRL_BIT_IMMEDIATE_STOP);
572 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
574 /* Clear the control register */
575 outl(0x0, dev->iobase + ME4000_AI_CTRL_REG);
580 static int me4000_ai_check_chanlist(struct comedi_device *dev,
581 struct comedi_subdevice *s,
582 struct comedi_cmd *cmd)
584 const struct me4000_board *board = dev->board_ptr;
585 unsigned int max_diff_chan = board->ai_diff_nchan;
586 unsigned int aref0 = CR_AREF(cmd->chanlist[0]);
589 for (i = 0; i < cmd->chanlist_len; i++) {
590 unsigned int chan = CR_CHAN(cmd->chanlist[i]);
591 unsigned int range = CR_RANGE(cmd->chanlist[i]);
592 unsigned int aref = CR_AREF(cmd->chanlist[i]);
595 dev_dbg(dev->class_dev,
596 "Mode is not equal for all entries\n");
600 if (aref == AREF_DIFF) {
601 if (chan >= max_diff_chan) {
602 dev_dbg(dev->class_dev,
603 "Channel number to high\n");
607 if (!comedi_range_is_bipolar(s, range)) {
608 dev_dbg(dev->class_dev,
609 "Bipolar is not selected in differential mode\n");
618 static int ai_round_cmd_args(struct comedi_device *dev,
619 struct comedi_subdevice *s,
620 struct comedi_cmd *cmd,
621 unsigned int *init_ticks,
622 unsigned int *scan_ticks, unsigned int *chan_ticks)
630 if (cmd->start_arg) {
631 *init_ticks = (cmd->start_arg * 33) / 1000;
632 rest = (cmd->start_arg * 33) % 1000;
634 if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_NEAREST) {
637 } else if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_UP) {
643 if (cmd->scan_begin_arg) {
644 *scan_ticks = (cmd->scan_begin_arg * 33) / 1000;
645 rest = (cmd->scan_begin_arg * 33) % 1000;
647 if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_NEAREST) {
650 } else if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_UP) {
656 if (cmd->convert_arg) {
657 *chan_ticks = (cmd->convert_arg * 33) / 1000;
658 rest = (cmd->convert_arg * 33) % 1000;
660 if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_NEAREST) {
663 } else if ((cmd->flags & CMDF_ROUND_MASK) == CMDF_ROUND_UP) {
672 static void ai_write_timer(struct comedi_device *dev,
673 unsigned int init_ticks,
674 unsigned int scan_ticks, unsigned int chan_ticks)
676 outl(init_ticks - 1, dev->iobase + ME4000_AI_SCAN_PRE_TIMER_LOW_REG);
677 outl(0x0, dev->iobase + ME4000_AI_SCAN_PRE_TIMER_HIGH_REG);
680 outl(scan_ticks - 1, dev->iobase + ME4000_AI_SCAN_TIMER_LOW_REG);
681 outl(0x0, dev->iobase + ME4000_AI_SCAN_TIMER_HIGH_REG);
684 outl(chan_ticks - 1, dev->iobase + ME4000_AI_CHAN_PRE_TIMER_REG);
685 outl(chan_ticks - 1, dev->iobase + ME4000_AI_CHAN_TIMER_REG);
688 static int ai_write_chanlist(struct comedi_device *dev,
689 struct comedi_subdevice *s, struct comedi_cmd *cmd)
697 for (i = 0; i < cmd->chanlist_len; i++) {
698 chan = CR_CHAN(cmd->chanlist[i]);
699 rang = CR_RANGE(cmd->chanlist[i]);
700 aref = CR_AREF(cmd->chanlist[i]);
705 entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_2_5;
707 entry |= ME4000_AI_LIST_RANGE_UNIPOLAR_10;
709 entry |= ME4000_AI_LIST_RANGE_BIPOLAR_2_5;
711 entry |= ME4000_AI_LIST_RANGE_BIPOLAR_10;
713 if (aref == AREF_DIFF)
714 entry |= ME4000_AI_LIST_INPUT_DIFFERENTIAL;
716 entry |= ME4000_AI_LIST_INPUT_SINGLE_ENDED;
718 outl(entry, dev->iobase + ME4000_AI_CHANNEL_LIST_REG);
724 static int ai_prepare(struct comedi_device *dev,
725 struct comedi_subdevice *s,
726 struct comedi_cmd *cmd,
727 unsigned int init_ticks,
728 unsigned int scan_ticks, unsigned int chan_ticks)
730 unsigned int tmp = 0;
732 /* Write timer arguments */
733 ai_write_timer(dev, init_ticks, scan_ticks, chan_ticks);
735 /* Reset control register */
736 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
739 if ((cmd->start_src == TRIG_EXT &&
740 cmd->scan_begin_src == TRIG_TIMER &&
741 cmd->convert_src == TRIG_TIMER) ||
742 (cmd->start_src == TRIG_EXT &&
743 cmd->scan_begin_src == TRIG_FOLLOW &&
744 cmd->convert_src == TRIG_TIMER)) {
745 tmp = ME4000_AI_CTRL_BIT_MODE_1 |
746 ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
747 ME4000_AI_CTRL_BIT_DATA_FIFO;
748 } else if (cmd->start_src == TRIG_EXT &&
749 cmd->scan_begin_src == TRIG_EXT &&
750 cmd->convert_src == TRIG_TIMER) {
751 tmp = ME4000_AI_CTRL_BIT_MODE_2 |
752 ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
753 ME4000_AI_CTRL_BIT_DATA_FIFO;
754 } else if (cmd->start_src == TRIG_EXT &&
755 cmd->scan_begin_src == TRIG_EXT &&
756 cmd->convert_src == TRIG_EXT) {
757 tmp = ME4000_AI_CTRL_BIT_MODE_0 |
758 ME4000_AI_CTRL_BIT_MODE_1 |
759 ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
760 ME4000_AI_CTRL_BIT_DATA_FIFO;
762 tmp = ME4000_AI_CTRL_BIT_MODE_0 |
763 ME4000_AI_CTRL_BIT_CHANNEL_FIFO |
764 ME4000_AI_CTRL_BIT_DATA_FIFO;
768 if (cmd->stop_src == TRIG_COUNT) {
769 outl(cmd->chanlist_len * cmd->stop_arg,
770 dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG);
771 tmp |= ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ;
772 } else if (cmd->stop_src == TRIG_NONE &&
773 cmd->scan_end_src == TRIG_COUNT) {
774 outl(cmd->scan_end_arg,
775 dev->iobase + ME4000_AI_SAMPLE_COUNTER_REG);
776 tmp |= ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ;
778 tmp |= ME4000_AI_CTRL_BIT_HF_IRQ;
781 /* Write the setup to the control register */
782 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
784 /* Write the channel list */
785 ai_write_chanlist(dev, s, cmd);
790 static int me4000_ai_do_cmd(struct comedi_device *dev,
791 struct comedi_subdevice *s)
794 unsigned int init_ticks = 0;
795 unsigned int scan_ticks = 0;
796 unsigned int chan_ticks = 0;
797 struct comedi_cmd *cmd = &s->async->cmd;
799 /* Reset the analog input */
800 err = me4000_ai_cancel(dev, s);
804 /* Round the timer arguments */
805 err = ai_round_cmd_args(dev,
806 s, cmd, &init_ticks, &scan_ticks, &chan_ticks);
810 /* Prepare the AI for acquisition */
811 err = ai_prepare(dev, s, cmd, init_ticks, scan_ticks, chan_ticks);
815 /* Start acquistion by dummy read */
816 inl(dev->iobase + ME4000_AI_START_REG);
821 static int me4000_ai_do_cmd_test(struct comedi_device *dev,
822 struct comedi_subdevice *s,
823 struct comedi_cmd *cmd)
825 unsigned int init_ticks;
826 unsigned int chan_ticks;
827 unsigned int scan_ticks;
830 /* Round the timer arguments */
831 ai_round_cmd_args(dev, s, cmd, &init_ticks, &scan_ticks, &chan_ticks);
833 /* Step 1 : check if triggers are trivially valid */
835 err |= comedi_check_trigger_src(&cmd->start_src, TRIG_NOW | TRIG_EXT);
836 err |= comedi_check_trigger_src(&cmd->scan_begin_src,
837 TRIG_FOLLOW | TRIG_TIMER | TRIG_EXT);
838 err |= comedi_check_trigger_src(&cmd->convert_src,
839 TRIG_TIMER | TRIG_EXT);
840 err |= comedi_check_trigger_src(&cmd->scan_end_src,
841 TRIG_NONE | TRIG_COUNT);
842 err |= comedi_check_trigger_src(&cmd->stop_src, TRIG_NONE | TRIG_COUNT);
847 /* Step 2a : make sure trigger sources are unique */
849 err |= comedi_check_trigger_is_unique(cmd->start_src);
850 err |= comedi_check_trigger_is_unique(cmd->scan_begin_src);
851 err |= comedi_check_trigger_is_unique(cmd->convert_src);
852 err |= comedi_check_trigger_is_unique(cmd->scan_end_src);
853 err |= comedi_check_trigger_is_unique(cmd->stop_src);
855 /* Step 2b : and mutually compatible */
857 if (cmd->start_src == TRIG_NOW &&
858 cmd->scan_begin_src == TRIG_TIMER &&
859 cmd->convert_src == TRIG_TIMER) {
860 } else if (cmd->start_src == TRIG_NOW &&
861 cmd->scan_begin_src == TRIG_FOLLOW &&
862 cmd->convert_src == TRIG_TIMER) {
863 } else if (cmd->start_src == TRIG_EXT &&
864 cmd->scan_begin_src == TRIG_TIMER &&
865 cmd->convert_src == TRIG_TIMER) {
866 } else if (cmd->start_src == TRIG_EXT &&
867 cmd->scan_begin_src == TRIG_FOLLOW &&
868 cmd->convert_src == TRIG_TIMER) {
869 } else if (cmd->start_src == TRIG_EXT &&
870 cmd->scan_begin_src == TRIG_EXT &&
871 cmd->convert_src == TRIG_TIMER) {
872 } else if (cmd->start_src == TRIG_EXT &&
873 cmd->scan_begin_src == TRIG_EXT &&
874 cmd->convert_src == TRIG_EXT) {
882 /* Step 3: check if arguments are trivially valid */
884 err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
886 if (cmd->chanlist_len < 1) {
887 cmd->chanlist_len = 1;
890 if (init_ticks < 66) {
891 cmd->start_arg = 2000;
894 if (scan_ticks && scan_ticks < 67) {
895 cmd->scan_begin_arg = 2031;
898 if (chan_ticks < 66) {
899 cmd->convert_arg = 2000;
903 if (cmd->stop_src == TRIG_COUNT)
904 err |= comedi_check_trigger_arg_min(&cmd->stop_arg, 1);
906 err |= comedi_check_trigger_arg_is(&cmd->stop_arg, 0);
912 * Stage 4. Check for argument conflicts.
914 if (cmd->start_src == TRIG_NOW &&
915 cmd->scan_begin_src == TRIG_TIMER &&
916 cmd->convert_src == TRIG_TIMER) {
917 /* Check timer arguments */
918 if (init_ticks < ME4000_AI_MIN_TICKS) {
919 dev_err(dev->class_dev, "Invalid start arg\n");
920 cmd->start_arg = 2000; /* 66 ticks at least */
923 if (chan_ticks < ME4000_AI_MIN_TICKS) {
924 dev_err(dev->class_dev, "Invalid convert arg\n");
925 cmd->convert_arg = 2000; /* 66 ticks at least */
928 if (scan_ticks <= cmd->chanlist_len * chan_ticks) {
929 dev_err(dev->class_dev, "Invalid scan end arg\n");
931 /* At least one tick more */
932 cmd->scan_end_arg = 2000 * cmd->chanlist_len + 31;
935 } else if (cmd->start_src == TRIG_NOW &&
936 cmd->scan_begin_src == TRIG_FOLLOW &&
937 cmd->convert_src == TRIG_TIMER) {
938 /* Check timer arguments */
939 if (init_ticks < ME4000_AI_MIN_TICKS) {
940 dev_err(dev->class_dev, "Invalid start arg\n");
941 cmd->start_arg = 2000; /* 66 ticks at least */
944 if (chan_ticks < ME4000_AI_MIN_TICKS) {
945 dev_err(dev->class_dev, "Invalid convert arg\n");
946 cmd->convert_arg = 2000; /* 66 ticks at least */
949 } else if (cmd->start_src == TRIG_EXT &&
950 cmd->scan_begin_src == TRIG_TIMER &&
951 cmd->convert_src == TRIG_TIMER) {
952 /* Check timer arguments */
953 if (init_ticks < ME4000_AI_MIN_TICKS) {
954 dev_err(dev->class_dev, "Invalid start arg\n");
955 cmd->start_arg = 2000; /* 66 ticks at least */
958 if (chan_ticks < ME4000_AI_MIN_TICKS) {
959 dev_err(dev->class_dev, "Invalid convert arg\n");
960 cmd->convert_arg = 2000; /* 66 ticks at least */
963 if (scan_ticks <= cmd->chanlist_len * chan_ticks) {
964 dev_err(dev->class_dev, "Invalid scan end arg\n");
966 /* At least one tick more */
967 cmd->scan_end_arg = 2000 * cmd->chanlist_len + 31;
970 } else if (cmd->start_src == TRIG_EXT &&
971 cmd->scan_begin_src == TRIG_FOLLOW &&
972 cmd->convert_src == TRIG_TIMER) {
973 /* Check timer arguments */
974 if (init_ticks < ME4000_AI_MIN_TICKS) {
975 dev_err(dev->class_dev, "Invalid start arg\n");
976 cmd->start_arg = 2000; /* 66 ticks at least */
979 if (chan_ticks < ME4000_AI_MIN_TICKS) {
980 dev_err(dev->class_dev, "Invalid convert arg\n");
981 cmd->convert_arg = 2000; /* 66 ticks at least */
984 } else if (cmd->start_src == TRIG_EXT &&
985 cmd->scan_begin_src == TRIG_EXT &&
986 cmd->convert_src == TRIG_TIMER) {
987 /* Check timer arguments */
988 if (init_ticks < ME4000_AI_MIN_TICKS) {
989 dev_err(dev->class_dev, "Invalid start arg\n");
990 cmd->start_arg = 2000; /* 66 ticks at least */
993 if (chan_ticks < ME4000_AI_MIN_TICKS) {
994 dev_err(dev->class_dev, "Invalid convert arg\n");
995 cmd->convert_arg = 2000; /* 66 ticks at least */
998 } else if (cmd->start_src == TRIG_EXT &&
999 cmd->scan_begin_src == TRIG_EXT &&
1000 cmd->convert_src == TRIG_EXT) {
1001 /* Check timer arguments */
1002 if (init_ticks < ME4000_AI_MIN_TICKS) {
1003 dev_err(dev->class_dev, "Invalid start arg\n");
1004 cmd->start_arg = 2000; /* 66 ticks at least */
1008 if (cmd->scan_end_src == TRIG_COUNT) {
1009 if (cmd->scan_end_arg == 0) {
1010 dev_err(dev->class_dev, "Invalid scan end arg\n");
1011 cmd->scan_end_arg = 1;
1019 /* Step 5: check channel list if it exists */
1020 if (cmd->chanlist && cmd->chanlist_len > 0)
1021 err |= me4000_ai_check_chanlist(dev, s, cmd);
1029 static irqreturn_t me4000_ai_isr(int irq, void *dev_id)
1032 struct comedi_device *dev = dev_id;
1033 struct comedi_subdevice *s = dev->read_subdev;
1041 if (inl(dev->iobase + ME4000_IRQ_STATUS_REG) &
1042 ME4000_IRQ_STATUS_BIT_AI_HF) {
1043 /* Read status register to find out what happened */
1044 tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
1046 if (!(tmp & ME4000_AI_STATUS_BIT_FF_DATA) &&
1047 !(tmp & ME4000_AI_STATUS_BIT_HF_DATA) &&
1048 (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
1049 c = ME4000_AI_FIFO_COUNT;
1052 * FIFO overflow, so stop conversion
1053 * and disable all interrupts
1055 tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
1056 tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
1057 ME4000_AI_CTRL_BIT_SC_IRQ);
1058 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
1060 s->async->events |= COMEDI_CB_ERROR;
1062 dev_err(dev->class_dev, "FIFO overflow\n");
1063 } else if ((tmp & ME4000_AI_STATUS_BIT_FF_DATA)
1064 && !(tmp & ME4000_AI_STATUS_BIT_HF_DATA)
1065 && (tmp & ME4000_AI_STATUS_BIT_EF_DATA)) {
1066 c = ME4000_AI_FIFO_COUNT / 2;
1068 dev_err(dev->class_dev,
1069 "Can't determine state of fifo\n");
1073 * Undefined state, so stop conversion
1074 * and disable all interrupts
1076 tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
1077 tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
1078 ME4000_AI_CTRL_BIT_SC_IRQ);
1079 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
1081 s->async->events |= COMEDI_CB_ERROR;
1083 dev_err(dev->class_dev, "Undefined FIFO state\n");
1086 for (i = 0; i < c; i++) {
1087 /* Read value from data fifo */
1088 lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF;
1091 if (!comedi_buf_write_samples(s, &lval, 1)) {
1093 * Buffer overflow, so stop conversion
1094 * and disable all interrupts
1096 tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
1097 tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ |
1098 ME4000_AI_CTRL_BIT_SC_IRQ);
1099 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
1104 /* Work is done, so reset the interrupt */
1105 tmp |= ME4000_AI_CTRL_BIT_HF_IRQ_RESET;
1106 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
1107 tmp &= ~ME4000_AI_CTRL_BIT_HF_IRQ_RESET;
1108 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
1111 if (inl(dev->iobase + ME4000_IRQ_STATUS_REG) &
1112 ME4000_IRQ_STATUS_BIT_SC) {
1113 s->async->events |= COMEDI_CB_EOA;
1116 * Acquisition is complete, so stop
1117 * conversion and disable all interrupts
1119 tmp = inl(dev->iobase + ME4000_AI_CTRL_REG);
1120 tmp |= ME4000_AI_CTRL_BIT_IMMEDIATE_STOP;
1121 tmp &= ~(ME4000_AI_CTRL_BIT_HF_IRQ | ME4000_AI_CTRL_BIT_SC_IRQ);
1122 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
1124 /* Poll data until fifo empty */
1125 while (inl(dev->iobase + ME4000_AI_CTRL_REG) &
1126 ME4000_AI_STATUS_BIT_EF_DATA) {
1127 /* Read value from data fifo */
1128 lval = inl(dev->iobase + ME4000_AI_DATA_REG) & 0xFFFF;
1131 if (!comedi_buf_write_samples(s, &lval, 1))
1135 /* Work is done, so reset the interrupt */
1136 tmp |= ME4000_AI_CTRL_BIT_SC_IRQ_RESET;
1137 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
1138 tmp &= ~ME4000_AI_CTRL_BIT_SC_IRQ_RESET;
1139 outl(tmp, dev->iobase + ME4000_AI_CTRL_REG);
1142 comedi_handle_events(dev, s);
1147 static int me4000_ao_insn_write(struct comedi_device *dev,
1148 struct comedi_subdevice *s,
1149 struct comedi_insn *insn,
1152 int chan = CR_CHAN(insn->chanspec);
1155 /* Stop any running conversion */
1156 tmp = inl(dev->iobase + ME4000_AO_CTRL_REG(chan));
1157 tmp |= ME4000_AO_CTRL_BIT_IMMEDIATE_STOP;
1158 outl(tmp, dev->iobase + ME4000_AO_CTRL_REG(chan));
1160 /* Clear control register and set to single mode */
1161 outl(0x0, dev->iobase + ME4000_AO_CTRL_REG(chan));
1163 /* Write data value */
1164 outl(data[0], dev->iobase + ME4000_AO_SINGLE_REG(chan));
1166 /* Store in the mirror */
1167 s->readback[chan] = data[0];
1172 static int me4000_dio_insn_bits(struct comedi_device *dev,
1173 struct comedi_subdevice *s,
1174 struct comedi_insn *insn,
1177 if (comedi_dio_update_state(s, data)) {
1178 outl((s->state >> 0) & 0xFF,
1179 dev->iobase + ME4000_DIO_PORT_0_REG);
1180 outl((s->state >> 8) & 0xFF,
1181 dev->iobase + ME4000_DIO_PORT_1_REG);
1182 outl((s->state >> 16) & 0xFF,
1183 dev->iobase + ME4000_DIO_PORT_2_REG);
1184 outl((s->state >> 24) & 0xFF,
1185 dev->iobase + ME4000_DIO_PORT_3_REG);
1188 data[1] = ((inl(dev->iobase + ME4000_DIO_PORT_0_REG) & 0xFF) << 0) |
1189 ((inl(dev->iobase + ME4000_DIO_PORT_1_REG) & 0xFF) << 8) |
1190 ((inl(dev->iobase + ME4000_DIO_PORT_2_REG) & 0xFF) << 16) |
1191 ((inl(dev->iobase + ME4000_DIO_PORT_3_REG) & 0xFF) << 24);
1196 static int me4000_dio_insn_config(struct comedi_device *dev,
1197 struct comedi_subdevice *s,
1198 struct comedi_insn *insn,
1201 unsigned int chan = CR_CHAN(insn->chanspec);
1215 ret = comedi_dio_insn_config(dev, s, insn, data, mask);
1219 tmp = inl(dev->iobase + ME4000_DIO_CTRL_REG);
1220 tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_0 | ME4000_DIO_CTRL_BIT_MODE_1 |
1221 ME4000_DIO_CTRL_BIT_MODE_2 | ME4000_DIO_CTRL_BIT_MODE_3 |
1222 ME4000_DIO_CTRL_BIT_MODE_4 | ME4000_DIO_CTRL_BIT_MODE_5 |
1223 ME4000_DIO_CTRL_BIT_MODE_6 | ME4000_DIO_CTRL_BIT_MODE_7);
1224 if (s->io_bits & 0x000000ff)
1225 tmp |= ME4000_DIO_CTRL_BIT_MODE_0;
1226 if (s->io_bits & 0x0000ff00)
1227 tmp |= ME4000_DIO_CTRL_BIT_MODE_2;
1228 if (s->io_bits & 0x00ff0000)
1229 tmp |= ME4000_DIO_CTRL_BIT_MODE_4;
1230 if (s->io_bits & 0xff000000)
1231 tmp |= ME4000_DIO_CTRL_BIT_MODE_6;
1234 * Check for optoisolated ME-4000 version.
1235 * If one the first port is a fixed output
1236 * port and the second is a fixed input port.
1238 if (inl(dev->iobase + ME4000_DIO_DIR_REG)) {
1239 s->io_bits |= 0x000000ff;
1240 s->io_bits &= ~0x0000ff00;
1241 tmp |= ME4000_DIO_CTRL_BIT_MODE_0;
1242 tmp &= ~(ME4000_DIO_CTRL_BIT_MODE_2 |
1243 ME4000_DIO_CTRL_BIT_MODE_3);
1246 outl(tmp, dev->iobase + ME4000_DIO_CTRL_REG);
1251 static int me4000_auto_attach(struct comedi_device *dev,
1252 unsigned long context)
1254 struct pci_dev *pcidev = comedi_to_pci_dev(dev);
1255 const struct me4000_board *thisboard = NULL;
1256 struct me4000_info *info;
1257 struct comedi_subdevice *s;
1260 if (context < ARRAY_SIZE(me4000_boards))
1261 thisboard = &me4000_boards[context];
1264 dev->board_ptr = thisboard;
1265 dev->board_name = thisboard->name;
1267 info = comedi_alloc_devpriv(dev, sizeof(*info));
1271 result = comedi_pci_enable(dev);
1275 info->plx_regbase = pci_resource_start(pcidev, 1);
1276 dev->iobase = pci_resource_start(pcidev, 2);
1277 if (!info->plx_regbase || !dev->iobase)
1280 result = comedi_load_firmware(dev, &pcidev->dev, ME4000_FIRMWARE,
1281 me4000_xilinx_download, 0);
1287 if (pcidev->irq > 0) {
1288 result = request_irq(pcidev->irq, me4000_ai_isr, IRQF_SHARED,
1289 dev->board_name, dev);
1291 dev->irq = pcidev->irq;
1294 result = comedi_alloc_subdevices(dev, 4);
1298 /*=========================================================================
1299 Analog input subdevice
1300 ========================================================================*/
1302 s = &dev->subdevices[0];
1304 if (thisboard->ai_nchan) {
1305 s->type = COMEDI_SUBD_AI;
1307 SDF_READABLE | SDF_COMMON | SDF_GROUND | SDF_DIFF;
1308 s->n_chan = thisboard->ai_nchan;
1309 s->maxdata = 0xFFFF; /* 16 bit ADC */
1310 s->len_chanlist = ME4000_AI_CHANNEL_LIST_COUNT;
1311 s->range_table = &me4000_ai_range;
1312 s->insn_read = me4000_ai_insn_read;
1315 dev->read_subdev = s;
1316 s->subdev_flags |= SDF_CMD_READ;
1317 s->cancel = me4000_ai_cancel;
1318 s->do_cmdtest = me4000_ai_do_cmd_test;
1319 s->do_cmd = me4000_ai_do_cmd;
1322 s->type = COMEDI_SUBD_UNUSED;
1325 /*=========================================================================
1326 Analog output subdevice
1327 ========================================================================*/
1329 s = &dev->subdevices[1];
1331 if (thisboard->ao_nchan) {
1332 s->type = COMEDI_SUBD_AO;
1333 s->subdev_flags = SDF_WRITABLE | SDF_COMMON | SDF_GROUND;
1334 s->n_chan = thisboard->ao_nchan;
1335 s->maxdata = 0xFFFF; /* 16 bit DAC */
1336 s->range_table = &range_bipolar10;
1337 s->insn_write = me4000_ao_insn_write;
1339 result = comedi_alloc_subdev_readback(s);
1343 s->type = COMEDI_SUBD_UNUSED;
1346 /*=========================================================================
1347 Digital I/O subdevice
1348 ========================================================================*/
1350 s = &dev->subdevices[2];
1352 if (thisboard->dio_nchan) {
1353 s->type = COMEDI_SUBD_DIO;
1354 s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
1355 s->n_chan = thisboard->dio_nchan;
1357 s->range_table = &range_digital;
1358 s->insn_bits = me4000_dio_insn_bits;
1359 s->insn_config = me4000_dio_insn_config;
1361 s->type = COMEDI_SUBD_UNUSED;
1365 * Check for optoisolated ME-4000 version. If one the first
1366 * port is a fixed output port and the second is a fixed input port.
1368 if (!inl(dev->iobase + ME4000_DIO_DIR_REG)) {
1370 outl(ME4000_DIO_CTRL_BIT_MODE_0,
1371 dev->iobase + ME4000_DIO_DIR_REG);
1374 /* Counter subdevice (8254) */
1375 s = &dev->subdevices[3];
1376 if (thisboard->has_counter) {
1377 unsigned long timer_base = pci_resource_start(pcidev, 3);
1382 dev->pacer = comedi_8254_init(timer_base, 0, I8254_IO8, 0);
1386 comedi_8254_subdevice_init(s, dev->pacer);
1388 s->type = COMEDI_SUBD_UNUSED;
1394 static void me4000_detach(struct comedi_device *dev)
1398 comedi_pci_detach(dev);
1401 static struct comedi_driver me4000_driver = {
1402 .driver_name = "me4000",
1403 .module = THIS_MODULE,
1404 .auto_attach = me4000_auto_attach,
1405 .detach = me4000_detach,
1408 static int me4000_pci_probe(struct pci_dev *dev,
1409 const struct pci_device_id *id)
1411 return comedi_pci_auto_config(dev, &me4000_driver, id->driver_data);
1414 static const struct pci_device_id me4000_pci_table[] = {
1415 { PCI_VDEVICE(MEILHAUS, 0x4650), BOARD_ME4650 },
1416 { PCI_VDEVICE(MEILHAUS, 0x4660), BOARD_ME4660 },
1417 { PCI_VDEVICE(MEILHAUS, 0x4661), BOARD_ME4660I },
1418 { PCI_VDEVICE(MEILHAUS, 0x4662), BOARD_ME4660S },
1419 { PCI_VDEVICE(MEILHAUS, 0x4663), BOARD_ME4660IS },
1420 { PCI_VDEVICE(MEILHAUS, 0x4670), BOARD_ME4670 },
1421 { PCI_VDEVICE(MEILHAUS, 0x4671), BOARD_ME4670I },
1422 { PCI_VDEVICE(MEILHAUS, 0x4672), BOARD_ME4670S },
1423 { PCI_VDEVICE(MEILHAUS, 0x4673), BOARD_ME4670IS },
1424 { PCI_VDEVICE(MEILHAUS, 0x4680), BOARD_ME4680 },
1425 { PCI_VDEVICE(MEILHAUS, 0x4681), BOARD_ME4680I },
1426 { PCI_VDEVICE(MEILHAUS, 0x4682), BOARD_ME4680S },
1427 { PCI_VDEVICE(MEILHAUS, 0x4683), BOARD_ME4680IS },
1430 MODULE_DEVICE_TABLE(pci, me4000_pci_table);
1432 static struct pci_driver me4000_pci_driver = {
1434 .id_table = me4000_pci_table,
1435 .probe = me4000_pci_probe,
1436 .remove = comedi_pci_auto_unconfig,
1438 module_comedi_pci_driver(me4000_driver, me4000_pci_driver);
1440 MODULE_AUTHOR("Comedi http://www.comedi.org");
1441 MODULE_DESCRIPTION("Comedi low-level driver");
1442 MODULE_LICENSE("GPL");
1443 MODULE_FIRMWARE(ME4000_FIRMWARE);