3 * Kyle Harris, kharris@nexus-tech.net
5 * SPDX-License-Identifier: GPL-2.0+
13 static int curr_device = -1;
15 static void print_mmcinfo(struct mmc *mmc)
19 printf("Device: %s\n", mmc->cfg->name);
20 printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24);
21 printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff);
22 printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff,
23 (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff,
24 (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff);
26 printf("Tran Speed: %d\n", mmc->tran_speed);
27 printf("Rd Block Len: %d\n", mmc->read_bl_len);
29 printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC",
30 EXTRACT_SDMMC_MAJOR_VERSION(mmc->version),
31 EXTRACT_SDMMC_MINOR_VERSION(mmc->version));
32 if (EXTRACT_SDMMC_CHANGE_VERSION(mmc->version) != 0)
33 printf(".%d", EXTRACT_SDMMC_CHANGE_VERSION(mmc->version));
36 printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No");
38 print_size(mmc->capacity, "\n");
40 printf("Bus Width: %d-bit%s\n", mmc->bus_width,
41 mmc->ddr_mode ? " DDR" : "");
43 puts("Erase Group Size: ");
44 print_size(((u64)mmc->erase_grp_size) << 9, "\n");
46 if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) {
47 bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0;
48 bool usr_enh = has_enh && (mmc->part_attr & EXT_CSD_ENH_USR);
50 puts("HC WP Group Size: ");
51 print_size(((u64)mmc->hc_wp_grp_size) << 9, "\n");
53 puts("User Capacity: ");
54 print_size(mmc->capacity_user, usr_enh ? " ENH" : "");
55 if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_USR)
60 puts("User Enhanced Start: ");
61 print_size(mmc->enh_user_start, "\n");
62 puts("User Enhanced Size: ");
63 print_size(mmc->enh_user_size, "\n");
65 puts("Boot Capacity: ");
66 print_size(mmc->capacity_boot, has_enh ? " ENH\n" : "\n");
67 puts("RPMB Capacity: ");
68 print_size(mmc->capacity_rpmb, has_enh ? " ENH\n" : "\n");
70 for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) {
71 bool is_enh = has_enh &&
72 (mmc->part_attr & EXT_CSD_ENH_GP(i));
73 if (mmc->capacity_gp[i]) {
74 printf("GP%i Capacity: ", i+1);
75 print_size(mmc->capacity_gp[i],
76 is_enh ? " ENH" : "");
77 if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_GP(i))
86 static struct mmc *init_mmc_device(int dev, bool force_init)
88 struct mmc *mmc = find_mmc_device(dev);
91 printf("no mmc device at slot %x\n", dev);
102 static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
106 if (curr_device < 0) {
107 if (get_mmc_num() > 0) {
110 puts("No MMC device available\n");
115 mmc = init_mmc_device(curr_device, false);
117 return CMD_RET_FAILURE;
120 return CMD_RET_SUCCESS;
123 #ifdef CONFIG_SUPPORT_EMMC_RPMB
124 static int confirm_key_prog(void)
126 puts("Warning: Programming authentication key can be done only once !\n"
127 " Use this command only if you are sure of what you are doing,\n"
128 "Really perform the key programming? <y/N> ");
132 puts("Authentication key programming aborted\n");
136 static int do_mmcrpmb_key(cmd_tbl_t *cmdtp, int flag,
137 int argc, char *const argv[])
140 struct mmc *mmc = find_mmc_device(curr_device);
143 return CMD_RET_USAGE;
145 key_addr = (void *)simple_strtoul(argv[1], NULL, 16);
146 if (!confirm_key_prog())
147 return CMD_RET_FAILURE;
148 if (mmc_rpmb_set_key(mmc, key_addr)) {
149 printf("ERROR - Key already programmed ?\n");
150 return CMD_RET_FAILURE;
152 return CMD_RET_SUCCESS;
155 static int do_mmcrpmb_read(cmd_tbl_t *cmdtp, int flag,
156 int argc, char *const argv[])
161 void *key_addr = NULL;
162 struct mmc *mmc = find_mmc_device(curr_device);
165 return CMD_RET_USAGE;
167 addr = (void *)simple_strtoul(argv[1], NULL, 16);
168 blk = simple_strtoul(argv[2], NULL, 16);
169 cnt = simple_strtoul(argv[3], NULL, 16);
172 key_addr = (void *)simple_strtoul(argv[4], NULL, 16);
174 printf("\nMMC RPMB read: dev # %d, block # %d, count %d ... ",
175 curr_device, blk, cnt);
176 n = mmc_rpmb_read(mmc, addr, blk, cnt, key_addr);
178 printf("%d RPMB blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR");
180 return CMD_RET_FAILURE;
181 return CMD_RET_SUCCESS;
184 static int do_mmcrpmb_write(cmd_tbl_t *cmdtp, int flag,
185 int argc, char *const argv[])
191 struct mmc *mmc = find_mmc_device(curr_device);
194 return CMD_RET_USAGE;
196 addr = (void *)simple_strtoul(argv[1], NULL, 16);
197 blk = simple_strtoul(argv[2], NULL, 16);
198 cnt = simple_strtoul(argv[3], NULL, 16);
199 key_addr = (void *)simple_strtoul(argv[4], NULL, 16);
201 printf("\nMMC RPMB write: dev # %d, block # %d, count %d ... ",
202 curr_device, blk, cnt);
203 n = mmc_rpmb_write(mmc, addr, blk, cnt, key_addr);
205 printf("%d RPMB blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR");
207 return CMD_RET_FAILURE;
208 return CMD_RET_SUCCESS;
211 static int do_mmcrpmb_counter(cmd_tbl_t *cmdtp, int flag,
212 int argc, char *const argv[])
214 unsigned long counter;
215 struct mmc *mmc = find_mmc_device(curr_device);
217 if (mmc_rpmb_get_counter(mmc, &counter))
218 return CMD_RET_FAILURE;
220 printf("RPMB Write counter= %lx\n", counter);
221 return CMD_RET_SUCCESS;
224 static cmd_tbl_t cmd_rpmb[] = {
225 U_BOOT_CMD_MKENT(key, 2, 0, do_mmcrpmb_key, "", ""),
226 U_BOOT_CMD_MKENT(read, 5, 1, do_mmcrpmb_read, "", ""),
227 U_BOOT_CMD_MKENT(write, 5, 0, do_mmcrpmb_write, "", ""),
228 U_BOOT_CMD_MKENT(counter, 1, 1, do_mmcrpmb_counter, "", ""),
231 static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag,
232 int argc, char *const argv[])
234 cmd_tbl_t *cp = find_cmd_tbl(argv[1], cmd_rpmb, ARRAY_SIZE(cmd_rpmb));
239 /* Drop the rpmb subcommand */
243 if (cp == NULL || argc > cp->maxargs)
244 return CMD_RET_USAGE;
245 if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
246 return CMD_RET_SUCCESS;
248 mmc = init_mmc_device(curr_device, false);
250 return CMD_RET_FAILURE;
252 if (!(mmc->version & MMC_VERSION_MMC)) {
253 printf("It is not a EMMC device\n");
254 return CMD_RET_FAILURE;
256 if (mmc->version < MMC_VERSION_4_41) {
257 printf("RPMB not supported before version 4.41\n");
258 return CMD_RET_FAILURE;
260 /* Switch to the RPMB partition */
261 original_part = mmc->block_dev.hwpart;
262 if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, MMC_PART_RPMB) !=
264 return CMD_RET_FAILURE;
265 ret = cp->cmd(cmdtp, flag, argc, argv);
267 /* Return to original partition */
268 if (blk_select_hwpart_devnum(IF_TYPE_MMC, curr_device, original_part) !=
270 return CMD_RET_FAILURE;
275 static int do_mmc_read(cmd_tbl_t *cmdtp, int flag,
276 int argc, char *const argv[])
283 return CMD_RET_USAGE;
285 addr = (void *)simple_strtoul(argv[1], NULL, 16);
286 blk = simple_strtoul(argv[2], NULL, 16);
287 cnt = simple_strtoul(argv[3], NULL, 16);
289 mmc = init_mmc_device(curr_device, false);
291 return CMD_RET_FAILURE;
293 printf("\nMMC read: dev # %d, block # %d, count %d ... ",
294 curr_device, blk, cnt);
296 n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, addr);
297 /* flush cache after read */
298 flush_cache((ulong)addr, cnt * 512); /* FIXME */
299 printf("%d blocks read: %s\n", n, (n == cnt) ? "OK" : "ERROR");
301 return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
304 static int do_mmc_write(cmd_tbl_t *cmdtp, int flag,
305 int argc, char *const argv[])
312 return CMD_RET_USAGE;
314 addr = (void *)simple_strtoul(argv[1], NULL, 16);
315 blk = simple_strtoul(argv[2], NULL, 16);
316 cnt = simple_strtoul(argv[3], NULL, 16);
318 mmc = init_mmc_device(curr_device, false);
320 return CMD_RET_FAILURE;
322 printf("\nMMC write: dev # %d, block # %d, count %d ... ",
323 curr_device, blk, cnt);
325 if (mmc_getwp(mmc) == 1) {
326 printf("Error: card is write protected!\n");
327 return CMD_RET_FAILURE;
329 n = blk_dwrite(mmc_get_blk_desc(mmc), blk, cnt, addr);
330 printf("%d blocks written: %s\n", n, (n == cnt) ? "OK" : "ERROR");
332 return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
335 static int do_mmc_erase(cmd_tbl_t *cmdtp, int flag,
336 int argc, char *const argv[])
342 return CMD_RET_USAGE;
344 blk = simple_strtoul(argv[1], NULL, 16);
345 cnt = simple_strtoul(argv[2], NULL, 16);
347 mmc = init_mmc_device(curr_device, false);
349 return CMD_RET_FAILURE;
351 printf("\nMMC erase: dev # %d, block # %d, count %d ... ",
352 curr_device, blk, cnt);
354 if (mmc_getwp(mmc) == 1) {
355 printf("Error: card is write protected!\n");
356 return CMD_RET_FAILURE;
358 n = blk_derase(mmc_get_blk_desc(mmc), blk, cnt);
359 printf("%d blocks erased: %s\n", n, (n == cnt) ? "OK" : "ERROR");
361 return (n == cnt) ? CMD_RET_SUCCESS : CMD_RET_FAILURE;
364 static int do_mmc_rescan(cmd_tbl_t *cmdtp, int flag,
365 int argc, char *const argv[])
367 struct mmc *mmc = init_mmc_device(curr_device, true);
370 return CMD_RET_FAILURE;
372 return CMD_RET_SUCCESS;
375 static int do_mmc_part(cmd_tbl_t *cmdtp, int flag,
376 int argc, char *const argv[])
378 struct blk_desc *mmc_dev;
379 struct mmc *mmc = init_mmc_device(curr_device, false);
382 return CMD_RET_FAILURE;
384 mmc_dev = blk_get_devnum_by_type(IF_TYPE_MMC, curr_device);
385 printf("%s@%d: curr_device=%u mmc_dev=%p type=%08x\n", __func__, __LINE__,
386 curr_device, mmc_dev, mmc_dev ? mmc_dev->type : -1);
387 if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) {
389 return CMD_RET_SUCCESS;
392 puts("get mmc type error!\n");
393 return CMD_RET_FAILURE;
396 static int do_mmc_dev(cmd_tbl_t *cmdtp, int flag,
397 int argc, char *const argv[])
399 int dev, part = 0, ret;
404 } else if (argc == 2) {
405 dev = simple_strtoul(argv[1], NULL, 10);
406 } else if (argc == 3) {
407 dev = (int)simple_strtoul(argv[1], NULL, 10);
408 part = (int)simple_strtoul(argv[2], NULL, 10);
409 if (part > PART_ACCESS_MASK) {
410 printf("#part_num shouldn't be larger than %d\n",
412 return CMD_RET_FAILURE;
415 return CMD_RET_USAGE;
418 mmc = init_mmc_device(dev, true);
420 return CMD_RET_FAILURE;
422 ret = blk_select_hwpart_devnum(IF_TYPE_MMC, dev, part);
423 printf("switch to partitions #%d, %s\n",
424 part, (!ret) ? "OK" : "ERROR");
429 if (mmc->part_config == MMCPART_NOAVAILABLE)
430 printf("mmc%d is current device\n", curr_device);
432 printf("mmc%d(part %d) is current device\n",
433 curr_device, mmc_get_blk_desc(mmc)->hwpart);
435 return CMD_RET_SUCCESS;
438 static int do_mmc_list(cmd_tbl_t *cmdtp, int flag,
439 int argc, char *const argv[])
441 print_mmc_devices('\n');
442 return CMD_RET_SUCCESS;
445 static int parse_hwpart_user(struct mmc_hwpart_conf *pconf,
446 int argc, char *const argv[])
450 memset(&pconf->user, 0, sizeof(pconf->user));
453 if (!strcmp(argv[i], "enh")) {
456 pconf->user.enh_start =
457 simple_strtoul(argv[i+1], NULL, 10);
458 pconf->user.enh_size =
459 simple_strtoul(argv[i+2], NULL, 10);
461 } else if (!strcmp(argv[i], "wrrel")) {
464 pconf->user.wr_rel_change = 1;
465 if (!strcmp(argv[i+1], "on"))
466 pconf->user.wr_rel_set = 1;
467 else if (!strcmp(argv[i+1], "off"))
468 pconf->user.wr_rel_set = 0;
479 static int parse_hwpart_gp(struct mmc_hwpart_conf *pconf, int pidx,
480 int argc, char *const argv[])
484 memset(&pconf->gp_part[pidx], 0, sizeof(pconf->gp_part[pidx]));
489 pconf->gp_part[pidx].size = simple_strtoul(argv[0], NULL, 10);
493 if (!strcmp(argv[i], "enh")) {
494 pconf->gp_part[pidx].enhanced = 1;
496 } else if (!strcmp(argv[i], "wrrel")) {
499 pconf->gp_part[pidx].wr_rel_change = 1;
500 if (!strcmp(argv[i+1], "on"))
501 pconf->gp_part[pidx].wr_rel_set = 1;
502 else if (!strcmp(argv[i+1], "off"))
503 pconf->gp_part[pidx].wr_rel_set = 0;
514 static int do_mmc_hwpartition(cmd_tbl_t *cmdtp, int flag,
515 int argc, char *const argv[])
518 struct mmc_hwpart_conf pconf = { };
519 enum mmc_hwpart_conf_mode mode = MMC_HWPART_CONF_CHECK;
522 mmc = init_mmc_device(curr_device, false);
524 return CMD_RET_FAILURE;
527 return CMD_RET_USAGE;
530 if (!strcmp(argv[i], "user")) {
532 r = parse_hwpart_user(&pconf, argc-i, &argv[i]);
534 return CMD_RET_USAGE;
536 } else if (!strncmp(argv[i], "gp", 2) &&
537 strlen(argv[i]) == 3 &&
538 argv[i][2] >= '1' && argv[i][2] <= '4') {
539 pidx = argv[i][2] - '1';
541 r = parse_hwpart_gp(&pconf, pidx, argc-i, &argv[i]);
543 return CMD_RET_USAGE;
545 } else if (!strcmp(argv[i], "check")) {
546 mode = MMC_HWPART_CONF_CHECK;
548 } else if (!strcmp(argv[i], "set")) {
549 mode = MMC_HWPART_CONF_SET;
551 } else if (!strcmp(argv[i], "complete")) {
552 mode = MMC_HWPART_CONF_COMPLETE;
555 return CMD_RET_USAGE;
559 puts("Partition configuration:\n");
560 if (pconf.user.enh_size) {
561 puts("\tUser Enhanced Start: ");
562 print_size(((u64)pconf.user.enh_start) << 9, "\n");
563 puts("\tUser Enhanced Size: ");
564 print_size(((u64)pconf.user.enh_size) << 9, "\n");
566 puts("\tNo enhanced user data area\n");
568 if (pconf.user.wr_rel_change)
569 printf("\tUser partition write reliability: %s\n",
570 pconf.user.wr_rel_set ? "on" : "off");
571 for (pidx = 0; pidx < 4; pidx++) {
572 if (pconf.gp_part[pidx].size) {
573 printf("\tGP%i Capacity: ", pidx+1);
574 print_size(((u64)pconf.gp_part[pidx].size) << 9,
575 pconf.gp_part[pidx].enhanced ?
578 printf("\tNo GP%i partition\n", pidx+1);
580 if (pconf.gp_part[pidx].wr_rel_change)
581 printf("\tGP%i write reliability: %s\n", pidx+1,
582 pconf.gp_part[pidx].wr_rel_set ? "on" : "off");
585 if (!mmc_hwpart_config(mmc, &pconf, mode)) {
586 if (mode == MMC_HWPART_CONF_COMPLETE)
587 puts("Partitioning successful, "
588 "power-cycle to make effective\n");
589 return CMD_RET_SUCCESS;
592 return CMD_RET_FAILURE;
596 #ifdef CONFIG_SUPPORT_EMMC_BOOT
597 static int do_mmc_bootbus(cmd_tbl_t *cmdtp, int flag,
598 int argc, char *const argv[])
602 u8 width, reset, mode;
605 return CMD_RET_USAGE;
607 dev = simple_strtoul(argv[1], NULL, 10);
608 width = simple_strtoul(argv[2], NULL, 10);
609 reset = simple_strtoul(argv[3], NULL, 10);
610 mode = simple_strtoul(argv[4], NULL, 10);
612 mmc = init_mmc_device(dev, false);
614 return CMD_RET_FAILURE;
617 puts("BOOT_BUS_WIDTH only exists on eMMC\n");
618 return CMD_RET_FAILURE;
621 /* acknowledge to be sent during boot operation */
622 return mmc_set_boot_bus_width(mmc, width, reset, mode);
625 static int do_mmc_boot_resize(cmd_tbl_t *cmdtp, int flag,
626 int argc, char *const argv[])
630 u32 bootsize, rpmbsize;
633 return CMD_RET_USAGE;
634 dev = simple_strtoul(argv[1], NULL, 10);
635 bootsize = simple_strtoul(argv[2], NULL, 10);
636 rpmbsize = simple_strtoul(argv[3], NULL, 10);
638 mmc = init_mmc_device(dev, false);
640 return CMD_RET_FAILURE;
643 printf("It is not a EMMC device\n");
644 return CMD_RET_FAILURE;
647 if (mmc_boot_partition_size_change(mmc, bootsize, rpmbsize)) {
648 printf("EMMC boot partition Size change Failed.\n");
649 return CMD_RET_FAILURE;
652 printf("EMMC boot partition Size %d MB\n", bootsize);
653 printf("EMMC RPMB partition Size %d MB\n", rpmbsize);
654 return CMD_RET_SUCCESS;
657 static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag,
658 int argc, char *const argv[])
662 u8 ack, part_num, access;
665 return CMD_RET_USAGE;
667 dev = simple_strtoul(argv[1], NULL, 10);
668 ack = simple_strtoul(argv[2], NULL, 10);
669 part_num = simple_strtoul(argv[3], NULL, 10);
670 access = simple_strtoul(argv[4], NULL, 10);
672 mmc = init_mmc_device(dev, false);
674 return CMD_RET_FAILURE;
677 puts("PARTITION_CONFIG only exists on eMMC\n");
678 return CMD_RET_FAILURE;
681 /* acknowledge to be sent during boot operation */
682 return mmc_set_part_conf(mmc, ack, part_num, access);
685 static int do_mmc_rst_func(cmd_tbl_t *cmdtp, int flag,
686 int argc, char *const argv[])
693 * Set the RST_n_ENABLE bit of RST_n_FUNCTION
694 * The only valid values are 0x0, 0x1 and 0x2 and writing
695 * a value of 0x1 or 0x2 sets the value permanently.
698 return CMD_RET_USAGE;
700 dev = simple_strtoul(argv[1], NULL, 10);
701 enable = simple_strtoul(argv[2], NULL, 10);
704 puts("Invalid RST_n_ENABLE value\n");
705 return CMD_RET_USAGE;
708 mmc = init_mmc_device(dev, false);
710 return CMD_RET_FAILURE;
713 puts("RST_n_FUNCTION only exists on eMMC\n");
714 return CMD_RET_FAILURE;
717 return mmc_set_rst_n_function(mmc, enable);
721 static int do_mmc_setdsr(cmd_tbl_t *cmdtp, int flag,
722 int argc, char *const argv[])
729 return CMD_RET_USAGE;
731 val = simple_strtoul(argv[2], NULL, 16);
733 mmc = find_mmc_device(curr_device);
735 printf("no mmc device at slot %x\n", curr_device);
736 return CMD_RET_FAILURE;
738 ret = mmc_set_dsr(mmc, val);
739 printf("set dsr %s\n", (!ret) ? "OK, force rescan" : "ERROR");
743 return CMD_RET_FAILURE;
745 return CMD_RET_SUCCESS;
750 static cmd_tbl_t cmd_mmc[] = {
751 U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""),
752 U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""),
753 U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""),
754 U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""),
755 U_BOOT_CMD_MKENT(rescan, 1, 1, do_mmc_rescan, "", ""),
756 U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""),
757 U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""),
758 U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""),
759 U_BOOT_CMD_MKENT(hwpartition, 28, 0, do_mmc_hwpartition, "", ""),
760 #ifdef CONFIG_SUPPORT_EMMC_BOOT
761 U_BOOT_CMD_MKENT(bootbus, 5, 0, do_mmc_bootbus, "", ""),
762 U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "", ""),
763 U_BOOT_CMD_MKENT(partconf, 5, 0, do_mmc_partconf, "", ""),
764 U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""),
766 #ifdef CONFIG_SUPPORT_EMMC_RPMB
767 U_BOOT_CMD_MKENT(rpmb, CONFIG_SYS_MAXARGS, 1, do_mmcrpmb, "", ""),
769 U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""),
772 static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
774 cmd_tbl_t *cp = find_cmd_tbl(argv[1], cmd_mmc, ARRAY_SIZE(cmd_mmc));
776 /* Drop the mmc command */
780 if (cp == NULL || argc > cp->maxargs)
781 return CMD_RET_USAGE;
782 if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
783 return CMD_RET_SUCCESS;
785 if (curr_device < 0) {
786 if (get_mmc_num() > 0) {
789 puts("No MMC device available\n");
790 return CMD_RET_FAILURE;
793 return cp->cmd(cmdtp, flag, argc, argv);
797 mmc, 29, 1, do_mmcops,
799 "info - display info of the current MMC device\n"
800 "mmc read addr blk# cnt\n"
801 "mmc write addr blk# cnt\n"
802 "mmc erase blk# cnt\n"
804 "mmc part - lists available partition on current mmc device\n"
805 "mmc dev [dev] [part] - show or set current mmc device [partition]\n"
806 "mmc list - lists available devices\n"
807 "mmc hwpartition [args...] - does hardware partitioning\n"
808 " arguments (sizes in 512-byte blocks):\n"
809 " [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes\n"
810 " [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition\n"
811 " [check|set|complete] - mode, complete set partitioning completed\n"
812 " WARNING: Partitioning is a write-once setting once it is set to complete.\n"
813 " Power cycling is required to initialize partitions after set to complete.\n"
814 #ifdef CONFIG_SUPPORT_EMMC_BOOT
815 "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
816 " - Set the BOOT_BUS_WIDTH field of the specified device\n"
817 "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
818 " - Change sizes of boot and RPMB partitions of specified device\n"
819 "mmc partconf dev boot_ack boot_partition partition_access\n"
820 " - Change the bits of the PARTITION_CONFIG field of the specified device\n"
821 "mmc rst-function dev value\n"
822 " - Change the RST_n_FUNCTION field of the specified device\n"
823 " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n"
825 #ifdef CONFIG_SUPPORT_EMMC_RPMB
826 "mmc rpmb read addr blk# cnt [address of auth-key] - block size is 256 bytes\n"
827 "mmc rpmb write addr blk# cnt <address of auth-key> - block size is 256 bytes\n"
828 "mmc rpmb key <address of auth-key> - program the RPMB authentication key.\n"
829 "mmc rpmb counter - read the value of the write counter\n"
831 "mmc setdsr <value> - set DSR register value\n"
834 /* Old command kept for compatibility. Same as 'mmc info' */
836 mmcinfo, 1, 0, do_mmcinfo,
838 "- display info of the current MMC device"