aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2017-08-29 14:15:53 -0600
committerSimon Glass <sjg@chromium.org>2017-09-15 05:27:47 -0600
commit72ab7c5e384f415b66dc9bef41db928cfc11c310 (patch)
tree087b046e5ca7a09c0affc6e89a22d1502fb6f231 /tools/dtoc
parent09264e04330479fbe5bdb647619be4fd90735bfc (diff)
downloadu-boot-72ab7c5e384f415b66dc9bef41db928cfc11c310.zip
u-boot-72ab7c5e384f415b66dc9bef41db928cfc11c310.tar.gz
u-boot-72ab7c5e384f415b66dc9bef41db928cfc11c310.tar.bz2
dtoc: Use the Fdt's class's phandle map
Now that the Fdt class can map phandles to the associated nodes, use that instead of a separate implementation. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Kever Yang <kever.yang@rock-chips.com>
Diffstat (limited to 'tools/dtoc')
-rw-r--r--tools/dtoc/dtb_platdata.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 0c71931..705ab27 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -144,17 +144,14 @@ class DtbPlatdata(object):
_dtb_fname: Filename of the input device tree binary file
_valid_nodes: A list of Node object with compatible strings
_include_disabled: true to include nodes marked status = "disabled"
- _phandle_nodes: A dict of nodes indexed by phandle number (1, 2...)
_outfile: The current output file (sys.stdout or a real file)
_lines: Stashed list of output lines for outputting in the future
- _phandle_nodes: A dict of Nodes indexed by phandle (an integer)
"""
def __init__(self, dtb_fname, include_disabled):
self._fdt = None
self._dtb_fname = dtb_fname
self._valid_nodes = None
self._include_disabled = include_disabled
- self._phandle_nodes = {}
self._outfile = None
self._lines = []
self._aliases = {}
@@ -210,8 +207,7 @@ class DtbPlatdata(object):
def scan_node(self, root):
"""Scan a node and subnodes to build a tree of node and phandle info
- This adds each node to self._valid_nodes and each phandle to
- self._phandle_nodes.
+ This adds each node to self._valid_nodes.
Args:
root: Root node for scan
@@ -222,10 +218,6 @@ class DtbPlatdata(object):
if (not self._include_disabled and not status or
status.value != 'disabled'):
self._valid_nodes.append(node)
- phandle_prop = node.props.get('phandle')
- if phandle_prop:
- phandle = phandle_prop.GetPhandle()
- self._phandle_nodes[phandle] = node
# recurse to handle any subnodes
self.scan_node(node)
@@ -234,11 +226,9 @@ class DtbPlatdata(object):
"""Scan the device tree for useful information
This fills in the following properties:
- _phandle_nodes: A dict of Nodes indexed by phandle (an integer)
_valid_nodes: A list of nodes we wish to consider include in the
platform data
"""
- self._phandle_nodes = {}
self._valid_nodes = []
return self.scan_node(self._fdt.GetRoot())
@@ -374,7 +364,7 @@ class DtbPlatdata(object):
value_it = iter(prop.value)
for phandle_cell, _ in zip(value_it, value_it):
phandle = fdt_util.fdt32_to_cpu(phandle_cell)
- target_node = self._phandle_nodes[phandle]
+ target_node = self._fdt.phandle_to_node[phandle]
node.phandles.add(target_node)
@@ -439,7 +429,7 @@ class DtbPlatdata(object):
for phandle_cell, id_cell in zip(value_it, value_it):
phandle = fdt_util.fdt32_to_cpu(phandle_cell)
id_num = fdt_util.fdt32_to_cpu(id_cell)
- target_node = self._phandle_nodes[phandle]
+ target_node = self._fdt.phandle_to_node[phandle]
name = conv_name_to_c(target_node.name)
vals.append('{&%s%s, %d}' % (VAL_PREFIX, name, id_num))
else: