mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 7/9] clk: handle CLK_OF_DECLARE in deep probe
Date: Mon,  8 Nov 2021 08:52:07 +0100	[thread overview]
Message-ID: <20211108075209.2366770-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20211108075209.2366770-1-a.fatoum@pengutronix.de>

An assigned-clock-parents referring to a fixed-clock will result in a
warning:

  WARNING: clk: couldn't get parent clock 0 for /ethernet@fe300000

That's because the device for the fixed clock is created on demand and
even after ensuring probe, no driver will have bound against it as
CLK_OF_DECLARE operates outside the driver model.

Fix this by creating devices and binding the dummy driver while
iterating over the CLK_OF_DECLARE list. No functional change for
systems not enabling deep-probe.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/clk/clk.c     | 8 +++++++-
 drivers/of/platform.c | 5 ++++-
 include/of.h          | 6 ++++++
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index fff1e21144dd..189c9c62df5c 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -845,9 +845,15 @@ int of_clk_init(struct device_node *root, const struct of_device_id *matches)
 
 			struct device_node *np = clk_provider->np;
 			if (force || parent_ready(np)) {
+				struct device_d *dev;
 
 				of_pinctrl_select_state_default(np);
-				clk_provider->clk_init_cb(np);
+
+				dev = of_device_create_on_demand(np);
+
+				if (clk_provider->clk_init_cb(np) == 0 && dev)
+					of_platform_device_dummy_drv(dev);
+
 				of_clk_set_defaults(np, true);
 
 				list_del(&clk_provider->node);
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index ea9b8fd9ce9b..ca9b7d153ae4 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -365,11 +365,14 @@ int of_platform_populate(struct device_node *root,
 }
 EXPORT_SYMBOL_GPL(of_platform_populate);
 
-static struct device_d *of_device_create_on_demand(struct device_node *np)
+struct device_d *of_device_create_on_demand(struct device_node *np)
 {
 	struct device_node *parent;
 	struct device_d *parent_dev, *dev;
 
+	if (!deep_probe_is_supported())
+		return NULL;
+
 	parent = of_get_parent(np);
 	if (!parent)
 		return NULL;
diff --git a/include/of.h b/include/of.h
index f9c2b283de71..a9fa2e095c87 100644
--- a/include/of.h
+++ b/include/of.h
@@ -279,6 +279,7 @@ extern struct device_d *of_device_enable_and_register_by_name(const char *name);
 extern struct device_d *of_device_enable_and_register_by_alias(
 							const char *alias);
 
+extern struct device_d *of_device_create_on_demand(struct device_node *np);
 extern int of_device_ensure_probed(struct device_node *np);
 extern int of_device_ensure_probed_by_alias(const char *alias);
 extern int of_devices_ensure_probed_by_property(const char *property_name);
@@ -372,6 +373,11 @@ static inline void of_platform_device_dummy_drv(struct device_d *dev)
 {
 }
 
+struct device_d *of_device_create_on_demand(struct device_node *np)
+{
+	return NULL;
+}
+
 static inline int of_device_ensure_probed(struct device_node *np)
 {
 	return 0;
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-11-08  7:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08  7:52 [PATCH 1/9] fixup! scripts/common: Add write_full() and read_full() Ahmad Fatoum
2021-11-08  7:52 ` [PATCH 2/9] fixup! scripts: Add rk-usb-loader tool Ahmad Fatoum
2021-11-08  7:52 ` [PATCH 3/9] ARM: Rockchip: init: propagate error in init function Ahmad Fatoum
2021-11-08  7:52 ` [PATCH 4/9] ARM: Rockchip: rk3568: make rk3568_lowlevel_init void Ahmad Fatoum
2021-11-08  7:52 ` [PATCH 5/9] ARM64: <asm/barebox-arm-head.h>: mark prologue location Ahmad Fatoum
2021-11-08  8:14   ` Ahmad Fatoum
2021-11-08  7:52 ` [PATCH 6/9] pinctrl: Rockchip: abort probe on lack of aliases Ahmad Fatoum
2021-11-08  7:52 ` Ahmad Fatoum [this message]
2021-11-08  7:52 ` [PATCH 8/9] ARM: Rockchip: make rk3568's atf_load_bl31 reusable Ahmad Fatoum
2021-11-08  7:52 ` [PATCH 9/9] ARM: Rockchip: add delimiter between boards and board features Ahmad Fatoum

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=20211108075209.2366770-7-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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