# \[RESEND PATCH 0/3\] input: touchscreen: am335x: fix and improvements

- Subsystems: INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN) DRIVERS, MULTIFUNCTION DEVICES (MFD), OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS, THE REST
- Maintainers: Dmitry Torokhov, Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Linus Torvalds
- Series: 6 patches touching 4 files, +20/-8
- Status: SUPERSEDED (Superseded by v2 posted 2021-11-25)
- Superseded by v2 (posted 2021-11-25).
- Revision resend (3 revisions archived).
- List: linux-input
- 5 messages, 2 authors
- Page: https://ratatoskr.run/linux-input/2021/12/1605227/t

## \[RESEND PATCH 0/3\] input: touchscreen: am335x: fix and improvements

- From: Dario Binacchi \<hidden\>
- Date: 2021-12-12 12:54:27 
- Message: https://ratatoskr.run/linux-input/2021/12/1605227.md

```text

This series grew out of a touchscreen validation activity on a custom
board. Oscilloscope measurements and driver source analysis led to these
patches.


Dario Binacchi (3):
  input: ti_am335x_tsc: set ADCREFM for X configuration
  input: ti_am335x_tsc: fix STEPCONFIG setup for Z2
  input: ti_am335x_tsc: lower the X and Y sampling time

 drivers/input/touchscreen/ti_am335x_tsc.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
2.17.1

```

## \[RESEND PATCH 1/3\] input: ti\_am335x\_tsc: set ADCREFM for X configuration

- From: Dario Binacchi \<hidden\>
- Date: 2021-12-12 12:54:08 
- Message: https://ratatoskr.run/linux-input/2021/12/1605225.md

```text
As reported by the STEPCONFIG[1-16] registered field descriptions of the
TI reference manual, for the ADC "in single ended, SEL_INM_SWC_3_0 must
be 1xxx".

Unlike the Y and Z coordinates, this bit has not been set for the step
configuration registers used to sample the X coordinate.

Fixes: 1b8be32e691 ("Input: add support for TI Touchscreen controller")
Signed-off-by: Dario Binacchi <redacted>
---

 drivers/input/touchscreen/ti_am335x_tsc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index 83e685557a19..fd3ffdd23470 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -131,7 +131,8 @@ static void titsc_step_config(struct titsc *ts_dev)
 	u32 stepenable;
 
 	config = STEPCONFIG_MODE_HWSYNC |
-			STEPCONFIG_AVG_16 | ts_dev->bit_xp;
+			STEPCONFIG_AVG_16 | ts_dev->bit_xp |
+			STEPCONFIG_INM_ADCREFM;
 	switch (ts_dev->wires) {
 	case 4:
 		config |= STEPCONFIG_INP(ts_dev->inp_yp) | ts_dev->bit_xn;
-- 
2.17.1

```

## \[RESEND PATCH 2/3\] input: ti\_am335x\_tsc: fix STEPCONFIG setup for Z2

- From: Dario Binacchi \<hidden\>
- Date: 2021-12-12 12:54:28 
- Message: https://ratatoskr.run/linux-input/2021/12/1605226.md

```text
The Z2 step configuration doesn't erase the SEL_INP_SWC_3_0 bit-field
before setting the ADC channel. This way its value could be corrupted by
the ADC channel selected for the Z1 coordinate.

Fixes: 8c896308fea ("input: ti_am335x_adc: use only FIFO0 and clean up a little")
Signed-off-by: Dario Binacchi <redacted>
---

 drivers/input/touchscreen/ti_am335x_tsc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index fd3ffdd23470..cfc943423241 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -196,7 +196,10 @@ static void titsc_step_config(struct titsc *ts_dev)
 			STEPCONFIG_OPENDLY);
 
 	end_step++;
-	config |= STEPCONFIG_INP(ts_dev->inp_yn);
+	config = STEPCONFIG_MODE_HWSYNC |
+			STEPCONFIG_AVG_16 | ts_dev->bit_yp |
+			ts_dev->bit_xn | STEPCONFIG_INM_ADCREFM |
+			STEPCONFIG_INP(ts_dev->inp_yn);
 	titsc_writel(ts_dev, REG_STEPCONFIG(end_step), config);
 	titsc_writel(ts_dev, REG_STEPDELAY(end_step),
 			STEPCONFIG_OPENDLY);
-- 
2.17.1

```

## \[RESEND PATCH 3/3\] input: ti\_am335x\_tsc: lower the X and Y sampling time

- From: Dario Binacchi \<hidden\>
- Date: 2021-12-12 12:55:05 
- Message: https://ratatoskr.run/linux-input/2021/12/1605228.md

```text
The open delay time has to be applied only on the first sample of the
X/Y coordinates because on the following samples the ADC channel is not
changed. Removing this time from the samples after the first one,
"ti,coordinate-readouts" greater than 1, decreases the total acquisition
time, allowing to increase the number of acquired coordinates in the time
unit.

Signed-off-by: Dario Binacchi <redacted>

---

 drivers/input/touchscreen/ti_am335x_tsc.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c
index cfc943423241..f4ef218bc1b8 100644
--- a/drivers/input/touchscreen/ti_am335x_tsc.c
+++ b/drivers/input/touchscreen/ti_am335x_tsc.c
@@ -126,7 +126,7 @@ static int titsc_config_wires(struct titsc *ts_dev)
 static void titsc_step_config(struct titsc *ts_dev)
 {
 	unsigned int	config;
-	int i;
+	int i, n;
 	int end_step, first_step, tsc_steps;
 	u32 stepenable;
 
@@ -151,9 +151,11 @@ static void titsc_step_config(struct titsc *ts_dev)
 	first_step = TOTAL_STEPS - tsc_steps;
 	/* Steps 16 to 16-coordinate_readouts is for X */
 	end_step = first_step + tsc_steps;
+	n = 0;
 	for (i = end_step - ts_dev->coordinate_readouts; i < end_step; i++) {
 		titsc_writel(ts_dev, REG_STEPCONFIG(i), config);
-		titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
+		titsc_writel(ts_dev, REG_STEPDELAY(i),
+			     n++ == 0 ? STEPCONFIG_OPENDLY : 0);
 	}
 
 	config = 0;
@@ -175,9 +177,11 @@ static void titsc_step_config(struct titsc *ts_dev)
 
 	/* 1 ... coordinate_readouts is for Y */
 	end_step = first_step + ts_dev->coordinate_readouts;
+	n = 0;
 	for (i = first_step; i < end_step; i++) {
 		titsc_writel(ts_dev, REG_STEPCONFIG(i), config);
-		titsc_writel(ts_dev, REG_STEPDELAY(i), STEPCONFIG_OPENDLY);
+		titsc_writel(ts_dev, REG_STEPDELAY(i),
+			     n++ == 0 ? STEPCONFIG_OPENDLY : 0);
 	}
 
 	/* Make CHARGECONFIG same as IDLECONFIG */
-- 
2.17.1

```

## Re: \[RESEND PATCH 0/3\] input: touchscreen: am335x: fix and improvements

- From: Dmitry Torokhov \<dmitry.torokhov@gmail.com\>
- Date: 2021-12-13 05:18:43 
- Message: https://ratatoskr.run/linux-input/2021/12/1605500.md

```text
On Sun, Dec 12, 2021 at 01:53:55PM +0100, Dario Binacchi wrote:
> 
> This series grew out of a touchscreen validation activity on a custom
> board. Oscilloscope measurements and driver source analysis led to these
> patches.
> 
> 
> Dario Binacchi (3):
>   input: ti_am335x_tsc: set ADCREFM for X configuration
>   input: ti_am335x_tsc: fix STEPCONFIG setup for Z2
>   input: ti_am335x_tsc: lower the X and Y sampling time
> 
>  drivers/input/touchscreen/ti_am335x_tsc.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)

Applied the lot, thank you.

-- 
Dmitry
```
