mfd: ti_am335x_tscadc: Fix idle timeout value
PATCH 1/2 mfd: ti_am335x_tscadc: Fix idle timeout value
The old timeout value was based on the assumption that the minimum values are used for the open and sample delay and no averaging is done. In fact the ADC and touchscreen driver both use an open delay of 152 cycles and averaging over 16 samples. This patch adjusts the timeout value accordingly
Signed-off-by Matthias Kaehlcke <[email protected]>
--- include/linux/mfd/ti_am335x_tscadc.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
include/linux/mfd/ti_am335x_tscadc.h +12 -7
@@ -126,13 +126,18 @@#define TOTAL_CHANNELS 8/* -* ADC runs at 3MHz, and it takes -* 15 cycles to latch one data output. -* Hence the idle time for ADC to -* process one sample data would be -* around 5 micro seconds. -*/ -#define IDLE_TIMEOUT 5/* microsec */ +* time in us for processing a single channel, calculated as follows: +* +* num cycles = open delay + (sample delay + conv time) * averaging +* +* num cycles: 152 + (1 + 13) * 16 = 376 +* +* clock frequency: 26MHz / 8 = 3.25MHz +* clock period: 1 / 3.25MHz = 308ns +* +* processing time: 376 * 308ns = 116us +*/ +#define IDLE_TIMEOUT 116/* microsec */ #define TSCADC_CELLS 2
Signature · 1 line
1.8.4.rc3
Quoted 27 lines · Matthias Kaehlcke
The old timeout value was based on the assumption that the minimum values are used for the open and sample delay and no averaging is done. In fact the ADC and touchscreen driver both use an open delay of 152 cycles and averaging over 16 samples. This patch adjusts the timeout value accordingly
Signed-off-by Matthias Kaehlcke <[email protected]>--- include/linux/mfd/ti_am335x_tscadc.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)include/linux/mfd/ti_am335x_tscadc.h +2
-7@@ -126,13 +126,18 @@#define TOTAL_CHANNELS 8/* -* ADC runs at 3MHz, and it takes -* 15 cycles to latch one data output. -* Hence the idle time for ADC to -* process one sample data would be -* around 5 micro seconds. -*/ -#define IDLE_TIMEOUT 5/* microsec */ +* time in us for processing a single channel, calculated as follows: +*
include/linux/mfd/ti_am335x_tscadc.h line 140
Quoted 10 lines
include/linux/mfd/ti_am335x_tscadc.h +10
-0+* num cycles = open delay + (sample delay + conv time) * averaging +* +* num cycles: 152 + (1 + 13) * 16 = 376 +* +* clock frequency: 26MHz / 8 = 3.25MHz +* clock period: 1 / 3.25MHz = 308ns +* +* processing time: 376 * 308ns = 116us +*/ +#define IDLE_TIMEOUT 116/* microsec */
Nice, clear explanation. I like it.
Patch applied, thanks.
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog