[PATCH v2 9/9] ARM: rockchip: fixup memory in device tree for TF-A
Michael Tretter
m.tretter at pengutronix.de
Wed May 28 07:11:27 PDT 2025
Add the memory nodes for the detected SDRAM configuration to the fdt
before passing it to the TF-A.
Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
---
Changes in v2:
- none
---
arch/arm/mach-rockchip/atf.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/arch/arm/mach-rockchip/atf.c b/arch/arm/mach-rockchip/atf.c
index f4a71ef2dc8dffc6ceb4f97ee542f5b83858120b..c412e7adb9c93c63d0dfcc312d6a7374770ce2da 100644
--- a/arch/arm/mach-rockchip/atf.c
+++ b/arch/arm/mach-rockchip/atf.c
@@ -173,6 +173,26 @@ void rk3588_atf_load_bl31(void *fdt)
rockchip_atf_load_bl31(RK3588, rk3588_bl31_bin, rk3588_bl32_bin, fdt);
}
+#ifdef CONFIG_ARCH_ROCKCHIP_ATF_PASS_FDT
+static int rk3588_fixup_mem(void *fdt)
+{
+ /* Use 4 blocks since rk3588 has 3 gaps in the address space */
+ unsigned long base[4];
+ unsigned long size[ARRAY_SIZE(base)];
+ phys_addr_t base_tmp[ARRAY_SIZE(base)];
+ resource_size_t size_tmp[ARRAY_SIZE(base_tmp)];
+ int i, n;
+
+ n = rk3588_ram_sizes(base_tmp, size_tmp, ARRAY_SIZE(base_tmp));
+ for (i = 0; i < n; i++) {
+ base[i] = base_tmp[i];
+ size[i] = size_tmp[i];
+ }
+
+ return fdt_fixup_mem(fdt, base, size, i);
+}
+#endif
+
void __noreturn rk3588_barebox_entry(void *fdt)
{
unsigned long membase, endmem;
@@ -195,6 +215,8 @@ void __noreturn rk3588_barebox_entry(void *fdt)
fdt_scratch = rk_scratch->fdt;
else
pr_warn("Failed to copy fdt to scratch: Continue without fdt\n");
+ if (fdt_scratch && rk3588_fixup_mem(fdt_scratch) != 0)
+ pr_warn("Failed to fixup memory nodes\n");
#endif
rk3588_atf_load_bl31(fdt_scratch);
--
2.39.5
More information about the barebox
mailing list