U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: trini@konsulko.com
Cc: lukma@denx.de, seanga2@gmail.com, marex@denx.de,
	francesco.dolcini@toradex.com, aford173@gmail.com,
	u-boot@lists.denx.de, Fabio Estevam <festevam@denx.de>
Subject: [PATCH v2] clk: fixed-rate: Use "clock-output-names" to name fixed clocks
Date: Thu, 17 Apr 2025 14:11:01 -0300	[thread overview]
Message-ID: <20250417171101.2566447-1-festevam@gmail.com> (raw)

From: Fabio Estevam <festevam@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.dolcini@toradex.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
Tested-by: Adam Ford <aford173@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


             reply	other threads:[~2025-04-17 17:11 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-17 17:11 Fabio Estevam [this message]
2025-04-18 14:51 ` [PATCH v2] clk: fixed-rate: Use "clock-output-names" to name fixed clocks Marek Vasut
2025-04-19 12:59   ` Adam Ford
2025-04-19 22:51     ` Marek Vasut
2025-04-19 19:11   ` Fabio Estevam
2025-04-19 20:40     ` Adam Ford
2025-04-20  0:47       ` Marek Vasut
2025-04-20  1:07         ` Fabio Estevam
2025-04-20 19:20           ` Marek Vasut
2025-04-21 23:29             ` Adam Ford
2025-04-25  2:02             ` Fabio Estevam
2025-04-25  2:20               ` Marek Vasut
2025-04-25  2:35                 ` Fabio Estevam
2025-04-25  2:37                   ` Adam Ford
2025-04-25  2:59                     ` Adam Ford
2025-04-25 12:55                   ` Fabio Estevam
2025-04-25 13:55                     ` Fabio Estevam
2025-04-25 17:14                       ` Marek Vasut
2025-04-25 17:13                     ` Marek Vasut
2025-04-19 22:52     ` Marek Vasut

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=20250417171101.2566447-1-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=aford173@gmail.com \
    --cc=festevam@denx.de \
    --cc=francesco.dolcini@toradex.com \
    --cc=lukma@denx.de \
    --cc=marex@denx.de \
    --cc=seanga2@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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