Skip to contentSkip to conversation

renesas: rcar: Apply ATF overlay for reserved-memory

PATCH In review Detlev Casanova 3 participants 3 messages Jun 9, 2023 – Jun 10, 2023 Arm/RISC-V/Renesas architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 renesas: rcar: Apply ATF overlay for reserved-memory

The function fdtdec_board_setup() is called early and adds the overlay from ATF to the u-boot device tree. That is necessary so that u-boot doesn't use reserved memory.

Linux also needs to know about that reserved memory so the overlay from ATF needs to be aplied on the linux device tree as well.

This commit makes sure that the ATF overlay is applied to both device trees.

---
 board/renesas/rcar-common/common.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
board/renesas/rcar-common/common.c +8 -2
index f38453af82c..f976c99028a 100644
@@ -25,12 +25,17 @@ extern u64 rcar_atf_boot_args[];
 
 #define FDT_RPC_PATH	"/soc/spi@ee200000"
 
-int fdtdec_board_setup(const void *fdt_blob)
+static void apply_atf_overlay(void *fdt_blob)
 {
 	void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]);
 
 	if (fdt_magic(atf_fdt_blob) == FDT_MAGIC)
-		fdt_overlay_apply_node((void *)fdt_blob, 0, atf_fdt_blob, 0);
+		fdt_overlay_apply_node(fdt_blob, 0, atf_fdt_blob, 0);
+}
+
+int fdtdec_board_setup(const void *fdt_blob)
+{
+	apply_atf_overlay((void *)fdt_blob);
 
 	return 0;
 }
@@ -159,6 +164,7 @@ static void update_rpc_status(void *blob)
 
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
+	apply_atf_overlay(blob);
 	scrub_duplicate_memory(blob);
 	update_rpc_status(blob);
 
Signature · 1 line
2.39.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Detlev Casanova

The function fdtdec_board_setup() is called early and adds the overlay from ATF to the u-boot device tree. That is necessary so that u-boot doesn't use reserved memory.

Linux also needs to know about that reserved memory so the overlay from ATF needs to be aplied on the linux device tree as well.

This commit makes sure that the ATF overlay is applied to both device trees.

Reviewed-by on v1 1/1
#2 lore raw
In reply to Detlev Casanova
Quoted 10 lines · Detlev Casanova

The function fdtdec_board_setup() is called early and adds the overlay from ATF to the u-boot device tree. That is necessary so that u-boot doesn't use reserved memory.

Linux also needs to know about that reserved memory so the overlay from ATF needs to be aplied on the linux device tree as well.

This commit makes sure that the ATF overlay is applied to both device trees.

Thanks for this. I was trying to do this very same thing, but your solution looks cleaner than mine.

Quoted 40 lines
---
 board/renesas/rcar-common/common.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
board/renesas/rcar-common/common.c +8 -3
index f38453af82c..f976c99028a 100644
@@ -25,12 +25,17 @@ extern u64 rcar_atf_boot_args[];
 
 #define FDT_RPC_PATH   "/soc/spi@ee200000"
 
-int fdtdec_board_setup(const void *fdt_blob)
+static void apply_atf_overlay(void *fdt_blob)
 {
        void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]);
 
        if (fdt_magic(atf_fdt_blob) == FDT_MAGIC)
-               fdt_overlay_apply_node((void *)fdt_blob, 0, atf_fdt_blob, 0);
+               fdt_overlay_apply_node(fdt_blob, 0, atf_fdt_blob, 0);
+}
+
+int fdtdec_board_setup(const void *fdt_blob)
+{
+       apply_atf_overlay((void *)fdt_blob);
 
        return 0;
 }
@@ -159,6 +164,7 @@ static void update_rpc_status(void *blob)
 
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
+       apply_atf_overlay(blob);
        scrub_duplicate_memory(blob);
        update_rpc_status(blob);
 
--

2.39.3