summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-03 16:00:59 +0300
committerSimon Glass <sjg@chromium.org>2021-03-22 09:23:27 +0300
commite525fea211d18a84bc33c6f5842f14153924cf50 (patch)
tree15df098ce7bec5f2391e0629d5829a06eeefff1e /tools
parent51d5d051fa419dc4bb66ce232708346859389b1c (diff)
downloadu-boot-e525fea211d18a84bc33c6f5842f14153924cf50.tar.xz
dtoc: Make use of node properties
Now that we have these available, use them instead of recalculating things each time. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/dtoc/dtb_platdata.py45
1 files changed, 19 insertions, 26 deletions
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 8c36fbc68d..2ec22edfbf 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -470,7 +470,6 @@ class DtbPlatdata():
"""
structs = self._struct_data
for node in self._valid_nodes:
- node_name, _ = self._scan.get_normalized_compat_name(node)
fields = {}
# Get a list of all the valid properties in this node.
@@ -478,9 +477,9 @@ class DtbPlatdata():
if name not in PROP_IGNORE_LIST and name[0] != '#':
fields[name] = copy.deepcopy(prop)
- # If we've seen this node_name before, update the existing struct.
- if node_name in structs:
- struct = structs[node_name]
+ # If we've seen this struct_name before, update the existing struct
+ if node.struct_name in structs:
+ struct = structs[node.struct_name]
for name, prop in fields.items():
oldprop = struct.get(name)
if oldprop:
@@ -490,11 +489,10 @@ class DtbPlatdata():
# Otherwise store this as a new struct.
else:
- structs[node_name] = fields
+ structs[node.struct_name] = fields
for node in self._valid_nodes:
- node_name, _ = self._scan.get_normalized_compat_name(node)
- struct = structs[node_name]
+ struct = structs[node.struct_name]
for name, prop in node.props.items():
if name not in PROP_IGNORE_LIST and name[0] != '#':
prop.Widen(struct[name])
@@ -598,23 +596,22 @@ class DtbPlatdata():
self.buf(', '.join(vals[i:i + 8]))
self.buf('}')
- def _declare_device(self, var_name, struct_name, node_parent):
+ def _declare_device(self, node):
"""Add a device declaration to the output
This declares a U_BOOT_DRVINFO() for the device being processed
Args:
- var_name (str): C name for the node
- struct_name (str): Name for the dt struct associated with the node
- node_parent (Node): Parent of the node (or None if none)
+ node: Node to process
"""
- self.buf('U_BOOT_DRVINFO(%s) = {\n' % var_name)
- self.buf('\t.name\t\t= "%s",\n' % struct_name)
- self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, var_name))
- self.buf('\t.plat_size\t= sizeof(%s%s),\n' % (VAL_PREFIX, var_name))
+ self.buf('U_BOOT_DRVINFO(%s) = {\n' % node.var_name)
+ self.buf('\t.name\t\t= "%s",\n' % node.struct_name)
+ self.buf('\t.plat\t= &%s%s,\n' % (VAL_PREFIX, node.var_name))
+ self.buf('\t.plat_size\t= sizeof(%s%s),\n' %
+ (VAL_PREFIX, node.var_name))
idx = -1
- if node_parent and node_parent in self._valid_nodes:
- idx = node_parent.idx
+ if node.parent and node.parent in self._valid_nodes:
+ idx = node.parent.idx
self.buf('\t.parent_idx\t= %d,\n' % idx)
self.buf('};\n')
self.buf('\n')
@@ -638,16 +635,14 @@ class DtbPlatdata():
self.buf(get_value(prop.type, prop.value))
self.buf(',\n')
- def _output_values(self, var_name, struct_name, node):
+ def _output_values(self, node):
"""Output the definition of a device's struct values
Args:
- var_name (str): C name for the node
- struct_name (str): Name for the dt struct associated with the node
- node (Node): Node being output
+ node (Node): Node to output
"""
self.buf('static struct %s%s %s%s = {\n' %
- (STRUCT_PREFIX, struct_name, VAL_PREFIX, var_name))
+ (STRUCT_PREFIX, node.struct_name, VAL_PREFIX, node.var_name))
for pname in sorted(node.props):
self._output_prop(node, node.props[pname])
self.buf('};\n')
@@ -658,12 +653,10 @@ class DtbPlatdata():
Args:
node (fdt.Node): node to output
"""
- struct_name, _ = self._scan.get_normalized_compat_name(node)
- var_name = conv_name_to_c(node.name)
self.buf('/* Node %s index %d */\n' % (node.path, node.idx))
- self._output_values(var_name, struct_name, node)
- self._declare_device(var_name, struct_name, node.parent)
+ self._output_values(node)
+ self._declare_device(node)
self.out(''.join(self.get_buf()))