2021-11-25 22:57:59

by Dario Binacchi

[permalink] [raw]
Subject: [PATCH v2 0/4] input: touchscreen: am335x: fix and improvements


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

Changes in v2:
- Rebase the series onto v5.16-rc2
- Replace CNTRLREG_8WIRE with CNTRLREG_TSC_8WIRE. In the meantime, the
file ti_am335x_tscadc.h has been modified, so the patch must be
updated.
- Drop patch 4/6 ("dt-bindings: input: ti-tsc-adc: fix tsc node example")
- Drop patch 5/6 ("mfd: ti_am335x_tscadc: fix reading a tsc property from DT")

Dario Binacchi (4):
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
mfd: ti_am335x_tscadc: drop the CNTRLREG_TSC_8WIRE macro

drivers/input/touchscreen/ti_am335x_tsc.c | 18 +++++++++++++-----
include/linux/mfd/ti_am335x_tscadc.h | 1 -
2 files changed, 13 insertions(+), 6 deletions(-)

--
2.17.1



2021-11-25 22:58:01

by Dario Binacchi

[permalink] [raw]
Subject: [PATCH v2 1/4] input: ti_am335x_tsc: set ADCREFM for X configuration

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 <[email protected]>
---

(no changes since v1)

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


2021-11-25 23:03:01

by Dario Binacchi

[permalink] [raw]
Subject: [PATCH v2 2/4] input: ti_am335x_tsc: fix STEPCONFIG setup for Z2

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 <[email protected]>
---

(no changes since v1)

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


2021-11-25 23:03:03

by Dario Binacchi

[permalink] [raw]
Subject: [PATCH v2 4/4] mfd: ti_am335x_tscadc: drop the CNTRLREG_TSC_8WIRE macro

In TI's reference manual description for the `AFE_Pen_Ctrl' bit-field
of the TSC's CTRL register, there is no mention of 8-wire touchscreens.
Even commit f0933a60d190 ("mfd: ti_am335x_tscadc: Update logic in CTRL
register for 5-wire TS") says that the value of this bit-field must be
the same for 4-wire and 8-wire touchscreens. So let's remove the
CNTRLREG_TSC_8WIRE macro to avoid misunderstandings.

Signed-off-by: Dario Binacchi <[email protected]>

---

Changes in v2:
- Replace CNTRLREG_8WIRE with CNTRLREG_TSC_8WIRE. In the meantime, the
file ti_am335x_tscadc.h has been modified, so the patch must be
updated.

include/linux/mfd/ti_am335x_tscadc.h | 1 -
1 file changed, 1 deletion(-)

diff --git a/include/linux/mfd/ti_am335x_tscadc.h b/include/linux/mfd/ti_am335x_tscadc.h
index ba13e043d910..4063b0614d90 100644
--- a/include/linux/mfd/ti_am335x_tscadc.h
+++ b/include/linux/mfd/ti_am335x_tscadc.h
@@ -103,7 +103,6 @@
#define CNTRLREG_TSC_AFE_CTRL(val) FIELD_PREP(GENMASK(6, 5), (val))
#define CNTRLREG_TSC_4WIRE CNTRLREG_TSC_AFE_CTRL(1)
#define CNTRLREG_TSC_5WIRE CNTRLREG_TSC_AFE_CTRL(2)
-#define CNTRLREG_TSC_8WIRE CNTRLREG_TSC_AFE_CTRL(3)
#define CNTRLREG_TSC_ENB BIT(7)

/*Control registers bitfields for MAGADC IP */
--
2.17.1


2021-11-26 09:01:20

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v2 4/4] mfd: ti_am335x_tscadc: drop the CNTRLREG_TSC_8WIRE macro

On Thu, 25 Nov 2021, Dario Binacchi wrote:

> In TI's reference manual description for the `AFE_Pen_Ctrl' bit-field
> of the TSC's CTRL register, there is no mention of 8-wire touchscreens.
> Even commit f0933a60d190 ("mfd: ti_am335x_tscadc: Update logic in CTRL
> register for 5-wire TS") says that the value of this bit-field must be
> the same for 4-wire and 8-wire touchscreens. So let's remove the
> CNTRLREG_TSC_8WIRE macro to avoid misunderstandings.
>
> Signed-off-by: Dario Binacchi <[email protected]>
>
> ---
>
> Changes in v2:
> - Replace CNTRLREG_8WIRE with CNTRLREG_TSC_8WIRE. In the meantime, the
> file ti_am335x_tscadc.h has been modified, so the patch must be
> updated.
>
> include/linux/mfd/ti_am335x_tscadc.h | 1 -
> 1 file changed, 1 deletion(-)

Applied, thanks.

--
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog