* [PATCH v2] power: pmic: rk8xx: Don't set RK817_POWER_EN_SAVE bits
@ 2026-11-25 22:34 Chris Morgan
0 siblings, 0 replies; only message in thread
From: Chris Morgan @ 2026-11-25 22:34 UTC (permalink / raw)
To: u-boot
Cc: trini, u-boot, peng.fan, jh80.chung, clamor95, zhangqing,
kever.yang, power.xu, Chris Morgan
From: Chris Morgan <macromorgan@hotmail.com>
Don't set the RK817_POWER_EN_SAVE0 or RK817_POWER_EN_SAVE1 bits, unless
the device-tree property of "not-save-power-en" is present and set to 0.
Per a discussion on the mailing list these registers are used by the
BSP kernel to save the regulator state at early power-on so that
late shutdown can ensure the regulators stay at this state to prevent
a possible overvolt situation. However, these registers are not used by
mainline Linux and actively setting them in U-boot interferes with
their function for BSP kernels, causing systems to hang when
regulators are enabled or disabled incorrectly. [1]
By skipping this behavior except when the BSP only parameter is
present and set to 0, we can preserve the registers function without
creating additional problems.
[1] https://gist.github.com/fr0z3n-cs/047b24a6fd430e816fe02a877ad7ab8c
Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
---
drivers/power/pmic/rk8xx.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/power/pmic/rk8xx.c b/drivers/power/pmic/rk8xx.c
index 95b71d2fe49..614d749d5ff 100644
--- a/drivers/power/pmic/rk8xx.c
+++ b/drivers/power/pmic/rk8xx.c
@@ -293,15 +293,23 @@ static int rk8xx_probe(struct udevice *dev)
off_source = RK817_OFF_SOURCE;
init_data = rk817_init_reg;
init_data_num = ARRAY_SIZE(rk817_init_reg);
- power_en0 = pmic_reg_read(dev, RK817_POWER_EN0);
- power_en1 = pmic_reg_read(dev, RK817_POWER_EN1);
- power_en2 = pmic_reg_read(dev, RK817_POWER_EN2);
- power_en3 = pmic_reg_read(dev, RK817_POWER_EN3);
-
- value = (power_en0 & 0x0f) | ((power_en1 & 0x0f) << 4);
- pmic_reg_write(dev, RK817_POWER_EN_SAVE0, value);
- value = (power_en2 & 0x0f) | ((power_en3 & 0x0f) << 4);
- pmic_reg_write(dev, RK817_POWER_EN_SAVE1, value);
+ /*
+ * If the BSP only attribute of "not-save-power-en" is present
+ * and if it is 0, only then would we save the register values
+ * for use by the BSP kernel for use on shutdown. If the value
+ * is not present or not 0, we skip this.
+ */
+ if (!dev_read_u32_default(dev, "not-save-power-en", 1)) {
+ power_en0 = pmic_reg_read(dev, RK817_POWER_EN0);
+ power_en1 = pmic_reg_read(dev, RK817_POWER_EN1);
+ power_en2 = pmic_reg_read(dev, RK817_POWER_EN2);
+ power_en3 = pmic_reg_read(dev, RK817_POWER_EN3);
+
+ value = (power_en0 & 0x0f) | ((power_en1 & 0x0f) << 4);
+ pmic_reg_write(dev, RK817_POWER_EN_SAVE0, value);
+ value = (power_en2 & 0x0f) | ((power_en3 & 0x0f) << 4);
+ pmic_reg_write(dev, RK817_POWER_EN_SAVE1, value);
+ }
break;
case RK806_ID: {
u32 rst_fun = 2;
--
2.53.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 22:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 22:34 [PATCH v2] power: pmic: rk8xx: Don't set RK817_POWER_EN_SAVE bits Chris Morgan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.