wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2003 |
| 3 | * Kyle Harris, kharris@nexus-tech.net |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <command.h> |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 10 | #include <mmc.h> |
| 11 | |
Mike Frysinger | 0289fe6 | 2009-06-14 21:35:21 -0400 | [diff] [blame] | 12 | static int curr_device = -1; |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 13 | #ifndef CONFIG_GENERIC_MMC |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 14 | int do_mmc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 15 | { |
Minkyu Kang | 0f92290 | 2009-03-30 14:55:51 +0900 | [diff] [blame] | 16 | int dev; |
| 17 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 18 | if (argc < 2) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 19 | return CMD_RET_USAGE; |
Minkyu Kang | 0f92290 | 2009-03-30 14:55:51 +0900 | [diff] [blame] | 20 | |
| 21 | if (strcmp(argv[1], "init") == 0) { |
| 22 | if (argc == 2) { |
| 23 | if (curr_device < 0) |
| 24 | dev = 1; |
| 25 | else |
| 26 | dev = curr_device; |
| 27 | } else if (argc == 3) { |
| 28 | dev = (int)simple_strtoul(argv[2], NULL, 10); |
| 29 | } else { |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 30 | return CMD_RET_USAGE; |
Minkyu Kang | 0f92290 | 2009-03-30 14:55:51 +0900 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | if (mmc_legacy_init(dev) != 0) { |
| 34 | puts("No MMC card found\n"); |
| 35 | return 1; |
| 36 | } |
| 37 | |
| 38 | curr_device = dev; |
| 39 | printf("mmc%d is available\n", curr_device); |
| 40 | } else if (strcmp(argv[1], "device") == 0) { |
| 41 | if (argc == 2) { |
| 42 | if (curr_device < 0) { |
| 43 | puts("No MMC device available\n"); |
| 44 | return 1; |
| 45 | } |
| 46 | } else if (argc == 3) { |
| 47 | dev = (int)simple_strtoul(argv[2], NULL, 10); |
| 48 | |
| 49 | #ifdef CONFIG_SYS_MMC_SET_DEV |
| 50 | if (mmc_set_dev(dev) != 0) |
| 51 | return 1; |
| 52 | #endif |
| 53 | curr_device = dev; |
| 54 | } else { |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 55 | return CMD_RET_USAGE; |
Minkyu Kang | 0f92290 | 2009-03-30 14:55:51 +0900 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | printf("mmc%d is current device\n", curr_device); |
| 59 | } else { |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 60 | return CMD_RET_USAGE; |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 61 | } |
Minkyu Kang | 0f92290 | 2009-03-30 14:55:51 +0900 | [diff] [blame] | 62 | |
wdenk | 7a428cc | 2003-06-15 22:40:42 +0000 | [diff] [blame] | 63 | return 0; |
| 64 | } |
| 65 | |
wdenk | f287a24 | 2003-07-01 21:06:45 +0000 | [diff] [blame] | 66 | U_BOOT_CMD( |
Minkyu Kang | 0f92290 | 2009-03-30 14:55:51 +0900 | [diff] [blame] | 67 | mmc, 3, 1, do_mmc, |
| 68 | "MMC sub-system", |
| 69 | "init [dev] - init MMC sub system\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 70 | "mmc device [dev] - show or set current device" |
wdenk | f12e396 | 2003-06-29 21:03:46 +0000 | [diff] [blame] | 71 | ); |
Dirk Behme | df8852a | 2009-02-18 19:59:39 +0100 | [diff] [blame] | 72 | #else /* !CONFIG_GENERIC_MMC */ |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 73 | |
| 74 | static void print_mmcinfo(struct mmc *mmc) |
| 75 | { |
Pantelis Antoniou | 2c85046 | 2014-03-11 19:34:20 +0200 | [diff] [blame] | 76 | printf("Device: %s\n", mmc->cfg->name); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 77 | printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24); |
| 78 | printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff); |
| 79 | printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff, |
| 80 | (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, |
| 81 | (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff); |
| 82 | |
| 83 | printf("Tran Speed: %d\n", mmc->tran_speed); |
| 84 | printf("Rd Block Len: %d\n", mmc->read_bl_len); |
| 85 | |
| 86 | printf("%s version %d.%d\n", IS_SD(mmc) ? "SD" : "MMC", |
Jaehoon Chung | 6108ef6 | 2013-01-29 19:31:16 +0000 | [diff] [blame] | 87 | (mmc->version >> 8) & 0xf, mmc->version & 0xff); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 88 | |
| 89 | printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No"); |
Minkyu Kang | 316f81a | 2011-01-04 01:04:19 +0000 | [diff] [blame] | 90 | puts("Capacity: "); |
| 91 | print_size(mmc->capacity, "\n"); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 92 | |
Andrew Gabbasov | 9fc2a41 | 2014-12-01 06:59:09 -0600 | [diff] [blame] | 93 | printf("Bus Width: %d-bit%s\n", mmc->bus_width, |
| 94 | mmc->ddr_mode ? " DDR" : ""); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 95 | } |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 96 | static struct mmc *init_mmc_device(int dev, bool force_init) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 97 | { |
| 98 | struct mmc *mmc; |
| 99 | mmc = find_mmc_device(dev); |
| 100 | if (!mmc) { |
| 101 | printf("no mmc device at slot %x\n", dev); |
| 102 | return NULL; |
| 103 | } |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 104 | if (force_init) |
| 105 | mmc->has_init = 0; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 106 | if (mmc_init(mmc)) |
| 107 | return NULL; |
| 108 | return mmc; |
| 109 | } |
Kim Phillips | dc00a68 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 110 | static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 111 | { |
| 112 | struct mmc *mmc; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 113 | |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 114 | if (curr_device < 0) { |
| 115 | if (get_mmc_num() > 0) |
| 116 | curr_device = 0; |
| 117 | else { |
| 118 | puts("No MMC device available\n"); |
| 119 | return 1; |
| 120 | } |
| 121 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 122 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 123 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 124 | if (!mmc) |
| 125 | return CMD_RET_FAILURE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 126 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 127 | print_mmcinfo(mmc); |
| 128 | return CMD_RET_SUCCESS; |
| 129 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 130 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 131 | #ifdef CONFIG_SUPPORT_EMMC_RPMB |
| 132 | static int confirm_key_prog(void) |
| 133 | { |
| 134 | puts("Warning: Programming authentication key can be done only once !\n" |
| 135 | " Use this command only if you are sure of what you are doing,\n" |
| 136 | "Really perform the key programming? <y/N> "); |
| 137 | if (confirm_yesno()) |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 138 | return 1; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 139 | |
| 140 | puts("Authentication key programming aborted\n"); |
| 141 | return 0; |
| 142 | } |
| 143 | static int do_mmcrpmb_key(cmd_tbl_t *cmdtp, int flag, |
| 144 | int argc, char * const argv[]) |
| 145 | { |
| 146 | void *key_addr; |
| 147 | struct mmc *mmc = find_mmc_device(curr_device); |
| 148 | |
| 149 | if (argc != 2) |
| 150 | return CMD_RET_USAGE; |
| 151 | |
| 152 | key_addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 153 | if (!confirm_key_prog()) |
| 154 | return CMD_RET_FAILURE; |
| 155 | if (mmc_rpmb_set_key(mmc, key_addr)) { |
| 156 | printf("ERROR - Key already programmed ?\n"); |
| 157 | return CMD_RET_FAILURE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 158 | } |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 159 | return CMD_RET_SUCCESS; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 160 | } |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 161 | static int do_mmcrpmb_read(cmd_tbl_t *cmdtp, int flag, |
| 162 | int argc, char * const argv[]) |
| 163 | { |
| 164 | u16 blk, cnt; |
| 165 | void *addr; |
| 166 | int n; |
| 167 | void *key_addr = NULL; |
| 168 | struct mmc *mmc = find_mmc_device(curr_device); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 169 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 170 | if (argc < 4) |
| 171 | return CMD_RET_USAGE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 172 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 173 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 174 | blk = simple_strtoul(argv[2], NULL, 16); |
| 175 | cnt = simple_strtoul(argv[3], NULL, 16); |
| 176 | |
| 177 | if (argc == 5) |
| 178 | key_addr = (void *)simple_strtoul(argv[4], NULL, 16); |
| 179 | |
| 180 | printf("\nMMC RPMB read: dev # %d, block # %d, count %d ... ", |
| 181 | curr_device, blk, cnt); |
| 182 | n = mmc_rpmb_read(mmc, addr, blk, cnt, key_addr); |
| 183 | |
| 184 | printf("%d RPMB blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 185 | if (n != cnt) |
| 186 | return CMD_RET_FAILURE; |
| 187 | return CMD_RET_SUCCESS; |
| 188 | } |
| 189 | static int do_mmcrpmb_write(cmd_tbl_t *cmdtp, int flag, |
| 190 | int argc, char * const argv[]) |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 191 | { |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 192 | u16 blk, cnt; |
| 193 | void *addr; |
| 194 | int n; |
| 195 | void *key_addr; |
| 196 | struct mmc *mmc = find_mmc_device(curr_device); |
Lei Wen | 64b2b1e | 2011-06-22 17:03:30 +0000 | [diff] [blame] | 197 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 198 | if (argc != 5) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 199 | return CMD_RET_USAGE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 200 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 201 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 202 | blk = simple_strtoul(argv[2], NULL, 16); |
| 203 | cnt = simple_strtoul(argv[3], NULL, 16); |
| 204 | key_addr = (void *)simple_strtoul(argv[4], NULL, 16); |
| 205 | |
| 206 | printf("\nMMC RPMB write: dev # %d, block # %d, count %d ... ", |
| 207 | curr_device, blk, cnt); |
| 208 | n = mmc_rpmb_write(mmc, addr, blk, cnt, key_addr); |
| 209 | |
| 210 | printf("%d RPMB blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
| 211 | if (n != cnt) |
| 212 | return CMD_RET_FAILURE; |
| 213 | return CMD_RET_SUCCESS; |
| 214 | } |
| 215 | static int do_mmcrpmb_counter(cmd_tbl_t *cmdtp, int flag, |
| 216 | int argc, char * const argv[]) |
| 217 | { |
| 218 | unsigned long counter; |
| 219 | struct mmc *mmc = find_mmc_device(curr_device); |
| 220 | |
| 221 | if (mmc_rpmb_get_counter(mmc, &counter)) |
| 222 | return CMD_RET_FAILURE; |
| 223 | printf("RPMB Write counter= %lx\n", counter); |
| 224 | return CMD_RET_SUCCESS; |
| 225 | } |
| 226 | |
| 227 | static cmd_tbl_t cmd_rpmb[] = { |
| 228 | U_BOOT_CMD_MKENT(key, 2, 0, do_mmcrpmb_key, "", ""), |
| 229 | U_BOOT_CMD_MKENT(read, 5, 1, do_mmcrpmb_read, "", ""), |
| 230 | U_BOOT_CMD_MKENT(write, 5, 0, do_mmcrpmb_write, "", ""), |
| 231 | U_BOOT_CMD_MKENT(counter, 1, 1, do_mmcrpmb_counter, "", ""), |
| 232 | }; |
| 233 | |
| 234 | static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag, |
| 235 | int argc, char * const argv[]) |
| 236 | { |
| 237 | cmd_tbl_t *cp; |
| 238 | struct mmc *mmc; |
| 239 | char original_part; |
| 240 | int ret; |
| 241 | |
| 242 | cp = find_cmd_tbl(argv[1], cmd_rpmb, ARRAY_SIZE(cmd_rpmb)); |
| 243 | |
| 244 | /* Drop the rpmb subcommand */ |
| 245 | argc--; |
| 246 | argv++; |
| 247 | |
| 248 | if (cp == NULL || argc > cp->maxargs) |
| 249 | return CMD_RET_USAGE; |
| 250 | if (flag == CMD_FLAG_REPEAT && !cp->repeatable) |
| 251 | return CMD_RET_SUCCESS; |
| 252 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 253 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 254 | if (!mmc) |
| 255 | return CMD_RET_FAILURE; |
| 256 | |
| 257 | if (!(mmc->version & MMC_VERSION_MMC)) { |
| 258 | printf("It is not a EMMC device\n"); |
| 259 | return CMD_RET_FAILURE; |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 260 | } |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 261 | if (mmc->version < MMC_VERSION_4_41) { |
| 262 | printf("RPMB not supported before version 4.41\n"); |
| 263 | return CMD_RET_FAILURE; |
| 264 | } |
| 265 | /* Switch to the RPMB partition */ |
| 266 | original_part = mmc->part_num; |
| 267 | if (mmc->part_num != MMC_PART_RPMB) { |
| 268 | if (mmc_switch_part(curr_device, MMC_PART_RPMB) != 0) |
| 269 | return CMD_RET_FAILURE; |
| 270 | mmc->part_num = MMC_PART_RPMB; |
| 271 | } |
| 272 | ret = cp->cmd(cmdtp, flag, argc, argv); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 273 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 274 | /* Return to original partition */ |
| 275 | if (mmc->part_num != original_part) { |
| 276 | if (mmc_switch_part(curr_device, original_part) != 0) |
| 277 | return CMD_RET_FAILURE; |
| 278 | mmc->part_num = original_part; |
| 279 | } |
| 280 | return ret; |
| 281 | } |
| 282 | #endif |
Rabin Vincent | 3e448aa | 2009-04-05 13:30:53 +0530 | [diff] [blame] | 283 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 284 | static int do_mmc_read(cmd_tbl_t *cmdtp, int flag, |
| 285 | int argc, char * const argv[]) |
| 286 | { |
| 287 | struct mmc *mmc; |
| 288 | u32 blk, cnt, n; |
| 289 | void *addr; |
Stephen Warren | 18faca7 | 2013-04-01 11:50:28 +0000 | [diff] [blame] | 290 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 291 | if (argc != 4) |
| 292 | return CMD_RET_USAGE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 293 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 294 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 295 | blk = simple_strtoul(argv[2], NULL, 16); |
| 296 | cnt = simple_strtoul(argv[3], NULL, 16); |
Lei Wen | 61dba93 | 2010-09-13 22:07:28 +0800 | [diff] [blame] | 297 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 298 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 299 | if (!mmc) |
| 300 | return CMD_RET_FAILURE; |
Lei Wen | 61dba93 | 2010-09-13 22:07:28 +0800 | [diff] [blame] | 301 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 302 | printf("\nMMC read: dev # %d, block # %d, count %d ... ", |
| 303 | curr_device, blk, cnt); |
Stephen Warren | 18faca7 | 2013-04-01 11:50:28 +0000 | [diff] [blame] | 304 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 305 | n = mmc->block_dev.block_read(curr_device, blk, cnt, addr); |
| 306 | /* flush cache after read */ |
| 307 | flush_cache((ulong)addr, cnt * 512); /* FIXME */ |
| 308 | printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 309 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 310 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 311 | } |
| 312 | static int do_mmc_write(cmd_tbl_t *cmdtp, int flag, |
| 313 | int argc, char * const argv[]) |
| 314 | { |
| 315 | struct mmc *mmc; |
| 316 | u32 blk, cnt, n; |
| 317 | void *addr; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 318 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 319 | if (argc != 4) |
| 320 | return CMD_RET_USAGE; |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 321 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 322 | addr = (void *)simple_strtoul(argv[1], NULL, 16); |
| 323 | blk = simple_strtoul(argv[2], NULL, 16); |
| 324 | cnt = simple_strtoul(argv[3], NULL, 16); |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 325 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 326 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 327 | if (!mmc) |
| 328 | return CMD_RET_FAILURE; |
Lei Wen | 31b9980 | 2011-05-02 16:26:26 +0000 | [diff] [blame] | 329 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 330 | printf("\nMMC write: dev # %d, block # %d, count %d ... ", |
| 331 | curr_device, blk, cnt); |
Lei Wen | 31b9980 | 2011-05-02 16:26:26 +0000 | [diff] [blame] | 332 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 333 | if (mmc_getwp(mmc) == 1) { |
| 334 | printf("Error: card is write protected!\n"); |
| 335 | return CMD_RET_FAILURE; |
| 336 | } |
| 337 | n = mmc->block_dev.block_write(curr_device, blk, cnt, addr); |
| 338 | printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 339 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 340 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 341 | } |
| 342 | static int do_mmc_erase(cmd_tbl_t *cmdtp, int flag, |
| 343 | int argc, char * const argv[]) |
| 344 | { |
| 345 | struct mmc *mmc; |
| 346 | u32 blk, cnt, n; |
Tom Rini | f8c6f79 | 2014-02-05 10:24:21 -0500 | [diff] [blame] | 347 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 348 | if (argc != 3) |
| 349 | return CMD_RET_USAGE; |
Tom Rini | f8c6f79 | 2014-02-05 10:24:21 -0500 | [diff] [blame] | 350 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 351 | blk = simple_strtoul(argv[1], NULL, 16); |
| 352 | cnt = simple_strtoul(argv[2], NULL, 16); |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 353 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 354 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 355 | if (!mmc) |
| 356 | return CMD_RET_FAILURE; |
Tom Rini | f8c6f79 | 2014-02-05 10:24:21 -0500 | [diff] [blame] | 357 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 358 | printf("\nMMC erase: dev # %d, block # %d, count %d ... ", |
| 359 | curr_device, blk, cnt); |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 360 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 361 | if (mmc_getwp(mmc) == 1) { |
| 362 | printf("Error: card is write protected!\n"); |
| 363 | return CMD_RET_FAILURE; |
| 364 | } |
| 365 | n = mmc->block_dev.block_erase(curr_device, blk, cnt); |
| 366 | printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR"); |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 367 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 368 | return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE; |
| 369 | } |
| 370 | static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag, |
| 371 | int argc, char * const argv[]) |
| 372 | { |
| 373 | struct mmc *mmc; |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 374 | |
Stephen Warren | 07ec4e7 | 2014-05-23 13:24:46 -0600 | [diff] [blame] | 375 | mmc = init_mmc_device(curr_device, true); |
| 376 | if (!mmc) |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 377 | return CMD_RET_FAILURE; |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 378 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 379 | return CMD_RET_SUCCESS; |
| 380 | } |
| 381 | static int do_mmc_part(cmd_tbl_t *cmdtp, int flag, |
| 382 | int argc, char * const argv[]) |
| 383 | { |
| 384 | block_dev_desc_t *mmc_dev; |
| 385 | struct mmc *mmc; |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 386 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 387 | mmc = init_mmc_device(curr_device, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 388 | if (!mmc) |
| 389 | return CMD_RET_FAILURE; |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 390 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 391 | mmc_dev = mmc_get_dev(curr_device); |
| 392 | if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) { |
| 393 | print_part(mmc_dev); |
| 394 | return CMD_RET_SUCCESS; |
| 395 | } |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 396 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 397 | puts("get mmc type error!\n"); |
| 398 | return CMD_RET_FAILURE; |
| 399 | } |
| 400 | static int do_mmc_dev(cmd_tbl_t *cmdtp, int flag, |
| 401 | int argc, char * const argv[]) |
| 402 | { |
Stephen Warren | 1854980 | 2014-05-23 12:48:10 -0600 | [diff] [blame] | 403 | int dev, part = 0, ret; |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 404 | struct mmc *mmc; |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 405 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 406 | if (argc == 1) { |
| 407 | dev = curr_device; |
| 408 | } else if (argc == 2) { |
| 409 | dev = simple_strtoul(argv[1], NULL, 10); |
| 410 | } else if (argc == 3) { |
| 411 | dev = (int)simple_strtoul(argv[1], NULL, 10); |
| 412 | part = (int)simple_strtoul(argv[2], NULL, 10); |
| 413 | if (part > PART_ACCESS_MASK) { |
| 414 | printf("#part_num shouldn't be larger than %d\n", |
| 415 | PART_ACCESS_MASK); |
| 416 | return CMD_RET_FAILURE; |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 417 | } |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 418 | } else { |
| 419 | return CMD_RET_USAGE; |
| 420 | } |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 421 | |
Stephen Warren | cf66e6f | 2014-05-23 13:24:47 -0600 | [diff] [blame] | 422 | mmc = init_mmc_device(dev, true); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 423 | if (!mmc) |
| 424 | return CMD_RET_FAILURE; |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 425 | |
Stephen Warren | 1854980 | 2014-05-23 12:48:10 -0600 | [diff] [blame] | 426 | ret = mmc_select_hwpart(dev, part); |
| 427 | printf("switch to partitions #%d, %s\n", |
| 428 | part, (!ret) ? "OK" : "ERROR"); |
| 429 | if (ret) |
| 430 | return 1; |
| 431 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 432 | curr_device = dev; |
| 433 | if (mmc->part_config == MMCPART_NOAVAILABLE) |
| 434 | printf("mmc%d is current device\n", curr_device); |
| 435 | else |
| 436 | printf("mmc%d(part %d) is current device\n", |
| 437 | curr_device, mmc->part_num); |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 438 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 439 | return CMD_RET_SUCCESS; |
| 440 | } |
| 441 | static int do_mmc_list(cmd_tbl_t *cmdtp, int flag, |
| 442 | int argc, char * const argv[]) |
| 443 | { |
| 444 | print_mmc_devices('\n'); |
| 445 | return CMD_RET_SUCCESS; |
| 446 | } |
| 447 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 448 | static int do_mmc_bootbus(cmd_tbl_t *cmdtp, int flag, |
| 449 | int argc, char * const argv[]) |
| 450 | { |
| 451 | int dev; |
| 452 | struct mmc *mmc; |
| 453 | u8 width, reset, mode; |
| 454 | |
| 455 | if (argc != 5) |
| 456 | return CMD_RET_USAGE; |
| 457 | dev = simple_strtoul(argv[1], NULL, 10); |
| 458 | width = simple_strtoul(argv[2], NULL, 10); |
| 459 | reset = simple_strtoul(argv[3], NULL, 10); |
| 460 | mode = simple_strtoul(argv[4], NULL, 10); |
| 461 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 462 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 463 | if (!mmc) |
| 464 | return CMD_RET_FAILURE; |
| 465 | |
| 466 | if (IS_SD(mmc)) { |
| 467 | puts("BOOT_BUS_WIDTH only exists on eMMC\n"); |
| 468 | return CMD_RET_FAILURE; |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 469 | } |
Markus Niebel | 0395141 | 2013-12-16 13:40:46 +0100 | [diff] [blame] | 470 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 471 | /* acknowledge to be sent during boot operation */ |
| 472 | return mmc_set_boot_bus_width(mmc, width, reset, mode); |
| 473 | } |
| 474 | static int do_mmc_boot_resize(cmd_tbl_t *cmdtp, int flag, |
| 475 | int argc, char * const argv[]) |
| 476 | { |
| 477 | int dev; |
| 478 | struct mmc *mmc; |
| 479 | u32 bootsize, rpmbsize; |
Markus Niebel | 0395141 | 2013-12-16 13:40:46 +0100 | [diff] [blame] | 480 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 481 | if (argc != 4) |
| 482 | return CMD_RET_USAGE; |
| 483 | dev = simple_strtoul(argv[1], NULL, 10); |
| 484 | bootsize = simple_strtoul(argv[2], NULL, 10); |
| 485 | rpmbsize = simple_strtoul(argv[3], NULL, 10); |
| 486 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 487 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 488 | if (!mmc) |
| 489 | return CMD_RET_FAILURE; |
| 490 | |
| 491 | if (IS_SD(mmc)) { |
| 492 | printf("It is not a EMMC device\n"); |
| 493 | return CMD_RET_FAILURE; |
Markus Niebel | 0395141 | 2013-12-16 13:40:46 +0100 | [diff] [blame] | 494 | } |
| 495 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 496 | if (mmc_boot_partition_size_change(mmc, bootsize, rpmbsize)) { |
| 497 | printf("EMMC boot partition Size change Failed.\n"); |
| 498 | return CMD_RET_FAILURE; |
| 499 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 500 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 501 | printf("EMMC boot partition Size %d MB\n", bootsize); |
| 502 | printf("EMMC RPMB partition Size %d MB\n", rpmbsize); |
| 503 | return CMD_RET_SUCCESS; |
| 504 | } |
| 505 | static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag, |
| 506 | int argc, char * const argv[]) |
| 507 | { |
| 508 | int dev; |
| 509 | struct mmc *mmc; |
| 510 | u8 ack, part_num, access; |
Lei Wen | ea52676 | 2011-06-22 17:03:31 +0000 | [diff] [blame] | 511 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 512 | if (argc != 5) |
| 513 | return CMD_RET_USAGE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 514 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 515 | dev = simple_strtoul(argv[1], NULL, 10); |
| 516 | ack = simple_strtoul(argv[2], NULL, 10); |
| 517 | part_num = simple_strtoul(argv[3], NULL, 10); |
| 518 | access = simple_strtoul(argv[4], NULL, 10); |
Rabin Vincent | 3e448aa | 2009-04-05 13:30:53 +0530 | [diff] [blame] | 519 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 520 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 521 | if (!mmc) |
| 522 | return CMD_RET_FAILURE; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 523 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 524 | if (IS_SD(mmc)) { |
| 525 | puts("PARTITION_CONFIG only exists on eMMC\n"); |
| 526 | return CMD_RET_FAILURE; |
| 527 | } |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 528 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 529 | /* acknowledge to be sent during boot operation */ |
| 530 | return mmc_set_part_conf(mmc, ack, part_num, access); |
| 531 | } |
| 532 | static int do_mmc_rst_func(cmd_tbl_t *cmdtp, int flag, |
| 533 | int argc, char * const argv[]) |
| 534 | { |
| 535 | int dev; |
| 536 | struct mmc *mmc; |
| 537 | u8 enable; |
Nikita Kiryanov | 020f261 | 2012-12-03 02:19:46 +0000 | [diff] [blame] | 538 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 539 | /* |
| 540 | * Set the RST_n_ENABLE bit of RST_n_FUNCTION |
| 541 | * The only valid values are 0x0, 0x1 and 0x2 and writing |
| 542 | * a value of 0x1 or 0x2 sets the value permanently. |
| 543 | */ |
| 544 | if (argc != 3) |
| 545 | return CMD_RET_USAGE; |
| 546 | |
| 547 | dev = simple_strtoul(argv[1], NULL, 10); |
| 548 | enable = simple_strtoul(argv[2], NULL, 10); |
| 549 | |
| 550 | if (enable > 2 || enable < 0) { |
| 551 | puts("Invalid RST_n_ENABLE value\n"); |
| 552 | return CMD_RET_USAGE; |
| 553 | } |
| 554 | |
Stephen Warren | b627f4b | 2014-05-23 13:24:45 -0600 | [diff] [blame] | 555 | mmc = init_mmc_device(dev, false); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 556 | if (!mmc) |
| 557 | return CMD_RET_FAILURE; |
| 558 | |
| 559 | if (IS_SD(mmc)) { |
| 560 | puts("RST_n_FUNCTION only exists on eMMC\n"); |
| 561 | return CMD_RET_FAILURE; |
| 562 | } |
| 563 | |
| 564 | return mmc_set_rst_n_function(mmc, enable); |
| 565 | } |
| 566 | #endif |
| 567 | static int do_mmc_setdsr(cmd_tbl_t *cmdtp, int flag, |
| 568 | int argc, char * const argv[]) |
| 569 | { |
| 570 | struct mmc *mmc; |
| 571 | u32 val; |
| 572 | int ret; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 573 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 574 | if (argc != 2) |
| 575 | return CMD_RET_USAGE; |
| 576 | val = simple_strtoul(argv[2], NULL, 16); |
| 577 | |
| 578 | mmc = find_mmc_device(curr_device); |
| 579 | if (!mmc) { |
| 580 | printf("no mmc device at slot %x\n", curr_device); |
| 581 | return CMD_RET_FAILURE; |
| 582 | } |
| 583 | ret = mmc_set_dsr(mmc, val); |
| 584 | printf("set dsr %s\n", (!ret) ? "OK, force rescan" : "ERROR"); |
| 585 | if (!ret) { |
| 586 | mmc->has_init = 0; |
| 587 | if (mmc_init(mmc)) |
| 588 | return CMD_RET_FAILURE; |
| 589 | else |
| 590 | return CMD_RET_SUCCESS; |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 591 | } |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 592 | return ret; |
| 593 | } |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 594 | |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 595 | static cmd_tbl_t cmd_mmc[] = { |
| 596 | U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""), |
| 597 | U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""), |
| 598 | U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""), |
| 599 | U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""), |
| 600 | U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""), |
| 601 | U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""), |
| 602 | U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""), |
| 603 | U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""), |
| 604 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
| 605 | U_BOOT_CMD_MKENT(bootbus, 5, 0, do_mmc_bootbus, "", ""), |
Wally Yeh | d49c4aa | 2014-09-25 23:00:16 +0800 | [diff] [blame] | 606 | U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "", ""), |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 607 | U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""), |
| 608 | U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""), |
| 609 | #endif |
| 610 | #ifdef CONFIG_SUPPORT_EMMC_RPMB |
| 611 | U_BOOT_CMD_MKENT(rpmb, CONFIG_SYS_MAXARGS, 1, do_mmcrpmb, "", ""), |
| 612 | #endif |
| 613 | U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""), |
| 614 | }; |
| 615 | |
| 616 | static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 617 | { |
| 618 | cmd_tbl_t *cp; |
| 619 | |
| 620 | cp = find_cmd_tbl(argv[1], cmd_mmc, ARRAY_SIZE(cmd_mmc)); |
| 621 | |
| 622 | /* Drop the mmc command */ |
| 623 | argc--; |
| 624 | argv++; |
| 625 | |
| 626 | if (cp == NULL || argc > cp->maxargs) |
| 627 | return CMD_RET_USAGE; |
| 628 | if (flag == CMD_FLAG_REPEAT && !cp->repeatable) |
| 629 | return CMD_RET_SUCCESS; |
| 630 | |
| 631 | if (curr_device < 0) { |
| 632 | if (get_mmc_num() > 0) { |
| 633 | curr_device = 0; |
| 634 | } else { |
| 635 | puts("No MMC device available\n"); |
| 636 | return CMD_RET_FAILURE; |
| 637 | } |
| 638 | } |
| 639 | return cp->cmd(cmdtp, flag, argc, argv); |
Andy Fleming | ad347bb | 2008-10-30 16:41:01 -0500 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | U_BOOT_CMD( |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 643 | mmc, 7, 1, do_mmcops, |
Mike Frysinger | 27e1e62 | 2009-03-23 22:27:34 -0400 | [diff] [blame] | 644 | "MMC sub system", |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 645 | "info - display info of the current MMC device\n" |
| 646 | "mmc read addr blk# cnt\n" |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 647 | "mmc write addr blk# cnt\n" |
Lei Wen | ea52676 | 2011-06-22 17:03:31 +0000 | [diff] [blame] | 648 | "mmc erase blk# cnt\n" |
Lei Wen | d430d7c | 2011-05-02 16:26:25 +0000 | [diff] [blame] | 649 | "mmc rescan\n" |
| 650 | "mmc part - lists available partition on current mmc device\n" |
Lei Wen | 31b9980 | 2011-05-02 16:26:26 +0000 | [diff] [blame] | 651 | "mmc dev [dev] [part] - show or set current mmc device [partition]\n" |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 652 | "mmc list - lists available devices\n" |
| 653 | #ifdef CONFIG_SUPPORT_EMMC_BOOT |
Tom Rini | 4cf854c | 2014-02-05 10:24:22 -0500 | [diff] [blame] | 654 | "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n" |
| 655 | " - Set the BOOT_BUS_WIDTH field of the specified device\n" |
Tom Rini | 7991946 | 2014-02-05 10:24:20 -0500 | [diff] [blame] | 656 | "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n" |
| 657 | " - Change sizes of boot and RPMB partitions of specified device\n" |
Tom Rini | f8c6f79 | 2014-02-05 10:24:21 -0500 | [diff] [blame] | 658 | "mmc partconf dev boot_ack boot_partition partition_access\n" |
| 659 | " - Change the bits of the PARTITION_CONFIG field of the specified device\n" |
Tom Rini | 35a3ea1 | 2014-02-07 14:15:20 -0500 | [diff] [blame] | 660 | "mmc rst-function dev value\n" |
| 661 | " - Change the RST_n_FUNCTION field of the specified device\n" |
| 662 | " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n" |
Dirk Behme | df8852a | 2009-02-18 19:59:39 +0100 | [diff] [blame] | 663 | #endif |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 664 | #ifdef CONFIG_SUPPORT_EMMC_RPMB |
| 665 | "mmc rpmb read addr blk# cnt [address of auth-key] - block size is 256 bytes\n" |
| 666 | "mmc rpmb write addr blk# cnt <address of auth-key> - block size is 256 bytes\n" |
| 667 | "mmc rpmb key <address of auth-key> - program the RPMB authentication key.\n" |
| 668 | "mmc rpmb counter - read the value of the write counter\n" |
| 669 | #endif |
| 670 | "mmc setdsr <value> - set DSR register value\n" |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 671 | ); |
Pierre Aubert | bcc302c | 2014-04-24 10:30:08 +0200 | [diff] [blame] | 672 | |
| 673 | /* Old command kept for compatibility. Same as 'mmc info' */ |
| 674 | U_BOOT_CMD( |
| 675 | mmcinfo, 1, 0, do_mmcinfo, |
| 676 | "display MMC info", |
| 677 | "- display info of the current MMC device" |
| 678 | ); |
| 679 | |
Amar | 3ccad53 | 2013-04-27 11:43:00 +0530 | [diff] [blame] | 680 | #endif /* !CONFIG_GENERIC_MMC */ |