All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag
@ 2022-04-22 13:15 Marek Vasut
  2022-04-22 13:15 ` [PATCH 2/3] led: Mark device instance with DM_FLAG_PROBE_AFTER_BIND Marek Vasut
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Marek Vasut @ 2022-04-22 13:15 UTC (permalink / raw)
  To: u-boot
  Cc: Marek Vasut, Patrice Chotard, Patrick Delaunay, Sean Anderson,
	Simon Glass, Steven Lawrance

Introduce DM_FLAG_PROBE_AFTER_BIND flag, which can be set by driver or
uclass in .bind(), to indicate such driver instance should be probe()d
once binding of all devices is complete.

This is useful in case the driver determines that hardware initialization
is mandatory on boot, and such initialization happens only in probe().
This also solves the inability to call device_probe() from .bind().

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Patrice Chotard <patrice.chotard@foss.st.com>
Cc: Patrick Delaunay <patrick.delaunay@foss.st.com>
Cc: Sean Anderson <seanga2@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Steven Lawrance <steven.lawrance@softathome.com>
---
 drivers/core/root.c | 24 +++++++++++++++++++++++-
 include/dm/device.h |  3 +++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index e09c12f4d6e..17dd1205a32 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -361,6 +361,28 @@ void *dm_priv_to_rw(void *priv)
 }
 #endif
 
+static int dm_probe_devices(struct udevice *dev, bool pre_reloc_only)
+{
+	u32 mask = DM_FLAG_PROBE_AFTER_BIND;
+	u32 flags = dev_get_flags(dev);
+	struct udevice *child;
+	int ret;
+
+	if (pre_reloc_only)
+		mask |= DM_FLAG_PRE_RELOC;
+
+	if ((flags & mask) == mask) {
+		ret = device_probe(dev);
+		if (ret)
+			return ret;
+	}
+
+	list_for_each_entry(child, &dev->child_head, sibling_node)
+		dm_probe_devices(child, pre_reloc_only);
+
+	return 0;
+}
+
 /**
  * dm_scan() - Scan tables to bind devices
  *
@@ -393,7 +415,7 @@ static int dm_scan(bool pre_reloc_only)
 	if (ret)
 		return ret;
 
-	return 0;
+	return dm_probe_devices(gd->dm_root, pre_reloc_only);
 }
 
 int dm_init_and_scan(bool pre_reloc_only)
diff --git a/include/dm/device.h b/include/dm/device.h
index e0f86f5df9f..e7dd90399f9 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -80,6 +80,9 @@ struct driver_info;
  */
 #define DM_FLAG_VITAL			(1 << 14)
 
+/* Device must be probed after it was bound */
+#define DM_FLAG_PROBE_AFTER_BIND	(1 << 15)
+
 /*
  * One or multiple of these flags are passed to device_remove() so that
  * a selective device removal as specified by the remove-stage and the
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-04-28 19:43 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 13:15 [PATCH 1/3] dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag Marek Vasut
2022-04-22 13:15 ` [PATCH 2/3] led: Mark device instance with DM_FLAG_PROBE_AFTER_BIND Marek Vasut
2022-04-22 13:44   ` Patrice CHOTARD
2022-04-25 14:31   ` Tom Rini
2022-04-25 16:43     ` Marek Vasut
2022-04-28 19:42   ` Tom Rini
2022-04-22 13:15 ` [PATCH 3/3] led: gpio: Check device compatible string to determine the top level node Marek Vasut
2022-04-22 13:45   ` Patrice CHOTARD
2022-04-28 19:42   ` Tom Rini
2022-04-22 13:43 ` [PATCH 1/3] dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag Patrice CHOTARD
2022-04-22 13:49 ` Sean Anderson
2022-04-22 13:52   ` Marek Vasut
2022-04-22 22:45     ` Sean Anderson
2022-04-22 23:07       ` Marek Vasut
2022-04-23  0:16         ` Sean Anderson
2022-04-23  2:02           ` Marek Vasut
2022-04-28 19:42 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.