[U-Boot] [PATCH 2/2] rpi: expose the firmware provided FDT blob in ${fw_fdt_addr}

Cédric Schieli cschieli at gmail.com
Wed Nov 2 19:06:13 CET 2016


If the fw_boot_param saved at an early stage points to a valid FDT
blob, let's expose it in ${fw_fdt_addr}.

Signed-off-by: Cédric Schieli <cschieli at gmail.com>
---

 board/raspberrypi/rpi/rpi.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index 6245b36..7261bc5 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -285,6 +285,24 @@ static void set_fdtfile(void)
 	setenv("fdtfile", fdtfile);
 }
 
+/*
+ * If the firmware provided us with a valid FDT at boot time, let's expose it
+ * in ${fw_fdt_addr} so it may be passed unmodified to the kernel.
+ */
+static void set_fw_fdt_addr(void)
+{
+	char s[3 + 2 * sizeof(fw_boot_param)];
+
+	if (getenv("fw_fdt_addr"))
+		return;
+
+	if (fdt_magic(fw_boot_param) != FDT_MAGIC)
+		return;
+
+	snprintf(s, sizeof(s), "0x%X", (unsigned int)fw_boot_param);
+	setenv("fw_fdt_addr", s);
+}
+
 static void set_usbethaddr(void)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(struct msg_get_mac_address, msg, 1);
@@ -356,6 +374,7 @@ static void set_serial_number(void)
 
 int misc_init_r(void)
 {
+	set_fw_fdt_addr();
 	set_fdtfile();
 	set_usbethaddr();
 #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-- 
2.7.3



More information about the U-Boot mailing list