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