arm64: dts: rockchip: Fix broken tsadc pinctrl binding for rk3588
Subsystems (4)
PATCH 1/1 arm64: dts: rockchip: Fix broken tsadc pinctrl binding for rk3588
There is no pinctrl "gpio" and "otpout" (probably designed as "output") handling in the tsadc driver.
Let's use proper binding "default" and "sleep".
--- arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +3 -3
@@ -2667,9 +2667,9 @@ tsadc: tsadc@fec00000 { rockchip,hw-tshut-temp = <120000>; rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */ rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */ - pinctrl-0 = <&tsadc_gpio_func>; - pinctrl-1 = <&tsadc_shut>; - pinctrl-names = "gpio", "otpout"; + pinctrl-0 = <&tsadc_shut>; + pinctrl-1 = <&tsadc_gpio_func>; + pinctrl-names = "default", "sleep"; #thermal-sensor-cells = <1>; status = "disabled"; };
Signature · 1 line
2.39.1
Hi Alexander,
Quoted 4 lines · Alexander Shiyan
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?
Best regards,
Alexey
Hello Alexey,
Quoted 7 lines · Alexey Charkov
Quoted 4 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output") handling in the tsadc driver.
Let's use proper binding "default" and "sleep".
Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
drivers/thermal/rockchip_thermal.c +5 -0
@@ -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); +for (i =0 ; i < thermal->chip->chn_num; i++) { error = rockchip_thermal_register_sensor(pdev, thermal, &thermal->sensors[i],
If you could test it, please, it would be great, and I'd prepare the proper patch tomorrow or so.
Quoted 39 lines · Dragan Simic
Hello Alexey,
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 8 lines
drivers/thermal/rockchip_thermal.c +4
-0@@ -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.
Will try and revert.
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.
Best,
Alexey
Quoted 41 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);
Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct platform_device *pdev) · line 1574
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.
You're right, but the "else block" is what the downstream driver does, 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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Hello Alexander,
Quoted 19 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output") handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Fixes 32641b8ab1a5 ("arm64: dts: rockchip: add rk3588 thermal sensor")Signed-off-by Alexander Shiyan <[email protected]>--- arch/arm64/boot/dts/rockchip/rk3588-base.dtsi | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +0
-0@@ -2667,9 +2667,9 @@ tsadc: tsadc@fec00000 { rockchip,hw-tshut-temp = <120000>; rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi tsadc: tsadc@fec00000 { · line 2675
Quoted 10 lines
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi +3
-3rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */ - pinctrl-0 = <&tsadc_gpio_func>; - pinctrl-1 = <&tsadc_shut>; - pinctrl-names = "gpio", "otpout"; + pinctrl-0 = <&tsadc_shut>; + pinctrl-1 = <&tsadc_gpio_func>; + pinctrl-names = "default", "sleep"; #thermal-sensor-cells = <1>; status = "disabled"; };
Thanks for the patch, it's looking good to me. The old values for the pinctrl names are leftovers back from the import of the downstream kernel code, while the new values follow the expected pinctrl naming scheme. The resulting behavior follows, almost entirely, the behavior found in the downstream kernel code.
Actually, there's some rather critical discrepancy between the upstream TSADC driver and it's downstream cousin, as already described in earlier responses from Alexey and me. However, those issues have to be addressed in a separate patch, while this patch, to me, remains fine on its own.
My only suggestions would be to adjust both the patch summary and the description not to use word "binding", because that technically isn't fixed here, but to use "pinctrl names" instead. Also, please note that the downstream kernel uses "otpout" as a pinctrl name, [1] so the assumption about "output" in the patch description should be removed.
With the suggestions from above addressed in the v2, please feel free to include my
Quoted 53 lines · Dragan Simic
Quoted 41 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct platform_device *pdev) · line 1574
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.
Quoted 8 lines
You're right, but the "else block" is what the downstream driver does, 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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Actually... Revert or report? :)
Quoted 12 lines
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 55 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.
Quoted 1 line
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]
Quoted 14 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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.
Quoted 6 lines
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.
Best regards,
Alexey
rock-5c ~ # cat /sys/kernel/debug/pinctrl/pinctrl-handles Requested pin control handlers their pinmux maps:
[...]
device: fec00000.tsadc current state: default
state: default
type: MUX_GROUP controller rockchip-pinctrl group: tsadc-shut (84)
function: tsadc (84)
type: CONFIGS_PIN controller rockchip-pinctrl pin gpio0-1 (1)config 00000001
state: sleep
type: MUX_GROUP controller rockchip-pinctrl group: tsadc-gpio-func
(95) function: gpio-func (97)
type: CONFIGS_PIN controller rockchip-pinctrl pin gpio0-1 (1)config 00000001
[...]
rock-5c ~ # gpioinfo 0
gpiochip0 - 32 lines:
line 0: unnamed "regulator-vdd-3v3" output active-high [used]
line 1: unnamed unused input active-high
line 2: unnamed unused input active-high
line 3: unnamed unused input active-high
line 4: unnamed unused input active-high
line 5: unnamed unused input active-high
line 6: unnamed unused input active-high
line 7: unnamed unused input active-high
line 8: unnamed unused input active-high
line 9: unnamed unused input active-high
line 10: unnamed unused input active-high
line 11: unnamed unused input active-high
line 12: unnamed unused input active-high
line 13: unnamed unused input active-high
line 14: unnamed unused input active-high
line 15: unnamed unused input active-high
line 16: unnamed unused input active-high
line 17: unnamed unused input active-high
line 18: unnamed unused input active-high
line 19: unnamed unused input active-high
line 20: unnamed unused input active-high
line 21: unnamed "regulator-pcie2x1l2-3v3" output
active-high [used]
line 22: unnamed unused input active-high
line 23: unnamed unused input active-high
line 24: unnamed unused input active-high
line 25: unnamed unused input active-high
line 26: unnamed unused input active-high
line 27: unnamed unused input active-high
line 28: unnamed "regulator-vcc5v0-usb-otg0" output
active-high [used]
line 29: unnamed unused input active-high
line 30: unnamed unused input active-high
line 31: unnamed unused input active-high(note line 1: unused above)
(quoted diff) +0 -0
b/arch/arm64/boot/dts/rockchip/rk3588s-rock-5c.dts index 6e56d7704cbe..e8c4d9b3f828 100644
arch/arm64/boot/dts/rockchip/rk3588s-rock-5c.dts +0 -0
@@ -873,6 +873,9 @@ regulator-state-mem {
};
&tsadc {
+ rockchip,hw-tshut-temp = <65000>;
+ rockchip,hw-tshut-mode = <1>; /* tshut mode 0:CRU 1:GPIO */
+ rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */
status = "okay";
};(quoted diff) +0 -0
b/drivers/thermal/rockchip_thermal.c
index f551df48eef9..4f474906b2b0 100644
drivers/thermal/rockchip_thermal.c +0 -0
@@ -1568,6 +1568,9 @@ 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(&pdev->dev);
+
for (i = 0; i < thermal->chip->chn_num; i++) {
error = rockchip_thermal_register_sensor(pdev, thermal,
&thermal->sensors[i],
@@ -1614,6 +1617,9 @@ static void rockchip_thermal_remove(struct
platform_device *pdev)
}
thermal->chip->control(thermal->regs, false);+
+ if (thermal->tshut_mode == TSHUT_MODE_GPIO)
+ pinctrl_pm_select_sleep_state(&pdev->dev);
}
static int __maybe_unused rockchip_thermal_suspend(struct device *dev) @@ -1629,7 +1635,8 @@ static int __maybe_unused rockchip_thermal_suspend(struct device *dev)
clk_disable(thermal->pclk);
clk_disable(thermal->clk);- pinctrl_pm_select_sleep_state(dev);
+ if (thermal->tshut_mode == TSHUT_MODE_GPIO)
+ pinctrl_pm_select_sleep_state(dev);
return 0;
}
@@ -1674,7 +1681,8 @@ static int __maybe_unused
rockchip_thermal_resume(struct device *dev)
for (i = 0; i < thermal->chip->chn_num; i++)
rockchip_thermal_toggle_sensor(&thermal->sensors[i], true);- pinctrl_pm_select_default_state(dev);
+ if (thermal->tshut_mode == TSHUT_MODE_GPIO)
+ pinctrl_pm_select_default_state(dev);
return 0; }
Quoted 81 lines · Alexey Charkov
Quoted 55 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 17 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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.
Quoted 8 lines
Quoted 3 lines
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-handlesshows 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.
Best,
Alexey
Hello Alexey,
Quoted 55 lines · Alexey Charkov
Quoted 54 lines · Dragan Simic
Quoted 52 lines · Alexey Charkov
Quoted 36 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 8 lines
drivers/thermal/rockchip_thermal.c +4
-0@@ -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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.
Quoted 6 lines
Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]
Ah, you're right. Somehow I saw something that actually wasn't there, so the else block would indeed be redundant.
Quoted 3 lines
Quoted 3 lines
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.
Quoted 84 lines · Alexey Charkov
Quoted 83 lines · Alexey Charkov
Quoted 54 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig instead of&tsadc_shut- then the PMIC reset works.
Huh, thanks for debugging, but this is quite confusing. Let me dig through everything again later today.
Hello.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig instead of&tsadc_shut- then the PMIC reset works.
Great, I'll use this in v2.
Thanks!
Hello Alexander,
Quoted 9 lines · Alexander Shiyan
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
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-handlesshows the expected pinctrls under tsadc, the driver still doesn't seem to be triggering a PMIC reset. Weird. Any thoughts welcome.
Quoted 5 lines
Quoted 3 lines
I found the culprit. "otpout" (or "default" if we follow Alexander's suggested approach) pinctrl state should refer to the
&tsadc_shut_orgconfig instead of&tsadc_shut- then the PMIC reset works.Great, I'll use this in v2.
Please, let's wait with the v2 until I go through the whole thing again, which I expected to have done already, but had some other "IRL stuff" that introduced a delay.
Quoted 13 lines · Dragan Simic
Hello Alexander,
Quoted 9 lines · Alexander Shiyan
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
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-handlesshows the expected pinctrls under tsadc, the driver still doesn't seem to be triggering a PMIC reset. Weird. Any thoughts welcome.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I found the culprit. "otpout" (or "default" if we follow Alexander's suggested approach) pinctrl state should refer to the
&tsadc_shut_orgconfig instead of&tsadc_shut- then the PMIC reset works.Great, I'll use this in v2.
Please, let's wait with the v2 until I go through the whole thing again
I, for one, would welcome a v2 that could be tested and confirmed working with and without driver changes. Especially given that:
- the changes are pretty small
- hardware docs say nothing about the difference between TSADC_SHUT
vs. TSADC_SHUT_ORG, except that one is config #2 and the other is config #1
- none of the source trees I looked at seem to enable PMIC based
resets on any RK3588-based boards, so these pinctrl configs appear to have never been tested in the wild for RK3588*
So trying and testing seems to be the only way to understand the best way forward. Unless, of course, someone from Rockchip can comment on how the hardware works with TSADC_SHUT vs. TSADC_SHUT_ORG.
Best regards,
Alexey
Quoted 3 lines
which I expected to have done already, but had some other "IRL stuff" that
introduced a delay.
Hello Alexey,
Quoted 29 lines · Alexey Charkov
Quoted 10 lines · Dragan Simic
Quoted 9 lines · Alexander Shiyan
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
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-handlesshows the expected pinctrls under tsadc, the driver still doesn't seem to be triggering a PMIC reset. Weird. Any thoughts welcome.Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
I found the culprit. "otpout" (or "default" if we follow Alexander's suggested approach) pinctrl state should refer to the
&tsadc_shut_orgconfig instead of&tsadc_shut- then the PMIC reset works.Great, I'll use this in v2.
Please, let's wait with the v2 until I go through the whole thing again
I, for one, would welcome a v2 that could be tested and confirmed working with and without driver changes. Especially given that:
- the changes are pretty small
- hardware docs say nothing about the difference betweenTSADC_SHUT
vs.TSADC_SHUT_ORG, except that one is config #2 and the other is config #1
- none of the source trees I looked at seem to enable PMIC based
resets on any RK3588-based boards, so these pinctrl configs appear to have never been tested in the wild for RK3588*
Quoted 3 lines
So trying and testing seems to be the only way to understand the best way forward. Unless, of course, someone from Rockchip can comment on how the hardware works with
TSADC_SHUTvs.TSADC_SHUT_ORG.
Perhaps the best approach would be to have the v2 that works without the driver changes, so it can be propagated into the stable kernels.
Then, a separate series, which I'll volunteer for, :) would introduce the cleanups and any needed driver changes, which wouldn't be propagated into the stable kernels. That way, we'd have the minimal bugfixes in stable kernels, and the nice cleanups in the latest kernel version.
Of course, detailed testing is mandatory.
Quoted 2 lines
Quoted 2 lines
which I expected to have done already, but had some other "IRL stuff" that introduced a delay.
Quoted 84 lines · Alexey Charkov
Quoted 83 lines · Alexey Charkov
Quoted 54 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig 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.
Unfortunately the schematics of the CM5 is not available so it's not immediately clear what the reset button is connected exactly. The same manufacturer sells another board based on the same SoC, the Orange Pi 5B ([4]) whose full schematics is available ([5]). The board also has a reset button pulling a PMIC_RESET_L signal to GND. The signal is pulled up to VCC_1V8_S3 and connected to
- RESETB on the PMIC
- NPOR on the RK3588S
- TSADC_SHUT (GPIO0_A1) on the RK3588S
[1] http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-CM5.html
[2] http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-CM5-Board.html
[3] https://drive.google.com/file/d/1t4WmXGWed8NnS0m2PWE7p5YLiR1dbnvP/view
[4] http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-5B.html
[5] https://drive.google.com/file/d/19iPdpAXhA1vFkVOgG5Sz7L6cV8BB6004/view
Signature · 3 lines
Regards, Laurent Pinchart
Hi Laurent,
Quoted 95 lines · Laurent Pinchart
Quoted 84 lines · Alexey Charkov
Quoted 83 lines · Alexey Charkov
Quoted 54 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig instead of&tsadc_shut- then the PMIC reset works.
Quoted 7 lines
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_Lsignal of the CM5 to GND (see page 3 of the schematics in [3]).With
&tsadc_shut_orgthe reset button has absolutely no effect. With&tsadc_shutit 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?
Best regards,
Alexey
Quoted 105 lines · Alexey Charkov
Hi Laurent,
Quoted 100 lines · Laurent Pinchart
Quoted 84 lines · Alexey Charkov
Quoted 83 lines · Alexey Charkov
Quoted 54 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig 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_Lsignal of the CM5 to GND (see page 3 of the schematics in [3]).
Quoted 7 lines
Quoted 2 lines
With
&tsadc_shut_orgthe reset button has absolutely no effect. With&tsadc_shutit 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.
On a second thought, I've got another hypothesis. Your baseboard only pulls the reset line through a 100 Ohm resistor when the button is pressed. So if the TSHUT pin is in its default push-pull mode and stays high when no thermal runaway reset is requested, the reset button won't pull the line fully to zero, as the TSHUT line pulls it high at the same time.
If you switch it from &tsadc_shut_org to &tsadc_shut, then it stops working properly as the thermal protection reset, and GPIO0_A1 remains high-impendance, thus allowing the reset button to function even though its pull is too weak.
So maybe change the pin configuration of &tsadc_shut_org in rk3588-base-pinctrl.dtsi to open drain and retry?
Best regards,
Alexey
Hi Alexey,
Quoted 109 lines · Alexey Charkov
Quoted 100 lines · Alexey Charkov
Quoted 99 lines · Laurent Pinchart
Quoted 84 lines · Alexey Charkov
Quoted 83 lines · Alexey Charkov
Quoted 54 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig 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_Lsignal of the CM5 to GND (see page 3 of the schematics in [3]).Quoted 7 lines
Quoted 2 lines
With
&tsadc_shut_orgthe reset button has absolutely no effect. With&tsadc_shutit 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.
Quoted 6 lines
On a second thought, I've got another hypothesis. Your baseboard only pulls the reset line through a 100 Ohm resistor when the button is pressed. So if the TSHUT pin is in its default push-pull mode and stays high when no thermal runaway reset is requested, the reset button won't pull the line fully to zero, as the TSHUT line pulls it high at the same time.
That's the most likely cause, I agree.
Quoted 4 lines
If you switch it from
&tsadc_shut_orgto&tsadc_shut, then it stops working properly as the thermal protection reset, andGPIO0_A1remains high-impendance, thus allowing the reset button to function even though its pull is too weak.
By the way, what is the difference between tsadc_shut_org and tsadc_shut ? I haven't seen it being clearly documented in the TRM.
Quoted 2 lines
So maybe change the pin configuration of
&tsadc_shut_orginrk3588-base-pinctrl.dtsito open drain and retry?
That's a good idea, but... how ? The pinctrl-rockchip driver doesn't seem to support generic open-drain configuration.
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 103 lines · Alexey Charkov
Quoted 94 lines · Laurent Pinchart
Quoted 84 lines · Alexey Charkov
Quoted 83 lines · Alexey Charkov
Quoted 54 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig instead of&tsadc_shut- then the PMIC reset works.Quoted 7 lines
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_Lsignal of the CM5 to GND (see page 3 of the schematics in [3]).With
&tsadc_shut_orgthe reset button has absolutely no effect. With&tsadc_shutit resets the board as expected.
Quoted 8 lines
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_A1pin to GPIO output mode with no pull? Does the button work then? Does the board reset if you toggle the GPIO value withgpioset?
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.
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 122 lines · Laurent Pinchart
Hi Alexey,
Quoted 109 lines · Alexey Charkov
Quoted 100 lines · Alexey Charkov
Quoted 99 lines · Laurent Pinchart
Quoted 84 lines · Alexey Charkov
Quoted 83 lines · Alexey Charkov
Quoted 54 lines · Dragan Simic
Quoted 42 lines · Alexey Charkov
Quoted 40 lines · Dragan Simic
Quoted 8 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig 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_Lsignal of the CM5 to GND (see page 3 of the schematics in [3]).Quoted 7 lines
Quoted 2 lines
With
&tsadc_shut_orgthe reset button has absolutely no effect. With&tsadc_shutit 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.
Quoted 6 lines
On a second thought, I've got another hypothesis. Your baseboard only pulls the reset line through a 100 Ohm resistor when the button is pressed. So if the TSHUT pin is in its default push-pull mode and stays high when no thermal runaway reset is requested, the reset button won't pull the line fully to zero, as the TSHUT line pulls it high at the same time.
That's the most likely cause, I agree.
Quoted 7 lines
Quoted 4 lines
If you switch it from
&tsadc_shut_orgto&tsadc_shut, then it stops working properly as the thermal protection reset, andGPIO0_A1remains high-impendance, thus allowing the reset button to function even though its pull is too weak.By the way, what is the difference between
tsadc_shut_organdtsadc_shut? I haven't seen it being clearly documented in the TRM.
No idea frankly. Looks like a half-finished design change to me, which left the non-"org" version unconnected internally.
Quoted 5 lines
Quoted 2 lines
So maybe change the pin configuration of
&tsadc_shut_orginrk3588-base-pinctrl.dtsito open drain and retry?That's a good idea, but... how ? The pinctrl-rockchip driver doesn't seem to support generic open-drain configuration.
I thought I saw open-drain configurations here, but after reviewing the TRM, bindings and the driver it turns out I must have been daydreaming :( Sorry.
Looks like the best we can try is a lower drive strength while keeping the push-pull mode, but I'm afraid this 100 Ohm pulldown is too weak, because the lowest TSHUT drive strength Rockchip offers is 100 Ohm, while the PMIC would only count anything below 30% reference voltage as logical low. Maybe adding a pulldown to the pin config can help, but most likely this board will require switching the pin to GPIO input for high-z, and switching the TSHUT mode to CRU.
So how about something like this first:
&tsadc_shut_org {
rockchip,pins = <0 RK_PA1 1 &pcfg_pull_down_drv_level_0>;
};Best regards,
Alexey
Quoted 123 lines · Alexey Charkov
Quoted 122 lines · Laurent Pinchart
Quoted 107 lines · Alexey Charkov
Quoted 98 lines · Alexey Charkov
Quoted 97 lines · Laurent Pinchart
Quoted 82 lines · Alexey Charkov
Quoted 81 lines · Alexey Charkov
Quoted 52 lines · Dragan Simic
Quoted 40 lines · Alexey Charkov
Quoted 39 lines · Dragan Simic
Quoted 7 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as "output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig 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_Lsignal of the CM5 to GND (see page 3 of the schematics in [3]).Quoted 7 lines
Quoted 2 lines
With
&tsadc_shut_orgthe reset button has absolutely no effect. With&tsadc_shutit 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.
Quoted 6 lines
On a second thought, I've got another hypothesis. Your baseboard only pulls the reset line through a 100 Ohm resistor when the button is pressed. So if the TSHUT pin is in its default push-pull mode and stays high when no thermal runaway reset is requested, the reset button won't pull the line fully to zero, as the TSHUT line pulls it high at the same time.
That's the most likely cause, I agree.
Quoted 4 lines
If you switch it from
&tsadc_shut_orgto&tsadc_shut, then it stops working properly as the thermal protection reset, andGPIO0_A1remains high-impendance, thus allowing the reset button to function even though its pull is too weak.
Quoted 5 lines
Quoted 2 lines
By the way, what is the difference between
tsadc_shut_organdtsadc_shut? I haven't seen it being clearly documented in the TRM.No idea frankly. Looks like a half-finished design change to me, which left the non-"org" version unconnected internally.
:-/
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
So maybe change the pin configuration of
&tsadc_shut_orginrk3588-base-pinctrl.dtsito open drain and retry?That's a good idea, but... how ? The pinctrl-rockchip driver doesn't seem to support generic open-drain configuration.
I thought I saw open-drain configurations here, but after reviewing the TRM, bindings and the driver it turns out I must have been daydreaming :( Sorry.
Quoted 7 lines
Looks like the best we can try is a lower drive strength while keeping the push-pull mode, but I'm afraid this 100 Ohm pulldown is too weak, because the lowest TSHUT drive strength Rockchip offers is 100 Ohm, while the PMIC would only count anything below 30% reference voltage as logical low. Maybe adding a pulldown to the pin config can help, but most likely this board will require switching the pin to GPIO input for high-z, and switching the TSHUT mode to CRU.
I agree with you, going through the CRU seems the best solution for this board. This is actually the default mode in arch/arm64/boot/dts/rockchip/rk3588-base.dtsi:
rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */ rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */ pinctrl-0 = <&tsadc_shut_org>; pinctrl-1 = <&tsadc_gpio_func>;
If hw-tshut-mode defaults to 0, why do we need to setup the GPIO0_A1 pin to output the TSADC_SHUT signal ?
Quoted 5 lines
So how about something like this first:
&tsadc_shut_org { rockchip,pins = <0 RK_PA1 1 &pcfg_pull_down_drv_level_0>; };
I've tested that and it's indeed not enough, the reset button still doesn't work.
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 155 lines · Laurent Pinchart
Quoted 123 lines · Alexey Charkov
Quoted 122 lines · Laurent Pinchart
Quoted 107 lines · Alexey Charkov
Quoted 98 lines · Alexey Charkov
Quoted 97 lines · Laurent Pinchart
Quoted 82 lines · Alexey Charkov
Quoted 81 lines · Alexey Charkov
Quoted 52 lines · Dragan Simic
Quoted 40 lines · Alexey Charkov
Quoted 39 lines · Dragan Simic
Quoted 7 lines · Alexey Charkov
Quoted 5 lines · Alexander Shiyan
There is no pinctrl "gpio" and "otpout" (probably designed as
"output")
handling in the tsadc driver.
Let's use proper binding "default" and "sleep".Quoted 7 lines
This looks reasonable, however I've tried it on my Radxa Rock 5C and the driver still doesn't claim GPIO0
RK_PA1even 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 directgpioset 0 1=0does.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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig 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_Lsignal of the CM5 to GND (see page 3 of the schematics in [3]).Quoted 7 lines
Quoted 2 lines
With
&tsadc_shut_orgthe reset button has absolutely no effect. With&tsadc_shutit 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.
Quoted 6 lines
On a second thought, I've got another hypothesis. Your baseboard only pulls the reset line through a 100 Ohm resistor when the button is pressed. So if the TSHUT pin is in its default push-pull mode and stays high when no thermal runaway reset is requested, the reset button won't pull the line fully to zero, as the TSHUT line pulls it high at the same time.
That's the most likely cause, I agree.
Quoted 4 lines
If you switch it from
&tsadc_shut_orgto&tsadc_shut, then it stops working properly as the thermal protection reset, andGPIO0_A1remains high-impendance, thus allowing the reset button to function even though its pull is too weak.Quoted 5 lines
Quoted 2 lines
By the way, what is the difference between
tsadc_shut_organdtsadc_shut? I haven't seen it being clearly documented in the TRM.No idea frankly. Looks like a half-finished design change to me, which left the non-"org" version unconnected internally.
:-/
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
So maybe change the pin configuration of
&tsadc_shut_orginrk3588-base-pinctrl.dtsito open drain and retry?That's a good idea, but... how ? The pinctrl-rockchip driver doesn't seem to support generic open-drain configuration.
I thought I saw open-drain configurations here, but after reviewing the TRM, bindings and the driver it turns out I must have been daydreaming :( Sorry.
Quoted 7 lines
Looks like the best we can try is a lower drive strength while keeping the push-pull mode, but I'm afraid this 100 Ohm pulldown is too weak, because the lowest TSHUT drive strength Rockchip offers is 100 Ohm, while the PMIC would only count anything below 30% reference voltage as logical low. Maybe adding a pulldown to the pin config can help, but most likely this board will require switching the pin to GPIO input for high-z, and switching the TSHUT mode to CRU.
I agree with you, going through the CRU seems the best solution for this board. This is actually the default mode in
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi:
Quoted 7 lines
rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */ rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */ pinctrl-0 = <&tsadc_shut_org>; pinctrl-1 = <&tsadc_gpio_func>;If hw-tshut-mode defaults to 0, why do we need to setup the
GPIO0_A1pin to output theTSADC_SHUTsignal ?
I believe the thinking was along the lines of "it can't hurt, so let's provide a default that's likely to work both for the boards where TSHUT is routed to the PMIC and those where it's not, with an added benefit of hogging the pin to prevent anyone from accidentally triggering it to a low level from user space thus suddenly resetting the board".
But this case of "TSHUT is routed, but with a deviation from the reference schematic which makes it impossible to use as designed" was likely never envisaged.
Technically, there is no reason to switch the pin to tsadc_shut_org when CRU mode is used, and the boottime default for this pin is high-impedance.
Heiko, shall we remove the pinctrl properties from the common .dtsi and move them to board specific .dts for those boards that use PMIC-assisted thermal resets? Happy to produce a patch to that effect.
Best regards,
Alexey
Quoted 170 lines · Alexey Charkov
Quoted 154 lines · Laurent Pinchart
Quoted 123 lines · Alexey Charkov
Quoted 122 lines · Laurent Pinchart
Quoted 107 lines · Alexey Charkov
Quoted 98 lines · Alexey Charkov
Quoted 97 lines · Laurent Pinchart
Quoted 82 lines · Alexey Charkov
Quoted 81 lines · Alexey Charkov
Quoted 52 lines · Dragan Simic
Quoted 40 lines · Alexey Charkov
Quoted 39 lines · Dragan Simic
Quoted 14 lines · Alexey Charkov
On Fri, Jan 24, 2025 at 9:26 AM Alexander Shiyan 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.
(quoted diff) +0
-0
w/drivers/thermal/rockchip_thermal.c
indexf551df48eef9..62f0e14a8d98100644drivers/thermal/rockchip_thermal.c +0
-0@@ -1568,6 +1568,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity);Quoted 10 lines
drivers/thermal/rockchip_thermal.c static int rockchip_thermal_probe(struct · line 1575
Quoted 4 lines
drivers/thermal/rockchip_thermal.c +4
-0+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_modeis notTSHUT_MODE_GPIOthen 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 theTSHUT_MODE_GPIOcase.Quoted 1 line
You're right, but the "else block" is what the downstream driver does,
Does it though? It only handles the
TSHUT_MODE_GPIOcase as far as I can tell (orTSHUT_MODE_OTPin downstream driver lingo) [1]Quoted 20 lines
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.
Quoted 1 line
Will try and revert.
Awesome, thanks!
Quoted 5 lines
P.S. Just looked at the downstream driver, and it actually callsTSHUT_MODE_GPIOTSHUT_MODE_OTPinstead, 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).
Quoted 8 lines
Quoted 4 lines
Anyway, I've just tried it after including the changes below, and while
/sys/kernel/debug/pinctrl/pinctrl-handlesshows 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_orgconfig 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_Lsignal of the CM5 to GND (see page 3 of the schematics in [3]).Quoted 7 lines
Quoted 2 lines
With
&tsadc_shut_orgthe reset button has absolutely no effect. With&tsadc_shutit 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.
Quoted 6 lines
On a second thought, I've got another hypothesis. Your baseboard only pulls the reset line through a 100 Ohm resistor when the button is pressed. So if the TSHUT pin is in its default push-pull mode and stays high when no thermal runaway reset is requested, the reset button won't pull the line fully to zero, as the TSHUT line pulls it high at the same time.
That's the most likely cause, I agree.
Quoted 4 lines
If you switch it from
&tsadc_shut_orgto&tsadc_shut, then it stops working properly as the thermal protection reset, andGPIO0_A1remains high-impendance, thus allowing the reset button to function even though its pull is too weak.Quoted 5 lines
Quoted 2 lines
By the way, what is the difference between
tsadc_shut_organdtsadc_shut? I haven't seen it being clearly documented in the TRM.No idea frankly. Looks like a half-finished design change to me, which left the non-"org" version unconnected internally.
:-/
Quoted 10 lines
Quoted 5 lines
Quoted 2 lines
So maybe change the pin configuration of
&tsadc_shut_orginrk3588-base-pinctrl.dtsito open drain and retry?That's a good idea, but... how ? The pinctrl-rockchip driver doesn't seem to support generic open-drain configuration.
I thought I saw open-drain configurations here, but after reviewing the TRM, bindings and the driver it turns out I must have been daydreaming :( Sorry.
Quoted 7 lines
Looks like the best we can try is a lower drive strength while keeping the push-pull mode, but I'm afraid this 100 Ohm pulldown is too weak, because the lowest TSHUT drive strength Rockchip offers is 100 Ohm, while the PMIC would only count anything below 30% reference voltage as logical low. Maybe adding a pulldown to the pin config can help, but most likely this board will require switching the pin to GPIO input for high-z, and switching the TSHUT mode to CRU.
I agree with you, going through the CRU seems the best solution for this board. This is actually the default mode in
arch/arm64/boot/dts/rockchip/rk3588-base.dtsi:Quoted 7 lines
rockchip,hw-tshut-mode = <0>; /* tshut mode 0:CRU 1:GPIO */ rockchip,hw-tshut-polarity = <0>; /* tshut polarity 0:LOW 1:HIGH */ pinctrl-0 = <&tsadc_shut_org>; pinctrl-1 = <&tsadc_gpio_func>;If hw-tshut-mode defaults to 0, why do we need to setup the
GPIO0_A1pin to output theTSADC_SHUTsignal ?I believe the thinking was along the lines of "it can't hurt, so let's provide a default that's likely to work both for the boards where TSHUT is routed to the PMIC and those where it's not, with an added benefit of hogging the pin to prevent anyone from accidentally triggering it to a low level from user space thus suddenly resetting the board".
Quoted 7 lines
But this case of "TSHUT is routed, but with a deviation from the reference schematic which makes it impossible to use as designed" was likely never envisaged.
Technically, there is no reason to switch the pin to
tsadc_shut_orgwhen CRU mode is used, and the boottime default for this pin is high-impedance.
I tried to trigger an over-temperature condition by setting rockchip,hw-tshut-temp to 40°C (yes, it's getting cold in Finland). With pinctrl-0 set to <&tsadc_shut_org>, the system reset when the trip point was reached, regardless of rockchip,hw-tshut-mode.
With pinctrl-0 set to <&tsadc_gpio_func>, reaching 40°C caused a reset with rockchip,hw-tshut-mode set to 0 (CRU), and no action occurred when rockchip,hw-tshut-mode was set to 1 (GPIO).
I've also tested <&tsadc_shut>. It resulted in a reset in CRU mode and no action in GPIO mode.
Quoted 3 lines
Heiko, shall we remove the pinctrl properties from the common .dtsi and move them to board specific .dts for those boards that use PMIC-assisted thermal resets? Happy to produce a patch to that effect.
Signature · 3 lines
Regards, Laurent Pinchart