summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAswath Govindraju <a-govindraju@ti.com>2020-12-03 10:55:45 +0530
committerPraneeth Bajjuri <praneeth@ti.com>2021-03-16 13:04:01 -0500
commitd69aa4c490b85ccdd2ba5cb56b04265588b65550 (patch)
tree9ac4a06316550a3fea0499eca255da709f1712a0 /lib
parentc4fddedc48f336eabc4ce3f74940e6aa372de18c (diff)
fdt: Use phandle to distinguish DT nodes with same name
commit c589132a1de0c24dd247dbeb31e387f3b945bcfb upstream. While assigning the sequence number to subsystem instances by reading the aliases property, only DT nodes names are compared and not the complete path. This causes a problem when there are two DT nodes with same name but have different paths. In arch/arm/dts/k3-am65-main.dtsi there are two USB controllers with the same device tree node name but different path. When aliases are defined for these USB controllers then fdtdec_get_alias_seq() fails to pick the correct instance for a given index. fdt_path_offset() function is slow and this would effect the U-Boot startup. To avert the time penalty on all boards, apply this extra check only when required by using a config option. Fix it by comparing the phandles of DT nodes after the node names match, under a config option. Signed-off-by: Aswath Govindraju <a-govindraju@ti.com> Reviewed-by: Simon Glass <sjg@chromium.org> Fix whitespace error in Kconfig: Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/Kconfig8
-rw-r--r--lib/fdtdec.c11
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Kconfig b/lib/Kconfig
index 7673d2e4e0..e059a83a04 100644
--- a/lib/Kconfig
+++ b/lib/Kconfig
@@ -699,3 +699,11 @@ config LIB_ELF
This supports fir 32 bit and 64 bit versions.
endmenu
+
+config PHANDLE_CHECK_SEQ
+ bool "Enable phandle check while getting sequence number"
+ default n
+ help
+ When there are multiple device tree nodes with same name,
+ enable this config option to distinguish them using
+ phandles in fdtdec_get_alias_seq() function.
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index ee1bd41b08..0ab7105fef 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -500,6 +500,17 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
slash = strrchr(prop, '/');
if (strcmp(slash + 1, find_name))
continue;
+
+ /*
+ * Adding an extra check to distinguish DT nodes with
+ * same name
+ */
+ if (IS_ENABLED(CONFIG_PHANDLE_CHECK_SEQ)) {
+ if (fdt_get_phandle(blob, offset) !=
+ fdt_get_phandle(blob, fdt_path_offset(blob, prop)))
+ continue;
+ }
+
val = trailing_strtol(name);
if (val != -1) {
*seqp = val;