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>
This commit is contained in:
Simon Glass
2018-07-17 13:25:46 -06:00
parent 4f5dea4543
commit 94a7c603b4
3 changed files with 57 additions and 0 deletions

View File

@@ -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