diff options
author | Simon Glass <sjg@chromium.org> | 2018-07-17 13:25:46 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2018-08-01 16:30:48 -0600 |
commit | 94a7c603b45b9abdd9e6960ed2b096dd4553c91c (patch) | |
tree | e3e937979b0820915341f4272e8a5b8918e2eac5 /tools/dtoc/fdt_util.py | |
parent | 4f5dea4543f2b7ebea803fe9b176abf5b637d988 (diff) |
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 <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt_util.py')
-rw-r--r-- | tools/dtoc/fdt_util.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/dtoc/fdt_util.py b/tools/dtoc/fdt_util.py index d762f93a9a..5fbfc8877b 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 |