From: Bin Meng <bmeng.cn@gmail.com>
Date: Wed, 5 Jan 2022 01:07:57 +0000 (+0800)
Subject: riscv: sifive: Fix OF_BOARD boot failure
X-Git-Tag: v2025.01-rc5-pxa1908~1597^2~7
X-Git-Url: http://git.dujemihanovic.xyz/%22mailto:Murray.Jensen%40csiro.au/static/%7B%7B%20%24style.RelPermalink%20%7D%7D?a=commitdiff_plain;h=f77549fe7459d7a44714dfc7af1f71e5ad68cbe6;p=u-boot.git

riscv: sifive: Fix OF_BOARD boot failure

When using QEMU to have a quick test of booting U-Boot S-mode payload
directly without the needs of preparing the SPI flash or SD card images
for SiFive Unleashed board, as per the instructions [1], it currently
does not boot any more.

This was caused by the OF_PRIOR_STAGE removal, as gd->fdt_blob no longer
points to a valid DTB. OF_BOARD is supposed to replace OF_PRIOR_STAGE,
hence we need to add the OF_BOARD logic in board_fdt_blob_setup().

[1] https://qemu.readthedocs.io/en/latest/system/riscv/sifive_u.html#running-u-boot

Fixes: 2e8d2f88439d ("riscv: Remove OF_PRIOR_STAGE from RISC-V boards")
Fixes: d6f8ab30a2af ("treewide: Remove OF_PRIOR_STAGE")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c
index 3c3e0e1d0d..f8aad862c6 100644
--- a/board/sifive/unleashed/unleashed.c
+++ b/board/sifive/unleashed/unleashed.c
@@ -117,7 +117,7 @@ int misc_init_r(void)
 void *board_fdt_blob_setup(int *err)
 {
 	*err = 0;
-	if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
+	if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) {
 		if (gd->arch.firmware_fdt_addr)
 			return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
 	}
diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
index 4895909f8d..6295deeae2 100644
--- a/board/sifive/unmatched/unmatched.c
+++ b/board/sifive/unmatched/unmatched.c
@@ -14,7 +14,7 @@
 void *board_fdt_blob_setup(int *err)
 {
 	*err = 0;
-	if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
+	if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) {
 		if (gd->arch.firmware_fdt_addr)
 			return (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
 	}