Since commit fdb1bffe2827 ("clk: scmi: Postpone clock name resolution"),
all clocks which are parent clocks are name "scmi-%zu" which
leads to error during their children clocks registration.

In order to not cancel boot time optimization done in
commit 3547e315c188 ("clk: scmi: Defer issue of SCMI_CLOCK_ATTRIBUTES"),
choice has been done to re-introduce scmi_clk_get_attribute() call
during scmi_clk_probe() under new CLK_SCMI_FORCE_ATTRIBUTE flag.

This restores boot on stm32mp13 and stm32mp2 family boards.

Fixes: fdb1bffe2827 ("clk: scmi: Postpone clock name resolution")

Signed-off-by: Patrice Chotard <[email protected]>

Cc: Alice Guo <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: Patrick Delaunay <[email protected]>
Cc: Peng Fan <[email protected]>
Cc: Sean Anderson <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Valentin Caron <[email protected]>
Cc: Vinh Nguyen <[email protected]>
Cc: [email protected]
---

 drivers/clk/Kconfig    |  8 ++++++++
 drivers/clk/clk_scmi.c | 10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
index b884a02bdeb..848f8635836 100644
--- a/drivers/clk/Kconfig
+++ b/drivers/clk/Kconfig
@@ -198,6 +198,14 @@ config CLK_SCMI
          by a SCMI agent based on SCMI clock protocol communication
          with a SCMI server.
 
+config CLK_SCMI_FORCE_ATTRIBUTE
+       bool "Force usage scmi_clk_get_attribute during probe"
+       depends on CLK_SCMI
+       help
+         Force call of scmi_clk_get_attribute() during scmi_clk_probe()
+         to allow clock registering using their name instead of default
+         "scmi-%zu" name.
+
 config SPL_CLK_SCMI
        bool "Enable SCMI clock driver in SPL"
        depends on SCMI_FIRMWARE && SPL_FIRMWARE
diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c
index f6132178205..7315c1e03aa 100644
--- a/drivers/clk/clk_scmi.c
+++ b/drivers/clk/clk_scmi.c
@@ -358,8 +358,16 @@ static int scmi_clk_probe(struct udevice *dev)
        for (i = 0; i < num_clocks; i++) {
                clk_scmi = clk_scmi_bulk + i;
                char *clock_name = clk_scmi->name;
+               u32 attributes;
 
-               snprintf(clock_name, SCMI_CLOCK_NAME_LENGTH_MAX, "scmi-%zu", i);
+               if (CONFIG_IS_ENABLED(CLK_SCMI_FORCE_ATTRIBUTE)) {
+                       ret = scmi_clk_get_attribute(dev, i, clock_name, 
&attributes);
+                       if (ret)
+                               return ret;
+
+               } else {
+                       snprintf(clock_name, SCMI_CLOCK_NAME_LENGTH_MAX, 
"scmi-%zu", i);
+               }
 
                ret = clk_register(&clk_scmi->clk, dev->driver->name,
                                   clock_name, dev->name);
-- 
2.43.0

Reply via email to