summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/dt2811.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2016-05-04 12:47:10 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-06-17 20:44:04 -0700
commitb99c859b8fc3db534c7ef7700c1627d0e3df4dbe (patch)
tree01069cae29ed92f584bf9f2ae0fcae3cb386aa6d /drivers/staging/comedi/drivers/dt2811.c
parent022ac9529986e494b39386ab59eb97c99d2e4983 (diff)
staging: comedi: dt2811: tidy up A/D Gain/Channel register defines
Cleanup the defines for this register and its bits and remove the redundant information in the comment. Make the (*insn_read) use the range to set the gain bits correctly. Currently the gain is always set to 1. 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>
Diffstat (limited to 'drivers/staging/comedi/drivers/dt2811.c')
-rw-r--r--drivers/staging/comedi/drivers/dt2811.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
index 433cfd136046..f72d6c8001ed 100644
--- a/drivers/staging/comedi/drivers/dt2811.c
+++ b/drivers/staging/comedi/drivers/dt2811.c
@@ -63,6 +63,10 @@
/* continuous conversion, external clock, external trigger */
#define DT2811_ADCSR_ADMODE_EXT DT2811_ADCSR_ADMODE(3)
+#define DT2811_ADGCR_REG 0x01 /* r/w A/D Gain/Channel */
+#define DT2811_ADGCR_GAIN(x) (((x) & 0x3) << 6)
+#define DT2811_ADGCR_CHAN(x) (((x) & 0xf) << 0)
+
static const struct comedi_lrange range_dt2811_pgh_ai_5_unipolar = {
4, {
UNI_RANGE(5),
@@ -119,16 +123,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = {
/*
- 0x01 ADGCR R/W A/D Gain/Channel Register
- bit 6,7 - (R/W) gain select
- 00 gain=1, both PGH, PGL models
- 01 gain=2 PGH, 10 PGL
- 10 gain=4 PGH, 100 PGL
- 11 gain=8 PGH, 500 PGL
- bit 4,5 - reserved
- bit 3-0 - (R/W) channel select
- channel number from 0-15
-
0x02,0x03 (R) ADDAT A/D Data Register
(W) DADAT0 D/A Data Register 0
0x02 low byte
@@ -166,7 +160,6 @@ static const struct comedi_lrange range_dt2811_pgl_ai_5_bipolar = {
#define TIMEOUT 10000
-#define DT2811_ADGCR 1
#define DT2811_ADDATLO 2
#define DT2811_ADDATHI 3
#define DT2811_DADAT0LO 2
@@ -219,12 +212,15 @@ static int dt2811_ai_eoc(struct comedi_device *dev,
static int dt2811_ai_insn(struct comedi_device *dev, struct comedi_subdevice *s,
struct comedi_insn *insn, unsigned int *data)
{
- int chan = CR_CHAN(insn->chanspec);
+ unsigned int chan = CR_CHAN(insn->chanspec);
+ unsigned int range = CR_RANGE(insn->chanspec);
int ret;
int i;
for (i = 0; i < insn->n; i++) {
- outb(chan, dev->iobase + DT2811_ADGCR);
+ /* select channel/gain and trigger conversion */
+ outb(DT2811_ADGCR_CHAN(chan) | DT2811_ADGCR_GAIN(range),
+ dev->iobase + DT2811_ADGCR_REG);
ret = comedi_timeout(dev, s, insn, dt2811_ai_eoc, 0);
if (ret)