All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Morgan <macroalpha82@gmail.com>
To: u-boot@lists.u-boot-project.org
Cc: trini@konsulko.com, u-boot@0leil.net, peng.fan@nxp.com,
	jh80.chung@samsung.com, clamor95@gmail.com,
	zhangqing@rock-chips.com, kever.yang@rock-chips.com,
	power.xu@rock-chips.com, Chris Morgan <macromorgan@hotmail.com>
Subject: [PATCH v2] power: pmic: rk8xx: Don't set RK817_POWER_EN_SAVE bits
Date: Wed, 25 Nov 2026 16:34:44 -0600	[thread overview]
Message-ID: <20261125223444.603529-1-macroalpha82@gmail.com> (raw)

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


                 reply	other threads:[~2026-11-25 22:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125223444.603529-1-macroalpha82@gmail.com \
    --to=macroalpha82@gmail.com \
    --cc=clamor95@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=kever.yang@rock-chips.com \
    --cc=macromorgan@hotmail.com \
    --cc=peng.fan@nxp.com \
    --cc=power.xu@rock-chips.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@0leil.net \
    --cc=u-boot@lists.u-boot-project.org \
    --cc=zhangqing@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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.