[PATCH 1/1] arm: apple: Switch to fully dynamic mem layout
Janne Grunau
j at jannau.net
Sun Feb 6 22:07:04 CET 2022
Support for Apple M1 Pro and Max will allow using a single binary for
all M1 SoCs. The M1 Pro/Max have a different memory layout. The RAM
start address is 0x100_0000_0000 instead of 0x8_0000_0000.
Replace the hardcoded memory layout with dynamic initialized
environment variables in board_late_init().
Tested on Mac Mini (2020) and Macbook Pro 14-inch (2021).
Signed-off-by: Janne Grunau <j at jannau.net>
---
arch/arm/mach-apple/board.c | 24 ++++++++++++++++++++++++
configs/apple_m1_defconfig | 1 +
include/configs/apple.h | 5 -----
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-apple/board.c b/arch/arm/mach-apple/board.c
index b7e8d212f1..09a75a6e4e 100644
--- a/arch/arm/mach-apple/board.c
+++ b/arch/arm/mach-apple/board.c
@@ -136,3 +136,27 @@ ulong board_get_usable_ram_top(ulong total_size)
*/
return 0x980000000;
}
+
+int board_late_init(void)
+{
+ ulong max_size;
+ u32 status = 0;
+
+ max_size = gd->start_addr_sp - CONFIG_STACK_SIZE;
+ max_size = round_down(max_size, SZ_16M);
+
+ status |= env_set_hex("scriptaddr", max_size + SZ_2M);
+
+ status |= env_set_hex("pxefile_addr_r", max_size + SZ_1M);
+
+ status |= env_set_hex("fdt_addr_r", gd->ram_base + SZ_32M - SZ_1M);
+
+ status |= env_set_hex("kernel_addr_r", gd->ram_base + SZ_32M);
+
+ status |= env_set_hex("ramdisk_addr_r", gd->ram_base + SZ_64M);
+
+ if (status)
+ printf("%s: Saving run time variables FAILED\n", __func__);
+
+ return 0;
+}
diff --git a/configs/apple_m1_defconfig b/configs/apple_m1_defconfig
index cb235e4e7d..ad49e2be65 100644
--- a/configs/apple_m1_defconfig
+++ b/configs/apple_m1_defconfig
@@ -8,6 +8,7 @@ CONFIG_SYS_LOAD_ADDR=0x880000000
CONFIG_USE_PREBOOT=y
# CONFIG_DISPLAY_CPUINFO is not set
CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_BOARD_LATE_INIT=y
# CONFIG_NET is not set
# CONFIG_MMC is not set
CONFIG_DEBUG_UART_ANNOUNCE=y
diff --git a/include/configs/apple.h b/include/configs/apple.h
index 3e5fb495f1..f73f4f047b 100644
--- a/include/configs/apple.h
+++ b/include/configs/apple.h
@@ -9,10 +9,6 @@
"stdout=serial,vidconsole\0" \
"stderr=serial,vidconsole\0"
-#define ENV_MEM_LAYOUT_SETTINGS \
- "fdt_addr_r=0x960100000\0" \
- "kernel_addr_r=0x960200000\0"
-
#if CONFIG_IS_ENABLED(CMD_USB)
#define BOOT_TARGET_USB(func) func(USB, usb, 0)
#else
@@ -26,7 +22,6 @@
#define CONFIG_EXTRA_ENV_SETTINGS \
ENV_DEVICE_SETTINGS \
- ENV_MEM_LAYOUT_SETTINGS \
BOOTENV
#endif
--
2.35.1
More information about the U-Boot
mailing list