linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Bastien Nocera <hadess@hadess.net>,
	Dmitry Mastykin <dmastykin@astralinux.ru>,
	linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: goodix - Try to reset the controller if the i2c-test fails
Date: Tue, 24 Mar 2020 11:52:14 -0700	[thread overview]
Message-ID: <20200324185214.GC75430@dtor-ws> (raw)
In-Reply-To: <20200311191013.10826-2-hdegoede@redhat.com>

On Wed, Mar 11, 2020 at 08:10:13PM +0100, Hans de Goede wrote:
> On some ACPI/x86 devices (where we use one of the ACPI IRQ pin access
> methods) the firmware is buggy, it does not properly reset the controller
> at boot, and we cannot communicate with it.
> 
> Normally on ACPI/x86 devices we do not want to reset the controller at
> probe time since in some cases this causes the controller to loose its
> configuration and this is loaded into it by the system's firmware.
> So on these systems we leave the reset_controller_at_probe flag unset,
> even though we have a access to both the IRQ and reset pins and thus
> could reset it.
> 
> In the case of the buggy firmware we have to reset the controller to
> actually be able to talk to it.
> 
> This commit adds a special case for this, if the goodix_i2c_test() fails,
> and we have not reset the controller yet; and we do have a way to reset
> the controller then retry the i2c-test after resetting the controller.
> 
> This fixes the driver failing at probe on ACPI/x86 systems with this
> firmware bug.
> 
> Reported-and-tested-by: Dmitry Mastykin <dmastykin@astralinux.ru>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied, thank you.

> ---
>  drivers/input/touchscreen/goodix.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
> index 2f135ac9484e..816d6ade89a9 100644
> --- a/drivers/input/touchscreen/goodix.c
> +++ b/drivers/input/touchscreen/goodix.c
> @@ -1165,6 +1165,7 @@ static int goodix_ts_probe(struct i2c_client *client,
>  	if (error)
>  		return error;
>  
> +reset:
>  	if (ts->reset_controller_at_probe) {
>  		/* reset the controller */
>  		error = goodix_reset(ts);
> @@ -1176,6 +1177,12 @@ static int goodix_ts_probe(struct i2c_client *client,
>  
>  	error = goodix_i2c_test(client);
>  	if (error) {
> +		if (!ts->reset_controller_at_probe &&
> +		    ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) {
> +			/* Retry after a controller reset */
> +			ts->reset_controller_at_probe = true;
> +			goto reset;
> +		}
>  		dev_err(&client->dev, "I2C communication failure: %d\n", error);
>  		return error;
>  	}
> -- 
> 2.25.1
> 

-- 
Dmitry

      reply	other threads:[~2020-03-24 18:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-11 19:10 [PATCH 0/1] Input: goodix - Try to reset the controller if the i2c-test fails Hans de Goede
2020-03-11 19:10 ` [PATCH] " Hans de Goede
2020-03-24 18:52   ` Dmitry Torokhov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200324185214.GC75430@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=dmastykin@astralinux.ru \
    --cc=hadess@hadess.net \
    --cc=hdegoede@redhat.com \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).