staging: comedi: s526: define the DAC (analog output) control register and bits
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 17 Aug 2015 23:58:14 +0000 (16:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Sep 2015 01:24:20 +0000 (18:24 -0700)
Define this register and its bits and remove the magic numbers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/s526.c

index df463a22fa7e32ba6612d4d70e3bf9848b84f16d..e71d850da882cc8fe1909a83222485e95b8a5254 100644 (file)
 #define S526_WDOG_INVERTED     BIT(4)
 #define S526_WDOG_ENA          BIT(3)
 #define S526_WDOG_INTERVAL(x)  (((x) & 0x7) << 0)
-#define REG_DAC 0x04
+#define S526_AO_CTRL_REG       0x04
+#define S526_AO_CTRL_RESET     BIT(3)
+#define S526_AO_CTRL_CHAN(x)   (((x) & 0x3) << 1)
+#define S526_AO_CTRL_START     BIT(0)
 #define REG_ADC 0x06
 #define REG_ADD 0x08
 #define REG_DIO 0x0A
@@ -452,16 +455,17 @@ static int s526_ao_insn_write(struct comedi_device *dev,
                              unsigned int *data)
 {
        unsigned int chan = CR_CHAN(insn->chanspec);
+       unsigned int ctrl = S526_AO_CTRL_CHAN(chan);
        unsigned int val = s->readback[chan];
        int i;
 
-       outw(chan << 1, dev->iobase + REG_DAC);
+       outw(ctrl, dev->iobase + S526_AO_CTRL_REG);
+       ctrl |= S526_AO_CTRL_START;
 
        for (i = 0; i < insn->n; i++) {
                val = data[i];
                outw(val, dev->iobase + REG_ADD);
-               /* starts the D/A conversion */
-               outw((chan << 1) | 1, dev->iobase + REG_DAC);
+               outw(ctrl, dev->iobase + S526_AO_CTRL_REG);
        }
        s->readback[chan] = val;