* [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup
2025-03-07 13:13 [PATCH v2 0/4] Simplify retrieving FDT from SBI in S-Mode Yao Zi
@ 2025-03-07 13:13 ` Yao Zi
2025-03-25 3:43 ` Leo Liang
` (2 more replies)
2025-03-07 13:13 ` [PATCH v2 2/4] board: qemu: riscv: Remove duplicated board_fdt_blob_setup Yao Zi
` (2 subsequent siblings)
3 siblings, 3 replies; 8+ messages in thread
From: Yao Zi @ 2025-03-07 13:13 UTC (permalink / raw)
To: Rick Chen, Leo, Tom Rini, Bin Meng, Paul Walmsley, Palmer Dabbelt,
Anup Patel, Atish Patra, Green Wan, Minda Chen, Simon Glass,
Angelo Dureghello, Ilias Apalodimas, Heinrich Schuchardt
Cc: u-boot, Yao Zi
It's common for S-Mode proper U-Boot to retrieve a FDT blob along with
taking control from SBI firmware. Add a weak version of
board_fdt_blob_setup to make use of it by default, avoiding copy-pasting
similar functions among boards.
Signed-off-by: Yao Zi <ziyao@disroot.org>
---
arch/riscv/lib/Makefile | 1 +
arch/riscv/lib/board.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
create mode 100644 arch/riscv/lib/board.c
diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
index 268116f3757..b33f9c646dd 100644
--- a/arch/riscv/lib/Makefile
+++ b/arch/riscv/lib/Makefile
@@ -27,6 +27,7 @@ obj-$(CONFIG_$(XPL_)SMP) += smp.o
obj-$(CONFIG_XPL_BUILD) += spl.o
obj-y += fdt_fixup.o
obj-$(CONFIG_$(SPL)CMD_BDI) += bdinfo.o
+obj-$(CONFIG_OF_BOARD) += board.o
# For building EFI apps
CFLAGS_NON_EFI := -fstack-protector-strong
diff --git a/arch/riscv/lib/board.c b/arch/riscv/lib/board.c
new file mode 100644
index 00000000000..1630355b2b1
--- /dev/null
+++ b/arch/riscv/lib/board.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * RISC-V-specific handling of firmware FDT
+ */
+
+#include <asm/global_data.h>
+#include <linux/errno.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+__weak int board_fdt_blob_setup(void **fdtp)
+{
+ if (IS_ENABLED(CONFIG_XPL_BUILD) || !gd->arch.firmware_fdt_addr)
+ return -EEXIST;
+
+ *fdtp = (void *)gd->arch.firmware_fdt_addr;
+
+ return 0;
+}
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup
2025-03-07 13:13 ` [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup Yao Zi
@ 2025-03-25 3:43 ` Leo Liang
2025-03-25 10:08 ` Leo Liang
2025-04-25 8:19 ` Leo Liang
2 siblings, 0 replies; 8+ messages in thread
From: Leo Liang @ 2025-03-25 3:43 UTC (permalink / raw)
To: Yao Zi
Cc: Rick Chen, Tom Rini, Bin Meng, Paul Walmsley, Palmer Dabbelt,
Anup Patel, Atish Patra, Green Wan, Minda Chen, Simon Glass,
Angelo Dureghello, Ilias Apalodimas, Heinrich Schuchardt, u-boot
On Fri, Mar 07, 2025 at 01:13:41PM +0000, Yao Zi wrote:
> It's common for S-Mode proper U-Boot to retrieve a FDT blob along with
> taking control from SBI firmware. Add a weak version of
> board_fdt_blob_setup to make use of it by default, avoiding copy-pasting
> similar functions among boards.
>
> Signed-off-by: Yao Zi <ziyao@disroot.org>
> ---
> arch/riscv/lib/Makefile | 1 +
> arch/riscv/lib/board.c | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+)
> create mode 100644 arch/riscv/lib/board.c
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup
2025-03-07 13:13 ` [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup Yao Zi
2025-03-25 3:43 ` Leo Liang
@ 2025-03-25 10:08 ` Leo Liang
2025-04-25 8:19 ` Leo Liang
2 siblings, 0 replies; 8+ messages in thread
From: Leo Liang @ 2025-03-25 10:08 UTC (permalink / raw)
To: Yao Zi
Cc: Rick Chen, Tom Rini, Bin Meng, Paul Walmsley, Palmer Dabbelt,
Anup Patel, Atish Patra, Green Wan, Minda Chen, Simon Glass,
Angelo Dureghello, Ilias Apalodimas, Heinrich Schuchardt, u-boot
Hi Yao,
On Fri, Mar 07, 2025 at 01:13:41PM +0000, Yao Zi wrote:
> It's common for S-Mode proper U-Boot to retrieve a FDT blob along with
> taking control from SBI firmware. Add a weak version of
> board_fdt_blob_setup to make use of it by default, avoiding copy-pasting
> similar functions among boards.
>
> Signed-off-by: Yao Zi <ziyao@disroot.org>
> Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
> ---
> arch/riscv/lib/Makefile | 1 +
> arch/riscv/lib/board.c | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+)
> create mode 100644 arch/riscv/lib/board.c
>
> diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
> index 268116f3757..b33f9c646dd 100644
> --- a/arch/riscv/lib/Makefile
> +++ b/arch/riscv/lib/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_$(XPL_)SMP) += smp.o
> obj-$(CONFIG_XPL_BUILD) += spl.o
> obj-y += fdt_fixup.o
> obj-$(CONFIG_$(SPL)CMD_BDI) += bdinfo.o
> +obj-$(CONFIG_OF_BOARD) += board.o
>
> # For building EFI apps
> CFLAGS_NON_EFI := -fstack-protector-strong
> diff --git a/arch/riscv/lib/board.c b/arch/riscv/lib/board.c
> new file mode 100644
> index 00000000000..1630355b2b1
> --- /dev/null
> +++ b/arch/riscv/lib/board.c
> @@ -0,0 +1,19 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * RISC-V-specific handling of firmware FDT
> + */
> +
> +#include <asm/global_data.h>
> +#include <linux/errno.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +__weak int board_fdt_blob_setup(void **fdtp)
> +{
> + if (IS_ENABLED(CONFIG_XPL_BUILD) || !gd->arch.firmware_fdt_addr)
> + return -EEXIST;
We don't need this check "CONFIG_XPL_BUILD", do we?
We do need this setup function for SPL and adding this would fail CI test.
> +
> + *fdtp = (void *)gd->arch.firmware_fdt_addr;
We should add proper casting to suppress compile warning for 32 bit.
Best regards,
Leo
> +
> + return 0;
> +}
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup
2025-03-07 13:13 ` [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup Yao Zi
2025-03-25 3:43 ` Leo Liang
2025-03-25 10:08 ` Leo Liang
@ 2025-04-25 8:19 ` Leo Liang
2 siblings, 0 replies; 8+ messages in thread
From: Leo Liang @ 2025-04-25 8:19 UTC (permalink / raw)
To: Yao Zi
Cc: Rick Chen, Tom Rini, Bin Meng, Paul Walmsley, Palmer Dabbelt,
Anup Patel, Atish Patra, Green Wan, Minda Chen, Simon Glass,
Angelo Dureghello, Ilias Apalodimas, Heinrich Schuchardt, u-boot
Hi Yao,
On Fri, Mar 07, 2025 at 01:13:41PM +0000, Yao Zi wrote:
> It's common for S-Mode proper U-Boot to retrieve a FDT blob along with
> taking control from SBI firmware. Add a weak version of
> board_fdt_blob_setup to make use of it by default, avoiding copy-pasting
> similar functions among boards.
>
> Signed-off-by: Yao Zi <ziyao@disroot.org>
> Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
> ---
> arch/riscv/lib/Makefile | 1 +
> arch/riscv/lib/board.c | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+)
> create mode 100644 arch/riscv/lib/board.c
>
> diff --git a/arch/riscv/lib/Makefile b/arch/riscv/lib/Makefile
> index 268116f3757..b33f9c646dd 100644
> --- a/arch/riscv/lib/Makefile
> +++ b/arch/riscv/lib/Makefile
> @@ -27,6 +27,7 @@ obj-$(CONFIG_$(XPL_)SMP) += smp.o
> obj-$(CONFIG_XPL_BUILD) += spl.o
> obj-y += fdt_fixup.o
> obj-$(CONFIG_$(SPL)CMD_BDI) += bdinfo.o
> +obj-$(CONFIG_OF_BOARD) += board.o
>
> # For building EFI apps
> CFLAGS_NON_EFI := -fstack-protector-strong
> diff --git a/arch/riscv/lib/board.c b/arch/riscv/lib/board.c
> new file mode 100644
> index 00000000000..1630355b2b1
> --- /dev/null
> +++ b/arch/riscv/lib/board.c
> @@ -0,0 +1,19 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * RISC-V-specific handling of firmware FDT
> + */
> +
> +#include <asm/global_data.h>
> +#include <linux/errno.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +__weak int board_fdt_blob_setup(void **fdtp)
> +{
> + if (IS_ENABLED(CONFIG_XPL_BUILD) || !gd->arch.firmware_fdt_addr)
> + return -EEXIST;
> +
> + *fdtp = (void *)gd->arch.firmware_fdt_addr;
I could fix the 'CONFIG_XPL_BUILD' check and add casting when merging.
Thanks for the patch!
Best regards,
Leo
> +
> + return 0;
> +}
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/4] board: qemu: riscv: Remove duplicated board_fdt_blob_setup
2025-03-07 13:13 [PATCH v2 0/4] Simplify retrieving FDT from SBI in S-Mode Yao Zi
2025-03-07 13:13 ` [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup Yao Zi
@ 2025-03-07 13:13 ` Yao Zi
2025-03-07 13:13 ` [PATCH v2 3/4] board: starfive: " Yao Zi
2025-03-07 13:13 ` [PATCH v2 4/4] board: sifive: Remove dead board_fdt_blob_setup Yao Zi
3 siblings, 0 replies; 8+ messages in thread
From: Yao Zi @ 2025-03-07 13:13 UTC (permalink / raw)
To: Rick Chen, Leo, Tom Rini, Bin Meng, Paul Walmsley, Palmer Dabbelt,
Anup Patel, Atish Patra, Green Wan, Minda Chen, Simon Glass,
Angelo Dureghello, Ilias Apalodimas, Heinrich Schuchardt
Cc: u-boot, Yao Zi
The default version should work for RISC-V QEMU.
Signed-off-by: Yao Zi <ziyao@disroot.org>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
board/emulation/qemu-riscv/qemu-riscv.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c
index a90222ea6a4..70190ebe8fc 100644
--- a/board/emulation/qemu-riscv/qemu-riscv.c
+++ b/board/emulation/qemu-riscv/qemu-riscv.c
@@ -63,11 +63,3 @@ int board_fit_config_name_match(const char *name)
return 0;
}
#endif
-
-int board_fdt_blob_setup(void **fdtp)
-{
- /* Stored the DTB address there during our init */
- *fdtp = (void *)(ulong)gd->arch.firmware_fdt_addr;
-
- return 0;
-}
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 3/4] board: starfive: Remove duplicated board_fdt_blob_setup
2025-03-07 13:13 [PATCH v2 0/4] Simplify retrieving FDT from SBI in S-Mode Yao Zi
2025-03-07 13:13 ` [PATCH v2 1/4] riscv: lib: Add a default implementation of board_fdt_blob_setup Yao Zi
2025-03-07 13:13 ` [PATCH v2 2/4] board: qemu: riscv: Remove duplicated board_fdt_blob_setup Yao Zi
@ 2025-03-07 13:13 ` Yao Zi
2025-03-07 13:13 ` [PATCH v2 4/4] board: sifive: Remove dead board_fdt_blob_setup Yao Zi
3 siblings, 0 replies; 8+ messages in thread
From: Yao Zi @ 2025-03-07 13:13 UTC (permalink / raw)
To: Rick Chen, Leo, Tom Rini, Bin Meng, Paul Walmsley, Palmer Dabbelt,
Anup Patel, Atish Patra, Green Wan, Minda Chen, Simon Glass,
Angelo Dureghello, Ilias Apalodimas, Heinrich Schuchardt
Cc: u-boot, Yao Zi
The default version should work for Starfive VisionFive 2.
Signed-off-by: Yao Zi <ziyao@disroot.org>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
board/starfive/visionfive2/starfive_visionfive2.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/board/starfive/visionfive2/starfive_visionfive2.c b/board/starfive/visionfive2/starfive_visionfive2.c
index 3940d45b13f..96fb8dfe934 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -115,16 +115,6 @@ int board_late_init(void)
return 0;
}
-int board_fdt_blob_setup(void **fdtp)
-{
- if (gd->arch.firmware_fdt_addr) {
- *fdtp = (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
- return 0;
- }
-
- return -EEXIST;
-}
-
int ft_board_setup(void *blob, struct bd_info *bd)
{
return fdt_fixup_memory(blob, 0x40000000, gd->ram_size);
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v2 4/4] board: sifive: Remove dead board_fdt_blob_setup
2025-03-07 13:13 [PATCH v2 0/4] Simplify retrieving FDT from SBI in S-Mode Yao Zi
` (2 preceding siblings ...)
2025-03-07 13:13 ` [PATCH v2 3/4] board: starfive: " Yao Zi
@ 2025-03-07 13:13 ` Yao Zi
3 siblings, 0 replies; 8+ messages in thread
From: Yao Zi @ 2025-03-07 13:13 UTC (permalink / raw)
To: Rick Chen, Leo, Tom Rini, Bin Meng, Paul Walmsley, Palmer Dabbelt,
Anup Patel, Atish Patra, Green Wan, Minda Chen, Simon Glass,
Angelo Dureghello, Ilias Apalodimas, Heinrich Schuchardt
Cc: u-boot, Yao Zi
CONFIG_OF_BOARD isn't enabled on SiFive Unleashed and Unmatched, thus
board_fdt_blob_setup is actually dead code on these platforms. Let's
remove it.
Signed-off-by: Yao Zi <ziyao@disroot.org>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
---
board/sifive/unleashed/unleashed.c | 11 -----------
board/sifive/unmatched/unmatched.c | 10 ----------
2 files changed, 21 deletions(-)
diff --git a/board/sifive/unleashed/unleashed.c b/board/sifive/unleashed/unleashed.c
index c1c374610c3..f5da289b836 100644
--- a/board/sifive/unleashed/unleashed.c
+++ b/board/sifive/unleashed/unleashed.c
@@ -114,17 +114,6 @@ int misc_init_r(void)
#endif
-int board_fdt_blob_setup(void **fdtp)
-{
- if (gd->arch.firmware_fdt_addr) {
- *fdtp = (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
-
- return 0;
- }
-
- return -EEXIST;
-}
-
int board_init(void)
{
/* enable all cache ways */
diff --git a/board/sifive/unmatched/unmatched.c b/board/sifive/unmatched/unmatched.c
index 23e03e145ee..a57ce1f10fe 100644
--- a/board/sifive/unmatched/unmatched.c
+++ b/board/sifive/unmatched/unmatched.c
@@ -10,16 +10,6 @@
#include <dm.h>
#include <asm/sections.h>
-int board_fdt_blob_setup(void **fdtp)
-{
- if (gd->arch.firmware_fdt_addr) {
- *fdtp = (ulong *)(uintptr_t)gd->arch.firmware_fdt_addr;
- return 0;
- }
-
- return -EEXIST;
-}
-
int board_init(void)
{
/* enable all cache ways */
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread