diff mbox series

[4/7] Input: cyttsp - Reduce reset pulse timings

Message ID 20210330085424.2244653-5-linus.walleij@linaro.org (mailing list archive)
State New, archived
Headers show
Series Input: cyttsp - First round of modernizations | expand

Commit Message

Linus Walleij March 30, 2021, 8:54 a.m. UTC
The data sheet for CY8CTMA340 specifies that the reset pulse
shall be at least 1 ms. Specify 1-2 ms with usleep_range()
to cut some slack for the scheduler.

Curiously the datasheet does not specify how long we have to
wait after a hard reset until the chip is up, but I have found
a vendor tree (Samsung GT-S7710) that has code for this touch
screen and there this is set to 5 ms so I use this with
the same 1 ms fuzz.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/input/touchscreen/cyttsp_core.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Javier Martinez Canillas March 30, 2021, 10:57 a.m. UTC | #1
On Tue, Mar 30, 2021 at 10:54 AM Linus Walleij <linus.walleij@linaro.org> wrote:
>
> The data sheet for CY8CTMA340 specifies that the reset pulse
> shall be at least 1 ms. Specify 1-2 ms with usleep_range()
> to cut some slack for the scheduler.
>
> Curiously the datasheet does not specify how long we have to
> wait after a hard reset until the chip is up, but I have found
> a vendor tree (Samsung GT-S7710) that has code for this touch
> screen and there this is set to 5 ms so I use this with
> the same 1 ms fuzz.
>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---

Makes sense.

Reviewed-by: Javier Martinez Canillas <javier@dowhile0.org>
diff mbox series

Patch

diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 91f8f38b3f06..84f4f1c1a220 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -230,10 +230,16 @@  static int cyttsp_set_sysinfo_regs(struct cyttsp *ts)
 static void cyttsp_hard_reset(struct cyttsp *ts)
 {
 	if (ts->reset_gpio) {
+		/*
+		 * According to the CY8CTMA340 datasheet page 21, the external
+		 * reset pulse width should be >= 1 ms. The datasheet does not
+		 * specify how long we have to wait after reset but a vendor
+		 * tree specifies 5 ms here.
+		 */
 		gpiod_set_value_cansleep(ts->reset_gpio, 1);
-		msleep(CY_DELAY_DFLT);
+		usleep_range(1000, 2000);
 		gpiod_set_value_cansleep(ts->reset_gpio, 0);
-		msleep(CY_DELAY_DFLT);
+		usleep_range(5000, 6000);
 	}
 }