]> git.sur5r.net Git - u-boot/commitdiff
dm: mmc: Allow driver model to be used for MMC in SPL
authorSimon Glass <sjg@chromium.org>
Tue, 23 Jun 2015 21:38:51 +0000 (15:38 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 21 Jul 2015 23:39:25 +0000 (17:39 -0600)
Enable MMC using driver model in SPL for consistency with U-Boot proper.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/spl/spl_mmc.c

index 51add39f7ebac44ba9ee3d8f48fbc8ccef622f0a..5f1cfbf98e97daf107d0e07a649534534d153423 100644 (file)
@@ -7,6 +7,7 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
+#include <dm.h>
 #include <spl.h>
 #include <linux/compiler.h>
 #include <asm/u-boot.h>
@@ -101,9 +102,18 @@ void spl_mmc_load_image(void)
 {
        struct mmc *mmc;
        u32 boot_mode;
-       int err;
+       int err = 0;
        __maybe_unused int part;
 
+#ifdef CONFIG_DM_MMC
+       struct udevice *dev;
+
+       mmc_initialize(NULL);
+       err = uclass_get_device(UCLASS_MMC, 0, &dev);
+       mmc = NULL;
+       if (!err)
+               mmc = mmc_get_mmc_dev(dev);
+#else
        mmc_initialize(gd->bd);
 
        /* We register only one device. So, the dev id is always 0 */
@@ -114,8 +124,11 @@ void spl_mmc_load_image(void)
 #endif
                hang();
        }
+#endif
+
+       if (!err)
+               err = mmc_init(mmc);
 
-       err = mmc_init(mmc);
        if (err) {
 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
                printf("spl: mmc init failed with error: %d\n", err);