From e875132a3a6d5dce0211f69ac5ad5ba6356b5180 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 23 Feb 2015 14:57:44 -0700 Subject: [PATCH] staging: comedi: ni_at_a2150: convert driver to use the comedi_8254 module The hardware supported by this driver includes an 8254 timer. For aesthetics, 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 --- drivers/staging/comedi/Kconfig | 1 + drivers/staging/comedi/drivers/ni_at_a2150.c | 17 +++++++---------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig index 20a906d49c42..b90b8a88273d 100644 --- a/drivers/staging/comedi/Kconfig +++ b/drivers/staging/comedi/Kconfig @@ -469,6 +469,7 @@ config COMEDI_ADQ12B config COMEDI_NI_AT_A2150 tristate "NI AT-A2150 ISA card support" select COMEDI_ISADMA if ISA_DMA_API + select COMEDI_8254 ---help--- Enable support for National Instruments AT-A2150 cards diff --git a/drivers/staging/comedi/drivers/ni_at_a2150.c b/drivers/staging/comedi/drivers/ni_at_a2150.c index a1ce0b0b8c41..66c0e65a953a 100644 --- a/drivers/staging/comedi/drivers/ni_at_a2150.c +++ b/drivers/staging/comedi/drivers/ni_at_a2150.c @@ -68,7 +68,7 @@ TRIG_WAKE_EOS #include "comedi_isadma.h" #include "comedi_fc.h" -#include "8253.h" +#include "comedi_8254.h" #define A2150_DMA_BUFFER_SIZE 0xff00 /* size in bytes of dma buffer */ @@ -110,8 +110,6 @@ TRIG_WAKE_EOS #define DMA_INTR_EN_BIT 0x800 /* enable interrupt on dma terminal count */ #define DMA_DEM_EN_BIT 0x1000 /* enables demand mode dma */ #define I8253_BASE_REG 0x14 -#define I8253_MODE_REG 0x17 -#define HW_COUNT_DISABLE 0x30 /* disable hardware counting of conversions */ struct a2150_board { const char *name; @@ -488,7 +486,6 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) struct comedi_isadma_desc *desc = &dma->desc[0]; struct comedi_async *async = s->async; struct comedi_cmd *cmd = &async->cmd; - unsigned long timer_base = dev->iobase + I8253_BASE_REG; unsigned int old_config_bits = devpriv->config_bits; unsigned int trigger_bits; @@ -547,8 +544,7 @@ static int a2150_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG); /* may need to wait 72 sampling periods if timing was changed */ - i8254_set_mode(timer_base, 0, 2, I8254_MODE0 | I8254_BINARY); - i8254_write(timer_base, 0, 2, 72); + comedi_8254_load(dev->pacer, 2, 72, I8254_MODE0 | I8254_BINARY); /* setup start triggering */ trigger_bits = 0; @@ -726,6 +722,11 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) /* an IRQ and DMA are required to support async commands */ a2150_alloc_irq_and_dma(dev, it); + dev->pacer = comedi_8254_init(dev->iobase + I8253_BASE_REG, + 0, I8254_IO8, 0); + if (!dev->pacer) + return -ENOMEM; + ret = comedi_alloc_subdevices(dev, 1); if (ret) return ret; @@ -747,10 +748,6 @@ static int a2150_attach(struct comedi_device *dev, struct comedi_devconfig *it) s->cancel = a2150_cancel; } - /* need to do this for software counting of completed conversions, to - * prevent hardware count from stopping acquisition */ - outw(HW_COUNT_DISABLE, dev->iobase + I8253_MODE_REG); - /* set card's irq and dma levels */ outw(devpriv->irq_dma_bits, dev->iobase + IRQ_DMA_CNTRL_REG); -- 2.30.2