Re: [PATCH 2/2] clk: sophgo: sg2042-clkgen: Keep gates of reserved devices enabled
From: Krzysztof Kozlowski
Date: Sat Nov 21 2026 - 11:11:29 EST
On 21/11/2026 11:38, Han Gao via B4 Relay wrote:
> From: Han Gao <gaohan@xxxxxxxxxxx>
>
> On Milk-V Pioneer, firmware can own I2C0 to back the EFI RTC, with the
> node marked status = "reserved". I2C0 shares GATE_CLK_APB_I2C with the
> I2C controllers Linux uses. When those runtime-suspend, the gate is
> switched off under the firmware and GetTime() returns EFI_NOT_READY.
>
> Walk the reserved children of /soc and match their clock references,
> as done in commit 6aa175476490 ("clk: renesas: cpg-mssr: Ignore all
> clocks assigned to non-Linux system"). Unlike that driver, use
> CLK_IS_CRITICAL rather than CLK_IGNORE_UNUSED: the gate is shared with
> devices Linux drives, and their runtime PM would still turn it off.
>
> Signed-off-by: Han Gao <gaohan@xxxxxxxxxxx>
> ---
> drivers/clk/sophgo/clk-sg2042-clkgen.c | 38 +++++++++++++++++++++++++++++++++-
> 1 file changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/clk/sophgo/clk-sg2042-clkgen.c b/drivers/clk/sophgo/clk-sg2042-clkgen.c
> index 6abc2c973c49..414904965edf 100644
> --- a/drivers/clk/sophgo/clk-sg2042-clkgen.c
> +++ b/drivers/clk/sophgo/clk-sg2042-clkgen.c
> @@ -11,6 +11,8 @@
> #include <linux/clk.h>
> #include <linux/clk-provider.h>
> #include <linux/io.h>
> +#include <linux/of.h>
> +#include <linux/of_clk.h>
> #include <linux/platform_device.h>
> #include <asm/div64.h>
>
> @@ -840,6 +842,35 @@ static int sg2042_clk_register_divs(struct device *dev,
> return ret;
> }
>
> +static bool sg2042_clk_is_reserved(struct device_node *clkgen, unsigned int id)
> +{
> + struct device_node *soc __free(device_node) = of_find_node_by_path("/soc");
Where did you document the ABI? Soc is implied but not enforced. commit
6aa175476490 makes the same mistake.
Reserved nodes might not even appear in DTB passed to Linux, because
they are not the hardware exposed to the OS, so this entire approach is
fragile. IMO, the list of clocks which are not controller by Linux
should be static in the driver, but if you insist on using some ABI then
you must document it.
Best regards,
Krzysztof