5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 2000 David A. Schleef <ds@schleef.org>
7 Copyright (C) 2001,2002,2003 Frank Mori Hess <fmhess@users.sourceforge.net>
8 Copyright (C) 2004 Salvador E. Tropea <set@users.sf.net> <set@ieee.org>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *****************************************************************
29 Description: DAS-08 compatible boards
30 Author: Warren Jasper, ds, Frank Hess
31 Devices: [Keithley Metrabyte] DAS08 (isa-das08), [ComputerBoards] DAS08 (isa-das08),
32 DAS08-PGM (das08-pgm),
33 DAS08-PGH (das08-pgh), DAS08-PGL (das08-pgl), DAS08-AOH (das08-aoh),
34 DAS08-AOL (das08-aol), DAS08-AOM (das08-aom), DAS08/JR-AO (das08/jr-ao),
35 DAS08/JR-16-AO (das08jr-16-ao), PCI-DAS08 (das08),
36 PC104-DAS08 (pc104-das08), DAS08/JR/16 (das08jr/16)
39 This is a rewrite of the das08 and das08jr drivers.
41 Options (for ISA cards):
44 Options (for pci-das08):
48 The das08 driver doesn't support asynchronous commands, since
49 the cheap das08 hardware doesn't really support them. The
50 comedi_rt_timer driver can be used to emulate commands for this
54 #include "../comedidev.h"
56 #include <linux/delay.h>
58 #include "comedi_pci.h"
62 #define DRV_NAME "das08"
64 #define PCI_VENDOR_ID_COMPUTERBOARDS 0x1307
65 #define PCI_DEVICE_ID_PCIDAS08 0x29
66 #define PCIDAS08_SIZE 0x54
68 // pci configuration registers
70 #define INTR1_ENABLE 0x1
71 #define INTR1_HIGH_POLARITY 0x2
72 #define PCI_INTR_ENABLE 0x40
73 #define INTR1_EDGE_TRIG 0x100 // requires high polarity
76 #define CNTRL_INTR 0x4
83 0 a/d bits 0-3 start 8 bit
84 1 a/d bits 4-11 start 12 bit
85 2 eoc, ip1-3, irq, mux op1-4, inte, mux
90 requires hard-wiring for async ai
96 #define DAS08_TRIG_12BIT 1
97 #define DAS08_STATUS 2
98 #define DAS08_EOC (1<<7)
99 #define DAS08_IRQ (1<<3)
100 #define DAS08_IP(x) (((x)>>4)&0x7)
101 #define DAS08_CONTROL 2
102 #define DAS08_MUX_MASK 0x7
103 #define DAS08_MUX(x) ((x) & DAS08_MUX_MASK)
104 #define DAS08_INTE (1<<3)
105 #define DAS08_DO_MASK 0xf0
106 #define DAS08_OP(x) (((x) << 4) & DAS08_DO_MASK)
113 0 a/d bits 0-3 unused
114 1 a/d bits 4-11 start 12 bit
124 #define DAS08JR_DIO 3
125 #define DAS08JR_AO_LSB(x) ((x)?6:4)
126 #define DAS08JR_AO_MSB(x) ((x)?7:5)
135 0 a/d bits 0-3 start 8 bit
136 1 a/d bits 4-11 start 12 bit
137 2 eoc, ip1-3, irq, mux op1-4, inte, mux
138 3 mux, gain status gain control
148 #define DAS08AO_GAIN_CONTROL 3
149 #define DAS08AO_GAIN_STATUS 3
151 #define DAS08AO_AO_LSB(x) ((x)?0xa:8)
152 #define DAS08AO_AO_MSB(x) ((x)?0xb:9)
153 #define DAS08AO_AO_UPDATE 8
155 /* gainlist same as _pgx_ below */
157 static int das08_ai_rinsn(comedi_device
* dev
, comedi_subdevice
* s
,
158 comedi_insn
* insn
, unsigned int * data
);
159 static int das08_di_rbits(comedi_device
* dev
, comedi_subdevice
* s
,
160 comedi_insn
* insn
, unsigned int * data
);
161 static int das08_do_wbits(comedi_device
* dev
, comedi_subdevice
* s
,
162 comedi_insn
* insn
, unsigned int * data
);
163 static int das08jr_di_rbits(comedi_device
* dev
, comedi_subdevice
* s
,
164 comedi_insn
* insn
, unsigned int * data
);
165 static int das08jr_do_wbits(comedi_device
* dev
, comedi_subdevice
* s
,
166 comedi_insn
* insn
, unsigned int * data
);
167 static int das08jr_ao_winsn(comedi_device
* dev
, comedi_subdevice
* s
,
168 comedi_insn
* insn
, unsigned int * data
);
169 static int das08ao_ao_winsn(comedi_device
* dev
, comedi_subdevice
* s
,
170 comedi_insn
* insn
, unsigned int * data
);
171 static void i8254_set_mode_low(unsigned int base
, int channel
,
174 static const comedi_lrange range_das08_pgl
= { 9, {
186 static const comedi_lrange range_das08_pgh
= { 12, {
201 static const comedi_lrange range_das08_pgm
= { 9, {
217 0 a/d bits 0-3 unused
218 1 a/d bits 4-11 start 12 bit
228 static const comedi_lrange
*const das08_ai_lranges
[] = {
236 static const int das08_pgh_gainlist
[] =
237 { 8, 0, 10, 2, 12, 4, 14, 6, 1, 3, 5, 7 };
238 static const int das08_pgl_gainlist
[] = { 8, 0, 2, 4, 6, 1, 3, 5, 7 };
239 static const int das08_pgm_gainlist
[] = { 8, 0, 10, 12, 14, 9, 11, 13, 15 };
241 static const int *const das08_gainlists
[] = {
249 static const struct das08_board_struct das08_boards
[] = {
251 name
: "isa-das08", // cio-das08.pdf
255 ai_pg
: das08_pg_none
,
256 ai_encoding
:das08_encode12
,
264 iosize
: 16, // unchecked
267 name
: "das08-pgm", // cio-das08pgx.pdf
272 ai_encoding
:das08_encode12
,
279 iosize
: 16, // unchecked
282 name
: "das08-pgh", // cio-das08pgx.pdf
287 ai_encoding
:das08_encode12
,
294 iosize
: 16, // unchecked
297 name
: "das08-pgl", // cio-das08pgx.pdf
302 ai_encoding
:das08_encode12
,
309 iosize
: 16, // unchecked
312 name
: "das08-aoh", // cio-das08_aox.pdf
317 ai_encoding
:das08_encode12
,
318 ao
: das08ao_ao_winsn
, // 8
325 iosize
: 16, // unchecked
328 name
: "das08-aol", // cio-das08_aox.pdf
333 ai_encoding
:das08_encode12
,
334 ao
: das08ao_ao_winsn
, // 8
341 iosize
: 16, // unchecked
344 name
: "das08-aom", // cio-das08_aox.pdf
349 ai_encoding
:das08_encode12
,
350 ao
: das08ao_ao_winsn
, // 8
357 iosize
: 16, // unchecked
360 name
: "das08/jr-ao", // cio-das08-jr-ao.pdf
364 ai_pg
: das08_pg_none
,
365 ai_encoding
:das08_encode12
,
366 ao
: das08jr_ao_winsn
,
368 di
: das08jr_di_rbits
,
369 do_
: das08jr_do_wbits
,
373 iosize
: 16, // unchecked
376 name
: "das08jr-16-ao", // cio-das08jr-16-ao.pdf
380 ai_pg
: das08_pg_none
,
381 ai_encoding
:das08_encode12
,
382 ao
: das08jr_ao_winsn
,
384 di
: das08jr_di_rbits
,
385 do_
: das08jr_do_wbits
,
389 iosize
: 16, // unchecked
391 #ifdef CONFIG_COMEDI_PCI
393 name
: "das08", // pci-das08
394 id
: PCI_DEVICE_ID_PCIDAS08
,
398 ai_pg
: das08_bipolar5
,
399 ai_encoding
:das08_encode12
,
415 ai_pg
: das08_pg_none
,
416 ai_encoding
:das08_encode12
,
424 iosize
: 16, // unchecked
439 ai_pg
: das08_pg_none
,
440 ai_encoding
:das08_encode16
,
443 di
: das08jr_di_rbits
,
444 do_
: das08jr_do_wbits
,
448 iosize
: 16, // unchecked
452 name
: "das48-pga", // cio-das48-pga.pdf
455 name
: "das08-pga-g2", // a KM board
460 #ifdef CONFIG_COMEDI_PCMCIA
461 struct das08_board_struct das08_cs_boards
[NUM_DAS08_CS_BOARDS
] = {
468 ai_pg
: das08_bipolar5
,
469 ai_encoding
:das08_pcm_encode12
,
479 // duplicate so driver name can be used also
486 ai_pg
: das08_bipolar5
,
487 ai_encoding
:das08_pcm_encode12
,
500 #ifdef CONFIG_COMEDI_PCI
501 static DEFINE_PCI_DEVICE_TABLE(das08_pci_table
) = {
502 {PCI_VENDOR_ID_COMPUTERBOARDS
, PCI_DEVICE_ID_PCIDAS08
, PCI_ANY_ID
,
503 PCI_ANY_ID
, 0, 0, 0},
507 MODULE_DEVICE_TABLE(pci
, das08_pci_table
);
510 #define devpriv ((struct das08_private_struct *)dev->private)
511 #define thisboard ((const struct das08_board_struct *)dev->board_ptr)
513 #define TIMEOUT 100000
515 static int das08_ai_rinsn(comedi_device
* dev
, comedi_subdevice
* s
,
516 comedi_insn
* insn
, unsigned int * data
)
523 chan
= CR_CHAN(insn
->chanspec
);
524 range
= CR_RANGE(insn
->chanspec
);
527 inb(dev
->iobase
+ DAS08_LSB
);
528 inb(dev
->iobase
+ DAS08_MSB
);
530 /* set multiplexer */
531 spin_lock(&dev
->spinlock
); // lock to prevent race with digital output
532 devpriv
->do_mux_bits
&= ~DAS08_MUX_MASK
;
533 devpriv
->do_mux_bits
|= DAS08_MUX(chan
);
534 outb(devpriv
->do_mux_bits
, dev
->iobase
+ DAS08_CONTROL
);
535 spin_unlock(&dev
->spinlock
);
537 if (s
->range_table
->length
> 1) {
539 range
= CR_RANGE(insn
->chanspec
);
540 outb(devpriv
->pg_gainlist
[range
],
541 dev
->iobase
+ DAS08AO_GAIN_CONTROL
);
544 for (n
= 0; n
< insn
->n
; n
++) {
545 /* clear over-range bits for 16-bit boards */
546 if (thisboard
->ai_nbits
== 16)
547 if (inb(dev
->iobase
+ DAS08_MSB
) & 0x80)
548 rt_printk("das08: over-range\n");
550 /* trigger conversion */
551 outb_p(0, dev
->iobase
+ DAS08_TRIG_12BIT
);
553 for (i
= 0; i
< TIMEOUT
; i
++) {
554 if (!(inb(dev
->iobase
+ DAS08_STATUS
) & DAS08_EOC
))
558 rt_printk("das08: timeout\n");
561 msb
= inb(dev
->iobase
+ DAS08_MSB
);
562 lsb
= inb(dev
->iobase
+ DAS08_LSB
);
563 if (thisboard
->ai_encoding
== das08_encode12
) {
564 data
[n
] = (lsb
>> 4) | (msb
<< 4);
565 } else if (thisboard
->ai_encoding
== das08_pcm_encode12
) {
566 data
[n
] = (msb
<< 8) + lsb
;
567 } else if (thisboard
->ai_encoding
== das08_encode16
) {
568 /* FPOS 16-bit boards are sign-magnitude */
570 data
[n
] = (1 << 15) | lsb
| ((msb
& 0x7f) << 8);
572 data
[n
] = (1 << 15) - (lsb
| (msb
& 0x7f) << 8);
574 comedi_error(dev
, "bug! unknown ai encoding");
582 static int das08_di_rbits(comedi_device
* dev
, comedi_subdevice
* s
,
583 comedi_insn
* insn
, unsigned int * data
)
586 data
[1] = DAS08_IP(inb(dev
->iobase
+ DAS08_STATUS
));
591 static int das08_do_wbits(comedi_device
* dev
, comedi_subdevice
* s
,
592 comedi_insn
* insn
, unsigned int * data
)
596 // get current settings of digital output lines
597 wbits
= (devpriv
->do_mux_bits
>> 4) & 0xf;
598 // null bits we are going to set
600 // set new bit values
601 wbits
|= data
[0] & data
[1];
602 // remember digital output bits
603 spin_lock(&dev
->spinlock
); // prevent race with setting of analog input mux
604 devpriv
->do_mux_bits
&= ~DAS08_DO_MASK
;
605 devpriv
->do_mux_bits
|= DAS08_OP(wbits
);
606 outb(devpriv
->do_mux_bits
, dev
->iobase
+ DAS08_CONTROL
);
607 spin_unlock(&dev
->spinlock
);
614 static int das08jr_di_rbits(comedi_device
* dev
, comedi_subdevice
* s
,
615 comedi_insn
* insn
, unsigned int * data
)
618 data
[1] = inb(dev
->iobase
+ DAS08JR_DIO
);
623 static int das08jr_do_wbits(comedi_device
* dev
, comedi_subdevice
* s
,
624 comedi_insn
* insn
, unsigned int * data
)
626 // null bits we are going to set
627 devpriv
->do_bits
&= ~data
[0];
628 // set new bit values
629 devpriv
->do_bits
|= data
[0] & data
[1];
630 outb(devpriv
->do_bits
, dev
->iobase
+ DAS08JR_DIO
);
632 data
[1] = devpriv
->do_bits
;
637 static int das08jr_ao_winsn(comedi_device
* dev
, comedi_subdevice
* s
,
638 comedi_insn
* insn
, unsigned int * data
)
644 lsb
= data
[0] & 0xff;
645 msb
= (data
[0] >> 8) & 0xf;
647 chan
= CR_CHAN(insn
->chanspec
);
649 for (n
= 0; n
< insn
->n
; n
++) {
651 outb(lsb
, dev
->iobase
+ devpriv
->ao_offset_lsb
[chan
]);
652 outb(msb
, dev
->iobase
+ devpriv
->ao_offset_msb
[chan
]);
654 outb(lsb
, dev
->iobase
+ DAS08JR_AO_LSB(chan
));
655 outb(msb
, dev
->iobase
+ DAS08JR_AO_MSB(chan
));
659 inb(dev
->iobase
+ DAS08JR_DIO
);
667 * The -aox boards have the DACs at a different offset and use
668 * a different method to force an update.
671 static int das08ao_ao_winsn(comedi_device
* dev
, comedi_subdevice
* s
,
672 comedi_insn
* insn
, unsigned int * data
)
678 lsb
= data
[0] & 0xff;
679 msb
= (data
[0] >> 8) & 0xf;
681 chan
= CR_CHAN(insn
->chanspec
);
683 for (n
= 0; n
< insn
->n
; n
++) {
685 outb(lsb
, dev
->iobase
+ devpriv
->ao_offset_lsb
[chan
]);
686 outb(msb
, dev
->iobase
+ devpriv
->ao_offset_msb
[chan
]);
688 outb(lsb
, dev
->iobase
+ DAS08AO_AO_LSB(chan
));
689 outb(msb
, dev
->iobase
+ DAS08AO_AO_MSB(chan
));
693 inb(dev
->iobase
+ DAS08AO_AO_UPDATE
);
699 static unsigned int i8254_read_channel_low(unsigned int base
, int chan
)
701 unsigned int msb
, lsb
;
703 /* The following instructions must be in order.
704 We must avoid other process reading the counter's value in the
706 The spin_lock isn't needed since ioctl calls grab the big kernel
707 lock automatically */
709 outb(chan
<< 6, base
+ I8254_CTRL
);
713 /*spin_unlock(sp); */
715 return lsb
| (msb
<< 8);
718 static void i8254_write_channel_low(unsigned int base
, int chan
,
721 unsigned int msb
, lsb
;
726 /* write lsb, then msb */
728 /* See comments in i8254_read_channel_low */
732 /*spin_unlock(sp); */
735 static unsigned int i8254_read_channel(struct i8254_struct
*st
, int channel
)
737 int chan
= st
->logic2phys
[channel
];
739 return i8254_read_channel_low(st
->iobase
, chan
);
742 static void i8254_write_channel(struct i8254_struct
*st
, int channel
,
745 int chan
= st
->logic2phys
[channel
];
747 i8254_write_channel_low(st
->iobase
, chan
, value
);
750 static void i8254_initialize(struct i8254_struct
*st
)
753 for (i
= 0; i
< 3; ++i
)
754 i8254_set_mode_low(st
->iobase
, i
, st
->mode
[i
]);
757 static void i8254_set_mode_low(unsigned int base
, int channel
,
760 outb((channel
<< 6) | 0x30 | (mode
& 0x0F), base
+ I8254_CTRL
);
763 static void i8254_set_mode(struct i8254_struct
*st
, int channel
,
766 int chan
= st
->logic2phys
[channel
];
768 st
->mode
[chan
] = mode
;
769 return i8254_set_mode_low(st
->iobase
, chan
, mode
);
772 static unsigned int i8254_read_status_low(unsigned int base
, int channel
)
774 outb(0xE0 | (2 << channel
), base
+ I8254_CTRL
);
775 return inb(base
+ channel
);
778 static unsigned int i8254_read_status(struct i8254_struct
*st
, int channel
)
780 int chan
= st
->logic2phys
[channel
];
782 return i8254_read_status_low(st
->iobase
, chan
);
785 static int das08_counter_read(comedi_device
* dev
, comedi_subdevice
* s
,
786 comedi_insn
* insn
, unsigned int * data
)
788 int chan
= insn
->chanspec
;
790 //printk("Reading counter channel %d ",chan);
791 data
[0] = i8254_read_channel(&devpriv
->i8254
, chan
);
792 //printk("=> 0x%08X\n",data[0]);
797 static int das08_counter_write(comedi_device
* dev
, comedi_subdevice
* s
,
798 comedi_insn
* insn
, unsigned int * data
)
800 int chan
= insn
->chanspec
;
802 //printk("Writing counter channel %d with 0x%04X\n",chan,data[0]);
803 i8254_write_channel(&devpriv
->i8254
, chan
, data
[0]);
808 static int das08_counter_config(comedi_device
* dev
, comedi_subdevice
* s
,
809 comedi_insn
* insn
, unsigned int * data
)
811 int chan
= insn
->chanspec
;
817 case INSN_CONFIG_SET_COUNTER_MODE
:
818 i8254_set_mode(&devpriv
->i8254
, chan
, data
[1]);
820 case INSN_CONFIG_8254_READ_STATUS
:
821 data
[1] = i8254_read_status(&devpriv
->i8254
, chan
);
830 static int das08_attach(comedi_device
* dev
, comedi_devconfig
* it
);
832 static comedi_driver driver_das08
= {
833 driver_name
: DRV_NAME
,
836 detach
:das08_common_detach
,
837 board_name
:&das08_boards
[0].name
,
838 num_names
:sizeof(das08_boards
) /
839 sizeof(struct das08_board_struct
),
840 offset
:sizeof(struct das08_board_struct
),
843 int das08_common_attach(comedi_device
* dev
, unsigned long iobase
)
848 // allocate ioports for non-pcmcia, non-pci boards
849 if ((thisboard
->bustype
!= pcmcia
) && (thisboard
->bustype
!= pci
)) {
850 printk(" iobase 0x%lx\n", iobase
);
851 if (!request_region(iobase
, thisboard
->iosize
, DRV_NAME
)) {
852 printk(" I/O port conflict\n");
856 dev
->iobase
= iobase
;
858 dev
->board_name
= thisboard
->name
;
860 if ((ret
= alloc_subdevices(dev
, 6)) < 0)
863 s
= dev
->subdevices
+ 0;
866 s
->type
= COMEDI_SUBD_AI
;
867 /* XXX some boards actually have differential inputs instead of single ended.
868 * The driver does nothing with arefs though, so it's no big deal. */
869 s
->subdev_flags
= SDF_READABLE
| SDF_GROUND
;
871 s
->maxdata
= (1 << thisboard
->ai_nbits
) - 1;
872 s
->range_table
= das08_ai_lranges
[thisboard
->ai_pg
];
873 s
->insn_read
= thisboard
->ai
;
874 devpriv
->pg_gainlist
= das08_gainlists
[thisboard
->ai_pg
];
876 s
->type
= COMEDI_SUBD_UNUSED
;
879 s
= dev
->subdevices
+ 1;
882 s
->type
= COMEDI_SUBD_AO
;
883 // XXX lacks read-back insn
884 s
->subdev_flags
= SDF_WRITABLE
;
886 s
->maxdata
= (1 << thisboard
->ao_nbits
) - 1;
887 s
->range_table
= &range_bipolar5
;
888 s
->insn_write
= thisboard
->ao
;
890 s
->type
= COMEDI_SUBD_UNUSED
;
893 s
= dev
->subdevices
+ 2;
896 s
->type
= COMEDI_SUBD_DI
;
897 s
->subdev_flags
= SDF_READABLE
;
898 s
->n_chan
= (thisboard
->di
== das08_di_rbits
) ? 3 : 8;
900 s
->range_table
= &range_digital
;
901 s
->insn_bits
= thisboard
->di
;
903 s
->type
= COMEDI_SUBD_UNUSED
;
906 s
= dev
->subdevices
+ 3;
908 if (thisboard
->do_
) {
909 s
->type
= COMEDI_SUBD_DO
;
910 s
->subdev_flags
= SDF_WRITABLE
| SDF_READABLE
;
911 s
->n_chan
= thisboard
->do_nchan
;
913 s
->range_table
= &range_digital
;
914 s
->insn_bits
= thisboard
->do_
;
916 s
->type
= COMEDI_SUBD_UNUSED
;
919 s
= dev
->subdevices
+ 4;
921 if (thisboard
->i8255_offset
!= 0) {
922 subdev_8255_init(dev
, s
, NULL
, (unsigned long)(dev
->iobase
+
923 thisboard
->i8255_offset
));
925 s
->type
= COMEDI_SUBD_UNUSED
;
928 s
= dev
->subdevices
+ 5;
930 if (thisboard
->i8254_offset
!= 0) {
931 s
->type
= COMEDI_SUBD_COUNTER
;
932 s
->subdev_flags
= SDF_WRITABLE
| SDF_READABLE
;
935 s
->insn_read
= das08_counter_read
;
936 s
->insn_write
= das08_counter_write
;
937 s
->insn_config
= das08_counter_config
;
938 /* Set-up the 8254 structure */
939 devpriv
->i8254
.channels
= 3;
940 devpriv
->i8254
.logic2phys
[0] = 0;
941 devpriv
->i8254
.logic2phys
[1] = 1;
942 devpriv
->i8254
.logic2phys
[2] = 2;
943 devpriv
->i8254
.iobase
= iobase
+ thisboard
->i8254_offset
;
944 devpriv
->i8254
.mode
[0] =
945 devpriv
->i8254
.mode
[1] =
946 devpriv
->i8254
.mode
[2] = I8254_MODE0
| I8254_BINARY
;
947 i8254_initialize(&devpriv
->i8254
);
949 s
->type
= COMEDI_SUBD_UNUSED
;
955 static int das08_attach(comedi_device
* dev
, comedi_devconfig
* it
)
958 unsigned long iobase
;
959 #ifdef CONFIG_COMEDI_PCI
960 unsigned long pci_iobase
= 0;
961 struct pci_dev
*pdev
;
964 if ((ret
= alloc_private(dev
, sizeof(struct das08_private_struct
))) < 0)
967 printk("comedi%d: das08: ", dev
->minor
);
968 // deal with a pci board
969 if (thisboard
->bustype
== pci
) {
970 #ifdef CONFIG_COMEDI_PCI
971 if (it
->options
[0] || it
->options
[1]) {
972 printk("bus %i slot %i ",
973 it
->options
[0], it
->options
[1]);
977 for (pdev
= pci_get_device(PCI_ANY_ID
, PCI_ANY_ID
, NULL
);
979 pdev
= pci_get_device(PCI_ANY_ID
, PCI_ANY_ID
, pdev
)) {
980 if (pdev
->vendor
== PCI_VENDOR_ID_COMPUTERBOARDS
981 && pdev
->device
== PCI_DEVICE_ID_PCIDAS08
) {
982 if (it
->options
[0] || it
->options
[1]) {
983 if (pdev
->bus
->number
== it
->options
[0]
984 && PCI_SLOT(pdev
->devfn
) ==
994 printk("No pci das08 cards found\n");
997 devpriv
->pdev
= pdev
;
998 // enable PCI device and reserve I/O spaces
999 if (comedi_pci_enable(pdev
, DRV_NAME
)) {
1000 printk(" Error enabling PCI device and requesting regions\n");
1003 // read base addresses
1004 pci_iobase
= pci_resource_start(pdev
, 1);
1005 iobase
= pci_resource_start(pdev
, 2);
1006 printk("pcibase 0x%lx iobase 0x%lx\n", pci_iobase
, iobase
);
1007 devpriv
->pci_iobase
= pci_iobase
;
1009 /* We could enable to pci-das08's interrupt here to make it possible
1010 * to do timed input in this driver, but there is little point since
1011 * conversions would have to be started by the interrupt handler
1012 * so you might as well use comedi_rt_timer to emulate commands
1014 /* set source of interrupt trigger to counter2 output */
1015 outb(CNTRL_INTR
| CNTRL_DIR
, pci_iobase
+ CNTRL
);
1016 /* Enable local interrupt 1 and pci interrupt */
1017 outw(INTR1_ENABLE
| PCI_INTR_ENABLE
, pci_iobase
+ INTCSR
);
1019 #else /* CONFIG_COMEDI_PCI */
1020 printk("this driver has not been built with PCI support.\n");
1022 #endif /* CONFIG_COMEDI_PCI */
1024 iobase
= it
->options
[0];
1028 return das08_common_attach(dev
, iobase
);
1031 int das08_common_detach(comedi_device
* dev
)
1033 printk(KERN_INFO
"comedi%d: das08: remove\n", dev
->minor
);
1035 if (dev
->subdevices
)
1036 subdev_8255_cleanup(dev
, dev
->subdevices
+ 4);
1038 // deallocate ioports for non-pcmcia, non-pci boards
1039 if ((thisboard
->bustype
!= pcmcia
) && (thisboard
->bustype
!= pci
)) {
1041 release_region(dev
->iobase
, thisboard
->iosize
);
1044 #ifdef CONFIG_COMEDI_PCI
1046 if (devpriv
->pdev
) {
1047 if (devpriv
->pci_iobase
) {
1048 comedi_pci_disable(devpriv
->pdev
);
1050 pci_dev_put(devpriv
->pdev
);
1058 #ifdef CONFIG_COMEDI_PCI
1059 COMEDI_PCI_INITCLEANUP(driver_das08
, das08_pci_table
);
1061 COMEDI_INITCLEANUP(driver_das08
);
1064 EXPORT_SYMBOL_GPL(das08_common_attach
);
1065 EXPORT_SYMBOL_GPL(das08_common_detach
);
1066 #ifdef CONFIG_COMEDI_PCMCIA
1067 EXPORT_SYMBOL_GPL(das08_cs_boards
);