X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Fmmc.c;h=6f3cb85cc0417882aee889e60ef18385385a6f94;hb=dee74e6cc4a94da19b99309ad1c99eb5bddfe217;hp=68bbf1f51353e6ffa496e75e8ff2d96aea031252;hpb=c590e62d3b6f6dd72eae1183614f919e3fd7ffcb;p=oweals%2Fu-boot.git diff --git a/cmd/mmc.c b/cmd/mmc.c index 68bbf1f513..6f3cb85cc0 100644 --- 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[]) @@ -128,7 +137,7 @@ static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return CMD_RET_SUCCESS; } -#ifdef CONFIG_SUPPORT_EMMC_RPMB +#if CONFIG_IS_ENABLED(CMD_MMC_RPMB) static int confirm_key_prog(void) { puts("Warning: Programming authentication key can be done only once !\n" @@ -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); @@ -308,8 +317,7 @@ static int do_mmc_read(cmd_tbl_t *cmdtp, int flag, return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; } -#if CONFIG_IS_ENABLED(MMC_WRITE) -#if defined(CONFIG_FASTBOOT_FLASH) +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk, lbaint_t blkcnt, const void *buffer) { @@ -367,13 +375,14 @@ static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag, sparse.mssg = NULL; sprintf(dest, "0x" LBAF, sparse.start * sparse.blksz); - if (write_sparse_image(&sparse, dest, addr)) + if (write_sparse_image(&sparse, dest, addr, NULL)) return CMD_RET_FAILURE; else return CMD_RET_SUCCESS; } #endif +#if CONFIG_IS_ENABLED(MMC_WRITE) static int do_mmc_write(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { @@ -868,10 +877,10 @@ static cmd_tbl_t cmd_mmc[] = { U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""), #if CONFIG_IS_ENABLED(MMC_WRITE) U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""), -#if defined(CONFIG_FASTBOOT_FLASH) - U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), -#endif U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""), +#endif +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) + U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), #endif U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""), U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""), @@ -886,7 +895,7 @@ static cmd_tbl_t cmd_mmc[] = { U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""), U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""), #endif -#ifdef CONFIG_SUPPORT_EMMC_RPMB +#if CONFIG_IS_ENABLED(CMD_MMC_RPMB) U_BOOT_CMD_MKENT(rpmb, CONFIG_SYS_MAXARGS, 1, do_mmcrpmb, "", ""), #endif U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""), @@ -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) { @@ -927,7 +936,7 @@ U_BOOT_CMD( "info - display info of the current MMC device\n" "mmc read addr blk# cnt\n" "mmc write addr blk# cnt\n" -#if defined(CONFIG_FASTBOOT_FLASH) +#if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) "mmc swrite addr blk#\n" #endif "mmc erase blk# cnt\n" @@ -935,6 +944,7 @@ U_BOOT_CMD( "mmc part - lists available partition on current mmc device\n" "mmc dev [dev] [part] - show or set current mmc device [partition]\n" "mmc list - lists available devices\n" +#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) "mmc hwpartition [args...] - does hardware partitioning\n" " arguments (sizes in 512-byte blocks):\n" " [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes\n" @@ -942,6 +952,7 @@ U_BOOT_CMD( " [check|set|complete] - mode, complete set partitioning completed\n" " WARNING: Partitioning is a write-once setting once it is set to complete.\n" " Power cycling is required to initialize partitions after set to complete.\n" +#endif #ifdef CONFIG_SUPPORT_EMMC_BOOT "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n" " - Set the BOOT_BUS_WIDTH field of the specified device\n" @@ -953,7 +964,7 @@ U_BOOT_CMD( " - Change the RST_n_FUNCTION field of the specified device\n" " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n" #endif -#ifdef CONFIG_SUPPORT_EMMC_RPMB +#if CONFIG_IS_ENABLED(CMD_MMC_RPMB) "mmc rpmb read addr blk# cnt [address of auth-key] - block size is 256 bytes\n" "mmc rpmb write addr blk# cnt
- block size is 256 bytes\n" "mmc rpmb key
- program the RPMB authentication key.\n"