staging: comedi: das16: convert driver to use the comedi_8254 module
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 23 Feb 2015 21:57:52 +0000 (14:57 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 2 Mar 2015 02:51:51 +0000 (18:51 -0800)
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.

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>
drivers/staging/comedi/Kconfig
drivers/staging/comedi/drivers/das16.c

index 77c1c99b1116c6d13955aae1c704a8f7591d0bb6..30951a3286f63ed5413655b047801a0874c8b38b 100644 (file)
@@ -287,6 +287,7 @@ config COMEDI_DAS08_ISA
 config COMEDI_DAS16
        tristate "DAS-16 compatible ISA and PC/104 card support"
        select COMEDI_ISADMA if ISA_DMA_API
+       select COMEDI_8254
        select COMEDI_8255
        ---help---
          Enable support for Keithley Metrabyte/ComputerBoards DAS16
index 2c20311120f18638d251225a79bf88f36d69a11a..4b3bdade6596808c1d95f8f95129b1e4897727cb 100644 (file)
@@ -77,7 +77,7 @@
 
 #include "comedi_isadma.h"
 #include "comedi_fc.h"
-#include "8253.h"
+#include "comedi_8254.h"
 #include "8255.h"
 
 #define DAS16_DMA_SIZE 0xff00  /*  size in bytes of allocated dma buffer */
@@ -663,18 +663,12 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
        /*  step 4: fix up arguments */
        if (cmd->scan_begin_src == TRIG_TIMER) {
                arg = cmd->scan_begin_arg;
-               i8253_cascade_ns_to_timer(devpriv->clockbase,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->scan_begin_arg, arg);
        }
        if (cmd->convert_src == TRIG_TIMER) {
                arg = cmd->convert_arg;
-               i8253_cascade_ns_to_timer(devpriv->clockbase,
-                                         &devpriv->divisor1,
-                                         &devpriv->divisor2,
-                                         &arg, cmd->flags);
+               comedi_8254_cascade_ns_to_timer(dev->pacer, &arg, cmd->flags);
                err |= cfc_check_trigger_arg_is(&cmd->convert_arg, arg);
        }
        if (err)
@@ -693,17 +687,9 @@ static int das16_cmd_test(struct comedi_device *dev, struct comedi_subdevice *s,
 static unsigned int das16_set_pacer(struct comedi_device *dev, unsigned int ns,
                                    unsigned int flags)
 {
-       struct das16_private_struct *devpriv = dev->private;
-       unsigned long timer_base = dev->iobase + DAS16_TIMER_BASE_REG;
-
-       i8253_cascade_ns_to_timer(devpriv->clockbase,
-                                 &devpriv->divisor1, &devpriv->divisor2,
-                                 &ns, flags);
-
-       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);
+       comedi_8254_cascade_ns_to_timer(dev->pacer, &ns, flags);
+       comedi_8254_update_divisors(dev->pacer);
+       comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
 
        return ns;
 }
@@ -935,7 +921,6 @@ static void das16_reset(struct comedi_device *dev)
        outb(0, dev->iobase + DAS16_STATUS_REG);
        outb(0, dev->iobase + DAS16_CTRL_REG);
        outb(0, dev->iobase + DAS16_PACER_REG);
-       outb(0, dev->iobase + DAS16_TIMER_BASE_REG + i8254_control_reg);
 }
 
 static void das16_alloc_dma(struct comedi_device *dev, unsigned int dma_chan)
@@ -1039,6 +1024,7 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
        const struct das16_board *board = dev->board_ptr;
        struct das16_private_struct *devpriv;
        struct comedi_subdevice *s;
+       unsigned int osc_base;
        unsigned int status;
        int ret;
 
@@ -1078,21 +1064,21 @@ static int das16_attach(struct comedi_device *dev, struct comedi_devconfig *it)
                return -EINVAL;
 
        /*  get master clock speed */
+       osc_base = I8254_OSC_BASE_1MHZ;
        if (devpriv->can_burst) {
                status = inb(dev->iobase + DAS1600_STATUS_REG);
-
                if (status & DAS1600_STATUS_CLK_10MHZ)
-                       devpriv->clockbase = I8254_OSC_BASE_10MHZ;
-               else
-                       devpriv->clockbase = I8254_OSC_BASE_1MHZ;
+                       osc_base = I8254_OSC_BASE_10MHZ;
        } else {
                if (it->options[3])
-                       devpriv->clockbase = I8254_OSC_BASE_1MHZ /
-                                            it->options[3];
-               else
-                       devpriv->clockbase = I8254_OSC_BASE_1MHZ;
+                       osc_base = I8254_OSC_BASE_1MHZ / it->options[3];
        }
 
+       dev->pacer = comedi_8254_init(dev->iobase + DAS16_TIMER_BASE_REG,
+                                     osc_base, I8254_IO8, 0);
+       if (!dev->pacer)
+               return -ENOMEM;
+
        das16_alloc_dma(dev, it->options[2]);
 
        ret = comedi_alloc_subdevices(dev, 4 + board->has_8255);