]> git.sur5r.net Git - u-boot/commitdiff
dtoc: Update the Fdt class to record phandles
authorSimon Glass <sjg@chromium.org>
Tue, 29 Aug 2017 20:15:52 +0000 (14:15 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 15 Sep 2017 11:27:47 +0000 (05:27 -0600)
Add a map from phandles to nodes. This can be used by clients of the the
class instead of maintaining this themselves.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Kever Yang <kever.yang@rock-chips.com>
tools/dtoc/fdt.py

index ffd42ce541d1c8945ddd7712a52a1cee818d1063..dbc338653bca6f542f8ab0676f3a1bb76e1a7b3a 100644 (file)
@@ -212,6 +212,10 @@ class Node:
         searching into subnodes so that the entire tree is built.
         """
         self.props = self._fdt.GetProps(self)
+        phandle = self.props.get('phandle')
+        if phandle:
+            val = fdt_util.fdt32_to_cpu(phandle.value)
+            self._fdt.phandle_to_node[val] = self
 
         offset = libfdt.fdt_first_subnode(self._fdt.GetFdt(), self.Offset())
         while offset >= 0:
@@ -263,6 +267,7 @@ class Fdt:
     def __init__(self, fname):
         self._fname = fname
         self._cached_offsets = False
+        self.phandle_to_node = {}
         if self._fname:
             self._fname = fdt_util.EnsureCompiled(self._fname)