diff mbox series

[2/5] spl: mmc: extend spl_mmc_boot_mode() to take mmc argument

Message ID 20201108131409.14320-3-andre.przywara@arm.com
State Superseded
Delegated to: Andre Przywara
Headers show
Series sunxi: enable automatic eMMC boot partition support | expand

Commit Message

Andre Przywara Nov. 8, 2020, 1:14 p.m. UTC
Platforms can overwrite the weak definition of spl_mmc_boot_mode() to
determine where to load U-Boot proper from.
For most of them this is a trivial decision based on Kconfig variables,
but it might be desirable the probe the actual device to answer this
question.

Pass the pointer to the mmc struct to that function, so implementations
can make use of them.

Compile-tested for all users changed.

Cc: Stefano Babic <sbabic@denx.de>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: NXP i.MX U-Boot Team <uboot-imx@nxp.com>
Cc: Lokesh Vutla <lokeshvutla@ti.com>
Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
Cc: Kever Yang <kever.yang@rock-chips.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Cc: Ley Foon Tan <ley.foon.tan@intel.com>
Cc: Patrick Delaunay <patrick.delaunay@st.com>
Cc: Patrice Chotard <patrice.chotard@st.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 arch/arm/mach-imx/spl.c                | 2 +-
 arch/arm/mach-k3/am6_init.c            | 2 +-
 arch/arm/mach-k3/j721e_init.c          | 2 +-
 arch/arm/mach-omap2/boot-common.c      | 2 +-
 arch/arm/mach-rockchip/spl.c           | 2 +-
 arch/arm/mach-socfpga/spl_a10.c        | 2 +-
 arch/arm/mach-socfpga/spl_agilex.c     | 2 +-
 arch/arm/mach-socfpga/spl_gen5.c       | 2 +-
 arch/arm/mach-socfpga/spl_s10.c        | 2 +-
 arch/arm/mach-stm32mp/spl.c            | 2 +-
 arch/arm/mach-uniphier/mmc-boot-mode.c | 5 +----
 common/spl/spl_mmc.c                   | 4 ++--
 include/spl.h                          | 3 ++-
 13 files changed, 15 insertions(+), 17 deletions(-)

Comments

Stefano Babic Nov. 8, 2020, 1:56 p.m. UTC | #1
On 08.11.20 14:14, Andre Przywara wrote:
> Platforms can overwrite the weak definition of spl_mmc_boot_mode() to
> determine where to load U-Boot proper from.
> For most of them this is a trivial decision based on Kconfig variables,
> but it might be desirable the probe the actual device to answer this
> question.
> 
> Pass the pointer to the mmc struct to that function, so implementations
> can make use of them.
> 
> Compile-tested for all users changed.
> 
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP i.MX U-Boot Team <uboot-imx@nxp.com>
> Cc: Lokesh Vutla <lokeshvutla@ti.com>
> Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Cc: Ley Foon Tan <ley.foon.tan@intel.com>
> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
>  arch/arm/mach-imx/spl.c                | 2 +-
>  arch/arm/mach-k3/am6_init.c            | 2 +-
>  arch/arm/mach-k3/j721e_init.c          | 2 +-
>  arch/arm/mach-omap2/boot-common.c      | 2 +-
>  arch/arm/mach-rockchip/spl.c           | 2 +-
>  arch/arm/mach-socfpga/spl_a10.c        | 2 +-
>  arch/arm/mach-socfpga/spl_agilex.c     | 2 +-
>  arch/arm/mach-socfpga/spl_gen5.c       | 2 +-
>  arch/arm/mach-socfpga/spl_s10.c        | 2 +-
>  arch/arm/mach-stm32mp/spl.c            | 2 +-
>  arch/arm/mach-uniphier/mmc-boot-mode.c | 5 +----
>  common/spl/spl_mmc.c                   | 4 ++--
>  include/spl.h                          | 3 ++-
>  13 files changed, 15 insertions(+), 17 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
> index aa2686bb921..2cfedccfaf2 100644
> --- a/arch/arm/mach-imx/spl.c
> +++ b/arch/arm/mach-imx/spl.c
> @@ -197,7 +197,7 @@ int g_dnl_get_board_bcd_device_number(int gcnum)
>  
>  #if defined(CONFIG_SPL_MMC_SUPPORT)
>  /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  #if defined(CONFIG_MX7) || defined(CONFIG_IMX8M) || defined(CONFIG_IMX8)
>  	switch (get_boot_device()) {
> diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
> index 603834e5078..55328757a64 100644
> --- a/arch/arm/mach-k3/am6_init.c
> +++ b/arch/arm/mach-k3/am6_init.c
> @@ -252,7 +252,7 @@ void board_init_f(ulong dummy)
>  	spl_enable_dcache();
>  }
>  
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  #if defined(CONFIG_SUPPORT_EMMC_BOOT)
>  	u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT);
> diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
> index a36e4ed603b..97818a0be6d 100644
> --- a/arch/arm/mach-k3/j721e_init.c
> +++ b/arch/arm/mach-k3/j721e_init.c
> @@ -220,7 +220,7 @@ void board_init_f(ulong dummy)
>  	spl_enable_dcache();
>  }
>  
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  	switch (boot_device) {
>  	case BOOT_DEVICE_MMC1:
> diff --git a/arch/arm/mach-omap2/boot-common.c b/arch/arm/mach-omap2/boot-common.c
> index cb9d7fdb156..b65827668de 100644
> --- a/arch/arm/mach-omap2/boot-common.c
> +++ b/arch/arm/mach-omap2/boot-common.c
> @@ -188,7 +188,7 @@ u32 spl_boot_device(void)
>  	return gd->arch.omap_boot_device;
>  }
>  
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  	return gd->arch.omap_boot_mode;
>  }
> diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
> index f148d48b6a3..24c5f385e19 100644
> --- a/arch/arm/mach-rockchip/spl.c
> +++ b/arch/arm/mach-rockchip/spl.c
> @@ -64,7 +64,7 @@ u32 spl_boot_device(void)
>  	return boot_device;
>  }
>  
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  	return MMCSD_MODE_RAW;
>  }
> diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
> index 45aea4ab6cc..618ca898dd7 100644
> --- a/arch/arm/mach-socfpga/spl_a10.c
> +++ b/arch/arm/mach-socfpga/spl_a10.c
> @@ -93,7 +93,7 @@ u32 spl_boot_device(void)
>  }
>  
>  #ifdef CONFIG_SPL_MMC_SUPPORT
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
>  	return MMCSD_MODE_FS;
> diff --git a/arch/arm/mach-socfpga/spl_agilex.c b/arch/arm/mach-socfpga/spl_agilex.c
> index 78b5d7c8d98..fe4253b8e65 100644
> --- a/arch/arm/mach-socfpga/spl_agilex.c
> +++ b/arch/arm/mach-socfpga/spl_agilex.c
> @@ -30,7 +30,7 @@ u32 spl_boot_device(void)
>  }
>  
>  #ifdef CONFIG_SPL_MMC_SUPPORT
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
>  	return MMCSD_MODE_FS;
> diff --git a/arch/arm/mach-socfpga/spl_gen5.c b/arch/arm/mach-socfpga/spl_gen5.c
> index 5a7c5ef76d5..e526470aa15 100644
> --- a/arch/arm/mach-socfpga/spl_gen5.c
> +++ b/arch/arm/mach-socfpga/spl_gen5.c
> @@ -52,7 +52,7 @@ u32 spl_boot_device(void)
>  }
>  
>  #ifdef CONFIG_SPL_MMC_SUPPORT
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
>  	return MMCSD_MODE_FS;
> diff --git a/arch/arm/mach-socfpga/spl_s10.c b/arch/arm/mach-socfpga/spl_s10.c
> index daed05653ad..732c6f6d648 100644
> --- a/arch/arm/mach-socfpga/spl_s10.c
> +++ b/arch/arm/mach-socfpga/spl_s10.c
> @@ -32,7 +32,7 @@ u32 spl_boot_device(void)
>  }
>  
>  #ifdef CONFIG_SPL_MMC_SUPPORT
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
>  	return MMCSD_MODE_FS;
> diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c
> index b679b0a6454..85d394b55da 100644
> --- a/arch/arm/mach-stm32mp/spl.c
> +++ b/arch/arm/mach-stm32mp/spl.c
> @@ -50,7 +50,7 @@ u32 spl_boot_device(void)
>  	return BOOT_DEVICE_MMC1;
>  }
>  
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  	return MMCSD_MODE_RAW;
>  }
> diff --git a/arch/arm/mach-uniphier/mmc-boot-mode.c b/arch/arm/mach-uniphier/mmc-boot-mode.c
> index e47e5df6480..09cad743c55 100644
> --- a/arch/arm/mach-uniphier/mmc-boot-mode.c
> +++ b/arch/arm/mach-uniphier/mmc-boot-mode.c
> @@ -7,10 +7,8 @@
>  #include <mmc.h>
>  #include <spl.h>
>  
> -u32 spl_mmc_boot_mode(const u32 boot_device)
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
> -	struct mmc *mmc;
> -
>  	/*
>  	 * work around a bug in the Boot ROM of LD4, Pro4, and sLD8:
>  	 *
> @@ -24,7 +22,6 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
>  	 * Fixup mmc->part_config here because it is used to determine the
>  	 * partition which the U-Boot image is read from.
>  	 */
> -	mmc = find_mmc_device(0);
>  	mmc->part_config &= ~EXT_CSD_BOOT_PART_NUM(PART_ACCESS_MASK);
>  	mmc->part_config |= EXT_CSD_BOOT_PARTITION_ENABLE;
>  
> diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
> index add2785b4e3..309abaf961a 100644
> --- a/common/spl/spl_mmc.c
> +++ b/common/spl/spl_mmc.c
> @@ -300,7 +300,7 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc,
>  }
>  #endif
>  
> -u32 __weak spl_mmc_boot_mode(const u32 boot_device)
> +u32 __weak spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
>  {
>  #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
>  	return MMCSD_MODE_FS;
> @@ -351,7 +351,7 @@ int spl_mmc_load(struct spl_image_info *spl_image,
>  		}
>  	}
>  
> -	boot_mode = spl_mmc_boot_mode(bootdev->boot_device);
> +	boot_mode = spl_mmc_boot_mode(mmc, bootdev->boot_device);
>  	err = -EINVAL;
>  	switch (boot_mode) {
>  	case MMCSD_MODE_EMMCBOOT:
> diff --git a/include/spl.h b/include/spl.h
> index b72dfc7e3d4..d3b960ccffe 100644
> --- a/include/spl.h
> +++ b/include/spl.h
> @@ -14,6 +14,7 @@
>  #include <asm/global_data.h>
>  #include <asm/spl.h>
>  #include <handoff.h>
> +#include <mmc.h>
>  
>  struct blk_desc;
>  struct image_header;
> @@ -271,7 +272,7 @@ u32 spl_boot_device(void);
>   * Note:  It is important to use the boot_device parameter instead of e.g.
>   * spl_boot_device() as U-Boot is not always loaded from the same device as SPL.
>   */
> -u32 spl_mmc_boot_mode(const u32 boot_device);
> +u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device);
>  
>  /**
>   * spl_mmc_boot_partition() - MMC partition to load U-Boot from.
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Ley Foon Tan Nov. 9, 2020, 1:40 a.m. UTC | #2
> -----Original Message-----
> From: Andre Przywara <andre.przywara@arm.com>
> Sent: Sunday, November 8, 2020 9:14 PM
> To: Jagan Teki <jagan@amarulasolutions.com>
> Cc: Petr Štetiar <ynezz@true.cz>; Sunil Mohan Adapa <sunil@medhas.org>;
> Samuel Holland <samuel@sholland.org>; Aleksandr Aleksandrov
> <aleksandr.aleksandrov@emlid.com>; Icenowy Zheng <icenowy@aosc.io>;
> Simon Glass <sjg@chromium.org>; Tom Rini <trini@konsulko.com>; linux-
> sunxi@googlegroups.com; u-boot@lists.denx.de; Stefano Babic
> <sbabic@denx.de>; Fabio Estevam <festevam@gmail.com>; NXP i . MX U-
> Boot Team <uboot-imx@nxp.com>; Lokesh Vutla <lokeshvutla@ti.com>;
> Philipp Tomsich <philipp.tomsich@theobroma-systems.com>; Kever Yang
> <kever.yang@rock-chips.com>; Marek Vasut <marex@denx.de>; Simon
> Goldschmidt <simon.k.r.goldschmidt@gmail.com>; Tan, Ley Foon
> <ley.foon.tan@intel.com>; Patrick Delaunay <patrick.delaunay@st.com>;
> Patrice Chotard <patrice.chotard@st.com>; Andre Przywara
> <andre.przywara@arm.com>
> Subject: [PATCH 2/5] spl: mmc: extend spl_mmc_boot_mode() to take mmc
> argument
> 
> Platforms can overwrite the weak definition of spl_mmc_boot_mode() to
> determine where to load U-Boot proper from.
> For most of them this is a trivial decision based on Kconfig variables, but it
> might be desirable the probe the actual device to answer this question.
> 
> Pass the pointer to the mmc struct to that function, so implementations can
> make use of them.
> 
> Compile-tested for all users changed.
> 
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP i.MX U-Boot Team <uboot-imx@nxp.com>
> Cc: Lokesh Vutla <lokeshvutla@ti.com>
> Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Cc: Ley Foon Tan <ley.foon.tan@intel.com>
> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
>  arch/arm/mach-imx/spl.c                | 2 +-
>  arch/arm/mach-k3/am6_init.c            | 2 +-
>  arch/arm/mach-k3/j721e_init.c          | 2 +-
>  arch/arm/mach-omap2/boot-common.c      | 2 +-
>  arch/arm/mach-rockchip/spl.c           | 2 +-
>  arch/arm/mach-socfpga/spl_a10.c        | 2 +-
>  arch/arm/mach-socfpga/spl_agilex.c     | 2 +-
>  arch/arm/mach-socfpga/spl_gen5.c       | 2 +-
>  arch/arm/mach-socfpga/spl_s10.c        | 2 +-
>  arch/arm/mach-stm32mp/spl.c            | 2 +-
>  arch/arm/mach-uniphier/mmc-boot-mode.c | 5 +----
>  common/spl/spl_mmc.c                   | 4 ++--
>  include/spl.h                          | 3 ++-
>  13 files changed, 15 insertions(+), 17 deletions(-)
> 

For SoCFPGA,
Reviewed-by: Ley Foon Tan <ley.foon.tan@inte.com>

Regards
Ley Foon
Lokesh Vutla Nov. 9, 2020, 4:38 a.m. UTC | #3
On 08/11/20 6:44 pm, Andre Przywara wrote:
> Platforms can overwrite the weak definition of spl_mmc_boot_mode() to
> determine where to load U-Boot proper from.
> For most of them this is a trivial decision based on Kconfig variables,
> but it might be desirable the probe the actual device to answer this
> question.
> 
> Pass the pointer to the mmc struct to that function, so implementations
> can make use of them.
> 
> Compile-tested for all users changed.
> 
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Fabio Estevam <festevam@gmail.com>
> Cc: NXP i.MX U-Boot Team <uboot-imx@nxp.com>
> Cc: Lokesh Vutla <lokeshvutla@ti.com>
> Cc: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Cc: Kever Yang <kever.yang@rock-chips.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Cc: Ley Foon Tan <ley.foon.tan@intel.com>
> Cc: Patrick Delaunay <patrick.delaunay@st.com>
> Cc: Patrice Chotard <patrice.chotard@st.com>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>


For OMAP and K3

Acked-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index aa2686bb921..2cfedccfaf2 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -197,7 +197,7 @@  int g_dnl_get_board_bcd_device_number(int gcnum)
 
 #if defined(CONFIG_SPL_MMC_SUPPORT)
 /* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 #if defined(CONFIG_MX7) || defined(CONFIG_IMX8M) || defined(CONFIG_IMX8)
 	switch (get_boot_device()) {
diff --git a/arch/arm/mach-k3/am6_init.c b/arch/arm/mach-k3/am6_init.c
index 603834e5078..55328757a64 100644
--- a/arch/arm/mach-k3/am6_init.c
+++ b/arch/arm/mach-k3/am6_init.c
@@ -252,7 +252,7 @@  void board_init_f(ulong dummy)
 	spl_enable_dcache();
 }
 
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 #if defined(CONFIG_SUPPORT_EMMC_BOOT)
 	u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT);
diff --git a/arch/arm/mach-k3/j721e_init.c b/arch/arm/mach-k3/j721e_init.c
index a36e4ed603b..97818a0be6d 100644
--- a/arch/arm/mach-k3/j721e_init.c
+++ b/arch/arm/mach-k3/j721e_init.c
@@ -220,7 +220,7 @@  void board_init_f(ulong dummy)
 	spl_enable_dcache();
 }
 
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 	switch (boot_device) {
 	case BOOT_DEVICE_MMC1:
diff --git a/arch/arm/mach-omap2/boot-common.c b/arch/arm/mach-omap2/boot-common.c
index cb9d7fdb156..b65827668de 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -188,7 +188,7 @@  u32 spl_boot_device(void)
 	return gd->arch.omap_boot_device;
 }
 
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 	return gd->arch.omap_boot_mode;
 }
diff --git a/arch/arm/mach-rockchip/spl.c b/arch/arm/mach-rockchip/spl.c
index f148d48b6a3..24c5f385e19 100644
--- a/arch/arm/mach-rockchip/spl.c
+++ b/arch/arm/mach-rockchip/spl.c
@@ -64,7 +64,7 @@  u32 spl_boot_device(void)
 	return boot_device;
 }
 
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 	return MMCSD_MODE_RAW;
 }
diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c
index 45aea4ab6cc..618ca898dd7 100644
--- a/arch/arm/mach-socfpga/spl_a10.c
+++ b/arch/arm/mach-socfpga/spl_a10.c
@@ -93,7 +93,7 @@  u32 spl_boot_device(void)
 }
 
 #ifdef CONFIG_SPL_MMC_SUPPORT
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
 	return MMCSD_MODE_FS;
diff --git a/arch/arm/mach-socfpga/spl_agilex.c b/arch/arm/mach-socfpga/spl_agilex.c
index 78b5d7c8d98..fe4253b8e65 100644
--- a/arch/arm/mach-socfpga/spl_agilex.c
+++ b/arch/arm/mach-socfpga/spl_agilex.c
@@ -30,7 +30,7 @@  u32 spl_boot_device(void)
 }
 
 #ifdef CONFIG_SPL_MMC_SUPPORT
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
 	return MMCSD_MODE_FS;
diff --git a/arch/arm/mach-socfpga/spl_gen5.c b/arch/arm/mach-socfpga/spl_gen5.c
index 5a7c5ef76d5..e526470aa15 100644
--- a/arch/arm/mach-socfpga/spl_gen5.c
+++ b/arch/arm/mach-socfpga/spl_gen5.c
@@ -52,7 +52,7 @@  u32 spl_boot_device(void)
 }
 
 #ifdef CONFIG_SPL_MMC_SUPPORT
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
 	return MMCSD_MODE_FS;
diff --git a/arch/arm/mach-socfpga/spl_s10.c b/arch/arm/mach-socfpga/spl_s10.c
index daed05653ad..732c6f6d648 100644
--- a/arch/arm/mach-socfpga/spl_s10.c
+++ b/arch/arm/mach-socfpga/spl_s10.c
@@ -32,7 +32,7 @@  u32 spl_boot_device(void)
 }
 
 #ifdef CONFIG_SPL_MMC_SUPPORT
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
 	return MMCSD_MODE_FS;
diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c
index b679b0a6454..85d394b55da 100644
--- a/arch/arm/mach-stm32mp/spl.c
+++ b/arch/arm/mach-stm32mp/spl.c
@@ -50,7 +50,7 @@  u32 spl_boot_device(void)
 	return BOOT_DEVICE_MMC1;
 }
 
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 	return MMCSD_MODE_RAW;
 }
diff --git a/arch/arm/mach-uniphier/mmc-boot-mode.c b/arch/arm/mach-uniphier/mmc-boot-mode.c
index e47e5df6480..09cad743c55 100644
--- a/arch/arm/mach-uniphier/mmc-boot-mode.c
+++ b/arch/arm/mach-uniphier/mmc-boot-mode.c
@@ -7,10 +7,8 @@ 
 #include <mmc.h>
 #include <spl.h>
 
-u32 spl_mmc_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
-	struct mmc *mmc;
-
 	/*
 	 * work around a bug in the Boot ROM of LD4, Pro4, and sLD8:
 	 *
@@ -24,7 +22,6 @@  u32 spl_mmc_boot_mode(const u32 boot_device)
 	 * Fixup mmc->part_config here because it is used to determine the
 	 * partition which the U-Boot image is read from.
 	 */
-	mmc = find_mmc_device(0);
 	mmc->part_config &= ~EXT_CSD_BOOT_PART_NUM(PART_ACCESS_MASK);
 	mmc->part_config |= EXT_CSD_BOOT_PARTITION_ENABLE;
 
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index add2785b4e3..309abaf961a 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -300,7 +300,7 @@  static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc,
 }
 #endif
 
-u32 __weak spl_mmc_boot_mode(const u32 boot_device)
+u32 __weak spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 #if defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
 	return MMCSD_MODE_FS;
@@ -351,7 +351,7 @@  int spl_mmc_load(struct spl_image_info *spl_image,
 		}
 	}
 
-	boot_mode = spl_mmc_boot_mode(bootdev->boot_device);
+	boot_mode = spl_mmc_boot_mode(mmc, bootdev->boot_device);
 	err = -EINVAL;
 	switch (boot_mode) {
 	case MMCSD_MODE_EMMCBOOT:
diff --git a/include/spl.h b/include/spl.h
index b72dfc7e3d4..d3b960ccffe 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -14,6 +14,7 @@ 
 #include <asm/global_data.h>
 #include <asm/spl.h>
 #include <handoff.h>
+#include <mmc.h>
 
 struct blk_desc;
 struct image_header;
@@ -271,7 +272,7 @@  u32 spl_boot_device(void);
  * Note:  It is important to use the boot_device parameter instead of e.g.
  * spl_boot_device() as U-Boot is not always loaded from the same device as SPL.
  */
-u32 spl_mmc_boot_mode(const u32 boot_device);
+u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device);
 
 /**
  * spl_mmc_boot_partition() - MMC partition to load U-Boot from.