board:samsung: check the boot device and init the right mmc driver.
authorPrzemyslaw Marczak <p.marczak@samsung.com>
Mon, 23 Jun 2014 11:13:40 +0000 (13:13 +0200)
committerPrzemyslaw Marczak <p.marczak@samsung.com>
Wed, 6 Aug 2014 12:10:24 +0000 (14:10 +0200)
It is possible to boot device using a micro SD or eMMC slots.
In this situation, boot device should be registered as a block
device 0 in the MMC framework, because CONFIG_SYS_MMC_ENV_DEV
is usually set to "0" in the most config cases.

Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com>
Change-Id: I39c654005138824c8acdfe4458f5f45294c902fe
---
Changes V3:
- separate two changes into two commits

Changes V4:
- board.c: add functions: init_mmc() and init_dwmmc()
- board_mmc_init(): call get_boot_mode()

Changes V5:
- none

Changes V6:
- update boot mode name

board/samsung/common/board.c

index 9dc7c832e6e370fc1f0b33053c874c486c5d2561..1fa0e51b3e646220fbd5587a38bd538f243267da 100644 (file)
@@ -240,22 +240,39 @@ int board_eth_init(bd_t *bis)
 }
 
 #ifdef CONFIG_GENERIC_MMC
-int board_mmc_init(bd_t *bis)
+static int init_mmc(void)
+{
+#ifdef CONFIG_SDHCI
+       return exynos_mmc_init(gd->fdt_blob);
+#else
+       return 0;
+#endif
+}
+
+static int init_dwmmc(void)
 {
-       int ret;
 #ifdef CONFIG_DWMMC
-       /* dwmmc initializattion for available channels */
-       ret = exynos_dwmmc_init(gd->fdt_blob);
-       if (ret)
-               debug("dwmmc init failed\n");
+       return exynos_dwmmc_init(gd->fdt_blob);
+#else
+       return 0;
 #endif
+}
+
+int board_mmc_init(bd_t *bis)
+{
+       int ret;
+
+       if (get_boot_mode() == BOOT_MODE_SD) {
+               ret = init_mmc();
+               ret |= init_dwmmc();
+       } else {
+               ret = init_dwmmc();
+               ret |= init_mmc();
+       }
 
-#ifdef CONFIG_SDHCI
-       /* mmc initializattion for available channels */
-       ret = exynos_mmc_init(gd->fdt_blob);
        if (ret)
                debug("mmc init failed\n");
-#endif
+
        return ret;
 }
 #endif