summaryrefslogtreecommitdiff
path: root/common/cmd_mmc.c
diff options
context:
space:
mode:
authorLei Wen <leiwen@marvell.com>2011-05-02 16:26:26 +0000
committerAndy Fleming <afleming@freescale.com>2011-05-18 14:37:03 -0500
commitbc897b1d4d86597311430dbe7b3e6c807c8c53e5 (patch)
treedc5136100f1b0a873dd8bc90708286215335f559 /common/cmd_mmc.c
parentea6ebe21772568ee97fb5c23c01e993140f0e0e6 (diff)
mmc: enable partition switch function for emmc
For emmc, it may have up to 7 partitions: two boot partitions, one user partition, one RPMB partition and four general purpose partitions. (Refer to JESD84-A44.pdf/page 154) As bootloader may need to read out or reflashing images on those different partitions, it is better to enable the partition switch with console command support. Also for partition would be restore to user partition(part 0) when CMD0 is used, so change mmc_init routine to perform normal initialization only once for each slot, unless use the rescan command to force init again. Signed-off-by: Lei Wen <leiwen@marvell.com> Acked-by: Andy Fleming <afleming@freescale.com>
Diffstat (limited to 'common/cmd_mmc.c')
-rw-r--r--common/cmd_mmc.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index e266d4fa43f..176646d4627 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -164,6 +164,7 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
+ mmc->has_init = 0;
mmc_init(mmc);
return 0;
@@ -189,14 +190,22 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
print_mmc_devices('\n');
return 0;
} else if (strcmp(argv[1], "dev") == 0) {
- int dev;
+ int dev, part = -1;
struct mmc *mmc;
if (argc == 2)
dev = curr_device;
else if (argc == 3)
dev = simple_strtoul(argv[2], NULL, 10);
- else
+ else if (argc == 4) {
+ dev = (int)simple_strtoul(argv[2], NULL, 10);
+ part = (int)simple_strtoul(argv[3], NULL, 10);
+ if (part > PART_ACCESS_MASK) {
+ printf("#part_num shouldn't be larger"
+ " than %d\n", PART_ACCESS_MASK);
+ return 1;
+ }
+ } else
return cmd_usage(cmdtp);
mmc = find_mmc_device(dev);
@@ -205,8 +214,29 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}
+ mmc_init(mmc);
+ if (part != -1) {
+ int ret;
+ if (mmc->part_config == MMCPART_NOAVAILABLE) {
+ printf("Card doesn't support part_switch\n");
+ return 1;
+ }
+
+ if (part != mmc->part_num) {
+ ret = mmc_switch_part(dev, part);
+ if (!ret)
+ mmc->part_num = part;
+
+ printf("switch to partions #%d, %s\n",
+ part, (!ret) ? "OK" : "ERROR");
+ }
+ }
curr_device = dev;
- printf("mmc%d is current device\n", curr_device);
+ if (mmc->part_config == MMCPART_NOAVAILABLE)
+ printf("mmc%d is current device\n", curr_device);
+ else
+ printf("mmc%d(part %d) is current device\n",
+ curr_device, mmc->part_num);
return 0;
} else if (strcmp(argv[1], "read") == 0) {
@@ -269,6 +299,6 @@ U_BOOT_CMD(
"mmc write addr blk# cnt\n"
"mmc rescan\n"
"mmc part - lists available partition on current mmc device\n"
- "mmc dev [dev] - show or set current mmc device\n"
+ "mmc dev [dev] [part] - show or set current mmc device [partition]\n"
"mmc list - lists available devices");
#endif