aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-10-03 09:25:19 -0600
committerSimon Glass <sjg@chromium.org>2020-10-29 14:42:17 -0600
commit97136eb5354c28c475cd2fb72d5cc1029ce9e743 (patch)
tree1b965ce1c20286b539c46d3a1924ea346b1f7988 /tools
parent26e408fe121016b8cfacddc03a23093bf867e7a2 (diff)
downloadu-boot-97136eb5354c28c475cd2fb72d5cc1029ce9e743.zip
u-boot-97136eb5354c28c475cd2fb72d5cc1029ce9e743.tar.gz
u-boot-97136eb5354c28c475cd2fb72d5cc1029ce9e743.tar.bz2
dtoc: Use a namedtuple for _links
The use of strings to access a dict is a bit ugly. Use a namedtuple for this instead. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/dtoc/dtb_platdata.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index bd1daa4..1b52198 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -54,6 +54,13 @@ VAL_PREFIX = 'dtv_'
# phandles is len(args). This is a list of integers.
PhandleInfo = collections.namedtuple('PhandleInfo', ['max_args', 'args'])
+# Holds a single phandle link, allowing a C struct value to be assigned to point
+# to a device
+#
+# var_node: C variable to assign (e.g. 'dtv_mmc.clocks[0].node')
+# dev_name: Name of device to assign to (e.g. 'clock')
+PhandleLink = collections.namedtuple('PhandleLink', ['var_node', 'dev_name'])
+
def conv_name_to_c(name):
"""Convert a device-tree name to a C identifier
@@ -146,7 +153,8 @@ class DtbPlatdata(object):
key: Driver alias declared with
U_BOOT_DRIVER_ALIAS(driver_alias, driver_name)
value: Driver name declared with U_BOOT_DRIVER(driver_name)
- _links: List of links to be included in dm_populate_phandle_data()
+ _links: List of links to be included in dm_populate_phandle_data(),
+ each a PhandleLink
_drivers_additional: List of additional drivers to use during scanning
"""
def __init__(self, dtb_fname, include_disabled, warning_disabled,
@@ -593,7 +601,7 @@ class DtbPlatdata(object):
(VAL_PREFIX, var_name, member_name, item)
# Save the the link information to be use to define
# dm_populate_phandle_data()
- self._links.append({'var_node': var_node, 'dev_name': name})
+ self._links.append(PhandleLink(var_node, name))
item += 1
for val in vals:
self.buf('\n\t\t%s,' % val)
@@ -669,9 +677,9 @@ class DtbPlatdata(object):
# nodes using DM_GET_DEVICE
# dtv_dmc_at_xxx.clocks[0].node = DM_GET_DEVICE(clock_controller_at_xxx)
self.buf('void dm_populate_phandle_data(void) {\n')
- for l in self._links:
+ for link in self._links:
self.buf('\t%s = DM_GET_DEVICE(%s);\n' %
- (l['var_node'], l['dev_name']))
+ (link.var_node, link.dev_name))
self.buf('}\n')
self.out(''.join(self.get_buf()))