For aesthetics, rename these register defines to give them namespace associated with the driver and define the bits in the registers. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregk@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/ni_daq_700.c | 37 +++++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c index 1798b47..3ba4da6 100644 --- a/drivers/staging/comedi/drivers/ni_daq_700.c +++ b/drivers/staging/comedi/drivers/ni_daq_700.c @@ -61,21 +61,31 @@ /* * Regsiter I/O map */ +#define DAQ700_CMD1_REG 0x00 +#define DAQ700_CMD1_SCANEN (0 << 7) +#define DAQ700_CMD1_SCANDISAB (1 << 7) +#define DAQ700_CMD1_CNTINTEN (1 << 6) +#define DAQ700_CMD1_EXTINTEN (1 << 5) +#define DAQ700_CMD1_FIFOINTEN (1 << 4) +#define DAQ700_CMD1_MA(x) ((x) << 0) #define DAQ700_DO_REG 0x04 #define DAQ700_DI_REG 0x05 +#define DAQ700_CMD3_REG 0x05 +#define DAQ700_CMD3_FIFOHFINT (1 << 5) +#define DAQ700_CMD3_CLK1SRC (1 << 3) +#define DAQ700_CMD3_DIFF (1 << 2) +#define DAQ700_CMD3_ARNG(x) ((x) << 0) +#define DAQ700_CMD2_REG 0x07 +#define DAQ700_CMD2_ENADAQ (0 << 1) +#define DAQ700_CMD2_DISABDAQ (1 << 1) #define DAQ700_TIMER_BASE 0x08 /* daqcard700 registers */ -#define CMD_R1 0x00 /* WO 8bit */ -#define CMD_R2 0x07 /* RW 8bit */ -#define CMD_R3 0x05 /* W0 8bit */ #define STA_R1 0x00 /* RO 8bit */ #define STA_R2 0x01 /* RO 8bit */ #define ADFIFO_R 0x02 /* RO 16bit */ #define ADCLEAR_R 0x01 /* WO 8bit */ #define TIC_R 0x06 /* WO 8bit */ -/* daqcard700 modes */ -#define CMD_R3_DIFF 0x04 /* diff mode */ static const struct comedi_lrange range_daq700_ai = { 3, @@ -176,15 +186,15 @@ static int daq700_ai_rinsn(struct comedi_device *dev, /* set channel input modes */ if (aref == AREF_DIFF) - r3_bits |= CMD_R3_DIFF; + r3_bits |= DAQ700_CMD3_DIFF; /* write channel mode/range */ if (range >= 1) range++; /* convert range to hardware value */ - outb(r3_bits | (range & 0x03), dev->iobase + CMD_R3); + outb(r3_bits | DAQ700_CMD3_ARNG(range), dev->iobase + DAQ700_CMD3_REG); - /* write channel to multiplexer */ - /* set mask scan bit high to disable scanning */ - outb(chan | 0x80, dev->iobase + CMD_R1); + /* set multiplexer for single-channel scan */ + outb(DAQ700_CMD1_SCANDISAB | DAQ700_CMD1_MA(chan), + dev->iobase + DAQ700_CMD1_REG); /* mux needs 2us to really settle [Fred Brooks]. */ udelay(2); @@ -224,9 +234,10 @@ static void daq700_ai_config(struct comedi_device *dev, { unsigned long iobase = dev->iobase; - outb(0x80, iobase + CMD_R1); /* disable scanning, ADC to chan 0 */ - outb(0x00, iobase + CMD_R2); /* clear all bits */ - outb(0x00, iobase + CMD_R3); /* set +-10 range */ + outb(DAQ700_CMD1_SCANDISAB | DAQ700_CMD1_MA(0), + iobase + DAQ700_CMD1_REG); + outb(DAQ700_CMD2_ENADAQ, iobase + DAQ700_CMD2_REG); + outb(DAQ700_CMD3_ARNG(0), iobase + DAQ700_CMD3_REG); i8254_set_mode(iobase + DAQ700_TIMER_BASE, 0, 0, I8254_MODE1 | I8254_BINARY); /* OUT0 high */ outb(0x00, iobase + TIC_R); /* clear counter interrupt */ -- 1.9.3 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel