aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-10-03 11:31:40 -0600
committerSimon Glass <sjg@chromium.org>2020-10-29 14:42:18 -0600
commit8a38abfc43f94a92b63e428738714111710bda53 (patch)
tree3457b30a58ed529fea91199bb7e9284f7e42292b /tools
parentbb44ebdd0f3eccece2081ec51cf3b3554dafd801 (diff)
downloadu-boot-8a38abfc43f94a92b63e428738714111710bda53.zip
u-boot-8a38abfc43f94a92b63e428738714111710bda53.tar.gz
u-boot-8a38abfc43f94a92b63e428738714111710bda53.tar.bz2
dm: Use driver_info index instead of pointer
At present we use a 'node' pointer in the of-platadata phandle_n_arg structs. This is a pointer to the struct driver_info for a particular device, and we can use it to obtain the struct udevice pointer itself. Since we don't know the struct udevice pointer until it is allocated in memory, we have to fix up the phandle_n_arg.node at runtime. This is annoying since it requires that SPL's data is writable and adds a small amount of extra (generated) code in the dm_populate_phandle_data() function. Now that we can find a driver_info by its index, it is easier to put the index in the phandle_n_arg structures. Update dtoc to do this, add a new device_get_by_driver_info_idx() to look up a device by drive_info index and update the tests to match. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/dtoc/dtb_platdata.py20
-rwxr-xr-xtools/dtoc/test_dtoc.py33
2 files changed, 15 insertions, 38 deletions
diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py
index 8832e6e..2be11ff 100644
--- a/tools/dtoc/dtb_platdata.py
+++ b/tools/dtoc/dtb_platdata.py
@@ -154,8 +154,6 @@ 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(),
- each a PhandleLink
_drivers_additional: List of additional drivers to use during scanning
"""
def __init__(self, dtb_fname, include_disabled, warning_disabled,
@@ -169,7 +167,6 @@ class DtbPlatdata(object):
self._lines = []
self._drivers = []
self._driver_aliases = {}
- self._links = []
self._drivers_additional = drivers_additional
def get_normalized_compat_name(self, node):
@@ -612,17 +609,11 @@ class DtbPlatdata(object):
name = conv_name_to_c(target_node.name)
arg_values = []
for i in range(args):
- arg_values.append(str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i])))
+ arg_values.append(
+ str(fdt_util.fdt32_to_cpu(prop.value[pos + 1 + i])))
pos += 1 + args
- # node member is filled with NULL as the real value
- # will be update at run-time during dm_init_and_scan()
- # by dm_populate_phandle_data()
- vals.append('\t{NULL, {%s}}' % (', '.join(arg_values)))
- var_node = '%s%s.%s[%d].node' % \
- (VAL_PREFIX, var_name, member_name, item)
- # Save the the link information to be use to define
- # dm_populate_phandle_data()
- self._links.append(PhandleLink(var_node, name))
+ vals.append('\t{%d, {%s}}' % (target_node.idx,
+ ', '.join(arg_values)))
item += 1
for val in vals:
self.buf('\n\t\t%s,' % val)
@@ -703,9 +694,6 @@ 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 link in self._links:
- self.buf('\t%s = DM_GET_DEVICE(%s);\n' %
- (link.var_node, link.dev_name))
self.buf('}\n')
self.out(''.join(self.get_buf()))
diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py
index fee9853..8e16dc0 100755
--- a/tools/dtoc/test_dtoc.py
+++ b/tools/dtoc/test_dtoc.py
@@ -419,10 +419,10 @@ U_BOOT_DEVICE(phandle_target) = {
/* Node /phandle-source index 2 */
static struct dtd_source dtv_phandle_source = {
\t.clocks\t\t\t= {
-\t\t\t{NULL, {}},
-\t\t\t{NULL, {11}},
-\t\t\t{NULL, {12, 13}},
-\t\t\t{NULL, {}},},
+\t\t\t{4, {}},
+\t\t\t{0, {11}},
+\t\t\t{1, {12, 13}},
+\t\t\t{4, {}},},
};
U_BOOT_DEVICE(phandle_source) = {
\t.name\t\t= "source",
@@ -434,7 +434,7 @@ U_BOOT_DEVICE(phandle_source) = {
/* Node /phandle-source2 index 3 */
static struct dtd_source dtv_phandle_source2 = {
\t.clocks\t\t\t= {
-\t\t\t{NULL, {}},},
+\t\t\t{4, {}},},
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
@@ -444,11 +444,6 @@ U_BOOT_DEVICE(phandle_source2) = {
};
void dm_populate_phandle_data(void) {
-\tdtv_phandle_source.clocks[0].node = DM_GET_DEVICE(phandle_target);
-\tdtv_phandle_source.clocks[1].node = DM_GET_DEVICE(phandle2_target);
-\tdtv_phandle_source.clocks[2].node = DM_GET_DEVICE(phandle3_target);
-\tdtv_phandle_source.clocks[3].node = DM_GET_DEVICE(phandle_target);
-\tdtv_phandle_source2.clocks[0].node = DM_GET_DEVICE(phandle_target);
}
''', data)
@@ -489,7 +484,7 @@ U_BOOT_DEVICE(phandle_target) = {
/* Node /phandle-source2 index 0 */
static struct dtd_source dtv_phandle_source2 = {
\t.clocks\t\t\t= {
-\t\t\t{NULL, {}},},
+\t\t\t{1, {}},},
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
@@ -499,7 +494,6 @@ U_BOOT_DEVICE(phandle_source2) = {
};
void dm_populate_phandle_data(void) {
-\tdtv_phandle_source2.clocks[0].node = DM_GET_DEVICE(phandle_target);
}
''', data)
@@ -547,10 +541,10 @@ U_BOOT_DEVICE(phandle_target) = {
/* Node /phandle-source index 2 */
static struct dtd_source dtv_phandle_source = {
\t.cd_gpios\t\t= {
-\t\t\t{NULL, {}},
-\t\t\t{NULL, {11}},
-\t\t\t{NULL, {12, 13}},
-\t\t\t{NULL, {}},},
+\t\t\t{4, {}},
+\t\t\t{0, {11}},
+\t\t\t{1, {12, 13}},
+\t\t\t{4, {}},},
};
U_BOOT_DEVICE(phandle_source) = {
\t.name\t\t= "source",
@@ -562,7 +556,7 @@ U_BOOT_DEVICE(phandle_source) = {
/* Node /phandle-source2 index 3 */
static struct dtd_source dtv_phandle_source2 = {
\t.cd_gpios\t\t= {
-\t\t\t{NULL, {}},},
+\t\t\t{4, {}},},
};
U_BOOT_DEVICE(phandle_source2) = {
\t.name\t\t= "source",
@@ -572,11 +566,6 @@ U_BOOT_DEVICE(phandle_source2) = {
};
void dm_populate_phandle_data(void) {
-\tdtv_phandle_source.cd_gpios[0].node = DM_GET_DEVICE(phandle_target);
-\tdtv_phandle_source.cd_gpios[1].node = DM_GET_DEVICE(phandle2_target);
-\tdtv_phandle_source.cd_gpios[2].node = DM_GET_DEVICE(phandle3_target);
-\tdtv_phandle_source.cd_gpios[3].node = DM_GET_DEVICE(phandle_target);
-\tdtv_phandle_source2.cd_gpios[0].node = DM_GET_DEVICE(phandle_target);
}
''', data)