From 94a7c603b45b9abdd9e6960ed2b096dd4553c91c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 17 Jul 2018 13:25:46 -0600 Subject: dtoc: Add a function to obtain a list of phandles Add a function which can decode a property containing a list of phandles. This is useful for finding nodes linked to a property. Also provide a way to look up a single phandle and get the Fdt object from a Node. Signed-off-by: Simon Glass --- tools/dtoc/fdt.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tools/dtoc/fdt.py') diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py index 01e39b8a2a..d36179bad3 100644 --- a/tools/dtoc/fdt.py +++ b/tools/dtoc/fdt.py @@ -181,6 +181,14 @@ class Node: self.subnodes = [] self.props = {} + def GetFdt(self): + """Get the Fdt object for this node + + Returns: + Fdt object + """ + return self._fdt + def FindNode(self, name): """Find a node given its name @@ -314,6 +322,17 @@ class Fdt: with open(self._fname) as fd: self._fdt_obj = libfdt.Fdt(fd.read()) + def LookupPhandle(self, phandle): + """Look up a phandle + + Args: + phandle: Phandle to look up (int) + + Returns: + Node object the phandle points to + """ + return self.phandle_to_node.get(phandle) + def Scan(self, root='/'): """Scan a device tree, building up a tree of Node objects -- cgit v1.2.3