Commit 7295475758e73aa72a92cdc720186698cec8d033

Authored by Russ Dill
Committed by Vaibhav Hiremath
1 parent da42b4c279

IIO: ti_adc: Reset and clear overrun status before capture.

While not pulling out samples, the FIFO will fill up causing an
overrun event. Before starting up another continuous sample, clear that
event.

Signed-off-by: Russ Dill <Russ.Dill@ti.com>

Showing 1 changed file with 16 additions and 9 deletions Side-by-side Diff

drivers/staging/iio/adc/ti_adc.c
... ... @@ -231,22 +231,29 @@
231 231 {
232 232 struct adc_device *adc_dev = iio_priv(idev);
233 233 struct iio_buffer *buffer = idev->buffer;
234   - unsigned int enb, fifo1count;
235   - int stepnum, i;
  234 + unsigned int enb, config;
  235 + int stepnum;
236 236 u8 bit;
237 237  
238 238 if (!adc_dev->is_continuous_mode) {
239 239 pr_info("Data cannot be read continuously in one shot mode\n");
240 240 return -EINVAL;
241 241 } else {
242   - adc_writel(adc_dev, TSCADC_REG_IRQENABLE,
243   - (TSCADC_IRQENB_FIFO1THRES |
244   - TSCADC_IRQENB_FIFO1OVRRUN |
245   - TSCADC_IRQENB_FIFO1UNDRFLW));
246 242  
247   - fifo1count = adc_readl(adc_dev, TSCADC_REG_FIFO1CNT);
248   - for (i = 0; i < fifo1count; i++)
249   - adc_readl(adc_dev, TSCADC_REG_FIFO1);
  243 + config = adc_readl(adc_dev, TSCADC_REG_CTRL);
  244 + adc_writel(adc_dev, TSCADC_REG_CTRL,
  245 + config & ~TSCADC_CNTRLREG_TSCSSENB);
  246 + adc_writel(adc_dev, TSCADC_REG_CTRL,
  247 + config | TSCADC_CNTRLREG_TSCSSENB);
  248 +
  249 +
  250 + adc_writel(adc_dev, TSCADC_REG_IRQSTATUS,
  251 + TSCADC_IRQENB_FIFO1THRES |
  252 + TSCADC_IRQENB_FIFO1OVRRUN |
  253 + TSCADC_IRQENB_FIFO1UNDRFLW);
  254 + adc_writel(adc_dev, TSCADC_REG_IRQENABLE,
  255 + TSCADC_IRQENB_FIFO1THRES |
  256 + TSCADC_IRQENB_FIFO1OVRRUN);
250 257  
251 258 adc_writel(adc_dev, TSCADC_REG_SE, 0x00);
252 259 for_each_set_bit(bit, buffer->scan_mask,