Re: [PATCH 2/2] arm64: dts: qcom: sc8280xp-x13s: Fix/enable touchscreen

From: Bjorn Andersson
Date: Fri Jan 26 2024 - 09:54:17 EST


On Fri, Jan 26, 2024 at 03:31:02PM +0100, Johan Hovold wrote:
> On Fri, Jan 26, 2024 at 01:02:32PM +0000, Daniel Thompson wrote:
> > On Fri, Jan 26, 2024 at 09:12:37AM +0100, Johan Hovold wrote:
> > > On Thu, Jan 25, 2024 at 07:55:14PM -0800, Bjorn Andersson wrote:
> > > > The failing read-test in __i2c_hid_core_probe() determines that there's
> > > > nothing connected at the documented address of the touchscreen.
> > > >
> > > > Introduce the 5ms after-power and 200ms after-reset delays found in the
> > > > ACPI tables. Also wire up the reset-gpio, for good measure.
> > >
> > > As the supplies for the touchscreen are always on (and left on by the
> > > bootloader) it would seem that it is really the addition of the reset
> > > gpio which makes things work here. Unless the delay is needed for some
> > > other reason.
> > >
> > > (The power-on delay also looks a bit short compared to what is used for
> > > other devices.)
> > >
> > > Reset support was only recently added with commit 2be404486c05 ("HID:
> > > i2c-hid-of: Add reset GPIO support to i2c-hid-of") so we should not
> > > backport this one before first determining that.
> >
> > This comment attracted my attention so I tried booting with each of the
> > three lines individually.
> >
> > On Thu, Jan 25, 2024 at 07:55:14PM -0800, Bjorn Andersson wrote:
> > > + reset-gpios = <&tlmm 99 GPIO_ACTIVE_LOW>;
> >
> > This is not enough, on it's own, to get the touch screen running.
> >
> > I guess that's not so much of a surprise since the rebind-the-driver
> > from userspace trick wouldn't have been touching this reset.
>
> Right, I realised that after hitting send.
>
> For the record, people have successfully been using the touchpad after
> forcing the driver to reprobe through sysfs:
>
> echo 4-0010 >/sys/bus/i2c/drivers/i2c_hid_of/bind
>
> > > + post-power-on-delay-ms = <5>;
> >
> > This line alone is enough (in v6.7.1).
>
> Thanks for confirming.
>
> > > + post-reset-deassert-delay-ms = <200>;
> >
> > This line alone is also enough!
>
> Yes, the driver honours this delay regardless of whether a reset gpio is
> defined currently, so this is expected.
>
> > In short it looks like the delays make the difference and, even a short
> > delay, can fix the problem.
>
> Right, but since the suppliers are left enabled by the bootloader (and
> never disabled by the kernel), that only begs the question of why this
> makes a difference.
>

You're right, the supply is kept on by other things, so this isn't the
problem.

> Without the delay, the other HID devices are probing (successfully)
> slightly before, but essentially in parallel with the touchscreen while
> using the same resources. Is that causing trouble somehow?
>

The difference to those other HID devices is GPIO 99 - the reset pin,
which is configured pull down input from boot - i.e. the chip is held in
reset.

When the HID device is being probed, pinctrl applies &ts0_default starts
driving it high, bringing the device out of reset. But insufficient time
is given for the chip to come up so the I2C read fails.

If you later try to probe again, 200ms has elapsed since the reset was
deasserted (driven high).

Regards,
Bjorn

> Or is there a bug in the i2c controller driver affecting only this
> device that can be worked around by adding a delay before the first
> transfer?
>
> Johan