[U-Boot] [PATCH v2 01/13] dm: core: Add a function to bind child devices
Simon Glass
sjg at chromium.org
Wed Jul 6 01:10:08 CEST 2016
We currently use dm_scan_fdt_node() to bind devices. It is an internal
function and it requires the caller to know whether we are pre- or post-
relocation.
This requirement has become quite common in drivers, so the current function
is not ideal.
Add a new function with fewer arguments, that does not require internal
headers. This can be used directly as a post_bind() method if needed.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Add new patch to bring in dm_scan_fdt_dev()
drivers/core/root.c | 9 +++++++++
include/dm/device.h | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 95886ad..d850bd0 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -218,6 +218,15 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset,
return ret;
}
+int dm_scan_fdt_dev(struct udevice *dev)
+{
+ if (dev->of_offset == -1)
+ return 0;
+
+ return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset,
+ gd->flags & GD_FLG_RELOC ? false : true);
+}
+
int dm_scan_fdt(const void *blob, bool pre_reloc_only)
{
return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only);
diff --git a/include/dm/device.h b/include/dm/device.h
index f03bcd3..15c0564 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -593,6 +593,22 @@ static inline bool device_is_on_pci_bus(struct udevice *dev)
#define device_foreach_child_safe(pos, next, parent) \
list_for_each_entry_safe(pos, next, &parent->child_head, sibling_node)
+/**
+ * dm_scan_fdt_dev() - Bind child device in a the device tree
+ *
+ * This handles device which have sub-nodes in the device tree. It scans all
+ * sub-nodes and binds drivers for each node where a driver can be found.
+ *
+ * If this is called prior to relocation, only pre-relocation devices will be
+ * bound (those marked with u-boot,dm-pre-reloc in the device tree, or where
+ * the driver has the DM_FLAG_PRE_RELOC flag set). Otherwise, all devices will
+ * be bound.
+ *
+ * @dev: Device to scan
+ * @return 0 if OK, -ve on error
+ */
+int dm_scan_fdt_dev(struct udevice *dev);
+
/* device resource management */
typedef void (*dr_release_t)(struct udevice *dev, void *res);
typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);
--
2.8.0.rc3.226.g39d4020
More information about the U-Boot
mailing list