From patchwork Sun Feb 6 21:07:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janne Grunau X-Patchwork-Id: 1589116 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JsS8q1Gjlz9s9c for ; Mon, 7 Feb 2022 11:44:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 915D683BB6; Mon, 7 Feb 2022 01:44:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jannau.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 79EB183C12; Sun, 6 Feb 2022 22:07:08 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from soltyk.jannau.net (soltyk.jannau.net [144.76.91.90]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3B0AE83BF3 for ; Sun, 6 Feb 2022 22:07:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=jannau.net Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=j@jannau.net Received: from coburn.home.jannau.net (p579ad520.dip0.t-ipconnect.de [87.154.213.32]) by soltyk.jannau.net (Postfix) with ESMTPSA id C893F26E358; Sun, 6 Feb 2022 22:07:04 +0100 (CET) From: Janne Grunau To: u-boot@lists.denx.de Cc: Mark Kettenis , trini@konsulko.com, sjg@chromium.com Subject: [PATCH 1/1] arm: apple: Switch to fully dynamic mem layout Date: Sun, 6 Feb 2022 22:07:04 +0100 Message-Id: <20220206210704.29138-1-j@jannau.net> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 07 Feb 2022 01:44:42 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 --- 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