From patchwork Thu Jan 5 14:28:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1721891 X-Patchwork-Delegate: jh80.chung@samsung.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=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=lJMJiaXC; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=cV8Vjli1; 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NnpkX1JSjz23fj for ; Fri, 6 Jan 2023 01:29:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C2E44855A5; Thu, 5 Jan 2023 15:29:02 +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=1672928943; bh=3mMbHmH2bkNvqmHPM9nvQh2po6MnSGOSG9/kXrgQw64=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=lJMJiaXCXvGAc6dGRa5wDsV9Da268PpiAEFxoqiU08yP/v3x+lpjWI+6AjQGkQYLv U24wPNBuj+99WhLfazzCbYC/WkpMbYqUAtQujg2xzHH8q9b+HXeQFuLXogWRYEsQ5g /f3wemQahr+dg6FY7h/TZUy/w7r6iHOs4Uh91tcspMgsC7grZDwQgYXfeXX50MPBd+ WTrohUFZ0Xpm9RXuupkysdABSqHZ9nGUc5aUcDo7/dGcmI9Sjp74WtmU1v6060Y+AB rLFkCT3AyUKDzTYd5NaqZNotPd814DYOvyo9T8PqviJEMHfTfjOAGy1dxN5tRNjBiY XZ48J0pUszt0w== 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 56D6783673; Thu, 5 Jan 2023 15:29:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1672928940; bh=3mMbHmH2bkNvqmHPM9nvQh2po6MnSGOSG9/kXrgQw64=; h=From:To:Cc:Subject:Date:From; b=cV8Vjli18inLl1a0rW4QpUsUcjXx3ZzpHFkaFAYE5d9SiBIoWDgP1NIeGkJVsQVfq JJT0zY14VWqrnIceaQ9ONhaFeQmv4Vjmi0LPu+W6yXWGh7MYJOuuBKGYyiiuV0AGJe wdwPLY1TeCmdDHHbmkB2RhrTWkbIaiKoTZArsPjOqfUpfSLBHtwRQpYtzw5CitKQF0 TB5ksAQBn672fBaBlkFb0Dt2BRT7Gb2j4b5v6SGVsP2UFnKU712SI7uM1vZcxKmSjX m2le2vVZagdpnlaYZjxJtqzFFNGsOtqWmHHfQwgYORS+ZcSBN66bJUASHo5Z6suCmu usnpxJziMXXwA== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fedor Ross , Jaehoon Chung , Peng Fan Subject: [PATCH 1/2] spl: mmc: Pass eMMC HW partition and SW partition to spl_mmc_get_uboot_raw_sector() Date: Thu, 5 Jan 2023 15:28:30 +0100 Message-Id: <20230105142831.163381-1-marex@denx.de> X-Mailer: git-send-email 2.39.0 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 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 --- 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 0e767864822..4518ea1f479 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 0c4b6dd1ca3..5a79e14535a 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -325,6 +325,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 From patchwork Thu Jan 5 14:28:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1721892 X-Patchwork-Delegate: jh80.chung@samsung.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=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=R/1+l1qV; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=wJb84CBO; 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Nnpkm6Hd6z23fC for ; Fri, 6 Jan 2023 01:29:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D3D3F855A9; Thu, 5 Jan 2023 15:29:06 +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=1672928947; bh=GCn2Mqso8RR8q8qup0GiIizEvFr65Gdy4F88uIeeoIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=R/1+l1qViH08ALXGomfECi4NwcHSDAJSPJytRZI54Zsc5G2AyDJf6DiSbH2subn5q D1JBiJUQCG/QvpbMmmGjDh7NiKwbLtybA+uz4C48422/WiK0F90DDc5qf2OvDQl/7S ktIegCjwviwvF0tuv8KOdgRSN6R1SgDQM/iWBF+ssFZGUdEj9iZLmTjDvlHJTUYMju N/CgyxGDpNQOcerrFqHW8xdLW8Sn65OJINvfnh347lqUUww1xXbIVkC2/9as5TG/GW HdjPwAXGYrW8j1qhzl24mv6C6XMc+qff5EtSFpN4r8T/TmK5jQZzNUkzd9hSq09MK4 iKmX9AHCvKQoQ== 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 E3A9E85248; Thu, 5 Jan 2023 15:29:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1672928941; bh=GCn2Mqso8RR8q8qup0GiIizEvFr65Gdy4F88uIeeoIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wJb84CBO8uDphOmQ9qPI7El/nObizFr7c9WT92R+//gpi6/kHjziqfgEkyW4WnF7k VAK90jM+5bVC2DVeYeSsG8IdgNtso/UHKcHrNH737IBlQm59CZOIB8F1Oj2YHJnywi 6st7KI3TgdI18GXyTjKnZV7O1ImXjl/iedftyBqOS1mJSMB8HPGnl4AzTxFHzDcNfi arMv3x1ISgaiVIwH8289yLmAUQ91c/2C5NOUir+GvSMD4mg7ziTwrAA5qK/mJlUhL3 JdUmG5z4f0kyw1DjKXhE9kH4FeJyx0aO5fQbvVOe1T51NlQludfjkv4+Yf1lZ9Duly GZdSeFb55TCJw== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Fedor Ross , Jaehoon Chung , Peng Fan Subject: [PATCH 2/2] spl: mmc: Pass eMMC HW partition 7 through Date: Thu, 5 Jan 2023 15:28:31 +0100 Message-Id: <20230105142831.163381-2-marex@denx.de> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105142831.163381-1-marex@denx.de> References: <20230105142831.163381-1-marex@denx.de> 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 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 --- 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..d634ccb0b9a 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, 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