From patchwork Sun Nov 8 13:14:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 1396297 X-Patchwork-Delegate: andre.przywara@arm.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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=arm.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CTZNy3fRNz9sSn for ; Mon, 9 Nov 2020 00:15:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E80EC824C4; Sun, 8 Nov 2020 14:14:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=arm.com 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 30123823F4; Sun, 8 Nov 2020 14:14:33 +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, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 60924822FB for ; Sun, 8 Nov 2020 14:14:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=andre.przywara@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1A51A12FC; Sun, 8 Nov 2020 05:14:28 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 893403F719; Sun, 8 Nov 2020 05:14:26 -0800 (PST) From: Andre Przywara To: Jagan Teki Cc: =?utf-8?q?Petr_=C5=A0tetiar?= , Sunil Mohan Adapa , Samuel Holland , Aleksandr Aleksandrov , Icenowy Zheng , Simon Glass , Tom Rini , linux-sunxi@googlegroups.com, u-boot@lists.denx.de, Andre Przywara Subject: [PATCH 3/5] sunxi: Simplify eMMC boot partition booting Date: Sun, 8 Nov 2020 13:14:07 +0000 Message-Id: <20201108131409.14320-4-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20201108131409.14320-1-andre.przywara@arm.com> References: <20201108131409.14320-1-andre.przywara@arm.com> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The Allwinner BROM also supports loading the SPL from the eMMC boot partition, for this we have to set the CONFIG_SUPPORT_EMMC_BOOT Kconfig symbol. But on top of that a user has to manually adjust the raw sector to load U-Boot proper from: CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR. To simplify this, we adjust the sector offset dynamically, whenever we find CONFIG_SUPPORT_EMMC_BOOT enabled and are booting from the eMMC. Unfortunately the BROM sets the same boot source code as for the boot from the normal eMMC user data partition, so we can't tell those two cases apart easily (yet). Signed-off-by: Andre Przywara --- arch/arm/mach-sunxi/board.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index f40fccd8f8b..586af24535d 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -279,21 +279,29 @@ uint32_t sunxi_get_boot_device(void) #ifdef CONFIG_SPL_BUILD /* * The eGON SPL image can be located at 8KB or at 128KB into an SD card or - * an eMMC device. The boot source has bit 4 set in the latter case. + * an eMMC user partition. The boot source has bit 4 set in the latter case. * By adding 120KB to the normal offset when booting from a "high" location * we can support both cases. + * In an eMMC boot partition the SPL is located at offset 0, so we subtract + * the usual 8K offset. */ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc) { unsigned long sector = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR; switch (sunxi_get_boot_source()) { + case SUNXI_BOOTED_FROM_MMC2: + if (IS_ENABLED(CONFIG_SUPPORT_EMMC_BOOT)) + sector -= 8 * 2; + break; case SUNXI_BOOTED_FROM_MMC0_HIGH: case SUNXI_BOOTED_FROM_MMC2_HIGH: sector += (128 - 8) * 2; break; } + debug("loading U-Boot proper from sector 0x%lx\n", sector); + return sector; }