public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Alexey Charkov <alchark@gmail.com>
Cc: Dragan Simic <dsimic@manjaro.org>,
	Alexander Shiyan <eagle.alexander923@gmail.com>,
	Rob Herring <robh@kernel.org>, Conor Dooley <conor+dt@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>,
	devicetree@vger.kernel.org,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	stable@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: dts: rockchip: Fix broken tsadc pinctrl binding for rk3588
Date: Sat, 4 Oct 2025 02:52:30 +0300	[thread overview]
Message-ID: <20251003235230.GD1492@pendragon.ideasonboard.com> (raw)
In-Reply-To: <CABjd4YxbyUWghd1ya8UayFkAE-VWQSd5-J2QD0sV7WmS8AXkCg@mail.gmail.com>

On Fri, Oct 03, 2025 at 06:13:39PM +0400, Alexey Charkov wrote:
> On Fri, Oct 3, 2025 at 5:33 PM Laurent Pinchart wrote:
> > On Fri, Jan 24, 2025 at 11:44:34PM +0400, Alexey Charkov wrote:
> > > On Fri, Jan 24, 2025 at 9:23 PM Alexey Charkov <alchark@gmail.com> wrote:
> > > > On Fri, Jan 24, 2025 at 2:37 PM Dragan Simic <dsimic@manjaro.org> wrote:
> > > > > On 2025-01-24 11:25, Alexey Charkov wrote:
> > > > > > On Fri, Jan 24, 2025 at 2:06 PM Dragan Simic <dsimic@manjaro.org>
> > > > > > wrote:
> > > > > >> On 2025-01-24 09:33, Alexey Charkov wrote:
> > > > > >> > On Fri, Jan 24, 2025 at 9:26 AM Alexander Shiyan
> > > > > >> > <eagle.alexander923@gmail.com> wrote:
> > > > > >> >>
> > > > > >> >> There is no pinctrl "gpio" and "otpout" (probably designed as
> > > > > >> >> "output")
> > > > > >> >> handling in the tsadc driver.
> > > > > >> >> Let's use proper binding "default" and "sleep".
> > > > > >> >
> > > > > >> > This looks reasonable, however I've tried it on my Radxa Rock 5C and
> > > > > >> > the driver still doesn't claim GPIO0 RK_PA1 even with this change. As
> > > > > >> > a result, a simulated thermal runaway condition (I've changed the
> > > > > >> > tshut temperature to 65000 and tshut mode to 1) doesn't trigger a PMIC
> > > > > >> > reset, even though a direct `gpioset 0 1=0` does.
> > > > > >> >
> > > > > >> > Are any additional changes needed to the driver itself?
> > > > > >>
> > > > > >> I've been digging through this patch the whole TSADC/OTP thing in the
> > > > > >> last couple of hours, and AFAIK some parts of the upstream driver are
> > > > > >> still missing, in comparison with the downstream driver.
> > > > > >>
> > > > > >> I've got some small suggestions for the patch itself, but the issue
> > > > > >> you observed is obviously of higher priority, and I've singled it out
> > > > > >> as well while digging through the code.
> > > > > >>
> > > > > >> Could you, please, try the patch below quickly, to see is it going to
> > > > > >> fix the issue you observed?  I've got some "IRL stuff" to take care of
> > > > > >> today, so I can't test it myself, and it would be great to know is it
> > > > > >> the right path to the proper fix.
> > > > > >>
> > > > > >> diff --git i/drivers/thermal/rockchip_thermal.c
> > > > > >> w/drivers/thermal/rockchip_thermal.c
> > > > > >> index f551df48eef9..62f0e14a8d98 100644
> > > > > >> --- i/drivers/thermal/rockchip_thermal.c
> > > > > >> +++ w/drivers/thermal/rockchip_thermal.c
> > > > > >> @@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct
> > > > > >> platform_device *pdev)
> > > > > >>          thermal->chip->initialize(thermal->grf, thermal->regs,
> > > > > >>                                    thermal->tshut_polarity);
> > > > > >>
> > > > > >> +       if (thermal->tshut_mode == TSHUT_MODE_GPIO)
> > > > > >> +               pinctrl_select_default_state(dev);
> > > > > >> +       else
> > > > > >> +               pinctrl_select_sleep_state(dev);
> > > > > >
> > > > > > I believe no 'else' block is needed here, because if tshut_mode is not
> > > > > > TSHUT_MODE_GPIO then the TSADC doesn't use this pin at all, so there's
> > > > > > no reason for the driver to mess with its pinctrl state. I'd rather
> > > > > > put a mirroring block to put the pin back to its 'sleep' state in the
> > > > > > removal function for the TSHUT_MODE_GPIO case.
> > > > >
> > > > > You're right, but the "else block" is what the downstream driver does,
> > > >
> > > > Does it though? It only handles the TSHUT_MODE_GPIO case as far as I
> > > > can tell (or TSHUT_MODE_OTP in downstream driver lingo) [1]
> > > >
> > > > [1] https://github.com/radxa/kernel/blob/edb3eeeaa4643ecac6f4185d6d391c574735fca1/drivers/thermal/rockchip_thermal.c#L2564
> > > >
> > > > > so I think it's better to simply stay on the safe side and follow that
> > > > > logic in the upstream driver.  Is it really needed?  Perhaps not, but
> > > > > it also shouldn't hurt.
> > > > >
> > > > > > Will try and revert.
> > > > >
> > > > > Awesome, thanks!
> > > > >
> > > > > > P.S. Just looked at the downstream driver, and it actually calls
> > > > > > TSHUT_MODE_GPIO TSHUT_MODE_OTP instead, so it seems that "otpout" was
> > > > > > not a typo in the first place. So maybe the right approach here is not
> > > > > > to change the device tree but rather fix the "gpio" / "otpout" pinctrl
> > > > > > state handling in the driver.
> > > > >
> > > > > Indeed, "otpout" wasn't a typo, and I've already addressed that in my
> > > > > comments to Alexander's patch.  Will send that response a bit later.
> > > > >
> > > > > I think it's actually better to accept the approach in Alexander's
> > > > > patch, because the whole thing applies to other Rockchip SoCs as well,
> > > > > not just to the RK3588(S).
> > > >
> > > > Anyway, I've just tried it after including the changes below, and
> > > > while /sys/kernel/debug/pinctrl/pinctrl-handles shows the expected
> > > > pinctrls under tsadc, the driver still doesn't seem to be triggering a
> > > > PMIC reset. Weird. Any thoughts welcome.
> > >
> > > I found the culprit. "otpout" (or "default" if we follow Alexander's
> > > suggested approach) pinctrl state should refer to the &tsadc_shut_org
> > > config instead of &tsadc_shut - then the PMIC reset works.
> >
> > I've recently brought up an RK3588S-based Orange Pi CM5 Base board, made
> > of a compute module (CM5, see [1]) and a carrier board (Base, see [2]).
> > The carrier board has a reset button which pulls the PMIC_RESET_L signal
> > of the CM5 to GND (see page 3 of the schematics in [3]).
> >
> > With &tsadc_shut_org the reset button has absolutely no effect. With
> > &tsadc_shut it resets the board as expected.
> 
> Interesting. The TSADC shouldn't affect the physical button operation
> at all, if it's really wired to the PMIC as the signal name implies.
> There isn't even any default pull value associated with the TSHUT pin
> config.
> 
> What if you switch the GPIO0_A1 pin to GPIO output mode with no pull?
> Does the button work then? Does the board reset if you toggle the GPIO
> value with `gpioset`?

The button works when GPIO0_A1 is configured as a GPIO input. It doesn't
work anymore when the GPIO is set to 1, and setting the GPIO to 0 resets
the board. This confirms your hypothesis that the reset button
functionality conflicts with TSADC_SHUT being configured as a push-pull
output.

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2025-10-03 23:52 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-24  5:26 [PATCH] arm64: dts: rockchip: Fix broken tsadc pinctrl binding for rk3588 Alexander Shiyan
2025-01-24  8:33 ` Alexey Charkov
2025-01-24 10:06   ` Dragan Simic
2025-01-24 10:25     ` Alexey Charkov
2025-01-24 10:37       ` Dragan Simic
2025-01-24 10:45         ` Dragan Simic
2025-01-24 17:23         ` Alexey Charkov
2025-01-24 19:44           ` Alexey Charkov
2025-01-26  6:10             ` Dragan Simic
2025-01-26 14:25             ` Alexander Shiyan
2025-01-28  9:24               ` Dragan Simic
2025-01-28 10:30                 ` Alexey Charkov
2025-01-28 10:44                   ` Dragan Simic
2025-10-03 13:33             ` Laurent Pinchart
2025-10-03 14:13               ` Alexey Charkov
2025-10-03 14:55                 ` Alexey Charkov
2025-10-03 23:28                   ` Laurent Pinchart
2025-10-04 11:41                     ` Alexey Charkov
2025-10-04 22:03                       ` Laurent Pinchart
2025-10-05 10:55                         ` Alexey Charkov
2025-10-05 18:29                           ` Laurent Pinchart
2025-10-03 23:52                 ` Laurent Pinchart [this message]
2025-01-26  6:09           ` Dragan Simic
2025-01-24 10:38 ` Dragan Simic

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=20251003235230.GD1492@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=alchark@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dsimic@manjaro.org \
    --cc=eagle.alexander923@gmail.com \
    --cc=heiko@sntech.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=robh@kernel.org \
    --cc=sebastian.reichel@collabora.com \
    --cc=stable@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