staging: comedi: das6402: convert driver to use the comedi_8254 module
This driver uses an 8254 timer to generate the pacer clock used for analog input data conversion. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Remove the unnecessary programming of timer 0. The private data 'count' value is never set by the driver and the timer is reset to MODE0 when the timers are initialized during the attach of the driver. Remove the unnecessart convert_src check in the (*do_cmdtest). The only valid convert_src is TRIG_TIMER. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e875132a3a
commit
ad4808b690
|
@ -329,6 +329,7 @@ config COMEDI_DAS1800
|
|||
|
||||
config COMEDI_DAS6402
|
||||
tristate "DAS6402 and compatible ISA card support"
|
||||
select COMEDI_8254
|
||||
---help---
|
||||
Enable support for DAS6402 and compatible ISA cards
|
||||
Computerboards, Keithley Metrabyte DAS6402 and compatibles
|
||||
|
|
|
@ -35,8 +35,9 @@
|
|||
#include <linux/interrupt.h>
|
||||
|
||||
#include "../comedidev.h"
|
||||
|
||||
#include "comedi_fc.h"
|
||||
#include "8253.h"
|
||||
#include "comedi_8254.h"
|
||||
|
||||
/*
|
||||
* Register I/O map
|
||||
|
@ -138,11 +139,6 @@ static struct das6402_boardinfo das6402_boards[] = {
|
|||
|
||||
struct das6402_private {
|
||||
unsigned int irq;
|
||||
|
||||
unsigned int count;
|
||||
unsigned int divider1;
|
||||
unsigned int divider2;
|
||||
|
||||
unsigned int ao_range;
|
||||
};
|
||||
|
||||
|
@ -172,27 +168,6 @@ static void das6402_ai_clear_eoc(struct comedi_device *dev)
|
|||
outb(DAS6402_STATUS_W_CLRINT, dev->iobase + DAS6402_STATUS_REG);
|
||||
}
|
||||
|
||||
static void das6402_enable_counter(struct comedi_device *dev, bool load)
|
||||
{
|
||||
struct das6402_private *devpriv = dev->private;
|
||||
unsigned long timer_iobase = dev->iobase + DAS6402_TIMER_BASE;
|
||||
|
||||
if (load) {
|
||||
i8254_set_mode(timer_iobase, 0, 0, I8254_MODE0 | I8254_BINARY);
|
||||
i8254_set_mode(timer_iobase, 0, 1, I8254_MODE2 | I8254_BINARY);
|
||||
i8254_set_mode(timer_iobase, 0, 2, I8254_MODE2 | I8254_BINARY);
|
||||
|
||||
i8254_write(timer_iobase, 0, 0, devpriv->count);
|
||||
i8254_write(timer_iobase, 0, 1, devpriv->divider1);
|
||||
i8254_write(timer_iobase, 0, 2, devpriv->divider2);
|
||||
|
||||
} else {
|
||||
i8254_set_mode(timer_iobase, 0, 0, I8254_MODE0 | I8254_BINARY);
|
||||
i8254_set_mode(timer_iobase, 0, 1, I8254_MODE0 | I8254_BINARY);
|
||||
i8254_set_mode(timer_iobase, 0, 2, I8254_MODE0 | I8254_BINARY);
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int das6402_ai_read_sample(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s)
|
||||
{
|
||||
|
@ -267,7 +242,8 @@ static int das6402_ai_cmd(struct comedi_device *dev,
|
|||
outw(DAS6402_AI_MUX_HI(chan_hi) | DAS6402_AI_MUX_LO(chan_lo),
|
||||
dev->iobase + DAS6402_AI_MUX_REG);
|
||||
|
||||
das6402_enable_counter(dev, true);
|
||||
comedi_8254_update_divisors(dev->pacer);
|
||||
comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
|
||||
|
||||
/* enable interrupt and pacer trigger */
|
||||
outb(DAS6402_CTRL_INTE |
|
||||
|
@ -322,7 +298,6 @@ static int das6402_ai_cmdtest(struct comedi_device *dev,
|
|||
struct comedi_subdevice *s,
|
||||
struct comedi_cmd *cmd)
|
||||
{
|
||||
struct das6402_private *devpriv = dev->private;
|
||||
int err = 0;
|
||||
unsigned int arg;
|
||||
|
||||
|
@ -364,14 +339,9 @@ static int das6402_ai_cmdtest(struct comedi_device *dev,
|
|||
|
||||
/* step 4: fix up any arguments */
|
||||
|
||||
if (cmd->convert_src == TRIG_TIMER) {
|
||||
arg = cmd->convert_arg;
|
||||
i8253_cascade_ns_to_timer(I8254_OSC_BASE_10MHZ,
|
||||
&devpriv->divider1,
|
||||
&devpriv->divider2,
|
||||
&arg, cmd->flags);
|
||||
err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
|
||||
}
|
||||
arg = cmd->convert_arg;
|
||||
comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
|
||||
err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
|
||||
|
||||
if (err)
|
||||
return 4;
|
||||
|
@ -581,8 +551,6 @@ static void das6402_reset(struct comedi_device *dev)
|
|||
outw(0, dev->iobase + DAS6402_AO_DATA_REG(0));
|
||||
inw(dev->iobase + DAS6402_AO_LSB_REG(0));
|
||||
|
||||
das6402_enable_counter(dev, false);
|
||||
|
||||
/* set all digital outputs low */
|
||||
outb(0, dev->iobase + DAS6402_DI_DO_REG);
|
||||
|
||||
|
@ -631,6 +599,11 @@ static int das6402_attach(struct comedi_device *dev,
|
|||
}
|
||||
}
|
||||
|
||||
dev->pacer = comedi_8254_init(dev->iobase + DAS6402_TIMER_BASE,
|
||||
I8254_OSC_BASE_10MHZ, I8254_IO8, 0);
|
||||
if (!dev->pacer)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue