Lines Matching full:mmc
10 #include <mmc.h>
16 static void print_mmcinfo(struct mmc *mmc) in print_mmcinfo() argument
20 printf("Device: %s\n", mmc->cfg->name); in print_mmcinfo()
21 printf("Manufacturer ID: %x\n", mmc->cid[0] >> 24); in print_mmcinfo()
22 printf("OEM: %x\n", (mmc->cid[0] >> 8) & 0xffff); in print_mmcinfo()
23 printf("Name: %c%c%c%c%c \n", mmc->cid[0] & 0xff, in print_mmcinfo()
24 (mmc->cid[1] >> 24), (mmc->cid[1] >> 16) & 0xff, in print_mmcinfo()
25 (mmc->cid[1] >> 8) & 0xff, mmc->cid[1] & 0xff); in print_mmcinfo()
27 printf("Bus Speed: %d\n", mmc->clock); in print_mmcinfo()
29 printf("Mode : %s\n", mmc_mode_name(mmc->selected_mode)); in print_mmcinfo()
30 mmc_dump_capabilities("card capabilities", mmc->card_caps); in print_mmcinfo()
31 mmc_dump_capabilities("host capabilities", mmc->host_caps); in print_mmcinfo()
33 printf("Rd Block Len: %d\n", mmc->read_bl_len); in print_mmcinfo()
35 printf("%s version %d.%d", IS_SD(mmc) ? "SD" : "MMC", in print_mmcinfo()
36 EXTRACT_SDMMC_MAJOR_VERSION(mmc->version), in print_mmcinfo()
37 EXTRACT_SDMMC_MINOR_VERSION(mmc->version)); in print_mmcinfo()
38 if (EXTRACT_SDMMC_CHANGE_VERSION(mmc->version) != 0) in print_mmcinfo()
39 printf(".%d", EXTRACT_SDMMC_CHANGE_VERSION(mmc->version)); in print_mmcinfo()
42 printf("High Capacity: %s\n", mmc->high_capacity ? "Yes" : "No"); in print_mmcinfo()
44 print_size(mmc->capacity, "\n"); in print_mmcinfo()
46 printf("Bus Width: %d-bit%s\n", mmc->bus_width, in print_mmcinfo()
47 mmc->ddr_mode ? " DDR" : ""); in print_mmcinfo()
51 print_size(((u64)mmc->erase_grp_size) << 9, "\n"); in print_mmcinfo()
54 if (!IS_SD(mmc) && mmc->version >= MMC_VERSION_4_41) { in print_mmcinfo()
55 bool has_enh = (mmc->part_support & ENHNCD_SUPPORT) != 0; in print_mmcinfo()
56 bool usr_enh = has_enh && (mmc->part_attr & EXT_CSD_ENH_USR); in print_mmcinfo()
60 print_size(((u64)mmc->hc_wp_grp_size) << 9, "\n"); in print_mmcinfo()
64 print_size(mmc->capacity_user, usr_enh ? " ENH" : ""); in print_mmcinfo()
65 if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_USR) in print_mmcinfo()
71 print_size(mmc->enh_user_start, "\n"); in print_mmcinfo()
73 print_size(mmc->enh_user_size, "\n"); in print_mmcinfo()
76 print_size(mmc->capacity_boot, has_enh ? " ENH\n" : "\n"); in print_mmcinfo()
78 print_size(mmc->capacity_rpmb, has_enh ? " ENH\n" : "\n"); in print_mmcinfo()
80 for (i = 0; i < ARRAY_SIZE(mmc->capacity_gp); i++) { in print_mmcinfo()
82 (mmc->part_attr & EXT_CSD_ENH_GP(i)); in print_mmcinfo()
83 if (mmc->capacity_gp[i]) { in print_mmcinfo()
85 print_size(mmc->capacity_gp[i], in print_mmcinfo()
87 if (mmc->wr_rel_set & EXT_CSD_WR_DATA_REL_GP(i)) in print_mmcinfo()
95 static struct mmc *init_mmc_device(int dev, bool force_init) in init_mmc_device()
97 struct mmc *mmc; in init_mmc_device() local
98 mmc = find_mmc_device(dev); in init_mmc_device()
99 if (!mmc) { in init_mmc_device()
100 printf("no mmc device at slot %x\n", dev); in init_mmc_device()
104 if (!mmc_getcd(mmc)) in init_mmc_device()
108 mmc->has_init = 0; in init_mmc_device()
109 if (mmc_init(mmc)) in init_mmc_device()
113 struct blk_desc *bd = mmc_get_blk_desc(mmc); in init_mmc_device()
117 return mmc; in init_mmc_device()
121 struct mmc *mmc; in do_mmcinfo() local
127 puts("No MMC device available\n"); in do_mmcinfo()
132 mmc = init_mmc_device(curr_device, false); in do_mmcinfo()
133 if (!mmc) in do_mmcinfo()
136 print_mmcinfo(mmc); in do_mmcinfo()
156 struct mmc *mmc = find_mmc_device(curr_device); in do_mmcrpmb_key() local
164 if (mmc_rpmb_set_key(mmc, key_addr)) { in do_mmcrpmb_key()
177 struct mmc *mmc = find_mmc_device(curr_device); in do_mmcrpmb_read() local
191 n = mmc_rpmb_read(mmc, addr, blk, cnt, key_addr); in do_mmcrpmb_read()
205 struct mmc *mmc = find_mmc_device(curr_device); in do_mmcrpmb_write() local
217 n = mmc_rpmb_write(mmc, addr, blk, cnt, key_addr); in do_mmcrpmb_write()
228 struct mmc *mmc = find_mmc_device(curr_device); in do_mmcrpmb_counter() local
230 if (mmc_rpmb_get_counter(mmc, &counter)) in do_mmcrpmb_counter()
247 struct mmc *mmc; in do_mmcrpmb() local
262 mmc = init_mmc_device(curr_device, false); in do_mmcrpmb()
263 if (!mmc) in do_mmcrpmb()
266 if (!(mmc->version & MMC_VERSION_MMC)) { in do_mmcrpmb()
270 if (mmc->version < MMC_VERSION_4_41) { in do_mmcrpmb()
276 original_part = mmc->block_dev.hwpart; in do_mmcrpmb()
278 original_part = mmc_get_blk_desc(mmc)->hwpart; in do_mmcrpmb()
296 struct mmc *mmc; in do_mmc_read() local
307 mmc = init_mmc_device(curr_device, false); in do_mmc_read()
308 if (!mmc) in do_mmc_read()
314 n = blk_dread(mmc_get_blk_desc(mmc), blk, cnt, addr); in do_mmc_read()
340 struct mmc *mmc; in do_mmc_sparse_write() local
356 mmc = init_mmc_device(curr_device, false); in do_mmc_sparse_write()
357 if (!mmc) in do_mmc_sparse_write()
363 if (mmc_getwp(mmc) == 1) { in do_mmc_sparse_write()
368 dev_desc = mmc_get_blk_desc(mmc); in do_mmc_sparse_write()
389 struct mmc *mmc; in do_mmc_write() local
400 mmc = init_mmc_device(curr_device, false); in do_mmc_write()
401 if (!mmc) in do_mmc_write()
407 if (mmc_getwp(mmc) == 1) { in do_mmc_write()
411 n = blk_dwrite(mmc_get_blk_desc(mmc), blk, cnt, addr); in do_mmc_write()
419 struct mmc *mmc; in do_mmc_erase() local
428 mmc = init_mmc_device(curr_device, false); in do_mmc_erase()
429 if (!mmc) in do_mmc_erase()
435 if (mmc_getwp(mmc) == 1) { in do_mmc_erase()
439 n = blk_derase(mmc_get_blk_desc(mmc), blk, cnt); in do_mmc_erase()
449 struct mmc *mmc; in do_mmc_rescan() local
451 mmc = init_mmc_device(curr_device, true); in do_mmc_rescan()
452 if (!mmc) in do_mmc_rescan()
461 struct mmc *mmc; in do_mmc_part() local
463 mmc = init_mmc_device(curr_device, false); in do_mmc_part()
464 if (!mmc) in do_mmc_part()
473 puts("get mmc type error!\n"); in do_mmc_part()
480 struct mmc *mmc; in do_mmc_dev() local
498 mmc = init_mmc_device(dev, true); in do_mmc_dev()
499 if (!mmc) in do_mmc_dev()
509 if (mmc->part_config == MMCPART_NOAVAILABLE) in do_mmc_dev()
510 printf("mmc%d is current device\n", curr_device); in do_mmc_dev()
512 printf("mmc%d(part %d) is current device\n", in do_mmc_dev()
513 curr_device, mmc_get_blk_desc(mmc)->hwpart); in do_mmc_dev()
596 struct mmc *mmc; in do_mmc_hwpartition() local
601 mmc = init_mmc_device(curr_device, false); in do_mmc_hwpartition()
602 if (!mmc) in do_mmc_hwpartition()
664 if (!mmc_hwpart_config(mmc, &pconf, mode)) { in do_mmc_hwpartition()
681 struct mmc *mmc; in do_mmc_bootbus() local
691 mmc = init_mmc_device(dev, false); in do_mmc_bootbus()
692 if (!mmc) in do_mmc_bootbus()
695 if (IS_SD(mmc)) { in do_mmc_bootbus()
701 return mmc_set_boot_bus_width(mmc, width, reset, mode); in do_mmc_bootbus()
707 struct mmc *mmc; in do_mmc_boot_resize() local
716 mmc = init_mmc_device(dev, false); in do_mmc_boot_resize()
717 if (!mmc) in do_mmc_boot_resize()
720 if (IS_SD(mmc)) { in do_mmc_boot_resize()
725 if (mmc_boot_partition_size_change(mmc, bootsize, rpmbsize)) { in do_mmc_boot_resize()
735 static int mmc_partconf_print(struct mmc *mmc) in mmc_partconf_print() argument
739 if (mmc->part_config == MMCPART_NOAVAILABLE) { in mmc_partconf_print()
740 printf("No part_config info for ver. 0x%x\n", mmc->version); in mmc_partconf_print()
744 access = EXT_CSD_EXTRACT_PARTITION_ACCESS(mmc->part_config); in mmc_partconf_print()
745 ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config); in mmc_partconf_print()
746 part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); in mmc_partconf_print()
760 struct mmc *mmc; in do_mmc_partconf() local
768 mmc = init_mmc_device(dev, false); in do_mmc_partconf()
769 if (!mmc) in do_mmc_partconf()
772 if (IS_SD(mmc)) { in do_mmc_partconf()
778 return mmc_partconf_print(mmc); in do_mmc_partconf()
785 return mmc_set_part_conf(mmc, ack, part_num, access); in do_mmc_partconf()
791 struct mmc *mmc; in do_mmc_rst_func() local
810 mmc = init_mmc_device(dev, false); in do_mmc_rst_func()
811 if (!mmc) in do_mmc_rst_func()
814 if (IS_SD(mmc)) { in do_mmc_rst_func()
819 return mmc_set_rst_n_function(mmc, enable); in do_mmc_rst_func()
825 struct mmc *mmc; in do_mmc_setdsr() local
833 mmc = find_mmc_device(curr_device); in do_mmc_setdsr()
834 if (!mmc) { in do_mmc_setdsr()
835 printf("no mmc device at slot %x\n", curr_device); in do_mmc_setdsr()
838 ret = mmc_set_dsr(mmc, val); in do_mmc_setdsr()
841 mmc->has_init = 0; in do_mmc_setdsr()
842 if (mmc_init(mmc)) in do_mmc_setdsr()
855 struct mmc *mmc; in do_mmc_bkops_enable() local
862 mmc = init_mmc_device(dev, false); in do_mmc_bkops_enable()
863 if (!mmc) in do_mmc_bkops_enable()
866 if (IS_SD(mmc)) { in do_mmc_bkops_enable()
871 return mmc_set_bkops_enable(mmc); in do_mmc_bkops_enable()
913 /* Drop the mmc command */ in do_mmcops()
926 puts("No MMC device available\n"); in do_mmcops()
934 mmc, 29, 1, do_mmcops,
935 "MMC sub system",
936 "info - display info of the current MMC device\n"
937 "mmc read addr blk# cnt\n"
938 "mmc write addr blk# cnt\n"
940 "mmc swrite addr blk#\n"
942 "mmc erase blk# cnt\n"
943 "mmc rescan\n"
944 "mmc part - lists available partition on current mmc device\n"
945 "mmc dev [dev] [part] - show or set current mmc device [partition]\n"
946 "mmc list - lists available devices\n"
948 "mmc hwpartition [args...] - does hardware partitioning\n"
957 "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
959 "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n"
961 "mmc partconf dev [boot_ack boot_partition partition_access]\n"
963 "mmc rst-function dev value\n"
968 "mmc rpmb read addr blk# cnt [address of auth-key] - block size is 256 bytes\n"
969 "mmc rpmb write addr blk# cnt <address of auth-key> - block size is 256 bytes\n"
970 "mmc rpmb key <address of auth-key> - program the RPMB authentication key.\n"
971 "mmc rpmb counter - read the value of the write counter\n"
973 "mmc setdsr <value> - set DSR register value\n"
975 "mmc bkops-enable <dev> - enable background operations handshake on device\n"
980 /* Old command kept for compatibility. Same as 'mmc info' */
983 "display MMC info",
984 "- display info of the current MMC device"