Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 030C7C6FD1C for ; Sat, 11 Mar 2023 16:15:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E615285FC0; Sat, 11 Mar 2023 17:15:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1678551306; bh=pHyN1/yPc7Miwdv5GTDGkkJON03Z0oK92LdXqW8VHOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=s8Cp3SPcwGmBiVRtdrZ3GJIsVC504YbZm9f+Qb5SojJH9UTeA/LlDTLrcin5OqSW0 DRCV5NpUn35YS64csRGjDLEJrTzQNUz32Mfa9NIZUye1rPU11t8jfv0ifjrRr0aEhU 1XSwQQO6YdTM67y0jj+7VEeZ7SqyeHbOn3MC4ER9zExQqSLI5e9hFcR91+BQfDXOpF M22J/cPfZSQ4KbNTDBniKz14Wq83oJwAjgPWsSSV5PgXryBQqNUdH35T8CjWHwYS3X Z3a8CdfXOoEQF7gBYyo9r7nuU7E+en4+TgqUC5PyE86++lYwnsGZWneGYdfqkEN6KG k6vqqQVDY55sg== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 7F59285FB1; Sat, 11 Mar 2023 17:14:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1678551294; bh=pHyN1/yPc7Miwdv5GTDGkkJON03Z0oK92LdXqW8VHOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bsx+IR48Bso5O76OmtjcoxQAydO3B9X6TciQGQoIH8VOxxu2T+EsiEJRikLxByzxZ 25xVqwdFyjPV8HWHgVcW85WLTYKJRlOG8WIoQrdAN5reW3Jn54ECsfbvv3SDQRFojJ 6uithtGxlTYI8DF96ozULwt1zlC/VmKbFb5LyN7UzsiR7emn8pt2J9VcZojmksFaZb yey+MF7qCKuGd3QH50dRSOLtF9xkd4KKJbVNKo5P+hlQ0+8ZglGvFiUXd/dXB6UdVh IB/tlyJ+zx1bahBBlUcpK+S6R/V9uNUfyaP22Dtg1s0kTjUwyVw6VNnXK4NW/ERBZe tAazLFqQ0DoPA== From: Marek Vasut To: u-boot@lists.denx.de Cc: trini@konsulko.com, Marek Vasut , Fedor Ross , Jaehoon Chung , Peng Fan Subject: [PATCH v2 2/2] spl: mmc: Pass eMMC HW partition 7 through Date: Sat, 11 Mar 2023 17:14:44 +0100 Message-Id: <20230311161444.144673-2-marex@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230311161444.144673-1-marex@denx.de> References: <20230311161444.144673-1-marex@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.8 at phobos.denx.de X-Virus-Status: Clean The eMMC HW partition 0 and 7 both mean USER HW partition. Use this as a mean of propagating A/B copy selection within USER HW partition. The spl_mmc_get_uboot_raw_sector() can detect that a USER HW partition is in use and based on whether it is 0 or 7, select appropriate sector to load from. Signed-off-by: Fedor Ross Signed-off-by: Marek Vasut --- Cc: Jaehoon Chung Cc: Peng Fan --- V2: Initialize the part variable, else it is passed uninitialized to mmc_load_image_raw_sector(..raw_sect + spl_mmc_raw_uboot_offset(part)); and that prevents pine64 from booting. Interestingly enough, there is no warning emitted, which sounds like a compiler bug. --- common/spl/spl_mmc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 8a0c7331267..7a3fd3590dd 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -420,7 +420,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, static struct mmc *mmc; u32 boot_mode; int err = 0; - __maybe_unused int hw_part = 0; + __maybe_unused int part = 0, hw_part = 0; int mmc_dev; /* Perform peripheral init only once for an mmc device */ @@ -445,11 +445,12 @@ int spl_mmc_load(struct spl_image_info *spl_image, switch (boot_mode) { case MMCSD_MODE_EMMCBOOT: hw_part = spl_mmc_emmc_boot_partition(mmc); + part = hw_part == 7 ? 0 : hw_part; if (CONFIG_IS_ENABLED(MMC_TINY)) - err = mmc_switch_part(mmc, hw_part); + err = mmc_switch_part(mmc, part); else - err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), hw_part); + err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT @@ -479,7 +480,7 @@ int spl_mmc_load(struct spl_image_info *spl_image, #endif #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR err = mmc_load_image_raw_sector(spl_image, bootdev, mmc, - raw_sect + spl_mmc_raw_uboot_offset(hw_part)); + raw_sect + spl_mmc_raw_uboot_offset(part)); if (!err) return err; #endif -- 2.39.2