summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-09-20 23:40:01 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-09-25 22:59:59 (GMT)
commitfe4489a5b2047c94ce0ce80b21e2aa3d4b657c0a (patch)
tree8e4e1b1a1c77ae1a833b54779a56549b1a284f19
parentdd89a8b60997eab41a1e92a618bd739535c58459 (diff)
downloadlinux-fsl-qoriq-fe4489a5b2047c94ce0ce80b21e2aa3d4b657c0a.tar.xz
staging: comedi: pcl711: fix pcl711_set_changain()
Currently the board->is_8112 handling in this function does not write the value to the mux register. Also, the value for channels >= 8 is calculated incorrectly. Define the magic numbers used with the mux register and fix the function so 8112 boards work correctly. 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>
-rw-r--r--drivers/staging/comedi/drivers/pcl711.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c
index aab3d73..8aa3d92 100644
--- a/drivers/staging/comedi/drivers/pcl711.c
+++ b/drivers/staging/comedi/drivers/pcl711.c
@@ -78,7 +78,10 @@ supported.
#define PCL711_DI_HI 0x07
#define PCL711_CLRINTR 0x08
#define PCL711_GAIN 0x09
-#define PCL711_MUX 0x0a
+#define PCL711_MUX_REG 0x0a
+#define PCL711_MUX_CHAN(x) (((x) & 0xf) << 0)
+#define PCL711_MUX_CS0 (1 << 4)
+#define PCL711_MUX_CS1 (1 << 5)
#define PCL711_MODE 0x0b
#define PCL711_SOFTTRIG 0x0c
#define PCL711_DO_LO 0x0d
@@ -220,32 +223,24 @@ static irqreturn_t pcl711_interrupt(int irq, void *d)
return IRQ_HANDLED;
}
-static void pcl711_set_changain(struct comedi_device *dev, int chan)
+static void pcl711_set_changain(struct comedi_device *dev,
+ unsigned int chanspec)
{
const struct pcl711_board *board = comedi_board(dev);
- int chan_register;
+ unsigned int chan = CR_CHAN(chanspec);
+ unsigned int range = CR_RANGE(chanspec);
+ unsigned int mux = 0;
- outb(CR_RANGE(chan), dev->iobase + PCL711_GAIN);
-
- chan_register = CR_CHAN(chan);
+ outb(range, dev->iobase + PCL711_GAIN);
if (board->is_8112) {
-
- /*
- * Set the correct channel. The two channel banks are switched
- * using the mask value.
- * NB: To use differential channels, you should use
- * mask = 0x30, but I haven't written the support for this
- * yet. /JJ
- */
-
- if (chan_register >= 8)
- chan_register = 0x20 | (chan_register & 0x7);
+ /* Select the correct MPC508A chip */
+ if (chan < 8)
+ mux |= PCL711_MUX_CS0;
else
- chan_register |= 0x10;
- } else {
- outb(chan_register, dev->iobase + PCL711_MUX);
+ mux |= PCL711_MUX_CS1;
}
+ outb(mux | PCL711_MUX_CHAN(chan), dev->iobase + PCL711_MUX_REG);
}
static int pcl711_ai_wait_for_eoc(struct comedi_device *dev,