Commit 931e7f0032c5113f82f7b59b29406d2e9eab1c48

Authored by Patil, Rachna
Committed by Vaibhav Hiremath
1 parent 4be2ce1b85

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 <rachna@ti.com>
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>

Showing 1 changed file with 12 additions and 20 deletions Side-by-side Diff

drivers/staging/iio/adc/ti_adc.c
... ... @@ -110,31 +110,23 @@
110 110 {
111 111 struct iio_dev *indio_dev = dev_get_drvdata(dev);
112 112 struct adc_device *adc_dev = iio_priv(indio_dev);
113   - int i, channels = 0, steps;
114   - unsigned int stepconfig, config;
  113 + unsigned int config;
115 114  
116   - steps = (TOTAL_STEPS - adc_dev->channels) + 1;
117   - channels = TOTAL_CHANNELS - adc_dev->channels;
118   -
119 115 config = adc_readl(adc_dev, TSCADC_REG_CTRL);
120 116 config &= ~(TSCADC_CNTRLREG_TSCSSENB);
121 117 adc_writel(adc_dev, TSCADC_REG_CTRL, config);
122 118  
123   - stepconfig = adc_readl(adc_dev, TSCADC_REG_STEPCONFIG(steps));
124   -
125   - for (i = steps; i <= TOTAL_STEPS; i++) {
126   - if (!strncmp(buf, "oneshot", 7)) {
127   - stepconfig &= ~(TSCADC_STEPCONFIG_MODE_SWCNT);
128   - adc_writel(adc_dev, TSCADC_REG_STEPCONFIG(i),
129   - stepconfig);
130   - adc_dev->is_continuous_mode = false;
131   - } else if (!strncmp(buf, "continuous", 10)) {
132   - adc_writel(adc_dev, TSCADC_REG_STEPCONFIG(i),
133   - stepconfig | TSCADC_STEPCONFIG_MODE_SWCNT);
134   - adc_dev->is_continuous_mode = true;
135   - }
  119 + if (!strncmp(buf, "oneshot", 7))
  120 + adc_dev->is_continuous_mode = false;
  121 + else if (!strncmp(buf, "continuous", 10))
  122 + adc_dev->is_continuous_mode = true;
  123 + else {
  124 + dev_err(dev, "Operational mode unknown\n");
  125 + return -EINVAL;
136 126 }
137 127  
  128 + adc_step_config(adc_dev, adc_dev->is_continuous_mode);
  129 +
138 130 config = adc_readl(adc_dev, TSCADC_REG_CTRL);
139 131 adc_writel(adc_dev, TSCADC_REG_CTRL,
140 132 (config | TSCADC_CNTRLREG_TSCSSENB));
... ... @@ -274,8 +266,8 @@
274 266 */
275 267 stepnum = chan->channel + 9;
276 268 enb = adc_readl(adc_dev, TSCADC_REG_SE);
277   - enb |= stepnum;
278   - adc_writel(adc_dev, TSCADC_REG_SE, TSCADC_ENB(enb));
  269 + enb |= (1 << stepnum);
  270 + adc_writel(adc_dev, TSCADC_REG_SE, enb);
279 271 }
280 272 return 0;
281 273 }