Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2003 |
| 4 | * Kyle Harris, kharris@nexus-tech.net |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | e6f6f9e | 2020-05-10 11:39:58 -0600 | [diff] [blame^] | 8 | #include <blk.h> |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 9 | #include <command.h> |
Simon Glass | 24b852a | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 10 | #include <console.h> |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 11 | #include <mmc.h> |
Simon Glass | e6f6f9e | 2020-05-10 11:39:58 -0600 | [diff] [blame^] | 12 | #include <part.h> |
Jassi Brar | 732bc7c | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 13 | #include <sparse_format.h> |
| 14 | #include <image-sparse.h> |
wdenk | 71f9511 | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 15 | |
Mike Frysinger | 02e22c2 | 2009-06-14 21:35:21 -0400 | [diff] [blame] | 16 | static int curr_device = -1; |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 17 | |
| 18 | static void print_mmcinfo(struct mmc *mmc) |
| 19 | { |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 20 | int i; |
| 21 | |
Pantelis Antoniou | 93bfd61 | 2014-03-11 19:34:20 +0200 | [diff] [blame] | 22 | printf("Device: %s\n", mmc->cfg->name); |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 23 | printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24); |
| 24 | printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff); |
| 25 | printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff, |
| 26 | (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, |
| 27 | (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff); |
| 28 | |
Jean-Jacques Hiblot | 7a96ec7 | 2017-09-21 16:29:56 +0200 | [diff] [blame] | 29 | printf("Bus Speed: %d\n", mmc->clock); |
Jean-Jacques Hiblot | 52d241d | 2017-11-30 17:43:54 +0100 | [diff] [blame] | 30 | #if CONFIG_IS_ENABLED(MMC_VERBOSE) |
Marek Vasut | 41e30dc | 2019-03-18 04:49:21 +0100 | [diff] [blame] | 31 | printf("Mode: %s\n", mmc_mode_name(mmc->selected_mode)); |
Jean-Jacques Hiblot | 52d241d | 2017-11-30 17:43:54 +0100 | [diff] [blame] | 32 | mmc_dump_capabilities("card capabilities", mmc->card_caps); |
| 33 | mmc_dump_capabilities("host capabilities", mmc->host_caps); |
| 34 | #endif |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 35 | printf("Rd Block Len: %d\n", mmc->read_bl_len); |
| 36 | |
Pantelis Antoniou | 4b7cee5 | 2015-01-23 12:12:01 +0200 | [diff] [blame] | 37 | printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC", |
| 38 | EXTRACT_SDMMC_MAJOR_VERSION(mmc->version), |
| 39 | EXTRACT_SDMMC_MINOR_VERSION(mmc->version)); |
| 40 | if (EXTRACT_SDMMC_CHANGE_VERSION(mmc->version) != 0) |
| 41 | printf(".%d", EXTRACT_SDMMC_CHANGE_VERSION(mmc->version)); |
| 42 | printf("\n"); |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 43 | |
| 44 | printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No"); |
Minkyu Kang | 940e078 | 2011-01-04 01:04:19 +0000 | [diff] [blame] | 45 | puts("Capacity: "); |
| 46 | print_size(mmc->capacity, "\n"); |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 47 | |
Andrew Gabbasov | 786e8f8 | 2014-12-01 06:59:09 -0600 | [diff] [blame] | 48 | printf("Bus Width: %d-bit%s\n", mmc->bus_width, |
| 49 | mmc->ddr_mode ? " DDR" : ""); |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 50 | |
Jean-Jacques Hiblot | e6fa5a5 | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 51 | #if CONFIG_IS_ENABLED(MMC_WRITE) |
Diego Santa Cruz | b036152 | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 52 | puts("Erase Group Size: "); |
| 53 | print_size(((u64)mmc->erase_grp_size) << 9, "\n"); |
Jean-Jacques Hiblot | e6fa5a5 | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 54 | #endif |
Diego Santa Cruz | b036152 | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 55 | |
Diego Santa Cruz | 525ada2 | 2014-12-23 10:50:19 +0100 | [diff] [blame] | 56 | if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) { |
Diego Santa Cruz | c3dbb4f | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 57 | bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0; |
Diego Santa Cruz | beb98a1 | 2014-12-23 10:50:23 +0100 | [diff] [blame] | 58 | bool usr_enh = has_enh && (mmc->part_attr & EXT_CSD_ENH_USR); |
Heinrich Schuchardt | d5210e4 | 2020-03-30 07:24:18 +0200 | [diff] [blame] | 59 | u8 wp, ext_csd[MMC_MAX_BLOCK_LEN]; |
| 60 | int ret; |
Diego Santa Cruz | b036152 | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 61 | |
Jean-Jacques Hiblot | b7a6e2c | 2018-01-04 15:23:36 +0100 | [diff] [blame] | 62 | #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) |
Diego Santa Cruz | b036152 | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 63 | puts("HC WP Group Size: "); |
| 64 | print_size(((u64)mmc->hc_wp_grp_size) << 9, "\n"); |
Jean-Jacques Hiblot | b7a6e2c | 2018-01-04 15:23:36 +0100 | [diff] [blame] | 65 | #endif |
Diego Santa Cruz | b036152 | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 66 | |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 67 | puts("User Capacity: "); |
Diego Santa Cruz | 9e41a00 | 2014-12-23 10:50:33 +0100 | [diff] [blame] | 68 | print_size(mmc->capacity_user, usr_enh ? " ENH" : ""); |
| 69 | if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_USR) |
| 70 | puts(" WRREL\n"); |
| 71 | else |
| 72 | putc('\n'); |
Diego Santa Cruz | beb98a1 | 2014-12-23 10:50:23 +0100 | [diff] [blame] | 73 | if (usr_enh) { |
| 74 | puts("User Enhanced Start: "); |
| 75 | print_size(mmc->enh_user_start, "\n"); |
| 76 | puts("User Enhanced Size: "); |
| 77 | print_size(mmc->enh_user_size, "\n"); |
| 78 | } |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 79 | puts("Boot Capacity: "); |
Diego Santa Cruz | c3dbb4f | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 80 | print_size(mmc->capacity_boot, has_enh ? " ENH\n" : "\n"); |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 81 | puts("RPMB Capacity: "); |
Diego Santa Cruz | c3dbb4f | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 82 | print_size(mmc->capacity_rpmb, has_enh ? " ENH\n" : "\n"); |
Diego Santa Cruz | b036152 | 2014-12-23 10:50:26 +0100 | [diff] [blame] | 83 | |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 84 | for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) { |
Diego Santa Cruz | c3dbb4f | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 85 | bool is_enh = has_enh && |
| 86 | (mmc->part_attr & EXT_CSD_ENH_GP(i)); |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 87 | if (mmc->capacity_gp[i]) { |
Diego Santa Cruz | f289fd7 | 2014-12-23 10:50:18 +0100 | [diff] [blame] | 88 | printf("GP%i Capacity: ", i+1); |
Diego Santa Cruz | c3dbb4f | 2014-12-23 10:50:17 +0100 | [diff] [blame] | 89 | print_size(mmc->capacity_gp[i], |
Diego Santa Cruz | 9e41a00 | 2014-12-23 10:50:33 +0100 | [diff] [blame] | 90 | is_enh ? " ENH" : ""); |
| 91 | if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_GP(i)) |
| 92 | puts(" WRREL\n"); |
| 93 | else |
| 94 | putc('\n'); |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 95 | } |
| 96 | } |
Heinrich Schuchardt | d5210e4 | 2020-03-30 07:24:18 +0200 | [diff] [blame] | 97 | ret = mmc_send_ext_csd(mmc, ext_csd); |
| 98 | if (ret) |
| 99 | return; |
| 100 | wp = ext_csd[EXT_CSD_BOOT_WP_STATUS]; |
| 101 | for (i = 0; i < 2; ++i) { |
| 102 | printf("Boot area %d is ", i); |
| 103 | switch (wp & 3) { |
| 104 | case 0: |
| 105 | printf("not write protected\n"); |
| 106 | break; |
| 107 | case 1: |
| 108 | printf("power on protected\n"); |
| 109 | break; |
| 110 | case 2: |
| 111 | printf("permanently protected\n"); |
| 112 | break; |
| 113 | default: |
| 114 | printf("in reserved protection state\n"); |
| 115 | break; |
| 116 | } |
| 117 | wp >>= 2; |
| 118 | } |
Diego Santa Cruz | c5f0d3f | 2014-12-23 10:50:16 +0100 | [diff] [blame] | 119 | } |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 120 | } |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 121 | static struct mmc *init_mmc_device(int dev, bool force_init) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 122 | { |
| 123 | struct mmc *mmc; |
| 124 | mmc = find_mmc_device(dev); |
| 125 | if (!mmc) { |
| 126 | printf("no mmc device at slot %x\n", dev); |
| 127 | return NULL; |
| 128 | } |
Eric Nelson | bcfde7f | 2016-03-27 12:00:14 -0700 | [diff] [blame] | 129 | |
Marek Vasut | d2a0836 | 2019-01-03 22:09:43 +0100 | [diff] [blame] | 130 | if (!mmc_getcd(mmc)) |
| 131 | force_init = true; |
| 132 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 133 | if (force_init) |
| 134 | mmc->has_init = 0; |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 135 | if (mmc_init(mmc)) |
| 136 | return NULL; |
Marek Vasut | 1d044d3 | 2019-01-03 22:09:44 +0100 | [diff] [blame] | 137 | |
| 138 | #ifdef CONFIG_BLOCK_CACHE |
| 139 | struct blk_desc *bd = mmc_get_blk_desc(mmc); |
| 140 | blkcache_invalidate(bd->if_type, bd->devnum); |
| 141 | #endif |
| 142 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 143 | return mmc; |
| 144 | } |
Kim Phillips | 088f1b1 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 145 | static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 146 | { |
| 147 | struct mmc *mmc; |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 148 | |
Lei Wen | ea6ebe2 | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 149 | if (curr_device < 0) { |
| 150 | if (get_mmc_num() > 0) |
| 151 | curr_device = 0; |
| 152 | else { |
| 153 | puts("No MMC device available\n"); |
| 154 | return 1; |
| 155 | } |
| 156 | } |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 157 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 158 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 159 | if (!mmc) |
| 160 | return CMD_RET_FAILURE; |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 161 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 162 | print_mmcinfo(mmc); |
| 163 | return CMD_RET_SUCCESS; |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 164 | } |
| 165 | |
Alex Kiernan | 5a7b11e | 2018-05-08 04:43:31 +0000 | [diff] [blame] | 166 | #if CONFIG_IS_ENABLED(CMD_MMC_RPMB) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 167 | static int confirm_key_prog(void) |
| 168 | { |
| 169 | puts("Warning: Programming authentication key can be done only once !\n" |
| 170 | " Use this command only if you are sure of what you are doing,\n" |
| 171 | "Really perform the key programming? <y/N> "); |
| 172 | if (confirm_yesno()) |
| 173 | return 1; |
| 174 | |
| 175 | puts("Authentication key programming aborted\n"); |
| 176 | return 0; |
| 177 | } |
| 178 | static int do_mmcrpmb_key(cmd_tbl_t *cmdtp, int flag, |
| 179 | int argc, char * const argv[]) |
| 180 | { |
| 181 | void *key_addr; |
| 182 | struct mmc *mmc = find_mmc_device(curr_device); |
| 183 | |
| 184 | if (argc != 2) |
| 185 | return CMD_RET_USAGE; |
| 186 | |
| 187 | key_addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 188 | if (!confirm_key_prog()) |
| 189 | return CMD_RET_FAILURE; |
| 190 | if (mmc_rpmb_set_key(mmc, key_addr)) { |
| 191 | printf("ERROR - Key already programmed ?\n"); |
| 192 | return CMD_RET_FAILURE; |
| 193 | } |
| 194 | return CMD_RET_SUCCESS; |
| 195 | } |
| 196 | static int do_mmcrpmb_read(cmd_tbl_t *cmdtp, int flag, |
| 197 | int argc, char * const argv[]) |
| 198 | { |
| 199 | u16 blk, cnt; |
| 200 | void *addr; |
| 201 | int n; |
| 202 | void *key_addr = NULL; |
| 203 | struct mmc *mmc = find_mmc_device(curr_device); |
| 204 | |
| 205 | if (argc < 4) |
| 206 | return CMD_RET_USAGE; |
| 207 | |
| 208 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 209 | blk = simple_strtoul(argv[2], NULL, 16); |
| 210 | cnt = simple_strtoul(argv[3], NULL, 16); |
| 211 | |
| 212 | if (argc == 5) |
| 213 | key_addr = (void *)simple_strtoul(argv[4], NULL, 16); |
| 214 | |
| 215 | printf("\nMMC RPMB read: dev # %d, block # %d, count %d ... ", |
| 216 | curr_device, blk, cnt); |
| 217 | n = mmc_rpmb_read(mmc, addr, blk, cnt, key_addr); |
| 218 | |
| 219 | printf("%d RPMB blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 220 | if (n != cnt) |
| 221 | return CMD_RET_FAILURE; |
| 222 | return CMD_RET_SUCCESS; |
| 223 | } |
| 224 | static int do_mmcrpmb_write(cmd_tbl_t *cmdtp, int flag, |
| 225 | int argc, char * const argv[]) |
| 226 | { |
| 227 | u16 blk, cnt; |
| 228 | void *addr; |
| 229 | int n; |
| 230 | void *key_addr; |
| 231 | struct mmc *mmc = find_mmc_device(curr_device); |
| 232 | |
| 233 | if (argc != 5) |
| 234 | return CMD_RET_USAGE; |
| 235 | |
| 236 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 237 | blk = simple_strtoul(argv[2], NULL, 16); |
| 238 | cnt = simple_strtoul(argv[3], NULL, 16); |
| 239 | key_addr = (void *)simple_strtoul(argv[4], NULL, 16); |
| 240 | |
| 241 | printf("\nMMC RPMB write: dev # %d, block # %d, count %d ... ", |
| 242 | curr_device, blk, cnt); |
| 243 | n = mmc_rpmb_write(mmc, addr, blk, cnt, key_addr); |
| 244 | |
| 245 | printf("%d RPMB blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 246 | if (n != cnt) |
| 247 | return CMD_RET_FAILURE; |
| 248 | return CMD_RET_SUCCESS; |
| 249 | } |
| 250 | static int do_mmcrpmb_counter(cmd_tbl_t *cmdtp, int flag, |
| 251 | int argc, char * const argv[]) |
| 252 | { |
| 253 | unsigned long counter; |
| 254 | struct mmc *mmc = find_mmc_device(curr_device); |
| 255 | |
| 256 | if (mmc_rpmb_get_counter(mmc, &counter)) |
| 257 | return CMD_RET_FAILURE; |
| 258 | printf("RPMB Write counter= %lx\n", counter); |
| 259 | return CMD_RET_SUCCESS; |
| 260 | } |
| 261 | |
| 262 | static cmd_tbl_t cmd_rpmb[] = { |
| 263 | U_BOOT_CMD_MKENT(key, 2, 0, do_mmcrpmb_key, "", ""), |
| 264 | U_BOOT_CMD_MKENT(read, 5, 1, do_mmcrpmb_read, "", ""), |
| 265 | U_BOOT_CMD_MKENT(write, 5, 0, do_mmcrpmb_write, "", ""), |
| 266 | U_BOOT_CMD_MKENT(counter, 1, 1, do_mmcrpmb_counter, "", ""), |
| 267 | }; |
| 268 | |
| 269 | static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag, |
| 270 | int argc, char * const argv[]) |
| 271 | { |
| 272 | cmd_tbl_t *cp; |
| 273 | struct mmc *mmc; |
| 274 | char original_part; |
| 275 | int ret; |
| 276 | |
| 277 | cp = find_cmd_tbl(argv[1], cmd_rpmb, ARRAY_SIZE(cmd_rpmb)); |
| 278 | |
| 279 | /* Drop the rpmb subcommand */ |
| 280 | argc--; |
| 281 | argv++; |
| 282 | |
| 283 | if (cp == NULL || argc > cp->maxargs) |
| 284 | return CMD_RET_USAGE; |
Boris Brezillon | 80a48dd | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 285 | if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 286 | return CMD_RET_SUCCESS; |
| 287 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 288 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 289 | if (!mmc) |
| 290 | return CMD_RET_FAILURE; |
| 291 | |
| 292 | if (!(mmc->version & MMC_VERSION_MMC)) { |
Heinrich Schuchardt | 71a3e5c | 2020-03-29 19:26:57 +0000 | [diff] [blame] | 293 | printf("It is not an eMMC device\n"); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 294 | return CMD_RET_FAILURE; |
| 295 | } |
| 296 | if (mmc->version < MMC_VERSION_4_41) { |
| 297 | printf("RPMB not supported before version 4.41\n"); |
| 298 | return CMD_RET_FAILURE; |
| 299 | } |
| 300 | /* Switch to the RPMB partition */ |
Kever Yang | 4dc80c8 | 2017-06-08 09:20:03 +0800 | [diff] [blame] | 301 | #ifndef CONFIG_BLK |
Marek Vasut | b955e42 | 2016-05-04 16:35:25 +0200 | [diff] [blame] | 302 | original_part = mmc->block_dev.hwpart; |
Kever Yang | 4dc80c8 | 2017-06-08 09:20:03 +0800 | [diff] [blame] | 303 | #else |
| 304 | original_part = mmc_get_blk_desc(mmc)->hwpart; |
| 305 | #endif |
Simon Glass | 69f45cd | 2016-05-01 13:52:29 -0600 | [diff] [blame] | 306 | if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, MMC_PART_RPMB) != |
| 307 | 0) |
Stephen Warren | 873cc1d | 2015-12-07 11:38:49 -0700 | [diff] [blame] | 308 | return CMD_RET_FAILURE; |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 309 | ret = cp->cmd(cmdtp, flag, argc, argv); |
| 310 | |
| 311 | /* Return to original partition */ |
Simon Glass | 69f45cd | 2016-05-01 13:52:29 -0600 | [diff] [blame] | 312 | if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, original_part) != |
| 313 | 0) |
Stephen Warren | 873cc1d | 2015-12-07 11:38:49 -0700 | [diff] [blame] | 314 | return CMD_RET_FAILURE; |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 315 | return ret; |
| 316 | } |
| 317 | #endif |
| 318 | |
| 319 | static int do_mmc_read(cmd_tbl_t *cmdtp, int flag, |
| 320 | int argc, char * const argv[]) |
| 321 | { |
| 322 | struct mmc *mmc; |
| 323 | u32 blk, cnt, n; |
| 324 | void *addr; |
| 325 | |
| 326 | if (argc != 4) |
| 327 | return CMD_RET_USAGE; |
| 328 | |
| 329 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 330 | blk = simple_strtoul(argv[2], NULL, 16); |
| 331 | cnt = simple_strtoul(argv[3], NULL, 16); |
| 332 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 333 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 334 | if (!mmc) |
| 335 | return CMD_RET_FAILURE; |
| 336 | |
| 337 | printf("\nMMC read: dev # %d, block # %d, count %d ... ", |
| 338 | curr_device, blk, cnt); |
| 339 | |
Simon Glass | c40fdca | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 340 | n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, addr); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 341 | printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 342 | |
| 343 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 344 | } |
Jean-Jacques Hiblot | e6fa5a5 | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 345 | |
Alex Kiernan | c232d14 | 2018-05-29 15:30:52 +0000 | [diff] [blame] | 346 | #if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) |
Jassi Brar | 732bc7c | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 347 | static lbaint_t mmc_sparse_write(struct sparse_storage *info, lbaint_t blk, |
| 348 | lbaint_t blkcnt, const void *buffer) |
| 349 | { |
| 350 | struct blk_desc *dev_desc = info->priv; |
| 351 | |
| 352 | return blk_dwrite(dev_desc, blk, blkcnt, buffer); |
| 353 | } |
| 354 | |
| 355 | static lbaint_t mmc_sparse_reserve(struct sparse_storage *info, |
| 356 | lbaint_t blk, lbaint_t blkcnt) |
| 357 | { |
| 358 | return blkcnt; |
| 359 | } |
| 360 | |
| 361 | static int do_mmc_sparse_write(cmd_tbl_t *cmdtp, int flag, |
| 362 | int argc, char * const argv[]) |
| 363 | { |
| 364 | struct sparse_storage sparse; |
| 365 | struct blk_desc *dev_desc; |
| 366 | struct mmc *mmc; |
| 367 | char dest[11]; |
| 368 | void *addr; |
| 369 | u32 blk; |
| 370 | |
| 371 | if (argc != 3) |
| 372 | return CMD_RET_USAGE; |
| 373 | |
| 374 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 375 | blk = simple_strtoul(argv[2], NULL, 16); |
| 376 | |
| 377 | if (!is_sparse_image(addr)) { |
| 378 | printf("Not a sparse image\n"); |
| 379 | return CMD_RET_FAILURE; |
| 380 | } |
| 381 | |
| 382 | mmc = init_mmc_device(curr_device, false); |
| 383 | if (!mmc) |
| 384 | return CMD_RET_FAILURE; |
| 385 | |
| 386 | printf("\nMMC Sparse write: dev # %d, block # %d ... ", |
| 387 | curr_device, blk); |
| 388 | |
| 389 | if (mmc_getwp(mmc) == 1) { |
| 390 | printf("Error: card is write protected!\n"); |
| 391 | return CMD_RET_FAILURE; |
| 392 | } |
| 393 | |
| 394 | dev_desc = mmc_get_blk_desc(mmc); |
| 395 | sparse.priv = dev_desc; |
| 396 | sparse.blksz = 512; |
| 397 | sparse.start = blk; |
| 398 | sparse.size = dev_desc->lba - blk; |
| 399 | sparse.write = mmc_sparse_write; |
| 400 | sparse.reserve = mmc_sparse_reserve; |
| 401 | sparse.mssg = NULL; |
| 402 | sprintf(dest, "0x" LBAF, sparse.start * sparse.blksz); |
| 403 | |
Alex Kiernan | c4ded03 | 2018-05-29 15:30:40 +0000 | [diff] [blame] | 404 | if (write_sparse_image(&sparse, dest, addr, NULL)) |
Jassi Brar | 732bc7c | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 405 | return CMD_RET_FAILURE; |
| 406 | else |
| 407 | return CMD_RET_SUCCESS; |
| 408 | } |
| 409 | #endif |
| 410 | |
Alex Kiernan | c232d14 | 2018-05-29 15:30:52 +0000 | [diff] [blame] | 411 | #if CONFIG_IS_ENABLED(MMC_WRITE) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 412 | static int do_mmc_write(cmd_tbl_t *cmdtp, int flag, |
| 413 | int argc, char * const argv[]) |
| 414 | { |
| 415 | struct mmc *mmc; |
| 416 | u32 blk, cnt, n; |
| 417 | void *addr; |
| 418 | |
| 419 | if (argc != 4) |
| 420 | return CMD_RET_USAGE; |
| 421 | |
| 422 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 423 | blk = simple_strtoul(argv[2], NULL, 16); |
| 424 | cnt = simple_strtoul(argv[3], NULL, 16); |
| 425 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 426 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 427 | if (!mmc) |
| 428 | return CMD_RET_FAILURE; |
| 429 | |
| 430 | printf("\nMMC write: dev # %d, block # %d, count %d ... ", |
| 431 | curr_device, blk, cnt); |
| 432 | |
| 433 | if (mmc_getwp(mmc) == 1) { |
| 434 | printf("Error: card is write protected!\n"); |
| 435 | return CMD_RET_FAILURE; |
| 436 | } |
Simon Glass | c40fdca | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 437 | n = blk_dwrite(mmc_get_blk_desc(mmc), blk, cnt, addr); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 438 | printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 439 | |
| 440 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 441 | } |
| 442 | static int do_mmc_erase(cmd_tbl_t *cmdtp, int flag, |
| 443 | int argc, char * const argv[]) |
| 444 | { |
| 445 | struct mmc *mmc; |
| 446 | u32 blk, cnt, n; |
| 447 | |
| 448 | if (argc != 3) |
| 449 | return CMD_RET_USAGE; |
| 450 | |
| 451 | blk = simple_strtoul(argv[1], NULL, 16); |
| 452 | cnt = simple_strtoul(argv[2], NULL, 16); |
| 453 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 454 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 455 | if (!mmc) |
| 456 | return CMD_RET_FAILURE; |
| 457 | |
| 458 | printf("\nMMC erase: dev # %d, block # %d, count %d ... ", |
| 459 | curr_device, blk, cnt); |
| 460 | |
| 461 | if (mmc_getwp(mmc) == 1) { |
| 462 | printf("Error: card is write protected!\n"); |
| 463 | return CMD_RET_FAILURE; |
| 464 | } |
Simon Glass | c40fdca | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 465 | n = blk_derase(mmc_get_blk_desc(mmc), blk, cnt); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 466 | printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 467 | |
| 468 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 469 | } |
Jean-Jacques Hiblot | e6fa5a5 | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 470 | #endif |
| 471 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 472 | static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag, |
| 473 | int argc, char * const argv[]) |
| 474 | { |
| 475 | struct mmc *mmc; |
| 476 | |
Stephen Warren | 941944e | 2014-05-23 13:24:46 -0600 | [diff] [blame] | 477 | mmc = init_mmc_device(curr_device, true); |
| 478 | if (!mmc) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 479 | return CMD_RET_FAILURE; |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 480 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 481 | return CMD_RET_SUCCESS; |
| 482 | } |
| 483 | static int do_mmc_part(cmd_tbl_t *cmdtp, int flag, |
| 484 | int argc, char * const argv[]) |
| 485 | { |
Simon Glass | 4101f68 | 2016-02-29 15:25:34 -0700 | [diff] [blame] | 486 | struct blk_desc *mmc_dev; |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 487 | struct mmc *mmc; |
| 488 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 489 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 490 | if (!mmc) |
| 491 | return CMD_RET_FAILURE; |
| 492 | |
Simon Glass | 3c457f4 | 2016-05-01 11:36:15 -0600 | [diff] [blame] | 493 | mmc_dev = blk_get_devnum_by_type(IF_TYPE_MMC, curr_device); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 494 | if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) { |
Simon Glass | 3e8bd46 | 2016-02-29 15:25:48 -0700 | [diff] [blame] | 495 | part_print(mmc_dev); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 496 | return CMD_RET_SUCCESS; |
| 497 | } |
| 498 | |
| 499 | puts("get mmc type error!\n"); |
| 500 | return CMD_RET_FAILURE; |
| 501 | } |
| 502 | static int do_mmc_dev(cmd_tbl_t *cmdtp, int flag, |
| 503 | int argc, char * const argv[]) |
| 504 | { |
Stephen Warren | 60dc58f | 2014-05-23 12:48:10 -0600 | [diff] [blame] | 505 | int dev, part = 0, ret; |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 506 | struct mmc *mmc; |
| 507 | |
| 508 | if (argc == 1) { |
| 509 | dev = curr_device; |
| 510 | } else if (argc == 2) { |
| 511 | dev = simple_strtoul(argv[1], NULL, 10); |
| 512 | } else if (argc == 3) { |
| 513 | dev = (int)simple_strtoul(argv[1], NULL, 10); |
| 514 | part = (int)simple_strtoul(argv[2], NULL, 10); |
| 515 | if (part > PART_ACCESS_MASK) { |
| 516 | printf("#part_num shouldn't be larger than %d\n", |
| 517 | PART_ACCESS_MASK); |
| 518 | return CMD_RET_FAILURE; |
| 519 | } |
| 520 | } else { |
| 521 | return CMD_RET_USAGE; |
| 522 | } |
| 523 | |
Stephen Warren | a571092 | 2014-05-23 13:24:47 -0600 | [diff] [blame] | 524 | mmc = init_mmc_device(dev, true); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 525 | if (!mmc) |
| 526 | return CMD_RET_FAILURE; |
| 527 | |
Simon Glass | 69f45cd | 2016-05-01 13:52:29 -0600 | [diff] [blame] | 528 | ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part); |
Stephen Warren | 60dc58f | 2014-05-23 12:48:10 -0600 | [diff] [blame] | 529 | printf("switch to partitions #%d, %s\n", |
| 530 | part, (!ret) ? "OK" : "ERROR"); |
| 531 | if (ret) |
| 532 | return 1; |
| 533 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 534 | curr_device = dev; |
| 535 | if (mmc->part_config == MMCPART_NOAVAILABLE) |
| 536 | printf("mmc%d is current device\n", curr_device); |
| 537 | else |
| 538 | printf("mmc%d(part %d) is current device\n", |
Simon Glass | c40fdca | 2016-05-01 13:52:35 -0600 | [diff] [blame] | 539 | curr_device, mmc_get_blk_desc(mmc)->hwpart); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 540 | |
| 541 | return CMD_RET_SUCCESS; |
| 542 | } |
| 543 | static int do_mmc_list(cmd_tbl_t *cmdtp, int flag, |
| 544 | int argc, char * const argv[]) |
| 545 | { |
| 546 | print_mmc_devices('\n'); |
| 547 | return CMD_RET_SUCCESS; |
| 548 | } |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 549 | |
Jean-Jacques Hiblot | cf17789 | 2017-11-30 17:44:02 +0100 | [diff] [blame] | 550 | #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 551 | static int parse_hwpart_user(struct mmc_hwpart_conf *pconf, |
| 552 | int argc, char * const argv[]) |
| 553 | { |
| 554 | int i = 0; |
| 555 | |
| 556 | memset(&pconf->user, 0, sizeof(pconf->user)); |
| 557 | |
| 558 | while (i < argc) { |
| 559 | if (!strcmp(argv[i], "enh")) { |
| 560 | if (i + 2 >= argc) |
| 561 | return -1; |
| 562 | pconf->user.enh_start = |
| 563 | simple_strtoul(argv[i+1], NULL, 10); |
| 564 | pconf->user.enh_size = |
| 565 | simple_strtoul(argv[i+2], NULL, 10); |
| 566 | i += 3; |
| 567 | } else if (!strcmp(argv[i], "wrrel")) { |
| 568 | if (i + 1 >= argc) |
| 569 | return -1; |
| 570 | pconf->user.wr_rel_change = 1; |
| 571 | if (!strcmp(argv[i+1], "on")) |
| 572 | pconf->user.wr_rel_set = 1; |
| 573 | else if (!strcmp(argv[i+1], "off")) |
| 574 | pconf->user.wr_rel_set = 0; |
| 575 | else |
| 576 | return -1; |
| 577 | i += 2; |
| 578 | } else { |
| 579 | break; |
| 580 | } |
| 581 | } |
| 582 | return i; |
| 583 | } |
| 584 | |
| 585 | static int parse_hwpart_gp(struct mmc_hwpart_conf *pconf, int pidx, |
| 586 | int argc, char * const argv[]) |
| 587 | { |
| 588 | int i; |
| 589 | |
| 590 | memset(&pconf->gp_part[pidx], 0, sizeof(pconf->gp_part[pidx])); |
| 591 | |
| 592 | if (1 >= argc) |
| 593 | return -1; |
| 594 | pconf->gp_part[pidx].size = simple_strtoul(argv[0], NULL, 10); |
| 595 | |
| 596 | i = 1; |
| 597 | while (i < argc) { |
| 598 | if (!strcmp(argv[i], "enh")) { |
| 599 | pconf->gp_part[pidx].enhanced = 1; |
| 600 | i += 1; |
| 601 | } else if (!strcmp(argv[i], "wrrel")) { |
| 602 | if (i + 1 >= argc) |
| 603 | return -1; |
| 604 | pconf->gp_part[pidx].wr_rel_change = 1; |
| 605 | if (!strcmp(argv[i+1], "on")) |
| 606 | pconf->gp_part[pidx].wr_rel_set = 1; |
| 607 | else if (!strcmp(argv[i+1], "off")) |
| 608 | pconf->gp_part[pidx].wr_rel_set = 0; |
| 609 | else |
| 610 | return -1; |
| 611 | i += 2; |
| 612 | } else { |
| 613 | break; |
| 614 | } |
| 615 | } |
| 616 | return i; |
| 617 | } |
| 618 | |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 619 | static int do_mmc_hwpartition(cmd_tbl_t *cmdtp, int flag, |
| 620 | int argc, char * const argv[]) |
| 621 | { |
| 622 | struct mmc *mmc; |
| 623 | struct mmc_hwpart_conf pconf = { }; |
| 624 | enum mmc_hwpart_conf_mode mode = MMC_HWPART_CONF_CHECK; |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 625 | int i, r, pidx; |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 626 | |
| 627 | mmc = init_mmc_device(curr_device, false); |
| 628 | if (!mmc) |
| 629 | return CMD_RET_FAILURE; |
| 630 | |
| 631 | if (argc < 1) |
| 632 | return CMD_RET_USAGE; |
| 633 | i = 1; |
| 634 | while (i < argc) { |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 635 | if (!strcmp(argv[i], "user")) { |
| 636 | i++; |
| 637 | r = parse_hwpart_user(&pconf, argc-i, &argv[i]); |
| 638 | if (r < 0) |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 639 | return CMD_RET_USAGE; |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 640 | i += r; |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 641 | } else if (!strncmp(argv[i], "gp", 2) && |
| 642 | strlen(argv[i]) == 3 && |
| 643 | argv[i][2] >= '1' && argv[i][2] <= '4') { |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 644 | pidx = argv[i][2] - '1'; |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 645 | i++; |
| 646 | r = parse_hwpart_gp(&pconf, pidx, argc-i, &argv[i]); |
| 647 | if (r < 0) |
| 648 | return CMD_RET_USAGE; |
| 649 | i += r; |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 650 | } else if (!strcmp(argv[i], "check")) { |
| 651 | mode = MMC_HWPART_CONF_CHECK; |
| 652 | i++; |
| 653 | } else if (!strcmp(argv[i], "set")) { |
| 654 | mode = MMC_HWPART_CONF_SET; |
| 655 | i++; |
| 656 | } else if (!strcmp(argv[i], "complete")) { |
| 657 | mode = MMC_HWPART_CONF_COMPLETE; |
| 658 | i++; |
| 659 | } else { |
| 660 | return CMD_RET_USAGE; |
| 661 | } |
| 662 | } |
| 663 | |
| 664 | puts("Partition configuration:\n"); |
| 665 | if (pconf.user.enh_size) { |
| 666 | puts("\tUser Enhanced Start: "); |
| 667 | print_size(((u64)pconf.user.enh_start) << 9, "\n"); |
| 668 | puts("\tUser Enhanced Size: "); |
| 669 | print_size(((u64)pconf.user.enh_size) << 9, "\n"); |
| 670 | } else { |
| 671 | puts("\tNo enhanced user data area\n"); |
| 672 | } |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 673 | if (pconf.user.wr_rel_change) |
| 674 | printf("\tUser partition write reliability: %s\n", |
| 675 | pconf.user.wr_rel_set ? "on" : "off"); |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 676 | for (pidx = 0; pidx < 4; pidx++) { |
| 677 | if (pconf.gp_part[pidx].size) { |
| 678 | printf("\tGP%i Capacity: ", pidx+1); |
| 679 | print_size(((u64)pconf.gp_part[pidx].size) << 9, |
| 680 | pconf.gp_part[pidx].enhanced ? |
| 681 | " ENH\n" : "\n"); |
| 682 | } else { |
| 683 | printf("\tNo GP%i partition\n", pidx+1); |
| 684 | } |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 685 | if (pconf.gp_part[pidx].wr_rel_change) |
| 686 | printf("\tGP%i write reliability: %s\n", pidx+1, |
| 687 | pconf.gp_part[pidx].wr_rel_set ? "on" : "off"); |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 688 | } |
| 689 | |
| 690 | if (!mmc_hwpart_config(mmc, &pconf, mode)) { |
| 691 | if (mode == MMC_HWPART_CONF_COMPLETE) |
| 692 | puts("Partitioning successful, " |
| 693 | "power-cycle to make effective\n"); |
| 694 | return CMD_RET_SUCCESS; |
| 695 | } else { |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 696 | puts("Failed!\n"); |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 697 | return CMD_RET_FAILURE; |
| 698 | } |
| 699 | } |
Jean-Jacques Hiblot | cf17789 | 2017-11-30 17:44:02 +0100 | [diff] [blame] | 700 | #endif |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 701 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 702 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 703 | static int do_mmc_bootbus(cmd_tbl_t *cmdtp, int flag, |
| 704 | int argc, char * const argv[]) |
| 705 | { |
| 706 | int dev; |
| 707 | struct mmc *mmc; |
| 708 | u8 width, reset, mode; |
| 709 | |
| 710 | if (argc != 5) |
| 711 | return CMD_RET_USAGE; |
| 712 | dev = simple_strtoul(argv[1], NULL, 10); |
| 713 | width = simple_strtoul(argv[2], NULL, 10); |
| 714 | reset = simple_strtoul(argv[3], NULL, 10); |
| 715 | mode = simple_strtoul(argv[4], NULL, 10); |
| 716 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 717 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 718 | if (!mmc) |
| 719 | return CMD_RET_FAILURE; |
| 720 | |
| 721 | if (IS_SD(mmc)) { |
| 722 | puts("BOOT_BUS_WIDTH only exists on eMMC\n"); |
| 723 | return CMD_RET_FAILURE; |
| 724 | } |
| 725 | |
| 726 | /* acknowledge to be sent during boot operation */ |
| 727 | return mmc_set_boot_bus_width(mmc, width, reset, mode); |
| 728 | } |
| 729 | static int do_mmc_boot_resize(cmd_tbl_t *cmdtp, int flag, |
| 730 | int argc, char * const argv[]) |
| 731 | { |
| 732 | int dev; |
| 733 | struct mmc *mmc; |
| 734 | u32 bootsize, rpmbsize; |
| 735 | |
| 736 | if (argc != 4) |
| 737 | return CMD_RET_USAGE; |
| 738 | dev = simple_strtoul(argv[1], NULL, 10); |
| 739 | bootsize = simple_strtoul(argv[2], NULL, 10); |
| 740 | rpmbsize = simple_strtoul(argv[3], NULL, 10); |
| 741 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 742 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 743 | if (!mmc) |
| 744 | return CMD_RET_FAILURE; |
| 745 | |
| 746 | if (IS_SD(mmc)) { |
Heinrich Schuchardt | 71a3e5c | 2020-03-29 19:26:57 +0000 | [diff] [blame] | 747 | printf("It is not an eMMC device\n"); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 748 | return CMD_RET_FAILURE; |
| 749 | } |
| 750 | |
| 751 | if (mmc_boot_partition_size_change(mmc, bootsize, rpmbsize)) { |
| 752 | printf("EMMC boot partition Size change Failed.\n"); |
| 753 | return CMD_RET_FAILURE; |
| 754 | } |
| 755 | |
| 756 | printf("EMMC boot partition Size %d MB\n", bootsize); |
| 757 | printf("EMMC RPMB partition Size %d MB\n", rpmbsize); |
| 758 | return CMD_RET_SUCCESS; |
| 759 | } |
Angelo Dureghello | bdb6099 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 760 | |
| 761 | static int mmc_partconf_print(struct mmc *mmc) |
| 762 | { |
| 763 | u8 ack, access, part; |
| 764 | |
| 765 | if (mmc->part_config == MMCPART_NOAVAILABLE) { |
| 766 | printf("No part_config info for ver. 0x%x\n", mmc->version); |
| 767 | return CMD_RET_FAILURE; |
| 768 | } |
| 769 | |
| 770 | access = EXT_CSD_EXTRACT_PARTITION_ACCESS(mmc->part_config); |
| 771 | ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config); |
| 772 | part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); |
| 773 | |
| 774 | printf("EXT_CSD[179], PARTITION_CONFIG:\n" |
| 775 | "BOOT_ACK: 0x%x\n" |
| 776 | "BOOT_PARTITION_ENABLE: 0x%x\n" |
| 777 | "PARTITION_ACCESS: 0x%x\n", ack, part, access); |
| 778 | |
| 779 | return CMD_RET_SUCCESS; |
| 780 | } |
| 781 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 782 | static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag, |
| 783 | int argc, char * const argv[]) |
| 784 | { |
| 785 | int dev; |
| 786 | struct mmc *mmc; |
| 787 | u8 ack, part_num, access; |
| 788 | |
Angelo Dureghello | bdb6099 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 789 | if (argc != 2 && argc != 5) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 790 | return CMD_RET_USAGE; |
| 791 | |
| 792 | dev = simple_strtoul(argv[1], NULL, 10); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 793 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 794 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 795 | if (!mmc) |
| 796 | return CMD_RET_FAILURE; |
| 797 | |
| 798 | if (IS_SD(mmc)) { |
| 799 | puts("PARTITION_CONFIG only exists on eMMC\n"); |
| 800 | return CMD_RET_FAILURE; |
| 801 | } |
| 802 | |
Angelo Dureghello | bdb6099 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 803 | if (argc == 2) |
| 804 | return mmc_partconf_print(mmc); |
| 805 | |
| 806 | ack = simple_strtoul(argv[2], NULL, 10); |
| 807 | part_num = simple_strtoul(argv[3], NULL, 10); |
| 808 | access = simple_strtoul(argv[4], NULL, 10); |
| 809 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 810 | /* acknowledge to be sent during boot operation */ |
| 811 | return mmc_set_part_conf(mmc, ack, part_num, access); |
| 812 | } |
| 813 | static int do_mmc_rst_func(cmd_tbl_t *cmdtp, int flag, |
| 814 | int argc, char * const argv[]) |
| 815 | { |
| 816 | int dev; |
| 817 | struct mmc *mmc; |
| 818 | u8 enable; |
| 819 | |
| 820 | /* |
| 821 | * Set the RST_n_ENABLE bit of RST_n_FUNCTION |
| 822 | * The only valid values are 0x0, 0x1 and 0x2 and writing |
| 823 | * a value of 0x1 or 0x2 sets the value permanently. |
| 824 | */ |
| 825 | if (argc != 3) |
| 826 | return CMD_RET_USAGE; |
| 827 | |
| 828 | dev = simple_strtoul(argv[1], NULL, 10); |
| 829 | enable = simple_strtoul(argv[2], NULL, 10); |
| 830 | |
Peng Fan | 678e931 | 2015-11-25 17:16:21 +0800 | [diff] [blame] | 831 | if (enable > 2) { |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 832 | puts("Invalid RST_n_ENABLE value\n"); |
| 833 | return CMD_RET_USAGE; |
| 834 | } |
| 835 | |
Stephen Warren | 1ae24a5 | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 836 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 837 | if (!mmc) |
| 838 | return CMD_RET_FAILURE; |
| 839 | |
| 840 | if (IS_SD(mmc)) { |
| 841 | puts("RST_n_FUNCTION only exists on eMMC\n"); |
| 842 | return CMD_RET_FAILURE; |
| 843 | } |
| 844 | |
| 845 | return mmc_set_rst_n_function(mmc, enable); |
| 846 | } |
| 847 | #endif |
| 848 | static int do_mmc_setdsr(cmd_tbl_t *cmdtp, int flag, |
| 849 | int argc, char * const argv[]) |
| 850 | { |
| 851 | struct mmc *mmc; |
| 852 | u32 val; |
| 853 | int ret; |
| 854 | |
| 855 | if (argc != 2) |
| 856 | return CMD_RET_USAGE; |
Markus Niebel | 84c1dfe | 2017-02-03 15:26:36 +0100 | [diff] [blame] | 857 | val = simple_strtoul(argv[1], NULL, 16); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 858 | |
| 859 | mmc = find_mmc_device(curr_device); |
| 860 | if (!mmc) { |
| 861 | printf("no mmc device at slot %x\n", curr_device); |
| 862 | return CMD_RET_FAILURE; |
| 863 | } |
| 864 | ret = mmc_set_dsr(mmc, val); |
| 865 | printf("set dsr %s\n", (!ret) ? "OK, force rescan" : "ERROR"); |
| 866 | if (!ret) { |
| 867 | mmc->has_init = 0; |
| 868 | if (mmc_init(mmc)) |
| 869 | return CMD_RET_FAILURE; |
| 870 | else |
| 871 | return CMD_RET_SUCCESS; |
| 872 | } |
| 873 | return ret; |
| 874 | } |
| 875 | |
Tomas Melin | cd3d488 | 2016-11-25 11:01:03 +0200 | [diff] [blame] | 876 | #ifdef CONFIG_CMD_BKOPS_ENABLE |
| 877 | static int do_mmc_bkops_enable(cmd_tbl_t *cmdtp, int flag, |
| 878 | int argc, char * const argv[]) |
| 879 | { |
| 880 | int dev; |
| 881 | struct mmc *mmc; |
| 882 | |
| 883 | if (argc != 2) |
| 884 | return CMD_RET_USAGE; |
| 885 | |
| 886 | dev = simple_strtoul(argv[1], NULL, 10); |
| 887 | |
| 888 | mmc = init_mmc_device(dev, false); |
| 889 | if (!mmc) |
| 890 | return CMD_RET_FAILURE; |
| 891 | |
| 892 | if (IS_SD(mmc)) { |
| 893 | puts("BKOPS_EN only exists on eMMC\n"); |
| 894 | return CMD_RET_FAILURE; |
| 895 | } |
| 896 | |
| 897 | return mmc_set_bkops_enable(mmc); |
| 898 | } |
| 899 | #endif |
| 900 | |
Heinrich Schuchardt | 0469d84 | 2020-03-30 07:24:19 +0200 | [diff] [blame] | 901 | static int do_mmc_boot_wp(cmd_tbl_t *cmdtp, int flag, |
| 902 | int argc, char * const argv[]) |
| 903 | { |
| 904 | int err; |
| 905 | struct mmc *mmc; |
| 906 | |
| 907 | mmc = init_mmc_device(curr_device, false); |
| 908 | if (!mmc) |
| 909 | return CMD_RET_FAILURE; |
| 910 | if (IS_SD(mmc)) { |
| 911 | printf("It is not an eMMC device\n"); |
| 912 | return CMD_RET_FAILURE; |
| 913 | } |
| 914 | err = mmc_boot_wp(mmc); |
| 915 | if (err) |
| 916 | return CMD_RET_FAILURE; |
| 917 | printf("boot areas protected\n"); |
| 918 | return CMD_RET_SUCCESS; |
| 919 | } |
| 920 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 921 | static cmd_tbl_t cmd_mmc[] = { |
| 922 | U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""), |
| 923 | U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""), |
Heinrich Schuchardt | 0469d84 | 2020-03-30 07:24:19 +0200 | [diff] [blame] | 924 | U_BOOT_CMD_MKENT(wp, 1, 0, do_mmc_boot_wp, "", ""), |
Jean-Jacques Hiblot | e6fa5a5 | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 925 | #if CONFIG_IS_ENABLED(MMC_WRITE) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 926 | U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""), |
| 927 | U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""), |
Jean-Jacques Hiblot | e6fa5a5 | 2018-01-04 15:23:34 +0100 | [diff] [blame] | 928 | #endif |
Alex Kiernan | c232d14 | 2018-05-29 15:30:52 +0000 | [diff] [blame] | 929 | #if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) |
| 930 | U_BOOT_CMD_MKENT(swrite, 3, 0, do_mmc_sparse_write, "", ""), |
| 931 | #endif |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 932 | U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""), |
| 933 | U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""), |
| 934 | U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""), |
| 935 | U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""), |
Jean-Jacques Hiblot | cf17789 | 2017-11-30 17:44:02 +0100 | [diff] [blame] | 936 | #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 937 | U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""), |
Jean-Jacques Hiblot | cf17789 | 2017-11-30 17:44:02 +0100 | [diff] [blame] | 938 | #endif |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 939 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 940 | U_BOOT_CMD_MKENT(bootbus, 5, 0, do_mmc_bootbus, "", ""), |
Wally Yeh | fa7b885 | 2014-09-25 23:00:16 +0800 | [diff] [blame] | 941 | U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "", ""), |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 942 | U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""), |
| 943 | U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""), |
| 944 | #endif |
Alex Kiernan | 5a7b11e | 2018-05-08 04:43:31 +0000 | [diff] [blame] | 945 | #if CONFIG_IS_ENABLED(CMD_MMC_RPMB) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 946 | U_BOOT_CMD_MKENT(rpmb, CONFIG_SYS_MAXARGS, 1, do_mmcrpmb, "", ""), |
| 947 | #endif |
| 948 | U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""), |
Tomas Melin | cd3d488 | 2016-11-25 11:01:03 +0200 | [diff] [blame] | 949 | #ifdef CONFIG_CMD_BKOPS_ENABLE |
| 950 | U_BOOT_CMD_MKENT(bkops-enable, 2, 0, do_mmc_bkops_enable, "", ""), |
| 951 | #endif |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 952 | }; |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 953 | |
Kim Phillips | 088f1b1 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 954 | static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 955 | { |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 956 | cmd_tbl_t *cp; |
Lei Wen | 6be95cc | 2011-06-22 17:03:30 +0000 | [diff] [blame] | 957 | |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 958 | cp = find_cmd_tbl(argv[1], cmd_mmc, ARRAY_SIZE(cmd_mmc)); |
| 959 | |
| 960 | /* Drop the mmc command */ |
| 961 | argc--; |
| 962 | argv++; |
| 963 | |
| 964 | if (cp == NULL || argc > cp->maxargs) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 965 | return CMD_RET_USAGE; |
Boris Brezillon | 80a48dd | 2018-12-03 22:54:20 +0100 | [diff] [blame] | 966 | if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp)) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 967 | return CMD_RET_SUCCESS; |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 968 | |
Lei Wen | ea6ebe2 | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 969 | if (curr_device < 0) { |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 970 | if (get_mmc_num() > 0) { |
Lei Wen | ea6ebe2 | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 971 | curr_device = 0; |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 972 | } else { |
Lei Wen | ea6ebe2 | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 973 | puts("No MMC device available\n"); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 974 | return CMD_RET_FAILURE; |
Lei Wen | ea6ebe2 | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 975 | } |
| 976 | } |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 977 | return cp->cmd(cmdtp, flag, argc, argv); |
Andy Fleming | 272cc70 | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | U_BOOT_CMD( |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 981 | mmc, 29, 1, do_mmcops, |
Mike Frysinger | 852dbfd | 2009-03-23 22:27:34 -0400 | [diff] [blame] | 982 | "MMC sub system", |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 983 | "info - display info of the current MMC device\n" |
| 984 | "mmc read addr blk# cnt\n" |
Lei Wen | ea6ebe2 | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 985 | "mmc write addr blk# cnt\n" |
Alex Kiernan | c232d14 | 2018-05-29 15:30:52 +0000 | [diff] [blame] | 986 | #if CONFIG_IS_ENABLED(CMD_MMC_SWRITE) |
Jassi Brar | 732bc7c | 2018-04-06 12:05:24 +0530 | [diff] [blame] | 987 | "mmc swrite addr blk#\n" |
| 988 | #endif |
Lei Wen | e6f99a5 | 2011-06-22 17:03:31 +0000 | [diff] [blame] | 989 | "mmc erase blk# cnt\n" |
Lei Wen | ea6ebe2 | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 990 | "mmc rescan\n" |
| 991 | "mmc part - lists available partition on current mmc device\n" |
Lei Wen | bc897b1 | 2011-05-02 16:26:26 +0000 | [diff] [blame] | 992 | "mmc dev [dev] [part] - show or set current mmc device [partition]\n" |
Amar | 2a91c91 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 993 | "mmc list - lists available devices\n" |
Heinrich Schuchardt | 0469d84 | 2020-03-30 07:24:19 +0200 | [diff] [blame] | 994 | "mmc wp - power on write protect booot partitions\n" |
Alex Kiernan | 8459367 | 2018-06-11 16:20:09 +0000 | [diff] [blame] | 995 | #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 996 | "mmc hwpartition [args...] - does hardware partitioning\n" |
| 997 | " arguments (sizes in 512-byte blocks):\n" |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 998 | " [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes\n" |
| 999 | " [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition\n" |
Diego Santa Cruz | c599f53 | 2014-12-23 10:50:30 +0100 | [diff] [blame] | 1000 | " [check|set|complete] - mode, complete set partitioning completed\n" |
Diego Santa Cruz | 189f963 | 2014-12-23 10:50:32 +0100 | [diff] [blame] | 1001 | " WARNING: Partitioning is a write-once setting once it is set to complete.\n" |
| 1002 | " Power cycling is required to initialize partitions after set to complete.\n" |
Alex Kiernan | 8459367 | 2018-06-11 16:20:09 +0000 | [diff] [blame] | 1003 | #endif |
Amar | 2a91c91 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 1004 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
Tom Rini | 5a99b9d | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 1005 | "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n" |
| 1006 | " - Set the BOOT_BUS_WIDTH field of the specified device\n" |
Tom Rini | f1fd957 | 2014-02-05 10:24:20 -0500 | [diff] [blame] | 1007 | "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n" |
| 1008 | " - Change sizes of boot and RPMB partitions of specified device\n" |
Angelo Dureghello | bdb6099 | 2017-08-01 14:27:10 +0200 | [diff] [blame] | 1009 | "mmc partconf dev [boot_ack boot_partition partition_access]\n" |
| 1010 | " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n" |
Tom Rini | 33ace36 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 1011 | "mmc rst-function dev value\n" |
| 1012 | " - Change the RST_n_FUNCTION field of the specified device\n" |
| 1013 | " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n" |
Dirk Behme | 3511b4e | 2009-02-18 19:59:39 +0100 | [diff] [blame] | 1014 | #endif |
Alex Kiernan | 5a7b11e | 2018-05-08 04:43:31 +0000 | [diff] [blame] | 1015 | #if CONFIG_IS_ENABLED(CMD_MMC_RPMB) |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1016 | "mmc rpmb read addr blk# cnt [address of auth-key] - block size is 256 bytes\n" |
| 1017 | "mmc rpmb write addr blk# cnt <address of auth-key> - block size is 256 bytes\n" |
| 1018 | "mmc rpmb key <address of auth-key> - program the RPMB authentication key.\n" |
| 1019 | "mmc rpmb counter - read the value of the write counter\n" |
| 1020 | #endif |
| 1021 | "mmc setdsr <value> - set DSR register value\n" |
Tomas Melin | cd3d488 | 2016-11-25 11:01:03 +0200 | [diff] [blame] | 1022 | #ifdef CONFIG_CMD_BKOPS_ENABLE |
| 1023 | "mmc bkops-enable <dev> - enable background operations handshake on device\n" |
| 1024 | " WARNING: This is a write-once setting.\n" |
| 1025 | #endif |
Amar | 2a91c91 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 1026 | ); |
Pierre Aubert | 1fd93c6 | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 1027 | |
| 1028 | /* Old command kept for compatibility. Same as 'mmc info' */ |
| 1029 | U_BOOT_CMD( |
| 1030 | mmcinfo, 1, 0, do_mmcinfo, |
| 1031 | "display MMC info", |
| 1032 | "- display info of the current MMC device" |
| 1033 | ); |