From 931e7f0032c5113f82f7b59b29406d2e9eab1c48 Mon Sep 17 00:00:00 2001 From: "Patil, Rachna" Date: Thu, 7 Mar 2013 16:52:32 +0530 Subject: [PATCH] IO: ti_adc: Fix step enable and step co nfiguration in continuous mode The current code does not enable all the input channels asked for. For example if we want to read continuous data from 3 channels at a time, the code only enables one channel. Also the step configuration while switching from one shot to continuous, configured the 1st input to the rest of the channels as well. Hence in continuous mode voltage from 1st channel appears on all the remaining channels. Fix the issue by configuring to correct input channels. Signed-off-by: Patil, Rachna Signed-off-by: Vaibhav Hiremath --- drivers/staging/iio/adc/ti_adc.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/drivers/staging/iio/adc/ti_adc.c b/drivers/staging/iio/adc/ti_adc.c index 57018a9..6a79df5 100644 --- a/drivers/staging/iio/adc/ti_adc.c +++ b/drivers/staging/iio/adc/ti_adc.c @@ -110,31 +110,23 @@ static ssize_t tiadc_set_mode(struct device *dev, { struct iio_dev *indio_dev = dev_get_drvdata(dev); struct adc_device *adc_dev = iio_priv(indio_dev); - int i, channels = 0, steps; - unsigned int stepconfig, config; - - steps = (TOTAL_STEPS - adc_dev->channels) + 1; - channels = TOTAL_CHANNELS - adc_dev->channels; + unsigned int config; config = adc_readl(adc_dev, TSCADC_REG_CTRL); config &= ~(TSCADC_CNTRLREG_TSCSSENB); adc_writel(adc_dev, TSCADC_REG_CTRL, config); - stepconfig = adc_readl(adc_dev, TSCADC_REG_STEPCONFIG(steps)); - - for (i = steps; i <= TOTAL_STEPS; i++) { - if (!strncmp(buf, "oneshot", 7)) { - stepconfig &= ~(TSCADC_STEPCONFIG_MODE_SWCNT); - adc_writel(adc_dev, TSCADC_REG_STEPCONFIG(i), - stepconfig); - adc_dev->is_continuous_mode = false; - } else if (!strncmp(buf, "continuous", 10)) { - adc_writel(adc_dev, TSCADC_REG_STEPCONFIG(i), - stepconfig | TSCADC_STEPCONFIG_MODE_SWCNT); - adc_dev->is_continuous_mode = true; - } + if (!strncmp(buf, "oneshot", 7)) + adc_dev->is_continuous_mode = false; + else if (!strncmp(buf, "continuous", 10)) + adc_dev->is_continuous_mode = true; + else { + dev_err(dev, "Operational mode unknown\n"); + return -EINVAL; } + adc_step_config(adc_dev, adc_dev->is_continuous_mode); + config = adc_readl(adc_dev, TSCADC_REG_CTRL); adc_writel(adc_dev, TSCADC_REG_CTRL, (config | TSCADC_CNTRLREG_TSCSSENB)); @@ -274,8 +266,8 @@ static int tiadc_buffer_postenable(struct iio_dev *idev) */ stepnum = chan->channel + 9; enb = adc_readl(adc_dev, TSCADC_REG_SE); - enb |= stepnum; - adc_writel(adc_dev, TSCADC_REG_SE, TSCADC_ENB(enb)); + enb |= (1 << stepnum); + adc_writel(adc_dev, TSCADC_REG_SE, enb); } return 0; } -- 1.9.1