Commit bdb6099666933491ce393e52132e05604da91b1a
Committed by
Jaehoon Chung
1 parent
e7881d85a9
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
cmd: mmc: add mmc partconf read capability
This patch allows to show the EXT_CSD[179] partition_config register info, just by specifying the dev param: U-Boot> mmc partconf 0 EXT_CSD[179], PARTITION_CONFIG: BOOT_ACK: 0x0 BOOT_PARTITION_ENABLE: 0x0 PARTITION_ACCESS: 0x0 Signed-off-by: Angelo Dureghello <angelo@sysam.it> Signed-off-by: Anatolij Gustschin <agust@denx.de>
Showing 3 changed files with 49 additions and 10 deletions Side-by-side Diff
cmd/mmc.c
... | ... | @@ -643,6 +643,28 @@ |
643 | 643 | printf("EMMC RPMB partition Size %d MB\n", rpmbsize); |
644 | 644 | return CMD_RET_SUCCESS; |
645 | 645 | } |
646 | + | |
647 | +static int mmc_partconf_print(struct mmc *mmc) | |
648 | +{ | |
649 | + u8 ack, access, part; | |
650 | + | |
651 | + if (mmc->part_config == MMCPART_NOAVAILABLE) { | |
652 | + printf("No part_config info for ver. 0x%x\n", mmc->version); | |
653 | + return CMD_RET_FAILURE; | |
654 | + } | |
655 | + | |
656 | + access = EXT_CSD_EXTRACT_PARTITION_ACCESS(mmc->part_config); | |
657 | + ack = EXT_CSD_EXTRACT_BOOT_ACK(mmc->part_config); | |
658 | + part = EXT_CSD_EXTRACT_BOOT_PART(mmc->part_config); | |
659 | + | |
660 | + printf("EXT_CSD[179], PARTITION_CONFIG:\n" | |
661 | + "BOOT_ACK: 0x%x\n" | |
662 | + "BOOT_PARTITION_ENABLE: 0x%x\n" | |
663 | + "PARTITION_ACCESS: 0x%x\n", ack, part, access); | |
664 | + | |
665 | + return CMD_RET_SUCCESS; | |
666 | +} | |
667 | + | |
646 | 668 | static int do_mmc_partconf(cmd_tbl_t *cmdtp, int flag, |
647 | 669 | int argc, char * const argv[]) |
648 | 670 | { |
649 | 671 | |
... | ... | @@ -650,13 +672,10 @@ |
650 | 672 | struct mmc *mmc; |
651 | 673 | u8 ack, part_num, access; |
652 | 674 | |
653 | - if (argc != 5) | |
675 | + if (argc != 2 && argc != 5) | |
654 | 676 | return CMD_RET_USAGE; |
655 | 677 | |
656 | 678 | dev = simple_strtoul(argv[1], NULL, 10); |
657 | - ack = simple_strtoul(argv[2], NULL, 10); | |
658 | - part_num = simple_strtoul(argv[3], NULL, 10); | |
659 | - access = simple_strtoul(argv[4], NULL, 10); | |
660 | 679 | |
661 | 680 | mmc = init_mmc_device(dev, false); |
662 | 681 | if (!mmc) |
... | ... | @@ -667,6 +686,13 @@ |
667 | 686 | return CMD_RET_FAILURE; |
668 | 687 | } |
669 | 688 | |
689 | + if (argc == 2) | |
690 | + return mmc_partconf_print(mmc); | |
691 | + | |
692 | + ack = simple_strtoul(argv[2], NULL, 10); | |
693 | + part_num = simple_strtoul(argv[3], NULL, 10); | |
694 | + access = simple_strtoul(argv[4], NULL, 10); | |
695 | + | |
670 | 696 | /* acknowledge to be sent during boot operation */ |
671 | 697 | return mmc_set_part_conf(mmc, ack, part_num, access); |
672 | 698 | } |
... | ... | @@ -832,8 +858,8 @@ |
832 | 858 | " - Set the BOOT_BUS_WIDTH field of the specified device\n" |
833 | 859 | "mmc bootpart-resize <dev> <boot part size MB> <RPMB part size MB>\n" |
834 | 860 | " - Change sizes of boot and RPMB partitions of specified device\n" |
835 | - "mmc partconf dev boot_ack boot_partition partition_access\n" | |
836 | - " - Change the bits of the PARTITION_CONFIG field of the specified device\n" | |
861 | + "mmc partconf dev [boot_ack boot_partition partition_access]\n" | |
862 | + " - Show or change the bits of the PARTITION_CONFIG field of the specified device\n" | |
837 | 863 | "mmc rst-function dev value\n" |
838 | 864 | " - Change the RST_n_FUNCTION field of the specified device\n" |
839 | 865 | " WARNING: This is a write-once field and 0 / 1 / 2 are the only valid values.\n" |
drivers/mmc/mmc_boot.c
... | ... | @@ -100,10 +100,19 @@ |
100 | 100 | */ |
101 | 101 | int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access) |
102 | 102 | { |
103 | - return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF, | |
104 | - EXT_CSD_BOOT_ACK(ack) | | |
105 | - EXT_CSD_BOOT_PART_NUM(part_num) | | |
106 | - EXT_CSD_PARTITION_ACCESS(access)); | |
103 | + int ret; | |
104 | + u8 part_conf; | |
105 | + | |
106 | + part_conf = EXT_CSD_BOOT_ACK(ack) | | |
107 | + EXT_CSD_BOOT_PART_NUM(part_num) | | |
108 | + EXT_CSD_PARTITION_ACCESS(access); | |
109 | + | |
110 | + ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF, | |
111 | + part_conf); | |
112 | + if (!ret) | |
113 | + mmc->part_config = part_conf; | |
114 | + | |
115 | + return ret; | |
107 | 116 | } |
108 | 117 | |
109 | 118 | /* |
include/mmc.h
... | ... | @@ -221,6 +221,10 @@ |
221 | 221 | #define EXT_CSD_BOOT_PART_NUM(x) (x << 3) |
222 | 222 | #define EXT_CSD_PARTITION_ACCESS(x) (x << 0) |
223 | 223 | |
224 | +#define EXT_CSD_EXTRACT_BOOT_ACK(x) (((x) >> 6) & 0x1) | |
225 | +#define EXT_CSD_EXTRACT_BOOT_PART(x) (((x) >> 3) & 0x7) | |
226 | +#define EXT_CSD_EXTRACT_PARTITION_ACCESS(x) ((x) & 0x7) | |
227 | + | |
224 | 228 | #define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x << 3) |
225 | 229 | #define EXT_CSD_BOOT_BUS_WIDTH_RESET(x) (x << 2) |
226 | 230 | #define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x) (x) |