Commit b3c8ee5c authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_apci_3120: move timer helpers to main driver source

Move the timer read/write and set mode helpers from the included source
file into the main driver source file.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e6da4c6a
...@@ -171,59 +171,6 @@ static const struct comedi_lrange range_apci3120_ai = { ...@@ -171,59 +171,6 @@ static const struct comedi_lrange range_apci3120_ai = {
} }
}; };
static void apci3120_timer_write(struct comedi_device *dev,
unsigned int timer, unsigned int val)
{
struct apci3120_private *devpriv = dev->private;
/* write 16-bit value to timer (lower 16-bits of timer 2) */
outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
APCI3120_CTR0_TIMER_SEL(timer),
dev->iobase + APCI3120_CTR0_REG);
outw(val & 0xffff, dev->iobase + APCI3120_TIMER_REG);
if (timer == 2) {
/* write upper 16-bits to timer 2 */
outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
APCI3120_CTR0_TIMER_SEL(timer + 1),
dev->iobase + APCI3120_CTR0_REG);
outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_REG);
}
}
static unsigned int apci3120_timer_read(struct comedi_device *dev,
unsigned int timer)
{
struct apci3120_private *devpriv = dev->private;
unsigned int val;
/* read 16-bit value from timer (lower 16-bits of timer 2) */
outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
APCI3120_CTR0_TIMER_SEL(timer),
dev->iobase + APCI3120_CTR0_REG);
val = inw(dev->iobase + APCI3120_TIMER_REG);
if (timer == 2) {
/* read upper 16-bits from timer 2 */
outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
APCI3120_CTR0_TIMER_SEL(timer + 1),
dev->iobase + APCI3120_CTR0_REG);
val |= (inw(dev->iobase + APCI3120_TIMER_REG) << 16);
}
return val;
}
static void apci3120_timer_set_mode(struct comedi_device *dev,
unsigned int timer, unsigned int mode)
{
struct apci3120_private *devpriv = dev->private;
devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(timer);
devpriv->timer_mode |= APCI3120_TIMER_MODE(timer, mode);
outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_MODE_REG);
}
static int apci3120_ai_insn_config(struct comedi_device *dev, static int apci3120_ai_insn_config(struct comedi_device *dev,
struct comedi_subdevice *s, struct comedi_subdevice *s,
struct comedi_insn *insn, struct comedi_insn *insn,
......
...@@ -150,6 +150,59 @@ static unsigned int apci3120_ns_to_timer(struct comedi_device *dev, ...@@ -150,6 +150,59 @@ static unsigned int apci3120_ns_to_timer(struct comedi_device *dev,
return divisor; return divisor;
} }
static void apci3120_timer_write(struct comedi_device *dev,
unsigned int timer, unsigned int val)
{
struct apci3120_private *devpriv = dev->private;
/* write 16-bit value to timer (lower 16-bits of timer 2) */
outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
APCI3120_CTR0_TIMER_SEL(timer),
dev->iobase + APCI3120_CTR0_REG);
outw(val & 0xffff, dev->iobase + APCI3120_TIMER_REG);
if (timer == 2) {
/* write upper 16-bits to timer 2 */
outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
APCI3120_CTR0_TIMER_SEL(timer + 1),
dev->iobase + APCI3120_CTR0_REG);
outw((val >> 16) & 0xffff, dev->iobase + APCI3120_TIMER_REG);
}
}
static unsigned int apci3120_timer_read(struct comedi_device *dev,
unsigned int timer)
{
struct apci3120_private *devpriv = dev->private;
unsigned int val;
/* read 16-bit value from timer (lower 16-bits of timer 2) */
outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
APCI3120_CTR0_TIMER_SEL(timer),
dev->iobase + APCI3120_CTR0_REG);
val = inw(dev->iobase + APCI3120_TIMER_REG);
if (timer == 2) {
/* read upper 16-bits from timer 2 */
outb(APCI3120_CTR0_DO_BITS(devpriv->do_bits) |
APCI3120_CTR0_TIMER_SEL(timer + 1),
dev->iobase + APCI3120_CTR0_REG);
val |= (inw(dev->iobase + APCI3120_TIMER_REG) << 16);
}
return val;
}
static void apci3120_timer_set_mode(struct comedi_device *dev,
unsigned int timer, unsigned int mode)
{
struct apci3120_private *devpriv = dev->private;
devpriv->timer_mode &= ~APCI3120_TIMER_MODE_MASK(timer);
devpriv->timer_mode |= APCI3120_TIMER_MODE(timer, mode);
outb(devpriv->timer_mode, dev->iobase + APCI3120_TIMER_MODE_REG);
}
#include "addi-data/hwdrv_apci3120.c" #include "addi-data/hwdrv_apci3120.c"
static void apci3120_dma_alloc(struct comedi_device *dev) static void apci3120_dma_alloc(struct comedi_device *dev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment