Merge https://gitlab.denx.de/u-boot/custodians/u-boot-x86
[oweals/u-boot.git] / cmd / mmc.c
index 3920a1836a594903116841f809676f34ff022061..1860a3f2e5dd223b02b335445dc1dcaacae01899 100644 (file)
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -26,7 +26,7 @@ static void print_mmcinfo(struct mmc *mmc)
 
        printf("Bus Speed: %d\n", mmc->clock);
 #if CONFIG_IS_ENABLED(MMC_VERBOSE)
-       printf("Mode : %s\n", mmc_mode_name(mmc->selected_mode));
+       printf("Mode: %s\n", mmc_mode_name(mmc->selected_mode));
        mmc_dump_capabilities("card capabilities", mmc->card_caps);
        mmc_dump_capabilities("host capabilities", mmc->host_caps);
 #endif
@@ -101,10 +101,19 @@ static struct mmc *init_mmc_device(int dev, bool force_init)
                return NULL;
        }
 
+       if (!mmc_getcd(mmc))
+               force_init = true;
+
        if (force_init)
                mmc->has_init = 0;
        if (mmc_init(mmc))
                return NULL;
+
+#ifdef CONFIG_BLOCK_CACHE
+       struct blk_desc *bd = mmc_get_blk_desc(mmc);
+       blkcache_invalidate(bd->if_type, bd->devnum);
+#endif
+
        return mmc;
 }
 static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -247,7 +256,7 @@ static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag,
 
        if (cp == NULL || argc > cp->maxargs)
                return CMD_RET_USAGE;
-       if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
+       if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp))
                return CMD_RET_SUCCESS;
 
        mmc = init_mmc_device(curr_device, false);
@@ -255,7 +264,7 @@ static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag,
                return CMD_RET_FAILURE;
 
        if (!(mmc->version & MMC_VERSION_MMC)) {
-               printf("It is not a EMMC device\n");
+               printf("It is not an eMMC device\n");
                return CMD_RET_FAILURE;
        }
        if (mmc->version < MMC_VERSION_4_41) {
@@ -709,7 +718,7 @@ static int do_mmc_boot_resize(cmd_tbl_t *cmdtp, int flag,
                return CMD_RET_FAILURE;
 
        if (IS_SD(mmc)) {
-               printf("It is not a EMMC device\n");
+               printf("It is not an eMMC device\n");
                return CMD_RET_FAILURE;
        }
 
@@ -907,7 +916,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
        if (cp == NULL || argc > cp->maxargs)
                return CMD_RET_USAGE;
-       if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
+       if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp))
                return CMD_RET_SUCCESS;
 
        if (curr_device < 0) {