aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Engl <michael.engl@wjw-solutions.com>2017-10-03 08:57:00 -0400
committerJonathan Cameron <jic23@kernel.org>2017-03-15 15:47:23 -0400
commite83bb3e6f3efa21f4a9d883a25d0ecd9dfb431e1 (patch)
tree40bd08460f21c216274f21f8c3d7414a77765088 /drivers
parentc42f8218610aa09d7d3795e5810387673c1f84b6 (diff)
iio: adc: ti_am335x_adc: fix fifo overrun recovery
The tiadc_irq_h(int irq, void *private) function is handling FIFO overruns by clearing flags, disabling and enabling the ADC to recover. If the ADC is running in continuous mode a FIFO overrun happens regularly. If the disabling of the ADC happens concurrently with a new conversion. It might happen that the enabling of the ADC is ignored by the hardware. This stops the ADC permanently. No more interrupts are triggered. According to the AM335x Reference Manual (SPRUH73H October 2011 - Revised April 2013 - Chapter 12.4 and 12.5) it is necessary to check the ADC FSM bits in REG_ADCFSM before enabling the ADC again. Because the disabling of the ADC is done right after the current conversion has been finished. To trigger this bug it is necessary to run the ADC in continuous mode. The ADC values of all channels need to be read in an endless loop. The bug appears within the first 6 hours (~5.4 million handled FIFO overruns). The user space application will hang on reading new values from the character device. Fixes: ca9a563805f7a ("iio: ti_am335x_adc: Add continuous sampling support") Signed-off-by: Michael Engl <michael.engl@wjw-solutions.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index ad9dec30bb30..4282ceca3d8f 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -169,7 +169,9 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
169{ 169{
170 struct iio_dev *indio_dev = private; 170 struct iio_dev *indio_dev = private;
171 struct tiadc_device *adc_dev = iio_priv(indio_dev); 171 struct tiadc_device *adc_dev = iio_priv(indio_dev);
172 unsigned int status, config; 172 unsigned int status, config, adc_fsm;
173 unsigned short count = 0;
174
173 status = tiadc_readl(adc_dev, REG_IRQSTATUS); 175 status = tiadc_readl(adc_dev, REG_IRQSTATUS);
174 176
175 /* 177 /*
@@ -183,6 +185,15 @@ static irqreturn_t tiadc_irq_h(int irq, void *private)
183 tiadc_writel(adc_dev, REG_CTRL, config); 185 tiadc_writel(adc_dev, REG_CTRL, config);
184 tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN 186 tiadc_writel(adc_dev, REG_IRQSTATUS, IRQENB_FIFO1OVRRUN
185 | IRQENB_FIFO1UNDRFLW | IRQENB_FIFO1THRES); 187 | IRQENB_FIFO1UNDRFLW | IRQENB_FIFO1THRES);
188
189 /* wait for idle state.
190 * ADC needs to finish the current conversion
191 * before disabling the module
192 */
193 do {
194 adc_fsm = tiadc_readl(adc_dev, REG_ADCFSM);
195 } while (adc_fsm != 0x10 && count++ < 100);
196
186 tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_TSCSSENB)); 197 tiadc_writel(adc_dev, REG_CTRL, (config | CNTRLREG_TSCSSENB));
187 return IRQ_HANDLED; 198 return IRQ_HANDLED;
188 } else if (status & IRQENB_FIFO1THRES) { 199 } else if (status & IRQENB_FIFO1THRES) {