From patchwork Tue Dec 20 18:38:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martyn Welch X-Patchwork-Id: 1717990 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=FazFLQAl; dkim-atps=neutral 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 ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nc5280nH5z1ydd for ; Wed, 21 Dec 2022 05:38:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 025ED852ED; Tue, 20 Dec 2022 19:38:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="FazFLQAl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4D3B185174; Tue, 20 Dec 2022 19:38:36 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) (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 B5842851A2 for ; Tue, 20 Dec 2022 19:38:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=martyn.welch@collabora.com Received: from pan.home (unknown [IPv6:2a00:23c6:c311:3401:be81:c5f8:bf74:3e79]) (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) (Authenticated sender: martyn) by madras.collabora.co.uk (Postfix) with ESMTPSA id 22CFA6602CAD; Tue, 20 Dec 2022 18:38:33 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1671561513; bh=dl35GayrfjsLtgnMcrpAYzEb7a4jzAIwrNv6yxVj5UE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FazFLQAl3BDKniN9xS0QU40UToO+t0tPkQjfSR3pBVhephp6ceXiaOZsTJbWMxGVB RpHx8M4OnD87Kup2UbO2NuW8h0TwcigkhZ1+MOXK1Dls5ToItQlIoZEQ1exASJ/cAh kihTK41KZ1NatTjSl4QRMvwpPdfF1V/aWfG0bqgnBpPwXe69SIwH4shISUTPbSvVst 7Cl3DBE+43nY+8M/kWUC1MSM4LQPxaIMzEUagdIZJBCiLiW7RySINRS1rSilHGYmO/ bh/MJpgW6slAwL77MLLmniUn15iwY+8png8R9Xm6sxk7JjyXit9IJvmea1SPEkHlS6 NiMrCqdydfwrQ== From: Martyn Welch To: Dave Gerlach Cc: u-boot@lists.denx.de, Martyn Welch Subject: [PATCH 1/2] arm64:mach-k3 am625_init: Correct boot mode detection Date: Tue, 20 Dec 2022 18:38:18 +0000 Message-Id: <20221220183819.515667-2-martyn.welch@collabora.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221220183819.515667-1-martyn.welch@collabora.com> References: <20221220183819.515667-1-martyn.welch@collabora.com> MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean The boot mode detection assumes that BOOT_DEVICE_MMC2 should always result in MMCSD_MODE_FS, but MMCSD_MODE_RAW is also a valid option for this port. The current logic also avoids looking at the bootmode pin strapping, which should be the primary means of determining whether a device is being booted in MMCSD_MODE_EMMCBOOT mode. Switch around the logic to check the boot mode to determine whether the eMMC boot mode is expected or MMC/SD boot mode. From there we can look at the boot mode config if in MMC/SD boot mode to determine whether to attempt RAW or FS based booting. This change allows U-Boot to also be successfully booted from RAW offsets in addition to from a filesystem. Signed-off-by: Martyn Welch --- arch/arm/mach-k3/am625_init.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c index da2229d0bf..a91c15ca4e 100644 --- a/arch/arm/mach-k3/am625_init.c +++ b/arch/arm/mach-k3/am625_init.c @@ -173,21 +173,20 @@ void board_init_f(ulong dummy) u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) { u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT); + u32 bootmode = (devstat & MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK) >> + MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT; u32 bootmode_cfg = (devstat & MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK) >> MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT; - switch (boot_device) { - case BOOT_DEVICE_MMC1: - if ((bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK) >> - MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_SHIFT) - return MMCSD_MODE_EMMCBOOT; - return MMCSD_MODE_FS; - - case BOOT_DEVICE_MMC2: - return MMCSD_MODE_FS; + switch (bootmode) { + case BOOT_DEVICE_EMMC: + return MMCSD_MODE_EMMCBOOT; + case BOOT_DEVICE_MMC: + if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK) + return MMCSD_MODE_RAW; default: - return MMCSD_MODE_RAW; + return MMCSD_MODE_FS; } }