mmc.c 30 KB

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