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

staging: comedi: cb_pcidda: cleanup DACCONTROL defines

Rename the defines used for the D/A Control register so that they
have namespace with this driver. Cleanup the use of these defines.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c8ffd143
...@@ -65,16 +65,14 @@ ...@@ -65,16 +65,14 @@
#define CB_DDA_DIO1_8255_BASE 0x04 #define CB_DDA_DIO1_8255_BASE 0x04
/* DAC registers */ /* DAC registers */
#define DACONTROL 0 /* D/A CONTROL REGISTER */ #define CB_DDA_DA_CTRL_REG 0x00 /* D/A Control Register */
#define SU 0000001 /* Simultaneous update enabled */ #define CB_DDA_DA_CTRL_SU (1 << 0) /* Simultaneous update */
#define NOSU 0000000 /* Simultaneous update disabled */ #define CB_DDA_DA_CTRL_EN (1 << 1) /* Enable specified DAC */
#define ENABLEDAC 0000002 /* Enable specified DAC */ #define CB_DDA_DA_CTRL_DAC(x) ((x) << 2) /* Specify DAC channel */
#define DISABLEDAC 0000000 /* Disable specified DAC */ #define CB_DDA_DA_CTRL_RANGE2V5 (0 << 6) /* 2.5V range */
#define RANGE2V5 0000000 /* 2.5V */ #define CB_DDA_DA_CTRL_RANGE5V (2 << 6) /* 5V range */
#define RANGE5V 0000200 /* 5V */ #define CB_DDA_DA_CTRL_RANGE10V (3 << 6) /* 10V range */
#define RANGE10V 0000300 /* 10V */ #define CB_DDA_DA_CTRL_UNIP (1 << 8) /* Unipolar range */
#define UNIP 0000400 /* Unipolar outputs */
#define BIP 0000000 /* Bipolar outputs */
#define DACALIBRATION1 4 /* D/A CALIBRATION REGISTER 1 */ #define DACALIBRATION1 4 /* D/A CALIBRATION REGISTER 1 */
/* write bits */ /* write bits */
...@@ -364,44 +362,35 @@ static int cb_pcidda_ao_winsn(struct comedi_device *dev, ...@@ -364,44 +362,35 @@ static int cb_pcidda_ao_winsn(struct comedi_device *dev,
struct comedi_insn *insn, unsigned int *data) struct comedi_insn *insn, unsigned int *data)
{ {
struct cb_pcidda_private *devpriv = dev->private; struct cb_pcidda_private *devpriv = dev->private;
unsigned int command; unsigned int channel = CR_CHAN(insn->chanspec);
unsigned int channel, range; unsigned int range = CR_RANGE(insn->chanspec);
unsigned int ctrl;
channel = CR_CHAN(insn->chanspec);
range = CR_RANGE(insn->chanspec);
/* adjust calibration dacs if range has changed */ /* adjust calibration dacs if range has changed */
if (range != devpriv->ao_range[channel]) if (range != devpriv->ao_range[channel])
cb_pcidda_calibrate(dev, channel, range); cb_pcidda_calibrate(dev, channel, range);
/* output channel configuration */ ctrl = CB_DDA_DA_CTRL_EN | CB_DDA_DA_CTRL_DAC(channel);
command = NOSU | ENABLEDAC;
/* output channel range */
switch (range) { switch (range) {
case 0: case 0:
command |= BIP | RANGE10V;
break;
case 1:
command |= BIP | RANGE5V;
break;
case 2:
command |= BIP | RANGE2V5;
break;
case 3: case 3:
command |= UNIP | RANGE10V; ctrl |= CB_DDA_DA_CTRL_RANGE10V;
break; break;
case 1:
case 4: case 4:
command |= UNIP | RANGE5V; ctrl |= CB_DDA_DA_CTRL_RANGE5V;
break; break;
case 2:
case 5: case 5:
command |= UNIP | RANGE2V5; ctrl |= CB_DDA_DA_CTRL_RANGE2V5;
break; break;
} }
/* output channel specification */ if (range > 2)
command |= channel << 2; ctrl |= CB_DDA_DA_CTRL_UNIP;
outw(command, dev->iobase + DACONTROL);
outw(ctrl, dev->iobase + CB_DDA_DA_CTRL_REG);
/* write data */ /* write data */
outw(data[0], dev->iobase + DADATA + channel * 2); outw(data[0], dev->iobase + DADATA + channel * 2);
......
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