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 2D6D1C6FD1C for ; Sat, 11 Mar 2023 16:14:59 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3C42985FC2; Sat, 11 Mar 2023 17:14:56 +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=1678551296; bh=8YEtQgFl6dGjttLJe1IP6j5Kc9Eytq/Ei+lzgyuXkHU=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=g+wMmJPvnCFz+4yhKAFcKJjAwvSowyKkfthhbyVkAzD8EKYXN+sy6dTh1kmrjVXdu 2hp1Fu9xpUfN94VY0HMWzNjYrHg0DccuPAIqU15kKIKb4hTE6yiI5YKjPZMyWRjpmt XA4J67tJJfZbJEwLl1R00JAd4mIUvvvAQunRAD17NZhxWzdC+6Lxrm+Trsq13mRMPs BXhkg9FFsypLGgMH0uDRBcsplfe5QNGpxZ52TOxeJLJ+zBq44NmyPE9Q6qZ+8Fs0R+ eF6GNi3OLj4D80yH9dgysiiB4/lI+TGFnSseNHITqjybYAuMXIcB51TG/O1HkYNINs RykIegvqfU47A== 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 CC9D785D4B; Sat, 11 Mar 2023 17:14:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1678551294; bh=8YEtQgFl6dGjttLJe1IP6j5Kc9Eytq/Ei+lzgyuXkHU=; h=From:To:Cc:Subject:Date:From; b=FKiVDFtVkggy991PI3Iy3zlLK4EZhTybzxnH/34rc7+4D1BIyDDiC385pjSJdR49S sjisfSgyIxjPHwkY6l3XYvHn6f/j0it5piLUEXX090QcGVU08NCcr4m/eDY3hA5KhX sXaGi5OSxMQvuMr8qxm1oYiu0yGndueLTIk1PXE+6x0j1SFMMxcmn630ZvqxhVF/mR LM9/ejbS3LwQforsX2qNg7jpOa6qt1F5k2YouVRdklkw0MKYVDQf7AqqomdyV1Mq5r hn/a7x4WoAYXwRJ8sVKr1g0cd+QyUR5CgYU12CL8YAav33h9hx1dIJ4Bd/58ncBOlu kn1JI9Omt9yqA== From: Marek Vasut To: u-boot@lists.denx.de Cc: trini@konsulko.com, Marek Vasut , Fedor Ross , Jaehoon Chung , Peng Fan Subject: [PATCH v2 1/2] spl: mmc: Pass eMMC HW partition and SW partition to spl_mmc_get_uboot_raw_sector() Date: Sat, 11 Mar 2023 17:14:43 +0100 Message-Id: <20230311161444.144673-1-marex@denx.de> X-Mailer: git-send-email 2.39.2 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 Pass both eMMC HW partition and software partition numbers to spl_mmc_get_uboot_raw_sector() so the function can better decide which offset within the partition to load payload from. Signed-off-by: Fedor Ross Signed-off-by: Marek Vasut --- Cc: Jaehoon Chung Cc: Peng Fan --- V2: No change --- arch/arm/mach-imx/image-container.c | 2 ++ arch/arm/mach-sunxi/board.c | 2 ++ common/spl/spl_mmc.c | 15 +++++++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-imx/image-container.c b/arch/arm/mach-imx/image-container.c index 06ee608c4a4..c8c263fde7e 100644 --- a/arch/arm/mach-imx/image-container.c +++ b/arch/arm/mach-imx/image-container.c @@ -215,6 +215,8 @@ unsigned long spl_spi_get_uboot_offs(struct spi_flash *flash) #ifdef CONFIG_SPL_MMC unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, + unsigned long hw_part, + unsigned long raw_part, unsigned long raw_sect) { int end; diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index 391a65a5495..3be444d84fe 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -324,6 +324,8 @@ uint32_t sunxi_get_spl_size(void) * immediately follow the SPL if that is bigger than that. */ unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc, + unsigned long hw_part, + unsigned long raw_part, unsigned long raw_sect) { unsigned long spl_size = sunxi_get_spl_size(); diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index e4135b20487..8a0c7331267 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -370,6 +370,8 @@ int __weak spl_mmc_boot_partition(const u32 boot_device) #endif unsigned long __weak spl_mmc_get_uboot_raw_sector(struct mmc *mmc, + unsigned long hw_part, + unsigned long raw_part, unsigned long raw_sect) { return raw_sect; @@ -418,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 part = 0; + __maybe_unused int hw_part = 0; int mmc_dev; /* Perform peripheral init only once for an mmc device */ @@ -442,12 +444,12 @@ int spl_mmc_load(struct spl_image_info *spl_image, err = -EINVAL; switch (boot_mode) { case MMCSD_MODE_EMMCBOOT: - part = spl_mmc_emmc_boot_partition(mmc); + hw_part = spl_mmc_emmc_boot_partition(mmc); if (CONFIG_IS_ENABLED(MMC_TINY)) - err = mmc_switch_part(mmc, part); + err = mmc_switch_part(mmc, hw_part); else - err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part); + err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), hw_part); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT @@ -465,7 +467,8 @@ int spl_mmc_load(struct spl_image_info *spl_image, return err; } - raw_sect = spl_mmc_get_uboot_raw_sector(mmc, raw_sect); + raw_sect = spl_mmc_get_uboot_raw_sector(mmc, hw_part, + raw_part, raw_sect); #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION err = mmc_load_image_raw_partition(spl_image, bootdev, @@ -476,7 +479,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(part)); + raw_sect + spl_mmc_raw_uboot_offset(hw_part)); if (!err) return err; #endif -- 2.39.2