spl: eMMC/SD: Provide one __weak spl_boot_mode() function
authorLukasz Majewski <lukma@denx.de>
Sat, 3 Feb 2018 07:29:52 +0000 (08:29 +0100)
committerTom Rini <trini@konsulko.com>
Thu, 8 Feb 2018 03:06:18 +0000 (22:06 -0500)
The goal of this patch is to clean up the code related to choosing SPL
MMC boot mode.

The spl_boot_mode() now is called only in spl_mmc_load_image() function,
which is only compiled in if CONFIG_SPL_MMC_SUPPORT is enabled.

To achieve the goal, all per mach/arch implementations eligible for
unification has been replaced with one __weak implementation.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Stefano Babic <sbabic@denx.de>
Acked-by: Michal Simek <michal.simek@xilinx.com> (For ZynqMP)
Reviewed-by: Fabio Estevam <fabio.estevam@nxp.com>
16 files changed:
arch/arm/cpu/arm1136/mx35/generic.c
arch/arm/cpu/armv7/ls102xa/spl.c
arch/arm/cpu/armv8/fsl-layerscape/spl.c
arch/arm/cpu/armv8/zynqmp/spl.c
arch/arm/mach-at91/spl.c
arch/arm/mach-davinci/spl.c
arch/arm/mach-imx/spl.c
arch/arm/mach-mvebu/spl.c
arch/arm/mach-rockchip/rk3188-board-spl.c
arch/arm/mach-rockchip/rk3288-board-spl.c
arch/arm/mach-rockchip/rk3368-board-spl.c
arch/arm/mach-rockchip/rk3399-board-spl.c
arch/arm/mach-socfpga/spl.c
arch/arm/mach-sunxi/board.c
arch/arm/mach-zynq/spl.c
common/spl/spl_mmc.c

index 5297d62d00021783a12daf0a161739ea716893d4..4dcfc7265612bd86a2a7b24325af850f505d74cc 100644 (file)
@@ -524,24 +524,3 @@ u32 spl_boot_device(void)
 
        return BOOT_DEVICE_NONE;
 }
-
-#ifdef CONFIG_SPL_BUILD
-u32 spl_boot_mode(const u32 boot_device)
-{
-       switch (spl_boot_device()) {
-       case BOOT_DEVICE_MMC1:
-#ifdef CONFIG_SPL_FAT_SUPPORT
-               return MMCSD_MODE_FS;
-#else
-               return MMCSD_MODE_RAW;
-#endif
-               break;
-       case BOOT_DEVICE_NAND:
-               return 0;
-               break;
-       default:
-               puts("spl: ERROR:  unsupported device\n");
-               hang();
-       }
-}
-#endif
index 1246eed2ca006606d6bddce500f7458d86831dfa..1e4a1641cb95f8fd13b0147641a28356269de566 100644 (file)
@@ -14,20 +14,3 @@ u32 spl_boot_device(void)
 #endif
        return BOOT_DEVICE_NAND;
 }
-
-u32 spl_boot_mode(const u32 boot_device)
-{
-       switch (spl_boot_device()) {
-       case BOOT_DEVICE_MMC1:
-#ifdef CONFIG_SPL_FAT_SUPPORT
-               return MMCSD_MODE_FS;
-#else
-               return MMCSD_MODE_RAW;
-#endif
-       case BOOT_DEVICE_NAND:
-               return 0;
-       default:
-               puts("spl: error: unsupported device\n");
-               hang();
-       }
-}
index 4093d15e56983d864564ed7000526b4db8a8fe86..3a74040b9747f096057e9f7206c3dcebace0778d 100644 (file)
@@ -26,23 +26,6 @@ u32 spl_boot_device(void)
        return 0;
 }
 
-u32 spl_boot_mode(const u32 boot_device)
-{
-       switch (spl_boot_device()) {
-       case BOOT_DEVICE_MMC1:
-#ifdef CONFIG_SPL_FAT_SUPPORT
-               return MMCSD_MODE_FS;
-#else
-               return MMCSD_MODE_RAW;
-#endif
-       case BOOT_DEVICE_NAND:
-               return 0;
-       default:
-               puts("spl: error: unsupported device\n");
-               hang();
-       }
-}
-
 #ifdef CONFIG_SPL_BUILD
 
 void spl_board_init(void)
index bc7313a88bd02303d77f3c97558f8d1a83301a84..0bfa5c1c4dd88d9d7fe9acdd564d3b5a75c3387a 100644 (file)
@@ -115,20 +115,6 @@ u32 spl_boot_device(void)
        return 0;
 }
 
-u32 spl_boot_mode(const u32 boot_device)
-{
-       switch (boot_device) {
-       case BOOT_DEVICE_RAM:
-               return 0;
-       case BOOT_DEVICE_MMC1:
-       case BOOT_DEVICE_MMC2:
-               return MMCSD_MODE_FS;
-       default:
-               puts("spl: error: unsupported device\n");
-               hang();
-       }
-}
-
 #ifdef CONFIG_SPL_OS_BOOT
 int spl_start_uboot(void)
 {
index 7e7e24bbe69d038d195d89616357dc02976d8a40..91add921c65d45e6cf5fc88672f48e0232f84d30 100644 (file)
@@ -87,18 +87,3 @@ u32 spl_boot_device(void)
        return BOOT_DEVICE_NONE;
 }
 #endif
-
-u32 spl_boot_mode(const u32 boot_device)
-{
-       switch (boot_device) {
-#if defined(CONFIG_SYS_USE_MMC) || defined(CONFIG_SD_BOOT)
-       case BOOT_DEVICE_MMC1:
-       case BOOT_DEVICE_MMC2:
-               return MMCSD_MODE_FS;
-               break;
-#endif
-       case BOOT_DEVICE_NONE:
-       default:
-               hang();
-       }
-}
index 564c2008e003f39480de64ad4887c877c34a117a..4c74db9ed03c5e84830237a4b9ab01436d3609ba 100644 (file)
@@ -45,11 +45,6 @@ void spl_board_init(void)
        preloader_console_init();
 }
 
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_RAW;
-}
-
 u32 spl_boot_device(void)
 {
        switch (davinci_syscfg_regs->bootcfg) {
index b2521b2101ccd72334f24b01955d104113549bc1..a9079fceac8d6a7d8f88999306ad4f90feb45526 100644 (file)
@@ -132,29 +132,6 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
 }
 #endif
 
-#if defined(CONFIG_SPL_MMC_SUPPORT)
-/* called from spl_mmc to see type of boot mode for storage (RAW or FAT) */
-u32 spl_boot_mode(const u32 boot_device)
-{
-       switch (spl_boot_device()) {
-       /* for MMC return either RAW or FAT mode */
-       case BOOT_DEVICE_MMC1:
-       case BOOT_DEVICE_MMC2:
-#if defined(CONFIG_SPL_FAT_SUPPORT)
-               return MMCSD_MODE_FS;
-#elif defined(CONFIG_SUPPORT_EMMC_BOOT)
-               return MMCSD_MODE_EMMCBOOT;
-#else
-               return MMCSD_MODE_RAW;
-#endif
-               break;
-       default:
-               puts("spl: ERROR:  unsupported device\n");
-               hang();
-       }
-}
-#endif
-
 #if defined(CONFIG_SECURE_BOOT)
 
 /*
index d16a62d2dd32f8d8d51369c664d1716b770f2c08..a5086f16fb2ecb0fb51f4d797a2acea06c4216fb 100644 (file)
@@ -70,13 +70,6 @@ u32 spl_boot_device(void)
        return get_boot_device();
 }
 
-#ifdef CONFIG_SPL_MMC_SUPPORT
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_RAW;
-}
-#endif
-
 void board_init_f(ulong dummy)
 {
        int ret;
index 8e3b8ae3bafdc5df540f81855ff853b1d8a12103..74771d3a0b04f33a08d2d4c46f20d115c589ec70 100644 (file)
@@ -72,11 +72,6 @@ fallback:
        return BOOT_DEVICE_MMC1;
 }
 
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_RAW;
-}
-
 static int setup_arm_clock(void)
 {
        struct udevice *dev;
index f64a54843f722594e2692c004a390687b9aa7103..f3ea6242773a8872a5c67176b6655975ffcf1eb6 100644 (file)
@@ -78,11 +78,6 @@ fallback:
        return BOOT_DEVICE_MMC1;
 }
 
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_RAW;
-}
-
 #ifdef CONFIG_SPL_MMC_SUPPORT
 static int configure_emmc(struct udevice *pinctrl)
 {
index 72d2c97d36367a8df193feb4a9f01344a095501d..8055ae538f1890f4aa114dad55da0fed62100057 100644 (file)
@@ -57,11 +57,6 @@ void board_init_f(ulong dummy)
        }
 }
 
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_RAW;
-}
-
 u32 spl_boot_device(void)
 {
        return BOOT_DEVICE_MMC1;
index b96903e70fa8c40fd465b080ceb92c2007cd04c4..d35990efd65198b12ef99bf94e523f7a65b3aab8 100644 (file)
@@ -60,11 +60,6 @@ u32 spl_boot_device(void)
        return boot_device;
 }
 
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_RAW;
-}
-
 #define TIMER_CHN10_BASE       0xff8680a0
 #define TIMER_END_COUNT_L      0x00
 #define TIMER_END_COUNT_H      0x04
index 71bae827a15b3b07df8594c82912da0db33d790b..9bf3b9a446a1840a6052684f35c755cc9c3b2ba5 100644 (file)
@@ -66,17 +66,6 @@ u32 spl_boot_device(void)
        }
 }
 
-#ifdef CONFIG_SPL_MMC_SUPPORT
-u32 spl_boot_mode(const u32 boot_device)
-{
-#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
-       return MMCSD_MODE_FS;
-#else
-       return MMCSD_MODE_RAW;
-#endif
-}
-#endif
-
 #if defined(CONFIG_TARGET_SOCFPGA_GEN5)
 static void socfpga_nic301_slave_ns(void)
 {
index 0c60ee04da54f1da84645bfb44243dd67ca05dec..1753faec1d9b7887d80bf93231b5ed92faab4eed 100644 (file)
@@ -260,12 +260,6 @@ u32 spl_boot_device(void)
        return sunxi_get_boot_device();
 }
 
-/* No confirmation data available in SPL yet. Hardcode bootmode */
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_RAW;
-}
-
 void board_init_f(ulong dummy)
 {
        spl_init();
index b7e6d98f0858e1da8705dd11512898463755df16..0a303f41ebdfb606f92f993facdde7761d79f07c 100644 (file)
@@ -69,13 +69,6 @@ u32 spl_boot_device(void)
        return mode;
 }
 
-#ifdef CONFIG_SPL_MMC_SUPPORT
-u32 spl_boot_mode(const u32 boot_device)
-{
-       return MMCSD_MODE_FS;
-}
-#endif
-
 #ifdef CONFIG_SPL_OS_BOOT
 int spl_start_uboot(void)
 {
index b57e0b04e46a3174a5ccead5c2489eb9c2ade1f0..351f4edd41e4ed52e8970cadcfc44f69a59e0037 100644 (file)
@@ -281,6 +281,17 @@ static int spl_mmc_do_fs_boot(struct spl_image_info *spl_image, struct mmc *mmc)
 }
 #endif
 
+u32 __weak spl_boot_mode(const u32 boot_device)
+{
+#if defined(CONFIG_SPL_FAT_SUPPORT) || defined(CONFIG_SPL_EXT_SUPPORT)
+       return MMCSD_MODE_FS;
+#elif defined(CONFIG_SUPPORT_EMMC_BOOT)
+       return MMCSD_MODE_EMMCBOOT;
+#else
+       return MMCSD_MODE_RAW;
+#endif
+}
+
 int spl_mmc_load_image(struct spl_image_info *spl_image,
                       struct spl_boot_device *bootdev)
 {