diff mbox series

[v2,6/8] sunxi: board: Set fdtfile to match the DT chosen by SPL

Message ID 20201024152156.25578-7-samuel@sholland.org
State Accepted
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series PinePhone automatic device tree selection | expand

Commit Message

Samuel Holland Oct. 24, 2020, 3:21 p.m. UTC
Previously, fdtfile was always the value in CONFIG_DEFAULT_DEVICE_TREE.
This meant that, regardless of the DT chosen by SPL (either by changing
the header in the image or by the selection code at runtime), Linux
always used the default DT.

By using the name from the SPL header (which, because of the previous
commit, always matches the DT used by U-Boot proper), Linux also sees
the same board as U-Boot/SPL, even if the boot script later loads a DT
from disk.

Acked-by: Maxime Ripard <mripard@kernel.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 board/sunxi/board.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 9d0e29788b1..d7ec66ed847 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -870,6 +870,7 @@  static void setup_environment(const void *fdt)
 
 int misc_init_r(void)
 {
+	const char *spl_dt_name;
 	uint boot;
 
 	env_set("fel_booted", NULL);
@@ -888,6 +889,16 @@  int misc_init_r(void)
 		env_set("mmc_bootdev", "1");
 	}
 
+	/* Set fdtfile to match the FIT configuration chosen in SPL. */
+	spl_dt_name = get_spl_dt_name();
+	if (spl_dt_name) {
+		char *prefix = IS_ENABLED(CONFIG_ARM64) ? "allwinner/" : "";
+		char str[64];
+
+		snprintf(str, sizeof(str), "%s%s.dtb", prefix, spl_dt_name);
+		env_set("fdtfile", str);
+	}
+
 	setup_environment(gd->fdt_blob);
 
 #ifdef CONFIG_USB_ETHER