linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Dmitry Osipenko <digetx@gmail.com>,
	Jiada Wang <jiada_wang@mentor.com>,
	Nick Dyer <nick@shmanahar.org>,
	Linux Input <linux-input@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Eugeniu Rosca <erosca@de.adit-jv.com>,
	Andrew_Gabbasov@mentor.com
Subject: Re: [PATCH v4 1/1] Input: atmel_mxt_ts - implement I2C retries
Date: Mon, 14 Sep 2020 19:13:00 -0600	[thread overview]
Message-ID: <CAL_JsqLNunrunERGThJ_CVrP0yxrw2dtm539CMH8aoonVq8pTA@mail.gmail.com> (raw)
In-Reply-To: <20200914223238.GD1681290@dtor-ws>

On Mon, Sep 14, 2020 at 4:32 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> On Tue, Sep 15, 2020 at 12:33:18AM +0300, Dmitry Osipenko wrote:
> > 14.09.2020 22:36, Dmitry Torokhov пишет:
> > > On Mon, Sep 14, 2020 at 12:33:40PM -0700, Dmitry Torokhov wrote:
> > >> On Mon, Sep 14, 2020 at 08:29:44PM +0300, Dmitry Osipenko wrote:
> > >>> 13.09.2020 19:56, Dmitry Torokhov пишет:
> > >>>> Hi Jiada,
> > >>>>
> > >>>> On Sat, Sep 12, 2020 at 09:55:21AM +0900, Jiada Wang wrote:
> > >>>>> From: Nick Dyer <nick.dyer@itdev.co.uk>
> > >>>>>
> > >>>>> Some maXTouch chips (eg mXT1386) will not respond on the first I2C request
> > >>>>> when they are in a sleep state. It must be retried after a delay for the
> > >>>>> chip to wake up.
> > >>>>
> > >>>> Do we know when the chip is in sleep state? Can we do a quick I2C
> > >>>> transaction in this case instead of adding retry logic to everything? Or
> > >>>> there is another benefit for having such retry logic?
> > >>>
> > >>> Hello!
> > >>>
> > >>> Please take a look at page 29 of:
> > >>>
> > >>> https://ww1.microchip.com/downloads/en/DeviceDoc/mXT1386_1vx_Datasheet_LX.pdf
> > >>>
> > >>> It says that the retry is needed after waking up from a deep-sleep mode.
> > >>>
> > >>> There are at least two examples when it's needed:
> > >>>
> > >>> 1. Driver probe. Controller could be in a deep-sleep mode at the probe
> > >>> time, and then first __mxt_read_reg() returns I2C NACK on reading out TS
> > >>> hardware info.
> > >>>
> > >>> 2. Touchscreen input device is opened. The touchscreen is in a
> > >>> deep-sleep mode at the time when input device is opened, hence first
> > >>> __mxt_write_reg() invoked from mxt_start() returns I2C NACK.
> > >>>
> > >>> I think placing the retries within __mxt_read() / write_reg() should be
> > >>> the most universal option.
> > >>>
> > >>> Perhaps it should be possible to add mxt_wake() that will read out some
> > >>> generic register
> > >>
> > >> I do not think we need to read a particular register, just doing a quick
> > >> read:
> > >>
> > >>    i2c_smbus_xfer(client->adapter, client->addr,
> > >>                    0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE, &dummy)
> > >>
> > >> should suffice.
> > >>
> > >>> and then this helper should be invoked after HW
> > >>> resetting (before mxt_read_info_block()) and from mxt_start() (before
> > >>> mxt_set_t7_power_cfg()). But this approach feels a bit fragile to me.
> > >>>
> > >>
> > >> Actually, reading the spec, it all depends on how the WAKE pin is wired
> > >> up on a given board. In certain setups retrying transaction is the right
> > >> approach, while in others explicit control is needed. So indeed, we need
> > >> a "wake" helper that we should call in probe and resume paths.
> >
> > The WAKE-GPIO was never supported and I'm not sure whether anyone
> > actually needs it. I think we could ignore this case until anyone would
> > really need and could test it.
>
> Right, I am not advocating adding GPIO control right away, I was simply
> arguing why I believe we should separate wakeup handling from normal
> communication handling.
>
> >
> > > By the way, I would like to avoid the unnecessary retries in probe paths
> > > if possible. I.e. on Chrome OS we really keep an eye on boot times and
> > > in case of multi-sourced touchscreens we may legitimately not have
> > > device at given address.
> >
> > We could add a new MXT1386 DT compatible and then do:
> >
> > static void mxt_wake(struct mxt_data *data)
> > {
> >       struct i2c_client *client = data->client;
> >       struct device *dev = &data->client->dev;
> >       union i2c_smbus_data dummy;
> >
> >       if (!of_device_is_compatible(dev, "atmel,mXT1386"))
> >               return;
> >
> >       /* TODO: add WAKE-GPIO support */
> >
> >       i2c_smbus_xfer(client->adapter, client->addr,
> >                       0, I2C_SMBUS_READ, 0, I2C_SMBUS_BYTE,
> >                       &dummy);
> >
> >       msleep(MXT_WAKEUP_TIME);
> > }
> >
> > Jiada, will you be able to re-work this patch? Please note that the new
> > "atmel,mXT1386" DT compatible needs to be added into the
> > atmel,maxtouch.txt binding.
>
> Another option is to have a device property "atmel,wakeup-type" or
> something, in case there are more Atmel variants needing this.
>
> Rob, any preferences here?

If device specific, then I prefer to be implied by the compatible. If
board specific, then a property is appropriate. Seems like this is the
former case.

Rob

  reply	other threads:[~2020-09-15  1:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12  0:55 [PATCH v4 1/1] Input: atmel_mxt_ts - implement I2C retries Jiada Wang
2020-09-13  8:43 ` Andy Shevchenko
2020-09-13 12:57   ` Dmitry Osipenko
2020-09-14 13:49     ` Andy Shevchenko
2020-09-14 15:26       ` Dmitry Osipenko
2020-09-14 15:50         ` Andy Shevchenko
2020-09-14 16:28           ` Dmitry Osipenko
2020-09-13 16:56 ` Dmitry Torokhov
2020-09-14 17:29   ` Dmitry Osipenko
2020-09-14 19:33     ` Dmitry Torokhov
2020-09-14 19:36       ` Dmitry Torokhov
2020-09-14 21:33         ` Dmitry Osipenko
2020-09-14 22:32           ` Dmitry Torokhov
2020-09-15  1:13             ` Rob Herring [this message]
2020-09-15 15:55           ` Wang, Jiada
2020-09-15 17:40             ` Dmitry Osipenko

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=CAL_JsqLNunrunERGThJ_CVrP0yxrw2dtm539CMH8aoonVq8pTA@mail.gmail.com \
    --to=robh@kernel.org \
    --cc=Andrew_Gabbasov@mentor.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=digetx@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=erosca@de.adit-jv.com \
    --cc=jiada_wang@mentor.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nick@shmanahar.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).