From: H Hartley Sweeten Date: Mon, 23 Feb 2015 21:57:37 +0000 (-0700) Subject: staging: comedi: das800: convert driver to use the comedi_8254 module X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e4690dec50ebb886b33a62858d13266ee020e035;p=linux-beck.git staging: comedi: das800: convert driver to use the comedi_8254 module This driver uses an 8254 timer to generate the pacer clock used for analog input data acquisition. Convert it to use the comedi_8254 module to provide support for the 8254 timer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index c15cce4859fe..8de03c81d2a4 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -302,6 +302,7 @@ config COMEDI_DAS16 config COMEDI_DAS800 tristate "DAS800 and compatible ISA card support" + select COMEDI_8254 ---help--- Enable support for Keithley Metrabyte DAS800 and compatible ISA cards Keithley Metrabyte DAS-800, DAS-801, DAS-802 diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c index ff7f4be3f314..50ca03bd6459 100644 --- a/drivers/staging/comedi/drivers/das800.c +++ b/drivers/staging/comedi/drivers/das800.c @@ -58,12 +58,12 @@ cmd triggers supported: #include #include -#include "../comedidev.h" - #include -#include "8253.h" +#include "../comedidev.h" + #include "comedi_fc.h" +#include "comedi_8254.h" #define N_CHAN_AI 8 /* number of analog input channels */ @@ -219,8 +219,6 @@ static const struct das800_board das800_boards[] = { }; struct das800_private { - unsigned int divisor1; /* counter 1 value for timed conversions */ - unsigned int divisor2; /* counter 2 value for timed conversions */ unsigned int do_bits; /* digital output bits */ }; @@ -272,17 +270,6 @@ static void das800_disable(struct comedi_device *dev) spin_unlock_irqrestore(&dev->spinlock, irq_flags); } -static void das800_set_frequency(struct comedi_device *dev) -{ - struct das800_private *devpriv = dev->private; - unsigned long timer_base = dev->iobase + DAS800_8254; - - i8254_set_mode(timer_base, 0, 1, I8254_MODE2 | I8254_BINARY); - i8254_set_mode(timer_base, 0, 2, I8254_MODE2 | I8254_BINARY); - i8254_write(timer_base, 0, 1, devpriv->divisor1); - i8254_write(timer_base, 0, 2, devpriv->divisor2); -} - static int das800_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { das800_disable(dev); @@ -322,9 +309,7 @@ static int das800_ai_do_cmdtest(struct comedi_device *dev, struct comedi_cmd *cmd) { const struct das800_board *thisboard = dev->board_ptr; - struct das800_private *devpriv = dev->private; int err = 0; - unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -370,11 +355,9 @@ static int das800_ai_do_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_1MHZ, - &devpriv->divisor1, - &devpriv->divisor2, - &arg, cmd->flags); + unsigned int 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); } @@ -426,8 +409,8 @@ static int das800_ai_do_cmd(struct comedi_device *dev, conv_bits |= DTEN; if (cmd->convert_src == TRIG_TIMER) { conv_bits |= CASC | ITE; - /* set conversion frequency */ - das800_set_frequency(dev); + comedi_8254_update_divisors(dev->pacer); + comedi_8254_pacer_enable(dev->pacer, 1, 2, true); } spin_lock_irqsave(&dev->spinlock, irq_flags); @@ -697,6 +680,11 @@ static int das800_attach(struct comedi_device *dev, struct comedi_devconfig *it) dev->irq = irq; } + dev->pacer = comedi_8254_init(dev->iobase + DAS800_8254, + I8254_OSC_BASE_1MHZ, I8254_IO8, 0); + if (!dev->pacer) + return -ENOMEM; + ret = comedi_alloc_subdevices(dev, 3); if (ret) return ret;