* [PATCH] iio: adc: at91: Add support for Touchscreen Switches Closure Time
@ 2016-08-30 12:27 Nicolas Ferre
2016-09-03 16:24 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Ferre @ 2016-08-30 12:27 UTC (permalink / raw)
To: Cristian Birsan, Ludovic Desroches
Cc: Alexandre Belloni, linux-arm-kernel, linux-kernel, linux-iio,
Nicolas Ferre
On newer components compatible with the at91sam9x5, the Touchscreen
Switches Closure Time or TSSCTIM value of the Touchscreen Mode Register is
not filled at all.
On some hardware, having no time indicated for it may lead to incoherent
values and jitter.
We fix this time to 10us as it is usually difficult to retrieve impedance
values from LCD manufacturers.
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
---
drivers/iio/adc/at91_adc.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 0438c68015e8..bbdac07f4aaa 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -113,6 +113,7 @@
#define AT91_ADC_TSMR_TSAV (3 << 4) /* Averages samples */
#define AT91_ADC_TSMR_TSAV_(x) ((x) << 4)
#define AT91_ADC_TSMR_SCTIM (0x0f << 16) /* Switch closure time */
+#define AT91_ADC_TSMR_SCTIM_(x) ((x) << 16)
#define AT91_ADC_TSMR_PENDBC (0x0f << 28) /* Pen Debounce time */
#define AT91_ADC_TSMR_PENDBC_(x) ((x) << 28)
#define AT91_ADC_TSMR_NOTSDMA (1 << 22) /* No Touchscreen DMA */
@@ -150,6 +151,7 @@
#define MAX_RLPOS_BITS 10
#define TOUCH_SAMPLE_PERIOD_US_RL 10000 /* 10ms, the SoC can't keep up with 2ms */
#define TOUCH_SHTIM 0xa
+#define TOUCH_SCTIM_US 10 /* 10us for the Touchscreen Switches Closure Time */
/**
* struct at91_adc_reg_desc - Various informations relative to registers
@@ -1001,7 +1003,9 @@ static void atmel_ts_close(struct input_dev *dev)
static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
{
+ struct iio_dev *idev = iio_priv_to_dev(st);
u32 reg = 0;
+ u32 tssctim = 0;
int i = 0;
/* a Pen Detect Debounce Time is necessary for the ADC Touch to avoid
@@ -1034,11 +1038,20 @@ static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
return 0;
}
+ /* Touchscreen Switches Closure time needed for allowing the value to
+ * stabilize.
+ * Switch Closure Time = (TSSCTIM * 4) ADCClock periods
+ */
+ tssctim = DIV_ROUND_UP(TOUCH_SCTIM_US * adc_clk_khz / 1000, 4);
+ dev_dbg(&idev->dev, "adc_clk at: %d KHz, tssctim at: %d\n",
+ adc_clk_khz, tssctim);
+
if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_4WIRE)
reg = AT91_ADC_TSMR_TSMODE_4WIRE_PRESS;
else
reg = AT91_ADC_TSMR_TSMODE_5WIRE;
+ reg |= AT91_ADC_TSMR_SCTIM_(tssctim) & AT91_ADC_TSMR_SCTIM;
reg |= AT91_ADC_TSMR_TSAV_(st->caps->ts_filter_average)
& AT91_ADC_TSMR_TSAV;
reg |= AT91_ADC_TSMR_PENDBC_(st->ts_pendbc) & AT91_ADC_TSMR_PENDBC;
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: at91: Add support for Touchscreen Switches Closure Time
2016-08-30 12:27 [PATCH] iio: adc: at91: Add support for Touchscreen Switches Closure Time Nicolas Ferre
@ 2016-09-03 16:24 ` Jonathan Cameron
2016-09-05 8:26 ` Nicolas Ferre
0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2016-09-03 16:24 UTC (permalink / raw)
To: Nicolas Ferre, Cristian Birsan, Ludovic Desroches
Cc: Alexandre Belloni, linux-arm-kernel, linux-kernel, linux-iio
On 30/08/16 13:27, Nicolas Ferre wrote:
> On newer components compatible with the at91sam9x5, the Touchscreen
> Switches Closure Time or TSSCTIM value of the Touchscreen Mode Register is
> not filled at all.
> On some hardware, having no time indicated for it may lead to incoherent
> values and jitter.
> We fix this time to 10us as it is usually difficult to retrieve impedance
> values from LCD manufacturers.
>
> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Hi Nicolas,
Stable / fixes material or just have it head for the next merge window?
Jonathan
> ---
> drivers/iio/adc/at91_adc.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index 0438c68015e8..bbdac07f4aaa 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -113,6 +113,7 @@
> #define AT91_ADC_TSMR_TSAV (3 << 4) /* Averages samples */
> #define AT91_ADC_TSMR_TSAV_(x) ((x) << 4)
> #define AT91_ADC_TSMR_SCTIM (0x0f << 16) /* Switch closure time */
> +#define AT91_ADC_TSMR_SCTIM_(x) ((x) << 16)
> #define AT91_ADC_TSMR_PENDBC (0x0f << 28) /* Pen Debounce time */
> #define AT91_ADC_TSMR_PENDBC_(x) ((x) << 28)
> #define AT91_ADC_TSMR_NOTSDMA (1 << 22) /* No Touchscreen DMA */
> @@ -150,6 +151,7 @@
> #define MAX_RLPOS_BITS 10
> #define TOUCH_SAMPLE_PERIOD_US_RL 10000 /* 10ms, the SoC can't keep up with 2ms */
> #define TOUCH_SHTIM 0xa
> +#define TOUCH_SCTIM_US 10 /* 10us for the Touchscreen Switches Closure Time */
>
> /**
> * struct at91_adc_reg_desc - Various informations relative to registers
> @@ -1001,7 +1003,9 @@ static void atmel_ts_close(struct input_dev *dev)
>
> static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
> {
> + struct iio_dev *idev = iio_priv_to_dev(st);
> u32 reg = 0;
> + u32 tssctim = 0;
> int i = 0;
>
> /* a Pen Detect Debounce Time is necessary for the ADC Touch to avoid
> @@ -1034,11 +1038,20 @@ static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
> return 0;
> }
>
> + /* Touchscreen Switches Closure time needed for allowing the value to
> + * stabilize.
> + * Switch Closure Time = (TSSCTIM * 4) ADCClock periods
> + */
> + tssctim = DIV_ROUND_UP(TOUCH_SCTIM_US * adc_clk_khz / 1000, 4);
> + dev_dbg(&idev->dev, "adc_clk at: %d KHz, tssctim at: %d\n",
> + adc_clk_khz, tssctim);
> +
> if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_4WIRE)
> reg = AT91_ADC_TSMR_TSMODE_4WIRE_PRESS;
> else
> reg = AT91_ADC_TSMR_TSMODE_5WIRE;
>
> + reg |= AT91_ADC_TSMR_SCTIM_(tssctim) & AT91_ADC_TSMR_SCTIM;
> reg |= AT91_ADC_TSMR_TSAV_(st->caps->ts_filter_average)
> & AT91_ADC_TSMR_TSAV;
> reg |= AT91_ADC_TSMR_PENDBC_(st->ts_pendbc) & AT91_ADC_TSMR_PENDBC;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: at91: Add support for Touchscreen Switches Closure Time
2016-09-03 16:24 ` Jonathan Cameron
@ 2016-09-05 8:26 ` Nicolas Ferre
2016-09-05 20:12 ` Jonathan Cameron
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Ferre @ 2016-09-05 8:26 UTC (permalink / raw)
To: Jonathan Cameron, Cristian Birsan, Ludovic Desroches
Cc: Alexandre Belloni, linux-arm-kernel, linux-kernel, linux-iio
Le 03/09/2016 à 18:24, Jonathan Cameron a écrit :
> On 30/08/16 13:27, Nicolas Ferre wrote:
>> On newer components compatible with the at91sam9x5, the Touchscreen
>> Switches Closure Time or TSSCTIM value of the Touchscreen Mode Register is
>> not filled at all.
>> On some hardware, having no time indicated for it may lead to incoherent
>> values and jitter.
>> We fix this time to 10us as it is usually difficult to retrieve impedance
>> values from LCD manufacturers.
>>
>> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> Hi Nicolas,
>
> Stable / fixes material or just have it head for the next merge window?
Well, I would say that it's an addition of a feature that fixes a bad
behavior ;-)
So, in summary, I would just add it to next kernel revision.
Thanks for the heads-up. Bye,
>> ---
>> drivers/iio/adc/at91_adc.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
>> index 0438c68015e8..bbdac07f4aaa 100644
>> --- a/drivers/iio/adc/at91_adc.c
>> +++ b/drivers/iio/adc/at91_adc.c
>> @@ -113,6 +113,7 @@
>> #define AT91_ADC_TSMR_TSAV (3 << 4) /* Averages samples */
>> #define AT91_ADC_TSMR_TSAV_(x) ((x) << 4)
>> #define AT91_ADC_TSMR_SCTIM (0x0f << 16) /* Switch closure time */
>> +#define AT91_ADC_TSMR_SCTIM_(x) ((x) << 16)
>> #define AT91_ADC_TSMR_PENDBC (0x0f << 28) /* Pen Debounce time */
>> #define AT91_ADC_TSMR_PENDBC_(x) ((x) << 28)
>> #define AT91_ADC_TSMR_NOTSDMA (1 << 22) /* No Touchscreen DMA */
>> @@ -150,6 +151,7 @@
>> #define MAX_RLPOS_BITS 10
>> #define TOUCH_SAMPLE_PERIOD_US_RL 10000 /* 10ms, the SoC can't keep up with 2ms */
>> #define TOUCH_SHTIM 0xa
>> +#define TOUCH_SCTIM_US 10 /* 10us for the Touchscreen Switches Closure Time */
>>
>> /**
>> * struct at91_adc_reg_desc - Various informations relative to registers
>> @@ -1001,7 +1003,9 @@ static void atmel_ts_close(struct input_dev *dev)
>>
>> static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
>> {
>> + struct iio_dev *idev = iio_priv_to_dev(st);
>> u32 reg = 0;
>> + u32 tssctim = 0;
>> int i = 0;
>>
>> /* a Pen Detect Debounce Time is necessary for the ADC Touch to avoid
>> @@ -1034,11 +1038,20 @@ static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
>> return 0;
>> }
>>
>> + /* Touchscreen Switches Closure time needed for allowing the value to
>> + * stabilize.
>> + * Switch Closure Time = (TSSCTIM * 4) ADCClock periods
>> + */
>> + tssctim = DIV_ROUND_UP(TOUCH_SCTIM_US * adc_clk_khz / 1000, 4);
>> + dev_dbg(&idev->dev, "adc_clk at: %d KHz, tssctim at: %d\n",
>> + adc_clk_khz, tssctim);
>> +
>> if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_4WIRE)
>> reg = AT91_ADC_TSMR_TSMODE_4WIRE_PRESS;
>> else
>> reg = AT91_ADC_TSMR_TSMODE_5WIRE;
>>
>> + reg |= AT91_ADC_TSMR_SCTIM_(tssctim) & AT91_ADC_TSMR_SCTIM;
>> reg |= AT91_ADC_TSMR_TSAV_(st->caps->ts_filter_average)
>> & AT91_ADC_TSMR_TSAV;
>> reg |= AT91_ADC_TSMR_PENDBC_(st->ts_pendbc) & AT91_ADC_TSMR_PENDBC;
>>
>
>
--
Nicolas Ferre
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: adc: at91: Add support for Touchscreen Switches Closure Time
2016-09-05 8:26 ` Nicolas Ferre
@ 2016-09-05 20:12 ` Jonathan Cameron
0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2016-09-05 20:12 UTC (permalink / raw)
To: Nicolas Ferre, Cristian Birsan, Ludovic Desroches
Cc: Alexandre Belloni, linux-arm-kernel, linux-kernel, linux-iio
On 05/09/16 09:26, Nicolas Ferre wrote:
> Le 03/09/2016 à 18:24, Jonathan Cameron a écrit :
>> On 30/08/16 13:27, Nicolas Ferre wrote:
>>> On newer components compatible with the at91sam9x5, the Touchscreen
>>> Switches Closure Time or TSSCTIM value of the Touchscreen Mode Register is
>>> not filled at all.
>>> On some hardware, having no time indicated for it may lead to incoherent
>>> values and jitter.
>>> We fix this time to 10us as it is usually difficult to retrieve impedance
>>> values from LCD manufacturers.
>>>
>>> Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
>> Hi Nicolas,
>>
>> Stable / fixes material or just have it head for the next merge window?
>
> Well, I would say that it's an addition of a feature that fixes a bad
> behavior ;-)
> So, in summary, I would just add it to next kernel revision.
>
> Thanks for the heads-up. Bye,
Thanks
Applied to the togreg branch of iio.git - initially pushed out
as testing for the autobuilders to play with it.
Jonathan
>
>
>>> ---
>>> drivers/iio/adc/at91_adc.c | 13 +++++++++++++
>>> 1 file changed, 13 insertions(+)
>>>
>>> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
>>> index 0438c68015e8..bbdac07f4aaa 100644
>>> --- a/drivers/iio/adc/at91_adc.c
>>> +++ b/drivers/iio/adc/at91_adc.c
>>> @@ -113,6 +113,7 @@
>>> #define AT91_ADC_TSMR_TSAV (3 << 4) /* Averages samples */
>>> #define AT91_ADC_TSMR_TSAV_(x) ((x) << 4)
>>> #define AT91_ADC_TSMR_SCTIM (0x0f << 16) /* Switch closure time */
>>> +#define AT91_ADC_TSMR_SCTIM_(x) ((x) << 16)
>>> #define AT91_ADC_TSMR_PENDBC (0x0f << 28) /* Pen Debounce time */
>>> #define AT91_ADC_TSMR_PENDBC_(x) ((x) << 28)
>>> #define AT91_ADC_TSMR_NOTSDMA (1 << 22) /* No Touchscreen DMA */
>>> @@ -150,6 +151,7 @@
>>> #define MAX_RLPOS_BITS 10
>>> #define TOUCH_SAMPLE_PERIOD_US_RL 10000 /* 10ms, the SoC can't keep up with 2ms */
>>> #define TOUCH_SHTIM 0xa
>>> +#define TOUCH_SCTIM_US 10 /* 10us for the Touchscreen Switches Closure Time */
>>>
>>> /**
>>> * struct at91_adc_reg_desc - Various informations relative to registers
>>> @@ -1001,7 +1003,9 @@ static void atmel_ts_close(struct input_dev *dev)
>>>
>>> static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
>>> {
>>> + struct iio_dev *idev = iio_priv_to_dev(st);
>>> u32 reg = 0;
>>> + u32 tssctim = 0;
>>> int i = 0;
>>>
>>> /* a Pen Detect Debounce Time is necessary for the ADC Touch to avoid
>>> @@ -1034,11 +1038,20 @@ static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
>>> return 0;
>>> }
>>>
>>> + /* Touchscreen Switches Closure time needed for allowing the value to
>>> + * stabilize.
>>> + * Switch Closure Time = (TSSCTIM * 4) ADCClock periods
>>> + */
>>> + tssctim = DIV_ROUND_UP(TOUCH_SCTIM_US * adc_clk_khz / 1000, 4);
>>> + dev_dbg(&idev->dev, "adc_clk at: %d KHz, tssctim at: %d\n",
>>> + adc_clk_khz, tssctim);
>>> +
>>> if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_4WIRE)
>>> reg = AT91_ADC_TSMR_TSMODE_4WIRE_PRESS;
>>> else
>>> reg = AT91_ADC_TSMR_TSMODE_5WIRE;
>>>
>>> + reg |= AT91_ADC_TSMR_SCTIM_(tssctim) & AT91_ADC_TSMR_SCTIM;
>>> reg |= AT91_ADC_TSMR_TSAV_(st->caps->ts_filter_average)
>>> & AT91_ADC_TSMR_TSAV;
>>> reg |= AT91_ADC_TSMR_PENDBC_(st->ts_pendbc) & AT91_ADC_TSMR_PENDBC;
>>>
>>
>>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-05 20:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-30 12:27 [PATCH] iio: adc: at91: Add support for Touchscreen Switches Closure Time Nicolas Ferre
2016-09-03 16:24 ` Jonathan Cameron
2016-09-05 8:26 ` Nicolas Ferre
2016-09-05 20:12 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).