u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] spl: mmc: Pass eMMC HW partition and SW partition to spl_mmc_get_uboot_raw_sector()
@ 2023-01-05 14:28 Marek Vasut
  2023-01-05 14:28 ` [PATCH 2/2] spl: mmc: Pass eMMC HW partition 7 through Marek Vasut
       [not found] ` <CGME20230310023029epcas1p2278035aa9a1d1bb0381335574dfa9b3e@epcas1p2.samsung.com>
  0 siblings, 2 replies; 4+ messages in thread
From: Marek Vasut @ 2023-01-05 14:28 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Fedor Ross, Jaehoon Chung, Peng Fan

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 <fedor.ross@ifm.com>
Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Peng Fan <peng.fan@nxp.com>
---
 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
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] spl: mmc: Pass eMMC HW partition 7 through
  2023-01-05 14:28 [PATCH 1/2] spl: mmc: Pass eMMC HW partition and SW partition to spl_mmc_get_uboot_raw_sector() Marek Vasut
@ 2023-01-05 14:28 ` Marek Vasut
       [not found]   ` <CGME20230310023048epcas1p3662237f506886db60230045bd1373a9a@epcas1p3.samsung.com>
       [not found] ` <CGME20230310023029epcas1p2278035aa9a1d1bb0381335574dfa9b3e@epcas1p2.samsung.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Marek Vasut @ 2023-01-05 14:28 UTC (permalink / raw)
  To: u-boot; +Cc: Marek Vasut, Fedor Ross, Jaehoon Chung, Peng Fan

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 <fedor.ross@ifm.com>
Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: Jaehoon Chung <jh80.chung@samsung.com>
Cc: Peng Fan <peng.fan@nxp.com>
---
 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
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] spl: mmc: Pass eMMC HW partition and SW partition to spl_mmc_get_uboot_raw_sector()
       [not found] ` <CGME20230310023029epcas1p2278035aa9a1d1bb0381335574dfa9b3e@epcas1p2.samsung.com>
@ 2023-03-10  2:30   ` Jaehoon Chung
  0 siblings, 0 replies; 4+ messages in thread
From: Jaehoon Chung @ 2023-03-10  2:30 UTC (permalink / raw)
  To: Marek Vasut, u-boot; +Cc: Fedor Ross, Peng Fan

On 1/5/23 23:28, Marek Vasut wrote:
> 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 <fedor.ross@ifm.com>
> Signed-off-by: Marek Vasut <marex@denx.de>


Applied to u-boot-mmc/master.

Best Regards,
Jaehoon Chung

> ---
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> ---
>  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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] spl: mmc: Pass eMMC HW partition 7 through
       [not found]   ` <CGME20230310023048epcas1p3662237f506886db60230045bd1373a9a@epcas1p3.samsung.com>
@ 2023-03-10  2:30     ` Jaehoon Chung
  0 siblings, 0 replies; 4+ messages in thread
From: Jaehoon Chung @ 2023-03-10  2:30 UTC (permalink / raw)
  To: Marek Vasut, u-boot; +Cc: Fedor Ross, Peng Fan

On 1/5/23 23:28, Marek Vasut wrote:
> 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 <fedor.ross@ifm.com>
> Signed-off-by: Marek Vasut <marex@denx.de>


Applied to u-boot-mmc/master.

Best Regards,
Jaehoon Chung


> ---
> Cc: Jaehoon Chung <jh80.chung@samsung.com>
> Cc: Peng Fan <peng.fan@nxp.com>
> ---
>  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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-03-10  2:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 14:28 [PATCH 1/2] spl: mmc: Pass eMMC HW partition and SW partition to spl_mmc_get_uboot_raw_sector() Marek Vasut
2023-01-05 14:28 ` [PATCH 2/2] spl: mmc: Pass eMMC HW partition 7 through Marek Vasut
     [not found]   ` <CGME20230310023048epcas1p3662237f506886db60230045bd1373a9a@epcas1p3.samsung.com>
2023-03-10  2:30     ` Jaehoon Chung
     [not found] ` <CGME20230310023029epcas1p2278035aa9a1d1bb0381335574dfa9b3e@epcas1p2.samsung.com>
2023-03-10  2:30   ` [PATCH 1/2] spl: mmc: Pass eMMC HW partition and SW partition to spl_mmc_get_uboot_raw_sector() Jaehoon Chung

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).