From: Fabio Estevam <feste...@denx.de> Currently, fixed-rate clocks in U-Boot are named based on their devicetree node names. For example, given the following node:
osc_24m: clock-osc-24m { compatible = "fixed-clock"; #clock-cells = <0>; clock-frequency = <24000000>; clock-output-names = "osc_24m"; }; U-Boot registers the clock as "clock-osc-24m", derived from the node name, ignoring the clock-output-names property. This differs from Linux, which uses the clock-output-names property when assigning clock names. As a result, clock consumers expecting names like "osc_24m" (as defined in the property) may fail to resolve clocks correctly in U-Boot. Update the fixed-rate clock driver to check for the clock-output-names property and use it as the clock name if present. If not, the fallback remains the node name. This makes U-Boot behavior consistent with Linux. One concrete impact is on i.MX8MP, where USB clock lookup failed following commit b4734c9c333b ("clk: imx: Convert clock-osc-* back to osc_*"). With this change applied, fixed-clocks are correctly registered with their expected names: u-boot=> clk dump Rate Usecnt Name ------------------------------------------ 32768 0 |-- osc_32k 24000000 5 |-- osc_24m This change restores i.MX8MP USB functionality by ensuring the proper clock names are used. Fixes: b4734c9c333b ("clk: imx: Convert clock-osc-* back to osc_*") Reported-by: Francesco Dolcini <francesco.dolc...@toradex.com> Signed-off-by: Fabio Estevam <feste...@denx.de> Tested-by: Adam Ford <aford...@gmail.com> #imx8mp-beacon --- Changes since v1: - Included <dm/read.h> that defines dev_read_string_index() instead of relying on indirect inclusion via <dm.h>. - Removed superflous parenthesis around dev_read_string_index(). - Added Adam's Reviewed-by tag. drivers/clk/clk_fixed_rate.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/clk/clk_fixed_rate.c b/drivers/clk/clk_fixed_rate.c index d1da05cc18a5..648e31b4fe14 100644 --- a/drivers/clk/clk_fixed_rate.c +++ b/drivers/clk/clk_fixed_rate.c @@ -9,6 +9,7 @@ #include <dm.h> #include <log.h> #include <dm/device-internal.h> +#include <dm/read.h> #include <linux/clk-provider.h> #define UBOOT_DM_CLK_FIXED_RATE "fixed_rate_clock" @@ -35,6 +36,8 @@ void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev, struct clk_fixed_rate *plat) { struct clk *clk = &plat->clk; + const char *clk_name; + if (CONFIG_IS_ENABLED(OF_REAL)) plat->fixed_rate = dev_read_u32_default(dev, "clock-frequency", 0); @@ -45,6 +48,16 @@ void clk_fixed_rate_ofdata_to_plat_(struct udevice *dev, clk->dev = dev; clk->enable_count = 0; + + /* + * If the "clock-output-names" property is present, use it + * as the clock name, like it is done in Linux. + * Otherwise, the original behavior will be preserved: the fixed clock + * name will be its node name. + * + */ + if (!dev_read_string_index(dev, "clock-output-names", 0, &clk_name)) + dev->name = clk_name; } static ulong clk_fixed_rate_raw_get_rate(struct clk *clk) -- 2.34.1