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>
}
#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
*
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)
*/
#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