diff mbox

[1/3] edt-ft5x06: fix reset pin behaviour

Message ID 20171005153508.32127-1-simon.budig@kernelconcepts.de (mailing list archive)
State New, archived
Headers show

Commit Message

Simon Budig Oct. 5, 2017, 3:35 p.m. UTC
From: Simon Budig <simon.budig@kernelconcepts.de>

For some reason the reset pin no longer gets toggeled when initializing
the touch. Fix that and restore the old behaviour.

Signed-off-by: Simon Budig <simon.budig@kernelconcepts.de>
---
 drivers/input/touchscreen/edt-ft5x06.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Dmitry Torokhov Oct. 10, 2017, 3:58 a.m. UTC | #1
On Thu, Oct 05, 2017 at 05:35:06PM +0200, simon.budig@kernelconcepts.de wrote:
> From: Simon Budig <simon.budig@kernelconcepts.de>
> 
> For some reason the reset pin no longer gets toggeled when initializing
> the touch. Fix that and restore the old behaviour.

Hmm, the GPIO is requested as GPIOD_OUT_HIGH, so it should be driven low
to being with and then released... I am not sure why we need to drive it
low explicitly again.

> 
> Signed-off-by: Simon Budig <simon.budig@kernelconcepts.de>
> ---
>  drivers/input/touchscreen/edt-ft5x06.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
> index 5bf63f7..867a61e 100644
> --- a/drivers/input/touchscreen/edt-ft5x06.c
> +++ b/drivers/input/touchscreen/edt-ft5x06.c
> @@ -936,8 +936,12 @@ static int edt_ft5x06_ts_probe(struct i2c_client *client,
>  
>  	if (tsdata->reset_gpio) {
>  		usleep_range(5000, 6000);
> -		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
> +		/* note that the reset pin needs to be registered as
> +		 * active low in the devicetree.
> +		 */
> +		gpiod_set_value_cansleep(tsdata->reset_gpio, 1);
>  		msleep(300);
> +		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
>  	}
>  
>  	input = devm_input_allocate_device(&client->dev);
> -- 
> 2.1.4
> 

Thanks.
Simon Budig Oct. 10, 2017, 10:25 a.m. UTC | #2
Hi Dmitry.

On Mon, 2017-10-09 at 20:58 -0700, Dmitry Torokhov wrote:
> On Thu, Oct 05, 2017 at 05:35:06PM +0200, simon.budig@kernelconcepts.
> de wrote:
> > From: Simon Budig <simon.budig@kernelconcepts.de>
> > 
> > For some reason the reset pin no longer gets toggeled when
> > initializing
> > the touch. Fix that and restore the old behaviour.
> 
> Hmm, the GPIO is requested as GPIOD_OUT_HIGH, so it should be driven
> low
> to being with and then released... I am not sure why we need to drive
> it
> low explicitly again.

It is possible that I misinterpreted something here - at some point I
did have the GPIO pin wrongly registered in the devicetree.

However, API-wise it is not clear to me, that GPIOD_OUT_HIGH results in
an actual low state of the Pin. That might be different if the constant
was called GPIOD_OUT_ACTIVE or something, since this would refer to the
"low_active" state of the pin.

*If* that is actually the case (i.e. requesting an pin specified as
GPIO_ACTIVE_LOW in the devicetree with the GPIOD_OUT_HIGH flag results
in 0V on this pin) then this patch should probably be dropped, although
I don't like how this code reads then.

I also reread the focaltec datasheet and I've messed up the delays in
this patch, so if the above does *not* happen then I'd need to rework
this...

Bye,
        Simon
Simon Budig Oct. 10, 2017, 10:39 a.m. UTC | #3
On Tue, 2017-10-10 at 12:25 +0200, Simon Budig wrote:
> *If* that is actually the case (i.e. requesting an pin specified as
> GPIO_ACTIVE_LOW in the devicetree with the GPIOD_OUT_HIGH flag
> results in 0V on this pin) then this patch should probably be
> dropped, although I don't like how this code reads then.

Ok, I've traced the code in the gpio-subsystem and indeed, requesting
with the GPIOD_OUT_HIGH flag results in a LOW leveGPIOD_OUT_HIGH upon
request when the GPIO_ACTIVE_LOW is set on that pin.

That constant really should've been called GPIOD_OUT_ACTIVE or
something. That reads confusing as heck.

Anyway, please drop this patch. It doesn't actually do any good.

Thanks,
        Simon
diff mbox

Patch

diff --git a/drivers/input/touchscreen/edt-ft5x06.c b/drivers/input/touchscreen/edt-ft5x06.c
index 5bf63f7..867a61e 100644
--- a/drivers/input/touchscreen/edt-ft5x06.c
+++ b/drivers/input/touchscreen/edt-ft5x06.c
@@ -936,8 +936,12 @@  static int edt_ft5x06_ts_probe(struct i2c_client *client,
 
 	if (tsdata->reset_gpio) {
 		usleep_range(5000, 6000);
-		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
+		/* note that the reset pin needs to be registered as
+		 * active low in the devicetree.
+		 */
+		gpiod_set_value_cansleep(tsdata->reset_gpio, 1);
 		msleep(300);
+		gpiod_set_value_cansleep(tsdata->reset_gpio, 0);
 	}
 
 	input = devm_input_allocate_device(&client->dev);