Lines Matching +full:no +full:- +full:mmc

3  * Kyle Harris, kharris@nexus-tech.net
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <mmc.h>
15 static int curr_device = -1;
17 static void print_mmcinfo(struct mmc *mmc) in print_mmcinfo() argument
25 printf("Device: %s\n", mmc->cfg->name); in print_mmcinfo()
26 printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24); in print_mmcinfo()
27 printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff); in print_mmcinfo()
28 printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff, in print_mmcinfo()
29 (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, in print_mmcinfo()
30 (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff); in print_mmcinfo()
32 printf("Timing Interface: %s\n", timing[mmc->timing]); in print_mmcinfo()
33 printf("Tran Speed: %d\n", mmc->clock); in print_mmcinfo()
34 printf("Rd Block Len: %d\n", mmc->read_bl_len); in print_mmcinfo()
36 printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC", in print_mmcinfo()
37 EXTRACT_SDMMC_MAJOR_VERSION(mmc->version), in print_mmcinfo()
38 EXTRACT_SDMMC_MINOR_VERSION(mmc->version)); in print_mmcinfo()
39 if (EXTRACT_SDMMC_CHANGE_VERSION(mmc->version) != 0) in print_mmcinfo()
40 printf(".%d", EXTRACT_SDMMC_CHANGE_VERSION(mmc->version)); in print_mmcinfo()
43 printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No"); in print_mmcinfo()
45 print_size(mmc->capacity, "\n"); in print_mmcinfo()
47 printf("Bus Width: %d-bit%s\n", mmc->bus_width, in print_mmcinfo()
48 mmc_card_ddr(mmc) ? " DDR" : ""); in print_mmcinfo()
51 print_size(((u64)mmc->erase_grp_size) << 9, "\n"); in print_mmcinfo()
53 if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) { in print_mmcinfo()
54 bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0; in print_mmcinfo()
55 bool usr_enh = has_enh && (mmc->part_attr & EXT_CSD_ENH_USR); in print_mmcinfo()
58 print_size(((u64)mmc->hc_wp_grp_size) << 9, "\n"); in print_mmcinfo()
61 print_size(mmc->capacity_user, usr_enh ? " ENH" : ""); in print_mmcinfo()
62 if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_USR) in print_mmcinfo()
68 print_size(mmc->enh_user_start, "\n"); in print_mmcinfo()
70 print_size(mmc->enh_user_size, "\n"); in print_mmcinfo()
73 print_size(mmc->capacity_boot, has_enh ? " ENH\n" : "\n"); in print_mmcinfo()
75 print_size(mmc->capacity_rpmb, has_enh ? " ENH\n" : "\n"); in print_mmcinfo()
77 for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) { in print_mmcinfo()
79 (mmc->part_attr & EXT_CSD_ENH_GP(i)); in print_mmcinfo()
80 if (mmc->capacity_gp[i]) { in print_mmcinfo()
82 print_size(mmc->capacity_gp[i], in print_mmcinfo()
84 if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_GP(i)) in print_mmcinfo()
92 static struct mmc *init_mmc_device(int dev, bool force_init) in init_mmc_device()
94 struct mmc *mmc; in init_mmc_device() local
95 mmc = find_mmc_device(dev); in init_mmc_device()
96 if (!mmc) { in init_mmc_device()
97 printf("no mmc device at slot %x\n", dev); in init_mmc_device()
102 mmc->has_init = 0; in init_mmc_device()
103 if (mmc_init(mmc)) in init_mmc_device()
105 return mmc; in init_mmc_device()
109 struct mmc *mmc; in do_mmcinfo() local
115 puts("No MMC device available\n"); in do_mmcinfo()
120 mmc = init_mmc_device(curr_device, false); in do_mmcinfo()
121 if (!mmc) in do_mmcinfo()
124 print_mmcinfo(mmc); in do_mmcinfo()
133 struct mmc *mmc; in do_mmc_test_secure_storage() local
137 puts("MMC device available\n"); in do_mmc_test_secure_storage()
140 puts("No MMC device available\n"); in do_mmc_test_secure_storage()
145 mmc = init_mmc_device(curr_device, false); in do_mmc_test_secure_storage()
146 if (!mmc) in do_mmc_test_secure_storage()
147 printf("No mmc device\n"); in do_mmc_test_secure_storage()
191 struct mmc *mmc; in init_rpmb() local
197 printf("No MMC device available\n"); in init_rpmb()
202 mmc = init_mmc_device(curr_device, false); in init_rpmb()
203 if (!mmc) in init_rpmb()
206 if (!(mmc->version & MMC_VERSION_MMC)) { in init_rpmb()
210 if (mmc->version < MMC_VERSION_4_41) { in init_rpmb()
217 temp_original_part = mmc->block_dev.hwpart; in init_rpmb()
218 debug("mmc->block_dev.hwpart\n"); in init_rpmb()
220 temp_original_part = mmc_get_blk_desc(mmc)->hwpart; in init_rpmb()
221 debug("mmc_get_blk_desc(mmc)->hwpart\n"); in init_rpmb()
244 struct mmc *mmc = find_mmc_device(curr_device); in do_readcounter() local
246 return read_counter(mmc, requestpackets); in do_readcounter()
251 struct mmc *mmc = find_mmc_device(curr_device); in do_programkey() local
253 return program_key(mmc, requestpackets); in do_programkey()
258 struct mmc *mmc = find_mmc_device(curr_device); in do_authenticatedread() local
260 return authenticated_read(mmc, requestpackets, block_count); in do_authenticatedread()
265 struct mmc *mmc = find_mmc_device(curr_device); in do_authenticatedwrite() local
267 return authenticated_write(mmc, requestpackets); in do_authenticatedwrite()
270 struct mmc *do_returnmmc(void) in do_returnmmc()
272 struct mmc *mmc = find_mmc_device(curr_device); in do_returnmmc() local
274 return mmc; in do_returnmmc()
292 struct mmc *mmc = find_mmc_device(curr_device); in do_mmcrpmb_key() local
300 if (mmc_rpmb_set_key(mmc, key_addr)) { in do_mmcrpmb_key()
301 printf("ERROR - Key already programmed ?\n"); in do_mmcrpmb_key()
313 struct mmc *mmc = find_mmc_device(curr_device); in do_mmcrpmb_read() local
327 n = mmc_rpmb_read(mmc, addr, blk, cnt, key_addr); in do_mmcrpmb_read()
341 struct mmc *mmc = find_mmc_device(curr_device); in do_mmcrpmb_write() local
353 n = mmc_rpmb_write(mmc, addr, blk, cnt, key_addr); in do_mmcrpmb_write()
364 struct mmc *mmc = find_mmc_device(curr_device); in do_mmcrpmb_counter() local
366 if (mmc_rpmb_get_counter(mmc, &counter)) in do_mmcrpmb_counter()
383 struct mmc *mmc; in do_mmcrpmb() local
390 argc--; in do_mmcrpmb()
393 if (cp == NULL || argc > cp->maxargs) in do_mmcrpmb()
395 if (flag == CMD_FLAG_REPEAT && !cp->repeatable) in do_mmcrpmb()
398 mmc = init_mmc_device(curr_device, false); in do_mmcrpmb()
399 if (!mmc) in do_mmcrpmb()
402 if (!(mmc->version & MMC_VERSION_MMC)) { in do_mmcrpmb()
406 if (mmc->version < MMC_VERSION_4_41) { in do_mmcrpmb()
412 original_part = mmc->block_dev.hwpart; in do_mmcrpmb()
414 original_part = mmc_get_blk_desc(mmc)->hwpart; in do_mmcrpmb()
419 ret = cp->cmd(cmdtp, flag, argc, argv); in do_mmcrpmb()
432 struct mmc *mmc; in do_mmc_read() local
443 mmc = init_mmc_device(curr_device, false); in do_mmc_read()
444 if (!mmc) in do_mmc_read()
450 n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, addr); in do_mmc_read()
458 struct mmc *mmc; in do_mmc_write() local
469 mmc = init_mmc_device(curr_device, false); in do_mmc_write()
470 if (!mmc) in do_mmc_write()
476 if (mmc_getwp(mmc) == 1) { in do_mmc_write()
480 n = blk_dwrite(mmc_get_blk_desc(mmc), blk, cnt, addr); in do_mmc_write()
488 struct mmc *mmc; in do_mmc_erase() local
497 mmc = init_mmc_device(curr_device, false); in do_mmc_erase()
498 if (!mmc) in do_mmc_erase()
504 if (mmc_getwp(mmc) == 1) { in do_mmc_erase()
508 n = blk_derase(mmc_get_blk_desc(mmc), blk, cnt); in do_mmc_erase()
516 struct mmc *mmc; in do_mmc_rescan() local
518 mmc = init_mmc_device(curr_device, true); in do_mmc_rescan()
519 if (!mmc) in do_mmc_rescan()
528 struct mmc *mmc; in do_mmc_part() local
530 mmc = init_mmc_device(curr_device, false); in do_mmc_part()
531 if (!mmc) in do_mmc_part()
535 if (mmc_dev != NULL && mmc_dev->type != DEV_TYPE_UNKNOWN) { in do_mmc_part()
540 puts("get mmc type error!\n"); in do_mmc_part()
547 struct mmc *mmc; in do_mmc_dev() local
565 mmc = init_mmc_device(dev, false); in do_mmc_dev()
566 if (!mmc) in do_mmc_dev()
576 if (mmc->part_config == MMCPART_NOAVAILABLE) in do_mmc_dev()
577 printf("mmc%d is current device\n", curr_device); in do_mmc_dev()
579 printf("mmc%d(part %d) is current device\n", in do_mmc_dev()
580 curr_device, mmc_get_blk_desc(mmc)->hwpart); in do_mmc_dev()
596 memset(&pconf->user, 0, sizeof(pconf->user)); in parse_hwpart_user()
601 return -1; in parse_hwpart_user()
602 pconf->user.enh_start = in parse_hwpart_user()
604 pconf->user.enh_size = in parse_hwpart_user()
609 return -1; in parse_hwpart_user()
610 pconf->user.wr_rel_change = 1; in parse_hwpart_user()
612 pconf->user.wr_rel_set = 1; in parse_hwpart_user()
614 pconf->user.wr_rel_set = 0; in parse_hwpart_user()
616 return -1; in parse_hwpart_user()
630 memset(&pconf->gp_part[pidx], 0, sizeof(pconf->gp_part[pidx])); in parse_hwpart_gp()
633 return -1; in parse_hwpart_gp()
634 pconf->gp_part[pidx].size = simple_strtoul(argv[0], NULL, 10); in parse_hwpart_gp()
639 pconf->gp_part[pidx].enhanced = 1; in parse_hwpart_gp()
643 return -1; in parse_hwpart_gp()
644 pconf->gp_part[pidx].wr_rel_change = 1; in parse_hwpart_gp()
646 pconf->gp_part[pidx].wr_rel_set = 1; in parse_hwpart_gp()
648 pconf->gp_part[pidx].wr_rel_set = 0; in parse_hwpart_gp()
650 return -1; in parse_hwpart_gp()
662 struct mmc *mmc; in do_mmc_hwpartition() local
667 mmc = init_mmc_device(curr_device, false); in do_mmc_hwpartition()
668 if (!mmc) in do_mmc_hwpartition()
677 r = parse_hwpart_user(&pconf, argc-i, &argv[i]); in do_mmc_hwpartition()
684 pidx = argv[i][2] - '1'; in do_mmc_hwpartition()
686 r = parse_hwpart_gp(&pconf, pidx, argc-i, &argv[i]); in do_mmc_hwpartition()
730 if (!mmc_hwpart_config(mmc, &pconf, mode)) { in do_mmc_hwpartition()
733 "power-cycle to make effective\n"); in do_mmc_hwpartition()
746 struct mmc *mmc; in do_mmc_bootbus() local
756 mmc = init_mmc_device(dev, false); in do_mmc_bootbus()
757 if (!mmc) in do_mmc_bootbus()
760 if (IS_SD(mmc)) { in do_mmc_bootbus()
766 return mmc_set_boot_bus_width(mmc, width, reset, mode); in do_mmc_bootbus()
772 struct mmc *mmc; in do_mmc_boot_resize() local
781 mmc = init_mmc_device(dev, false); in do_mmc_boot_resize()
782 if (!mmc) in do_mmc_boot_resize()
785 if (IS_SD(mmc)) { in do_mmc_boot_resize()
790 if (mmc_boot_partition_size_change(mmc, bootsize, rpmbsize)) { in do_mmc_boot_resize()
800 static int mmc_partconf_print(struct mmc *mmc) in mmc_partconf_print() argument
804 if (mmc->part_config == MMCPART_NOAVAILABLE) { in mmc_partconf_print()
805 printf("No part_config info for ver. 0x%x\n", mmc->version); in mmc_partconf_print()
809 access = EXT_CSD_EXTRACT_PARTITION_ACCESS(mmc->part_config); in mmc_partconf_print()
810 ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config); in mmc_partconf_print()
811 part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); in mmc_partconf_print()
825 struct mmc *mmc; in do_mmc_partconf() local
833 mmc = init_mmc_device(dev, false); in do_mmc_partconf()
834 if (!mmc) in do_mmc_partconf()
837 if (IS_SD(mmc)) { in do_mmc_partconf()
843 return mmc_partconf_print(mmc); in do_mmc_partconf()
850 return mmc_set_part_conf(mmc, ack, part_num, access); in do_mmc_partconf()
856 struct mmc *mmc; in do_mmc_rst_func() local
875 mmc = init_mmc_device(dev, false); in do_mmc_rst_func()
876 if (!mmc) in do_mmc_rst_func()
879 if (IS_SD(mmc)) { in do_mmc_rst_func()
884 return mmc_set_rst_n_function(mmc, enable); in do_mmc_rst_func()
890 struct mmc *mmc; in do_mmc_setdsr() local
898 mmc = find_mmc_device(curr_device); in do_mmc_setdsr()
899 if (!mmc) { in do_mmc_setdsr()
900 printf("no mmc device at slot %x\n", curr_device); in do_mmc_setdsr()
903 ret = mmc_set_dsr(mmc, val); in do_mmc_setdsr()
906 mmc->has_init = 0; in do_mmc_setdsr()
907 if (mmc_init(mmc)) in do_mmc_setdsr()
920 struct mmc *mmc; in do_mmc_bkops_enable() local
927 mmc = init_mmc_device(dev, false); in do_mmc_bkops_enable()
928 if (!mmc) in do_mmc_bkops_enable()
931 if (IS_SD(mmc)) { in do_mmc_bkops_enable()
936 return mmc_set_bkops_enable(mmc); in do_mmc_bkops_enable()
952 U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "", ""),
954 U_BOOT_CMD_MKENT(rst-function, 3, 0, do_mmc_rst_func, "", ""),
965 U_BOOT_CMD_MKENT(bkops-enable, 2, 0, do_mmc_bkops_enable, "", ""),
975 /* Drop the mmc command */ in do_mmcops()
976 argc--; in do_mmcops()
979 if (cp == NULL || argc > cp->maxargs) in do_mmcops()
981 if (flag == CMD_FLAG_REPEAT && !cp->repeatable) in do_mmcops()
988 puts("No MMC device available\n"); in do_mmcops()
992 return cp->cmd(cmdtp, flag, argc, argv); in do_mmcops()
996 mmc, 29, 1, do_mmcops,
997 "MMC sub system",
998 "info - display info of the current MMC device\n"
999 "mmc read addr blk# cnt\n"
1000 "mmc write addr blk# cnt\n"
1001 "mmc erase blk# cnt\n"
1002 "mmc rescan\n"
1003 "mmc part - lists available partition on current mmc device\n"
1004 "mmc dev [dev] [part] - show or set current mmc device [partition]\n"
1005 "mmc list - lists available devices\n"
1006 "mmc hwpartition [args...] - does hardware partitioning\n"
1007 " arguments (sizes in 512-byte blocks):\n"
1008 " [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes\n"
1009 " [gp1|gp2|gp3|gp4 cnt [enh] [wrrel {on|off}]] - general purpose partition\n"
1010 " [check|set|complete] - mode, complete set partitioning completed\n"
1011 " WARNING: Partitioning is a write-once setting once it is set to complete.\n"
1014 "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
1015 " - Set the BOOT_BUS_WIDTH field of the specified device\n"
1016 "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
1017 " - Change sizes of boot and RPMB partitions of specified device\n"
1018 "mmc partconf dev [boot_ack boot_partition partition_access]\n"
1019 " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n"
1020 "mmc rst-function dev value\n"
1021 " - Change the RST_n_FUNCTION field of the specified device\n"
1022 " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n"
1025 "mmc testsecurestorage - test CA call static TA to store data in security\n"
1026 "mmc testefuse - test CA call static TA,and TA read or write efuse\n"
1029 "mmc rpmb read addr blk# cnt [address of auth-key] - block size is 256 bytes\n"
1030 "mmc rpmb write addr blk# cnt <address of auth-key> - block size is 256 bytes\n"
1031 "mmc rpmb key <address of auth-key> - program the RPMB authentication key.\n"
1032 "mmc rpmb counter - read the value of the write counter\n"
1034 "mmc setdsr <value> - set DSR register value\n"
1036 "mmc bkops-enable <dev> - enable background operations handshake on device\n"
1037 " WARNING: This is a write-once setting.\n"
1041 /* Old command kept for compatibility. Same as 'mmc info' */
1044 "display MMC info",
1045 "- display info of the current MMC device"