genio: u-boot: patch: mt8195: adjust memory size at runtime and fixup fdt
- Use TFA + libdram to obtain and set the actual memory size. - Overwrite the memory size in the devicetree that is passed to the kernel with the actual size detected. - All credit to Bartosz Bilas' work for the mt8188/mt8370. - This doesn't really "use" TF-A/libdram though, those call bl33 with magic arguments which we read here. - That is implemented by a patch in TF-A for the mt8195 platform.
This commit is contained in:
parent
5911f02880
commit
a03b88841c
@ -0,0 +1,125 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ricardo Pardini <ricardo@pardini.net>
|
||||
Date: Sat, 3 Jan 2026 23:11:34 +0100
|
||||
Subject: GENIO: arch: mediatek: 1200-evk/radxa-nio-12l: adjust memory size at
|
||||
runtime and fixup fdt
|
||||
|
||||
Use TFA + libdram to obtain and set the actual memory size.
|
||||
Overwrite the memory size in the devicetree that is passed to the kernel with the actual size detected.
|
||||
All credit to Bartosz Bilas' work for the mt8188/mt8370.
|
||||
This doesn't really "use" TF-A/libdram though, those call bl33 with magic arguments which we read here.
|
||||
That is implemented by a patch in TF-A for the mt8195 platform.
|
||||
|
||||
Signed-off-by: Ricardo Pardini <ricardo@pardini.net>
|
||||
---
|
||||
arch/arm/mach-mediatek/mt8195/init.c | 17 +++++++---
|
||||
board/mediatek/genio-1200-evk/mt8195_evk.c | 9 +++++
|
||||
configs/genio_1200_radxa_nio_12l_d16_defconfig | 3 +-
|
||||
configs/genio_1200_radxa_nio_12l_d4_defconfig | 3 +-
|
||||
configs/genio_1200_radxa_nio_12l_d8_defconfig | 3 +-
|
||||
include/configs/mt8195.h | 3 ++
|
||||
6 files changed, 31 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/arch/arm/mach-mediatek/mt8195/init.c b/arch/arm/mach-mediatek/mt8195/init.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/arch/arm/mach-mediatek/mt8195/init.c
|
||||
+++ b/arch/arm/mach-mediatek/mt8195/init.c
|
||||
@@ -22,11 +22,20 @@ int dram_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
- ret = fdtdec_setup_memory_banksize();
|
||||
- if (ret)
|
||||
- return ret;
|
||||
+ if (BOOT_ARGUMENT->magic_number == BOOT_ARGUMENT_MAGIC) {
|
||||
+ gd->ram_base = CONFIG_SYS_SDRAM_BASE;
|
||||
+ gd->ram_size = BOOT_ARGUMENT->dram_size;
|
||||
+ debug("Boot argument DRAM size: %lluGB\n", gd->ram_size >> 30);
|
||||
+ } else {
|
||||
+ debug("Did NOT get magic number from BOOT_ARGUMENT, use FDT to get DRAM size\n");
|
||||
+ ret = fdtdec_setup_mem_size_base();
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+ }
|
||||
|
||||
- fdtdec_setup_mem_size_base();
|
||||
+ mem_map[0].size = gd->ram_size;
|
||||
+ mem_map[0].phys = gd->ram_base;
|
||||
+ mem_map[0].virt = gd->ram_base;
|
||||
|
||||
/*
|
||||
* Limit gd->ram_top not exceeding SZ_4G.
|
||||
diff --git a/board/mediatek/genio-1200-evk/mt8195_evk.c b/board/mediatek/genio-1200-evk/mt8195_evk.c
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/board/mediatek/genio-1200-evk/mt8195_evk.c
|
||||
+++ b/board/mediatek/genio-1200-evk/mt8195_evk.c
|
||||
@@ -229,3 +229,12 @@ int board_init(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
+
|
||||
+int ft_board_setup(void *blob, struct bd_info *bd)
|
||||
+{
|
||||
+ /*
|
||||
+ * Overwrite the memory size in the devicetree that is
|
||||
+ * passed to the kernel with the actual size detected.
|
||||
+ */
|
||||
+ return fdt_fixup_memory(blob, gd->ram_base, gd->ram_size);
|
||||
+}
|
||||
diff --git a/configs/genio_1200_radxa_nio_12l_d16_defconfig b/configs/genio_1200_radxa_nio_12l_d16_defconfig
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/configs/genio_1200_radxa_nio_12l_d16_defconfig
|
||||
+++ b/configs/genio_1200_radxa_nio_12l_d16_defconfig
|
||||
@@ -21,7 +21,8 @@ CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_FIT=y
|
||||
CONFIG_FIT_SIGNATURE=y
|
||||
CONFIG_LEGACY_IMAGE_FORMAT=y
|
||||
-# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
|
||||
+CONFIG_OF_CONTROL=y
|
||||
+CONFIG_OF_BOARD_SETUP=y
|
||||
CONFIG_DEFAULT_FDT_FILE="mediatek/mt8395-radxa-nio-12l"
|
||||
# CONFIG_DISPLAY_BOARDINFO is not set
|
||||
# CONFIG_CMD_CONSOLE is not set
|
||||
diff --git a/configs/genio_1200_radxa_nio_12l_d4_defconfig b/configs/genio_1200_radxa_nio_12l_d4_defconfig
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/configs/genio_1200_radxa_nio_12l_d4_defconfig
|
||||
+++ b/configs/genio_1200_radxa_nio_12l_d4_defconfig
|
||||
@@ -21,7 +21,8 @@ CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_FIT=y
|
||||
CONFIG_FIT_SIGNATURE=y
|
||||
CONFIG_LEGACY_IMAGE_FORMAT=y
|
||||
-# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
|
||||
+CONFIG_OF_CONTROL=y
|
||||
+CONFIG_OF_BOARD_SETUP=y
|
||||
CONFIG_DEFAULT_FDT_FILE="mediatek/mt8395-radxa-nio-12l"
|
||||
# CONFIG_DISPLAY_BOARDINFO is not set
|
||||
# CONFIG_CMD_CONSOLE is not set
|
||||
diff --git a/configs/genio_1200_radxa_nio_12l_d8_defconfig b/configs/genio_1200_radxa_nio_12l_d8_defconfig
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/configs/genio_1200_radxa_nio_12l_d8_defconfig
|
||||
+++ b/configs/genio_1200_radxa_nio_12l_d8_defconfig
|
||||
@@ -21,7 +21,8 @@ CONFIG_DISTRO_DEFAULTS=y
|
||||
CONFIG_FIT=y
|
||||
CONFIG_FIT_SIGNATURE=y
|
||||
CONFIG_LEGACY_IMAGE_FORMAT=y
|
||||
-# CONFIG_ARCH_FIXUP_FDT_MEMORY is not set
|
||||
+CONFIG_OF_CONTROL=y
|
||||
+CONFIG_OF_BOARD_SETUP=y
|
||||
CONFIG_DEFAULT_FDT_FILE="mediatek/mt8395-radxa-nio-12l"
|
||||
# CONFIG_DISPLAY_BOARDINFO is not set
|
||||
# CONFIG_CMD_CONSOLE is not set
|
||||
diff --git a/include/configs/mt8195.h b/include/configs/mt8195.h
|
||||
index 111111111111..222222222222 100644
|
||||
--- a/include/configs/mt8195.h
|
||||
+++ b/include/configs/mt8195.h
|
||||
@@ -162,4 +162,7 @@
|
||||
#define MTK_SIP_PLAT_BINFO 0xC2000529
|
||||
#endif
|
||||
|
||||
+/* DRAM */
|
||||
+#define CONFIG_SYS_SDRAM_BASE 0x40000000 // I got this from the DeviceTree "reg = <0 0x40000000 4 0x00000000>;"
|
||||
+
|
||||
#endif
|
||||
--
|
||||
Armbian
|
||||
|
||||
Loading…
Reference in New Issue
Block a user