linux_dsm_epyc7002/drivers/iio/adc
Sebastian Andrzej Siewior 7ca6740cd1 mfd: input: iio: ti_amm335x: Rework TSC/ADC synchronization
The ADC driver always programs all possible ADC values and discards
them except for the value IIO asked for. On the am335x-evm the driver
programs four values and it takes 500us to gather them. Reducing the number
of conversations down to the (required) one also reduces the busy loop down
to 125us.

This leads to another error, namely the FIFOCOUNT register is sometimes
(like one out of 10 attempts) not updated in time leading to EBUSY.
The next read has the FIFOCOUNT register updated.
Checking for the ADCSTAT register for being idle isn't a good choice either.
The problem is that if TSC is used at the same time, the HW completes the
conversation for ADC *and* before the driver noticed it, the HW begins to
perform a TSC conversation and so the driver never seen the HW idle. The
next time we would have two values in the FIFO but since the driver reads
everything we always see the current one.
So instead of polling for the IDLE bit in ADCStatus register, we should
check the FIFOCOUNT register. It should be one instead of zero because we
request one value.

This change in turn leads to another error. Sometimes if TSC & ADC are
used together the TSC starts generating interrupts even if nobody
actually touched the touchscreen. The interrupts seem valid because TSC's
FIFO is filled with values for each channel of the TSC. This condition stops
after a few ADC reads but will occur again. Not good.

On top of this (even without the changes I just mentioned) there is a ADC
& TSC lockup condition which was reported to me by Jeff Lance including the
following test case:
A busy loop of "cat /sys/bus/iio/devices/iio\:device0/in_voltage4_raw"
and a mug on touch screen. With this setup, the hardware will lockup after
something between 20 minutes and it could take up to a couple of hours.
During that lockup, the ADCSTAT register says 0x30 (or 0x70) which means
STEP_ID = IDLE and FSM_BUSY = yes. That means the hardware says that it is
idle and busy at the same time which is an invalid condition.

For all this reasons I decided to rework this TSC/ADC part and add a
handshake / synchronization here:
First the ADC signals that it needs the HW and writes a 0 mask into the
SE register. The HW (if active) will complete the current conversation
and become idle. The TSC driver will gather the values from the FIFO
(woken up by an interrupt) and won't "enable" another conversation.
Instead it will wake up the ADC driver which is already waiting. The ADC
driver will start "its" conversation and once it is done, it will
enable the TSC steps so the TSC will work again.

After this rework I haven't observed the lockup so far. Plus the busy
loop has been reduced from 500us to 125us.

The continues-read mode remains unchanged.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2014-01-07 08:45:00 +00:00
..
ad7266.c iio:ad7266: Remove redundant call to iio_sw_preenable() 2013-10-16 19:11:31 +01:00
ad7298.c iio:ad7298: Use iio_push_to_buffers_with_timestamp() 2013-09-21 19:23:52 +01:00
ad7476.c iio:ad7476: Report scale as fractional value 2013-10-01 16:19:12 +01:00
ad7791.c iio:ad7791: Report scale as fractional value 2013-10-01 16:19:12 +01:00
ad7793.c iio: adc: ad7793: Use devm_* APIs 2013-08-03 18:40:39 +01:00
ad7887.c iio:ad7887: Remove redundant call to iio_sw_buffer_preenable(). 2013-10-16 19:12:04 +01:00
ad7923.c iio:ad7923: Use iio_push_to_buffers_with_timestamp() 2013-09-21 19:23:53 +01:00
ad_sigma_delta.c tree-wide: use reinit_completion instead of INIT_COMPLETION 2013-11-15 09:32:21 +09:00
at91_adc.c iio: at91: introduce touch screen support in iio adc driver 2013-10-17 23:57:10 +01:00
exynos_adc.c iio: exynos_adc: Use devm_iio_device_alloc 2013-08-03 18:40:42 +01:00
Kconfig iio:ti_am335x_adc ensure that IIO_KFIFO_BUF is not selected witout IIO_BUFFER 2013-09-28 11:36:29 +01:00
lp8788_adc.c iio: adc: lp8788_adc: Use devm_* APIs 2013-08-03 18:40:40 +01:00
Makefile iio: adc: Add driver for Microchip MCP3422/3/4 high resolution ADC 2013-09-07 22:17:44 +01:00
max1363.c iio:adc:max1363 support SMBus for 8-bit devices 2013-10-20 22:36:21 +01:00
mcp320x.c iio: adc: mcp320x: Use devm_* APIs 2013-08-03 18:40:41 +01:00
mcp3422.c iio: adc: mcp3422: Include linux/of.h header 2013-10-18 20:05:56 +01:00
nau7802.c tree-wide: use reinit_completion instead of INIT_COMPLETION 2013-11-15 09:32:21 +09:00
ti_am335x_adc.c mfd: input: iio: ti_amm335x: Rework TSC/ADC synchronization 2014-01-07 08:45:00 +00:00
ti-adc081c.c iio: adc: ti-adc081c: Include linux/of.h header 2013-10-18 20:05:56 +01:00
twl6030-gpadc.c iio: adc: twl6030-gpadc: Remove redundant code 2013-10-24 14:45:09 +01:00
viperboard_adc.c iio: adc: viperboard_adc: Use devm_iio_device_alloc 2013-08-03 18:40:42 +01:00