mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heiko Stuebner <heiko@sntech.de>
To: Lee Jones <lee@kernel.org>, Yaozhong Li <yaozhonguwl@gmail.com>
Cc: Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Chris Zhong <zyw@rock-chips.com>,
	Zhang Qing <zhangqing@rock-chips.com>,
	Joseph Chen <chenjh@rock-chips.com>,
	Sebastian Reichel <sebastian.reichel@collabora.com>,
	Yaozhong Li <yaozhonguwl@gmail.com>,
	mfd@lists.linux.dev, devicetree@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 2/3] mfd: rk8xx: Release the power hold GPIOs before powering off
Date: Fri, 13 Nov 2026 20:30:17 +0100	[thread overview]
Message-ID: <R_CRTELbTC-4nNJy2OQEFg@sntech.de> (raw)
In-Reply-To: <20261101154053.3874-3-yaozhonguwl@gmail.com>

Am Sonntag, 1. November 2026, 16:40:51 Mitteleuropäische Normalzeit schrieb Yaozhong Li:
> rk808_power_off() writes the PMIC's shutdown bit directly. On boards where
> lines driven by the SoC gate the PMIC's power-off path, 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.
> 
> The array is claimed before any child device is registered, so that a
> -EPROBE_DEFER from the GPIO provider does not tear down the regulators,
> RTC and clocks that devm_mfd_add_devices() has already registered.
> 
> On a Firefly-RK3399 the shutdown stuck when such a line went from high to
> low before the shutdown bit was written, and did not when the line was
> never driven.
> 
> Assisted-by: LLM
> Signed-off-by: Yaozhong Li <yaozhonguwl@gmail.com>
> ---
>  drivers/mfd/rk8xx-core.c  | 49 +++++++++++++++++++++++++++++++++++++--
>  include/linux/mfd/rk808.h |  3 +++
>  2 files changed, 50 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mfd/rk8xx-core.c b/drivers/mfd/rk8xx-core.c
> index 3dcf6ab..137ab20 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,22 @@ 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,
> +	 * otherwise the rails can drop and come back up instead of staying
> +	 * off. Releasing them here rather than from a separate handler keeps
> +	 * the ordering against the I2C write explicit.

this will be called from both the I2C and SPI variants of the controller.
Also please shorten that comment block.

> +	 */
> +	if (rk808->power_hold_gpios) {

unsigned int line; here not in for() ... could also just be "i", as it's
simply counting

> +		for (unsigned int line = 0; line < rk808->power_hold_gpios->ndescs; line++)
> +			gpiod_set_value_cansleep(rk808->power_hold_gpios->desc[line], 0);

This code is (now again and more correctly) running when irqs have
already been turned off, so nothing is allowed to sleep here

When you enable
CONFIG_DEBUG_ATOMIC_SLEEP=y
you should get nice warning splat about that.


Heiko



  reply	other threads:[~2026-11-13 19:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 15:40 [PATCH v6 0/3] Fix poweroff restarting the board on Firefly-RK3399 Yaozhong Li
2026-11-01 15:40 ` [PATCH v6 1/3] dt-bindings: mfd: rk8xx: add board level power hold GPIOs Yaozhong Li
2026-11-12 22:34   ` Rob Herring (Arm)
2026-11-01 15:40 ` [PATCH v6 2/3] mfd: rk8xx: Release the power hold GPIOs before powering off Yaozhong Li
2026-11-13 19:30   ` Heiko Stuebner [this message]
2026-11-01 15:40 ` [PATCH v6 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=R_CRTELbTC-4nNJy2OQEFg@sntech.de \
    --to=heiko@sntech.de \
    --cc=chenjh@rock-chips.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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=sebastian.reichel@collabora.com \
    --cc=yaozhonguwl@gmail.com \
    --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

all inboxes | Powered by JetHome®