[PATCH] regulator: tps65910: keep external control of always-on rails at shutdown

Jerome Berclaz via B4 Relay posted 1 patch 1 day, 17 hours ago
drivers/regulator/tps65910-regulator.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
[PATCH] regulator: tps65910: keep external control of always-on rails at shutdown
Posted by Jerome Berclaz via B4 Relay 1 day, 17 hours ago
From: Jerome Berclaz <jerome.berclaz@proton.me>

tps65910_shutdown() clears the external (EN1/EN2/sleep) control of every
regulator. On the Microsoft Surface RT (Tegra 30 + TPS65911), the CPU rail
VDDCTRL is always-on and assigned to EN1, which is driven by the SoC's
CPU_PWR_REQ, with a 0 V sleep voltage. Releasing that assignment drops the
CPU supply while the CPU is still running this loop, so the system hangs
before the PMIC receives the power-off (DEV_OFF) or restart (DEV_OFF_RST)
command: the screen goes black, the PMIC stays on, and the power button
has to be held to turn the device off.

Skip always-on regulators that have external control. They power the SoC
that is still executing, and the final power-off or restart resets the
PMIC anyway.

The hang was traced with netconsole and initcall_debug: the last message
was the clearing of regulator 4 (vddctrl, ext=0x1).

Tested on a Surface RT with a 7.3.1-based kernel (libre-tegra tree):
poweroff and reboot complete, booted either through the vendor UEFI or
through U-Boot. Mainline does not have a Surface RT device tree yet.

The problem was investigated, and this change and its description written,
with the help of an AI coding assistant (Claude); I reviewed the change and
tested it on my device as described above.

Fixes: 1e0c66f49762 ("regulator: tps65910: Sleep control through external inputs")
Signed-off-by: Jerome Berclaz <jerome.berclaz@proton.me>
---
Found while bringing up Linux on a Microsoft Surface RT (libre-tegra kernel
tree, https://codeberg.org/libre-tegra/linux/pulls/10). The Surface RT
device tree is not in mainline yet; the maintainer of that tree suggested
sending this fix here.

Since then, one incomplete shutdown was seen once, with cpuidle enabled
on the U-Boot boot path; it did not reproduce in 16 consecutive reboots
and 2 shutdowns, and I am keeping an eye on it.
---
 drivers/regulator/tps65910-regulator.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index 6b14c39e42de..db1f637fbdc0 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -1237,6 +1237,19 @@ static void tps65910_shutdown(struct platform_device *pdev)
 		if (!pmic->rdev[i])
 			continue;
 
+		/*
+		 * Keep external control on always-on rails: they power the
+		 * SoC that is still executing this code. On the Microsoft
+		 * Surface RT the CPU rail (VDDCTRL) is controlled by EN1 and
+		 * its sleep voltage is 0, so releasing EN1 here drops the CPU
+		 * supply before the PMIC can be told to power off or restart,
+		 * leaving the system hung with the PMIC still on.
+		 */
+		if (pmic->board_ext_control[i] &&
+		    pmic->rdev[i]->constraints &&
+		    pmic->rdev[i]->constraints->always_on)
+			continue;
+
 		err = tps65910_set_ext_sleep_config(pmic, i, 0);
 		if (err < 0)
 			dev_err(&pdev->dev,

---
base-commit: 4843f6873f7c4835e62f2c73ba0fd538e57a2f22
change-id: 20261122-tps65910-shutdown-ext-control-6a9792cb5a92

Best regards,
--  
Jerome Berclaz <jerome.berclaz@proton.me>