diff options
author | Kever Yang <kever.yang@rock-chips.com> | 2018-02-23 17:38:50 +0100 |
---|---|---|
committer | Anatolij Gustschin <agust@denx.de> | 2018-02-23 20:48:09 +0100 |
commit | b4f20767b12a5718ed8549aece73d405c6cac800 (patch) | |
tree | 2e3374f58faf55f5389b6398116bef8dad0c3079 /drivers/core/ofnode.c | |
parent | e2d5997ffdf5cbf4f7d53584dab2ffc673f50987 (diff) | |
download | u-boot-b4f20767b12a5718ed8549aece73d405c6cac800.tar.gz |
core: add ofnode_get_by_phandle() api
We need to get ofnode from a phandle, add interface to support
both live dt and fdt.
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Tested-by: Klaus Goger <klaus.goger@theobroma-systems.com>
Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Diffstat (limited to 'drivers/core/ofnode.c')
-rw-r--r-- | drivers/core/ofnode.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index dd6d57c49b..d0bdea08df 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; |