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_util.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tools/dtoc/fdt_util.py') diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index d762f93a9a8..5fbfc8877bd 100644 --- a/tools/dtoc/fdt_util.py +++ b/tools/dtoc/fdt_util.py @@ -171,6 +171,24 @@ def GetByte(node, propname, default=None): (node.name, propname, len(value), 1)) return ord(value[0]) +def GetPhandleList(node, propname): + """Get a list of phandles from a property + + Args: + node: Node object to read from + propname: property name to read + + Returns: + List of phandles read, each an integer + """ + prop = node.props.get(propname) + if not prop: + return None + value = prop.value + if not isinstance(value, list): + value = [value] + return [fdt32_to_cpu(v) for v in value] + def GetDatatype(node, propname, datatype): """Get a value of a given type from a property -- cgit v1.2.3