]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
core: add ofnode_get_by_phandle() api
authorKever Yang <kever.yang@rock-chips.com>
Fri, 23 Feb 2018 16:38:50 +0000 (17:38 +0100)
committerAnatolij Gustschin <agust@denx.de>
Fri, 23 Feb 2018 19:48:09 +0000 (20:48 +0100)
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>
drivers/core/ofnode.c
include/dm/ofnode.h

index dd6d57c49bd5c48ea12e20895c5b0e48e2854123..d0bdea08df649852d4bafe04d4e188ff1d037d02 100644 (file)
@@ -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;
index 6938e62993e83b8d9cda7d8f53a28182e1bb23c9..0d008404f90f29402dd4790151a03ea55a33cca7 100644 (file)
@@ -317,6 +317,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
  *