From: Yaozhong Li <yaozhonguwl@gmail.com>
To: Lee Jones <lee@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heiko Stuebner <heiko@sntech.de>,
Chris Zhong <zyw@rock-chips.com>,
Zhang Qing <zhangqing@rock-chips.com>
Cc: mfd@lists.linux.dev, devicetree@vger.kernel.org,
linux-rockchip@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Yaozhong Li <yaozhonguwl@gmail.com>
Subject: [RFC PATCH 2/3] mfd: rk8xx: release the power hold GPIOs before powering off
Date: Wed, 9 Sep 2026 17:27:27 +0800 [thread overview]
Message-ID: <20260909092728.1859-3-yaozhonguwl@gmail.com> (raw)
In-Reply-To: <20260909092728.1859-1-yaozhonguwl@gmail.com>
rk808_power_off() writes the PMIC's shutdown bit directly. On boards with
"power hold" lines driven by the SoC, a shutdown performed this way does
not stick: the rails drop and immediately come back up, so the board
restarts instead of staying off. U-Boot reports the result as a power-on
reset.
Take those lines as an optional GPIO array, hold them asserted while the
system runs and release them - waiting power-hold-delay-ms - before
writing the shutdown bit. Device trees without the property retain the
existing behaviour.
Releasing every described line matters: on a Firefly-RK3399 the board
stays off when both lines described for it are released, whereas releasing
GPIO1_D0 while GPIO1_B5 is left asserted makes it come back up.
Signed-off-by: Yaozhong Li <yaozhonguwl@gmail.com>
---
drivers/mfd/rk8xx-core.c | 29 +++++++++++++++++++++++++++++
include/linux/mfd/rk808.h | 4 ++++
2 files changed, 33 insertions(+)
diff --git a/drivers/mfd/rk8xx-core.c b/drivers/mfd/rk8xx-core.c
index 3dcf6ab..fd1efbb 100644
--- a/drivers/mfd/rk8xx-core.c
+++ b/drivers/mfd/rk8xx-core.c
@@ -11,6 +11,8 @@
*/
#include <linux/bitfield.h>
+#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/interrupt.h>
#include <linux/mfd/rk808.h>
#include <linux/mfd/core.h>
@@ -703,6 +705,24 @@ static int rk808_power_off(struct sys_off_data *data)
default:
return NOTIFY_DONE;
}
+
+ /*
+ * Some boards route "power hold" lines from the SoC into the board's
+ * power circuitry. They have to be held asserted while the system is
+ * running and released before the PMIC shutdown request is written:
+ * with any of them left asserted, the rails drop and then come back
+ * up. Releasing them here rather than from a separate handler keeps
+ * the ordering against the I2C write explicit.
+ */
+ if (rk808->power_hold_gpios) {
+ unsigned int i;
+
+ for (i = 0; i < rk808->power_hold_gpios->ndescs; i++)
+ gpiod_set_value_cansleep(rk808->power_hold_gpios->desc[i], 0);
+
+ msleep(rk808->power_hold_delay_ms);
+ }
+
ret = regmap_update_bits(rk808->regmap, reg, bit, bit);
if (ret)
dev_err(rk808->dev, "Failed to shutdown device!\n");
@@ -874,6 +894,15 @@ int rk8xx_probe(struct device *dev, int variant, unsigned int irq, struct regmap
if (device_property_read_bool(dev, "system-power-controller") ||
device_property_read_bool(dev, "rockchip,system-power-controller")) {
+ rk808->power_hold_gpios = devm_gpiod_get_array_optional(dev,
+ "power-hold", GPIOD_OUT_HIGH);
+ if (IS_ERR(rk808->power_hold_gpios))
+ return dev_err_probe(dev, PTR_ERR(rk808->power_hold_gpios),
+ "failed to get power hold GPIOs\n");
+
+ device_property_read_u32(dev, "power-hold-delay-ms",
+ &rk808->power_hold_delay_ms);
+
ret = devm_register_sys_off_handler(dev,
SYS_OFF_MODE_POWER_OFF_PREPARE, SYS_OFF_PRIO_HIGH,
&rk808_power_off, rk808);
diff --git a/include/linux/mfd/rk808.h b/include/linux/mfd/rk808.h
index 7ffc904..eda111e 100644
--- a/include/linux/mfd/rk808.h
+++ b/include/linux/mfd/rk808.h
@@ -1459,6 +1459,8 @@ enum {
RK818_ID = 0x8180,
};
+struct gpio_descs;
+
struct rk808 {
struct device *dev;
struct regmap_irq_chip_data *irq_data;
@@ -1466,6 +1468,8 @@ struct rk808 {
long variant;
const struct regmap_config *regmap_cfg;
const struct regmap_irq_chip *regmap_irq_chip;
+ struct gpio_descs *power_hold_gpios;
+ u32 power_hold_delay_ms;
};
void rk8xx_shutdown(struct device *dev);
--
2.55.0.windows.3
next prev parent reply other threads:[~2026-09-09 9:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 9:27 [RFC PATCH 0/3] Fix poweroff restarting the board on Firefly-RK3399 Yaozhong Li
2026-09-09 9:27 ` [RFC PATCH 1/3] dt-bindings: mfd: rk808: add board level power hold GPIOs Yaozhong Li
2026-09-09 9:27 ` Yaozhong Li [this message]
2026-09-09 9:27 ` [RFC PATCH 3/3] arm64: dts: rockchip: fix power-off on Firefly-RK3399 Yaozhong Li
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=20260909092728.1859-3-yaozhonguwl@gmail.com \
--to=yaozhonguwl@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=krzk+dt@kernel.org \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mfd@lists.linux.dev \
--cc=robh@kernel.org \
--cc=zhangqing@rock-chips.com \
--cc=zyw@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox