aboutsummaryrefslogtreecommitdiff
path: root/drivers/core
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2022-04-22 15:15:53 +0200
committerTom Rini <trini@konsulko.com>2022-04-28 09:26:43 -0400
commit9cc32bfa49d23a4d1bed9e6119255f2e78e20232 (patch)
tree8b63349bf905b4b66764235a1361a79f3c2a2b20 /drivers/core
parent8b2b125e95c44bb007b4573945f4aedb8a56222c (diff)
downloadu-boot-9cc32bfa49d23a4d1bed9e6119255f2e78e20232.zip
u-boot-9cc32bfa49d23a4d1bed9e6119255f2e78e20232.tar.gz
u-boot-9cc32bfa49d23a4d1bed9e6119255f2e78e20232.tar.bz2
dm: core: Add DM_FLAG_PROBE_AFTER_BIND flag
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> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com>
Diffstat (limited to 'drivers/core')
-rw-r--r--drivers/core/root.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/drivers/core/root.c b/drivers/core/root.c
index e09c12f..17dd120 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)