3 * Comedi driver for Analog Devices RTI-802 board
5 * COMEDI - Linux Control and Measurement Device Interface
6 * Copyright (C) 1999 Anders Blomdell <anders.blomdell@control.lth.se>
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.
21 * Description: Analog Devices RTI-802
22 * Author: Anders Blomdell <anders.blomdell@control.lth.se>
23 * Devices: [Analog Devices] RTI-802 (rti802)
26 * Configuration Options:
29 * [2,4,6,8,10,12,14,16] - dac#[0-7] 0=two's comp, 1=straight
30 * [3,5,7,9,11,13,15,17] - dac#[0-7] 0=bipolar, 1=unipolar
33 #include <linux/module.h>
34 #include "../comedidev.h"
39 #define RTI802_SELECT 0x00
40 #define RTI802_DATALOW 0x01
41 #define RTI802_DATAHIGH 0x02
43 struct rti802_private
{
45 dac_2comp
, dac_straight
47 const struct comedi_lrange
*range_type_list
[8];
50 static int rti802_ao_insn_write(struct comedi_device
*dev
,
51 struct comedi_subdevice
*s
,
52 struct comedi_insn
*insn
,
55 struct rti802_private
*devpriv
= dev
->private;
56 unsigned int chan
= CR_CHAN(insn
->chanspec
);
59 outb(chan
, dev
->iobase
+ RTI802_SELECT
);
61 for (i
= 0; i
< insn
->n
; i
++) {
62 unsigned int val
= data
[i
];
64 s
->readback
[chan
] = val
;
66 /* munge offset binary to two's complement if needed */
67 if (devpriv
->dac_coding
[chan
] == dac_2comp
)
68 val
= comedi_offset_munge(s
, val
);
70 outb(val
& 0xff, dev
->iobase
+ RTI802_DATALOW
);
71 outb((val
>> 8) & 0xff, dev
->iobase
+ RTI802_DATAHIGH
);
77 static int rti802_attach(struct comedi_device
*dev
, struct comedi_devconfig
*it
)
79 struct rti802_private
*devpriv
;
80 struct comedi_subdevice
*s
;
84 ret
= comedi_request_region(dev
, it
->options
[0], 0x04);
88 devpriv
= comedi_alloc_devpriv(dev
, sizeof(*devpriv
));
92 ret
= comedi_alloc_subdevices(dev
, 1);
96 /* Analog Output subdevice */
97 s
= &dev
->subdevices
[0];
98 s
->type
= COMEDI_SUBD_AO
;
99 s
->subdev_flags
= SDF_WRITABLE
;
102 s
->insn_write
= rti802_ao_insn_write
;
104 ret
= comedi_alloc_subdev_readback(s
);
108 s
->range_table_list
= devpriv
->range_type_list
;
109 for (i
= 0; i
< 8; i
++) {
110 devpriv
->dac_coding
[i
] = (it
->options
[3 + 2 * i
])
111 ? (dac_straight
) : (dac_2comp
);
112 devpriv
->range_type_list
[i
] = (it
->options
[2 + 2 * i
])
113 ? &range_unipolar10
: &range_bipolar10
;
119 static struct comedi_driver rti802_driver
= {
120 .driver_name
= "rti802",
121 .module
= THIS_MODULE
,
122 .attach
= rti802_attach
,
123 .detach
= comedi_legacy_detach
,
125 module_comedi_driver(rti802_driver
);
127 MODULE_AUTHOR("Comedi http://www.comedi.org");
128 MODULE_DESCRIPTION("Comedi driver for Analog Devices RTI-802 board");
129 MODULE_LICENSE("GPL");