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

staging: comedi: addi_apci_3120: tidy up APCI3120_ENABLE_TIMER[012]

For aesthetics, replace these defines with a macro that returns the
correct bit needed to set the gate bit to enable a timer.
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 e0ca363a
...@@ -101,7 +101,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY ...@@ -101,7 +101,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
#define APCI3120_10_GAIN 0x30 #define APCI3120_10_GAIN 0x30
#define APCI3120_SEQ_RAM_ADDRESS 0x06 #define APCI3120_SEQ_RAM_ADDRESS 0x06
#define APCI3120_RESET_FIFO 0x0c #define APCI3120_RESET_FIFO 0x0c
#define APCI3120_ENABLE_TIMER0 0x1000
/* nWrMode_Select */ /* nWrMode_Select */
#define APCI3120_ENABLE_SCAN 0x8 #define APCI3120_ENABLE_SCAN 0x8
...@@ -130,7 +129,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY ...@@ -130,7 +129,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
#define APCI3120_WATCHDOG 2 #define APCI3120_WATCHDOG 2
#define APCI3120_TIMER_DISABLE 0 #define APCI3120_TIMER_DISABLE 0
#define APCI3120_TIMER_ENABLE 1 #define APCI3120_TIMER_ENABLE 1
#define APCI3120_ENABLE_TIMER2 0x4000
#define APCI3120_ENABLE_TIMER_INT 0x04 #define APCI3120_ENABLE_TIMER_INT 0x04
#define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT) #define APCI3120_DISABLE_TIMER_INT (~APCI3120_ENABLE_TIMER_INT)
#define APCI3120_WRITE_MODE_SELECT 0x0e #define APCI3120_WRITE_MODE_SELECT 0x0e
...@@ -143,9 +141,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY ...@@ -143,9 +141,6 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
#define APCI3120_ENABLE_TIMER_COUNTER 0x10 #define APCI3120_ENABLE_TIMER_COUNTER 0x10
#define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER) #define APCI3120_DISABLE_TIMER_COUNTER (~APCI3120_ENABLE_TIMER_COUNTER)
#define APCI3120_FC_TIMER 0x1000 #define APCI3120_FC_TIMER 0x1000
#define APCI3120_ENABLE_TIMER0 0x1000
#define APCI3120_ENABLE_TIMER1 0x2000
#define APCI3120_ENABLE_TIMER2 0x4000
#define APCI3120_TIMER2_SELECT_EOS 0xc0 #define APCI3120_TIMER2_SELECT_EOS 0xc0
#define APCI3120_COUNTER 3 #define APCI3120_COUNTER 3
...@@ -338,7 +333,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, ...@@ -338,7 +333,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
dev->iobase + APCI3120_WRITE_MODE_SELECT); dev->iobase + APCI3120_WRITE_MODE_SELECT);
/* Sets gate 0 */ /* Sets gate 0 */
devpriv->ctrl |= APCI3120_ENABLE_TIMER0; devpriv->ctrl |= APCI3120_CTRL_GATE(0);
outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
/* Set the conversion time */ /* Set the conversion time */
...@@ -411,7 +406,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev, ...@@ -411,7 +406,7 @@ static int apci3120_ai_insn_read(struct comedi_device *dev,
inw(dev->iobase + APCI3120_RD_STATUS); inw(dev->iobase + APCI3120_RD_STATUS);
/* Sets gate 0 */ /* Sets gate 0 */
devpriv->ctrl |= APCI3120_ENABLE_TIMER0; devpriv->ctrl |= APCI3120_CTRL_GATE(0);
outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
/* Start conversion */ /* Start conversion */
...@@ -903,20 +898,20 @@ static int apci3120_cyclic_ai(int mode, ...@@ -903,20 +898,20 @@ static int apci3120_cyclic_ai(int mode,
if (devpriv->us_UseDma == APCI3120_DISABLE && if (devpriv->us_UseDma == APCI3120_DISABLE &&
cmd->stop_src == TRIG_COUNT) { cmd->stop_src == TRIG_COUNT) {
/* set gate 2 to start conversion */ /* set gate 2 to start conversion */
devpriv->ctrl |= APCI3120_ENABLE_TIMER2; devpriv->ctrl |= APCI3120_CTRL_GATE(2);
outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
} }
switch (mode) { switch (mode) {
case 1: case 1:
/* set gate 0 to start conversion */ /* set gate 0 to start conversion */
devpriv->ctrl |= APCI3120_ENABLE_TIMER0; devpriv->ctrl |= APCI3120_CTRL_GATE(0);
outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
break; break;
case 2: case 2:
/* set gate 0 and gate 1 */ /* set gate 0 and gate 1 */
devpriv->ctrl |= APCI3120_ENABLE_TIMER1 | devpriv->ctrl |= APCI3120_CTRL_GATE(1) |
APCI3120_ENABLE_TIMER0; APCI3120_CTRL_GATE(0);
outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
break; break;
...@@ -1251,8 +1246,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d) ...@@ -1251,8 +1246,8 @@ static irqreturn_t apci3120_interrupt(int irq, void *d)
} else { } else {
/* Stops the Timer */ /* Stops the Timer */
outw(devpriv->ctrl & outw(devpriv->ctrl &
~APCI3120_ENABLE_TIMER0 & ~APCI3120_CTRL_GATE(0) &
~APCI3120_ENABLE_TIMER1, ~APCI3120_CTRL_GATE(1),
dev->iobase + APCI3120_WR_ADDRESS); dev->iobase + APCI3120_WR_ADDRESS);
} }
...@@ -1286,7 +1281,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev, ...@@ -1286,7 +1281,7 @@ static int apci3120_config_insn_timer(struct comedi_device *dev,
divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN); divisor = apci3120_ns_to_timer(dev, 2, data[1], CMDF_ROUND_DOWN);
/* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */ /* Reset gate 2 of Timer 2 to disable it (Set Bit D14 to 0) */
devpriv->ctrl &= ~APCI3120_ENABLE_TIMER2; devpriv->ctrl &= ~APCI3120_CTRL_GATE(2);
outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
/* Disable TIMER Interrupt */ /* Disable TIMER Interrupt */
...@@ -1398,7 +1393,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev, ...@@ -1398,7 +1393,7 @@ static int apci3120_write_insn_timer(struct comedi_device *dev,
if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */ if (devpriv->b_Timer2Mode == APCI3120_TIMER) { /* start timer */
/* For Timer mode is Gate2 must be activated timer started */ /* For Timer mode is Gate2 must be activated timer started */
devpriv->ctrl |= APCI3120_ENABLE_TIMER2; devpriv->ctrl |= APCI3120_CTRL_GATE(2);
outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS); outw(devpriv->ctrl, dev->iobase + APCI3120_WR_ADDRESS);
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
/* /*
* PCI BAR 1 register map (dev->iobase) * PCI BAR 1 register map (dev->iobase)
*/ */
#define APCI3120_CTRL_GATE(x) (1 << (12 + (x)))
#define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8) #define APCI3120_CTRL_PR(x) (((x) & 0xf) << 8)
#define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0) #define APCI3120_CTRL_PA(x) (((x) & 0xf) << 0)
#define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf) #define APCI3120_STATUS_TO_VERSION(x) (((x) >> 4) & 0xf)
......
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