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

staging: comedi: cb_pcidas: tidy up DAC control/status register

Rename this register and its bit defines so they have namespace
associated with the driver. Use the BIT macro to define the bits.

For aesthetics, rename the associated member of the private data.
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 21b6476a
...@@ -133,22 +133,21 @@ ...@@ -133,22 +133,21 @@
#define PCIDAS_CALIB_EN BIT(14) /* calibration source enable */ #define PCIDAS_CALIB_EN BIT(14) /* calibration source enable */
#define PCIDAS_CALIB_DATA BIT(15) /* serial data bit going to caldac */ #define PCIDAS_CALIB_DATA BIT(15) /* serial data bit going to caldac */
#define DAC_CSR 0x8 /* dac control and status register */ #define PCIDAS_AO_REG 0x08 /* dac control and status register */
#define DACEN 0x02 /* dac enable */ #define PCIDAS_AO_EMPTY BIT(0) /* fifo empty, write clear (1602) */
#define DAC_MODE_UPDATE_BOTH 0x80 /* update both dacs */ #define PCIDAS_AO_DACEN BIT(1) /* dac enable */
#define PCIDAS_AO_START BIT(2) /* start/arm fifo (1602) */
#define DAC_RANGE(c, r) (((r) & 0x3) << (8 + 2 * ((c) & 0x1))) #define PCIDAS_AO_PACER(x) (((x) & 0x3) << 3) /* (1602) */
#define DAC_RANGE_MASK(c) DAC_RANGE((c), 0x3) #define PCIDAS_AO_PACER_SW PCIDAS_AO_PACER(0) /* software pacer */
#define PCIDAS_AO_PACER_INT PCIDAS_AO_PACER(1) /* int. pacer */
/* bits for 1602 series only */ #define PCIDAS_AO_PACER_EXTN PCIDAS_AO_PACER(2) /* ext. falling edge */
#define DAC_EMPTY 0x1 /* fifo empty, read, write clear */ #define PCIDAS_AO_PACER_EXTP PCIDAS_AO_PACER(3) /* ext. rising edge */
#define DAC_START 0x4 /* start/arm fifo operations */ #define PCIDAS_AO_PACER_MASK PCIDAS_AO_PACER(3) /* pacer source bits */
#define DAC_PACER_MASK 0x18 /* bits that set pacer source */ #define PCIDAS_AO_CHAN_EN(c) BIT(5 + ((c) & 0x1))
#define DAC_PACER_INT 0x8 /* int. pacing */ #define PCIDAS_AO_CHAN_MASK (PCIDAS_AO_CHAN_EN(0) | PCIDAS_AO_CHAN_EN(1))
#define DAC_PACER_EXT_FALL 0x10 /* ext. pacing, falling edge */ #define PCIDAS_AO_UPDATE_BOTH BIT(7) /* update both dacs */
#define DAC_PACER_EXT_RISE 0x18 /* ext. pacing, rising edge */ #define PCIDAS_AO_RANGE(c, r) (((r) & 0x3) << (8 + 2 * ((c) & 0x1)))
#define PCIDAS_AO_RANGE_MASK(c) PCIDAS_AO_RANGE((c), 0x3)
#define DAC_CHAN_EN(c) BIT(5 + ((c) & 0x1))
/* /*
* PCI BAR2 Register map (devpriv->pcibar2) * PCI BAR2 Register map (devpriv->pcibar2)
...@@ -316,7 +315,7 @@ struct cb_pcidas_private { ...@@ -316,7 +315,7 @@ struct cb_pcidas_private {
/* bits to write to registers */ /* bits to write to registers */
unsigned int ctrl; unsigned int ctrl;
unsigned int s5933_intcsr_bits; unsigned int s5933_intcsr_bits;
unsigned int ao_control_bits; unsigned int ao_ctrl;
/* fifo buffers */ /* fifo buffers */
unsigned short ai_buffer[AI_BUFFER_SIZE]; unsigned short ai_buffer[AI_BUFFER_SIZE];
unsigned short ao_buffer[AO_BUFFER_SIZE]; unsigned short ao_buffer[AO_BUFFER_SIZE];
...@@ -432,10 +431,10 @@ static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev, ...@@ -432,10 +431,10 @@ static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev,
/* set channel and range */ /* set channel and range */
spin_lock_irqsave(&dev->spinlock, flags); spin_lock_irqsave(&dev->spinlock, flags);
devpriv->ao_control_bits &= (~DAC_MODE_UPDATE_BOTH & devpriv->ao_ctrl &= ~(PCIDAS_AO_UPDATE_BOTH |
~DAC_RANGE_MASK(chan)); PCIDAS_AO_RANGE_MASK(chan));
devpriv->ao_control_bits |= (DACEN | DAC_RANGE(chan, range)); devpriv->ao_ctrl |= PCIDAS_AO_DACEN | PCIDAS_AO_RANGE(chan, range);
outw(devpriv->ao_control_bits, devpriv->pcibar1 + DAC_CSR); outw(devpriv->ao_ctrl, devpriv->pcibar1 + PCIDAS_AO_REG);
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
/* remember value for readback */ /* remember value for readback */
...@@ -462,11 +461,11 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, ...@@ -462,11 +461,11 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev,
/* set channel and range */ /* set channel and range */
spin_lock_irqsave(&dev->spinlock, flags); spin_lock_irqsave(&dev->spinlock, flags);
devpriv->ao_control_bits &= (~DAC_CHAN_EN(0) & ~DAC_CHAN_EN(1) & devpriv->ao_ctrl &= ~(PCIDAS_AO_CHAN_MASK | PCIDAS_AO_RANGE_MASK(chan) |
~DAC_RANGE_MASK(chan) & ~DAC_PACER_MASK); PCIDAS_AO_PACER_MASK);
devpriv->ao_control_bits |= (DACEN | DAC_RANGE(chan, range) | devpriv->ao_ctrl |= PCIDAS_AO_DACEN | PCIDAS_AO_RANGE(chan, range) |
DAC_CHAN_EN(chan) | DAC_START); PCIDAS_AO_CHAN_EN(chan) | PCIDAS_AO_START;
outw(devpriv->ao_control_bits, devpriv->pcibar1 + DAC_CSR); outw(devpriv->ao_ctrl, devpriv->pcibar1 + PCIDAS_AO_REG);
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
/* remember value for readback */ /* remember value for readback */
...@@ -1083,8 +1082,8 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev, ...@@ -1083,8 +1082,8 @@ static int cb_pcidas_ao_inttrig(struct comedi_device *dev,
devpriv->pcibar1 + PCIDAS_CTRL_REG); devpriv->pcibar1 + PCIDAS_CTRL_REG);
/* start dac */ /* start dac */
devpriv->ao_control_bits |= DAC_START | DACEN | DAC_EMPTY; devpriv->ao_ctrl |= PCIDAS_AO_START | PCIDAS_AO_DACEN | PCIDAS_AO_EMPTY;
outw(devpriv->ao_control_bits, devpriv->pcibar1 + DAC_CSR); outw(devpriv->ao_ctrl, devpriv->pcibar1 + PCIDAS_AO_REG);
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
...@@ -1109,13 +1108,13 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev, ...@@ -1109,13 +1108,13 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev,
unsigned int range = CR_RANGE(cmd->chanlist[i]); unsigned int range = CR_RANGE(cmd->chanlist[i]);
/* enable channel */ /* enable channel */
devpriv->ao_control_bits |= DAC_CHAN_EN(chan); devpriv->ao_ctrl |= PCIDAS_AO_CHAN_EN(chan);
/* set range */ /* set range */
devpriv->ao_control_bits |= DAC_RANGE(chan, range); devpriv->ao_ctrl |= PCIDAS_AO_RANGE(chan, range);
} }
/* disable analog out before settings pacer source and count values */ /* disable analog out before settings pacer source and count values */
outw(devpriv->ao_control_bits, devpriv->pcibar1 + DAC_CSR); outw(devpriv->ao_ctrl, devpriv->pcibar1 + PCIDAS_AO_REG);
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
/* clear fifo */ /* clear fifo */
...@@ -1131,10 +1130,10 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev, ...@@ -1131,10 +1130,10 @@ static int cb_pcidas_ao_cmd(struct comedi_device *dev,
spin_lock_irqsave(&dev->spinlock, flags); spin_lock_irqsave(&dev->spinlock, flags);
switch (cmd->scan_begin_src) { switch (cmd->scan_begin_src) {
case TRIG_TIMER: case TRIG_TIMER:
devpriv->ao_control_bits |= DAC_PACER_INT; devpriv->ao_ctrl |= PCIDAS_AO_PACER_INT;
break; break;
case TRIG_EXT: case TRIG_EXT:
devpriv->ao_control_bits |= DAC_PACER_EXT_RISE; devpriv->ao_ctrl |= PCIDAS_AO_PACER_EXTP;
break; break;
default: default:
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
...@@ -1161,8 +1160,8 @@ static int cb_pcidas_ao_cancel(struct comedi_device *dev, ...@@ -1161,8 +1160,8 @@ static int cb_pcidas_ao_cancel(struct comedi_device *dev,
outw(devpriv->ctrl, devpriv->pcibar1 + PCIDAS_CTRL_REG); outw(devpriv->ctrl, devpriv->pcibar1 + PCIDAS_CTRL_REG);
/* disable output */ /* disable output */
devpriv->ao_control_bits &= ~DACEN & ~DAC_PACER_MASK; devpriv->ao_ctrl &= ~(PCIDAS_AO_DACEN | PCIDAS_AO_PACER_MASK);
outw(devpriv->ao_control_bits, devpriv->pcibar1 + DAC_CSR); outw(devpriv->ao_ctrl, devpriv->pcibar1 + PCIDAS_AO_REG);
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
return 0; return 0;
...@@ -1183,7 +1182,7 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status) ...@@ -1183,7 +1182,7 @@ static void handle_ao_interrupt(struct comedi_device *dev, unsigned int status)
outw(devpriv->ctrl | PCIDAS_CTRL_DAEMI, outw(devpriv->ctrl | PCIDAS_CTRL_DAEMI,
devpriv->pcibar1 + PCIDAS_CTRL_REG); devpriv->pcibar1 + PCIDAS_CTRL_REG);
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
if (inw(devpriv->pcibar4 + DAC_CSR) & DAC_EMPTY) { if (inw(devpriv->pcibar4 + PCIDAS_AO_REG) & PCIDAS_AO_EMPTY) {
if (cmd->stop_src == TRIG_COUNT && if (cmd->stop_src == TRIG_COUNT &&
async->scans_done >= cmd->stop_arg) { async->scans_done >= cmd->stop_arg) {
async->events |= COMEDI_CB_EOA; async->events |= COMEDI_CB_EOA;
......
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