public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Cc: Marek Vasut <marex@denx.de>, Adam Ford <aford173@gmail.com>,
	Christoph Niedermaier <cniedermaier@dh-electronics.com>,
	Dong Aisheng <aisheng.dong@nxp.com>,
	Fabio Estevam <festevam@denx.de>,
	Hou Zhiqiang <Zhiqiang.Hou@nxp.com>,
	Michael Trimarchi <michael@amarulasolutions.com>,
	Peng Fan <peng.fan@nxp.com>, Tim Harvey <tharvey@gateworks.com>,
	Tom Rini <trini@konsulko.com>,
	uboot-imx@nxp.com
Subject: [PATCH v2 01/24] clk: Add clk_resolve_parent_clk()
Date: Sun, 23 Mar 2025 16:58:30 +0100	[thread overview]
Message-ID: <20250323160107.145749-2-marex@denx.de> (raw)
In-Reply-To: <20250323160107.145749-1-marex@denx.de>

Add clk_resolve_parent_clk() to resolve parent clock udevice name
based on clock-names DT property. This is used in SoC clock drivers
to look up the clock name in clock tables, which matches a clock
name in DT clock-names property, and convert it into udevice name
which is used by U-Boot clock framework to look up parent clock in
e.g. clk_register() using uclass_get_device_by_name(UCLASS_CLK,
parent_name, &parent);

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Adam Ford <aford173@gmail.com>
Cc: Christoph Niedermaier <cniedermaier@dh-electronics.com>
Cc: Dong Aisheng <aisheng.dong@nxp.com>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Cc: Michael Trimarchi <michael@amarulasolutions.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Tim Harvey <tharvey@gateworks.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de
Cc: uboot-imx@nxp.com
---
V2: Rebase on u-boot/next with additional clock patches
---
 drivers/clk/clk-uclass.c | 18 ++++++++++++++++++
 include/clk.h            |  9 +++++++++
 2 files changed, 27 insertions(+)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 353ae476068..90b70529a47 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -420,6 +420,24 @@ int clk_get_by_name_nodev(ofnode node, const char *name, struct clk *clk)
 	return clk_get_by_index_nodev(node, index, clk);
 }
 
+const char *
+clk_resolve_parent_clk(struct udevice *dev, const char *name)
+{
+	struct udevice *parent;
+	struct clk clk;
+	int ret;
+
+	ret = uclass_get_device_by_name(UCLASS_CLK, name, &parent);
+	if (!ret)
+		return name;
+
+	ret = clk_get_by_name(dev, name, &clk);
+	if (!clk.dev)
+		return name;
+
+	return clk.dev->name;
+}
+
 int clk_release_all(struct clk *clk, unsigned int count)
 {
 	unsigned int i;
diff --git a/include/clk.h b/include/clk.h
index 045e923a529..a6ef4e02692 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -350,6 +350,15 @@ static inline int clk_get_by_name_nodev_optional(ofnode node, const char *name,
 	return ret;
 }
 
+/**
+ * clk_resolve_parent_clk - Determine name of clock udevice based on clock-names
+ * @dev:	The client udevice.
+ * @name:	The name of the clock to look up.
+ *
+ * Return name of the clock udevice which represents clock with clock-names name.
+ */
+const char *clk_resolve_parent_clk(struct udevice *dev, const char *name);
+
 /**
  * enum clk_defaults_stage - What stage clk_set_defaults() is called at
  * @CLK_DEFAULTS_PRE: Called before probe. Setting of defaults for clocks owned
-- 
2.47.2


  reply	other threads:[~2025-03-23 16:02 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-23 15:58 [PATCH v2 00/24] clk: Add clk_resolve_parent_clk() and fix up iMX clock drivers Marek Vasut
2025-03-23 15:58 ` Marek Vasut [this message]
2025-03-23 15:58 ` [PATCH v2 02/24] clk: clk-mux: Fold clk_register_mux() Marek Vasut
2025-03-23 15:58 ` [PATCH v2 03/24] clk: clk-mux: Use struct udevice instead of struct device Marek Vasut
2025-03-23 15:58 ` [PATCH v2 04/24] clk: clk-mux: Resolve parent clock by name Marek Vasut
2025-03-23 15:58 ` [PATCH v2 05/24] clk: imx: Pass struct udevice into imx_clk_mux*() Marek Vasut
2025-03-23 15:58 ` [PATCH v2 06/24] clk: imx: Pass struct udevice to clk_register_mux() Marek Vasut
2025-03-23 15:58 ` [PATCH v2 07/24] clk: clk-gate: Use struct udevice instead of struct device Marek Vasut
2025-03-23 15:58 ` [PATCH v2 08/24] clk: clk-gate: Resolve parent clock by name Marek Vasut
2025-03-23 15:58 ` [PATCH v2 09/24] clk: imx: gate2: Use struct udevice instead of struct device Marek Vasut
2025-03-23 15:58 ` [PATCH v2 10/24] clk: imx: gate2: Resolve parent clock by name Marek Vasut
2025-03-23 15:58 ` [PATCH v2 11/24] clk: imx: Pass struct udevice into imx_clk_gate*() Marek Vasut
2025-03-23 15:58 ` [PATCH v2 12/24] clk: imx: Pass struct udevice to clk_register_gate*() Marek Vasut
2025-03-23 15:58 ` [PATCH v2 13/24] clk: clk-composite: Use struct udevice instead of struct device Marek Vasut
2025-03-23 15:58 ` [PATCH v2 14/24] clk: clk-composite: Resolve parent clock by name Marek Vasut
2025-03-30 15:15   ` Heinrich Schuchardt
2025-03-30 16:14     ` Heinrich Schuchardt
2026-01-27  2:55       ` Simon Glass
2026-01-27  4:36         ` E Shattow
2026-02-04  0:23           ` Simon Glass
2026-02-05  3:14             ` E Shattow
2026-02-04  1:26           ` Heinrich Schuchardt
2025-03-23 15:58 ` [PATCH v2 15/24] clk: imx: Pass struct udevice into imx_clk_composite*() Marek Vasut
2025-03-23 15:58 ` [PATCH v2 16/24] clk: imx: Convert clock-osc-* back to osc_* Marek Vasut
2025-04-15 14:28   ` [REGRESSION] " Francesco Dolcini
2025-04-15 14:43     ` Adam Ford
2025-04-15 15:03       ` Francesco Dolcini
2025-04-15 16:50         ` Marek Vasut
2025-04-15 17:13           ` Fabio Estevam
2025-04-16  4:38             ` Adam Ford
2025-04-16  9:26             ` Francesco Dolcini
2025-04-16 14:18               ` Christoph Niedermaier
2025-04-16 22:34                 ` Adam Ford
2025-04-16 23:35                   ` Adam Ford
2025-04-16 23:47                     ` Marek Vasut
2025-04-16 23:58                       ` Fabio Estevam
2025-04-17  0:40                         ` Fabio Estevam
2025-04-17  7:24                         ` Marek Vasut
2025-04-17 10:51                           ` Adam Ford
2025-04-17 11:30                             ` Marek Vasut
2025-04-17 12:34                               ` Adam Ford
2025-04-18 14:49                                 ` Marek Vasut
2025-04-17 12:33                           ` Fabio Estevam
2025-03-23 15:58 ` [PATCH v2 17/24] clk: imx: Pass struct udevice into imx_clk_pllv3*() Marek Vasut
2025-03-23 15:58 ` [PATCH v2 18/24] clk: imx: pllv3: Resolve parent clock by name Marek Vasut
2025-03-23 15:58 ` [PATCH v2 19/24] clk: clk-divider: Use struct udevice instead of struct device Marek Vasut
2025-03-23 15:58 ` [PATCH v2 20/24] clk: imx: Pass struct udevice into imx_clk_divider*() Marek Vasut
2025-03-23 15:58 ` [PATCH v2 21/24] clk: clk-divider: Resolve parent clock by name Marek Vasut
2025-03-23 15:58 ` [PATCH v2 22/24] clk: clk-fixed-factor: Use struct udevice instead of struct device Marek Vasut
2025-03-23 15:58 ` [PATCH v2 23/24] clk: clk-fixed-factor: Resolve parent clock by name Marek Vasut
2025-03-23 15:58 ` [PATCH v2 24/24] clk: imx: Pass struct udevice into imx_clk_fixed_factor*() Marek Vasut
2025-03-24 23:33 ` [PATCH v2 00/24] clk: Add clk_resolve_parent_clk() and fix up iMX clock drivers Adam Ford
2025-03-24 23:41   ` Marek Vasut
2025-03-25  7:50 ` Peng Fan
2025-03-25 12:55 ` Fabio Estevam

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=20250323160107.145749-2-marex@denx.de \
    --to=marex@denx.de \
    --cc=Zhiqiang.Hou@nxp.com \
    --cc=aford173@gmail.com \
    --cc=aisheng.dong@nxp.com \
    --cc=cniedermaier@dh-electronics.com \
    --cc=festevam@denx.de \
    --cc=michael@amarulasolutions.com \
    --cc=peng.fan@nxp.com \
    --cc=tharvey@gateworks.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@nxp.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