[U-Boot] [PATCH 2/5] core: add ofnode_get_by_phandle() api
Philipp Tomsich
philipp.tomsich at theobroma-systems.com
Fri Feb 23 16:38:50 UTC 2018
From: Kever Yang <kever.yang at rock-chips.com>
We need to get ofnode from a phandle, add interface to support
both live dt and fdt.
Signed-off-by: Kever Yang <kever.yang at rock-chips.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
Reviewed-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
Tested-by: Klaus Goger <klaus.goger at theobroma-systems.com>
Signed-off-by: Philipp Tomsich <philipp.tomsich at theobroma-systems.com>
---
drivers/core/ofnode.c | 13 +++++++++++++
include/dm/ofnode.h | 8 ++++++++
2 files changed, 21 insertions(+)
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index dd6d57c..d0bdea0 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -188,6 +188,19 @@ const char *ofnode_get_name(ofnode node)
return fdt_get_name(gd->fdt_blob, ofnode_to_offset(node), NULL);
}
+ofnode ofnode_get_by_phandle(uint phandle)
+{
+ ofnode node;
+
+ if (of_live_active())
+ node = np_to_ofnode(of_find_node_by_phandle(phandle));
+ else
+ node.of_offset = fdt_node_offset_by_phandle(gd->fdt_blob,
+ phandle);
+
+ return node;
+}
+
int ofnode_read_size(ofnode node, const char *propname)
{
int len;
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 6938e62..0d00840 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -318,6 +318,14 @@ ofnode ofnode_get_parent(ofnode node);
const char *ofnode_get_name(ofnode node);
/**
+ * ofnode_get_by_phandle() - get ofnode from phandle
+ *
+ * @phandle: phandle to look up
+ * @return ofnode reference to the phandle
+ */
+ofnode ofnode_get_by_phandle(uint phandle);
+
+/**
* ofnode_read_size() - read the size of a property
*
* @node: node to check
--
2.1.4
More information about the U-Boot
mailing list