summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorLei Wen <leiwen@marvell.com>2011-06-22 17:03:31 +0000
committerAndy Fleming <afleming@freescale.com>2011-07-15 20:29:17 -0500
commite6f99a5611e1ff59555f93de88e527070f8548af (patch)
tree77577e3a0f6db5f84f2d9d879e9abfc221685c69 /common
parent6be95ccf9ff52d629526d1c20c5343c2a91d9e72 (diff)
downloadu-boot-imx-e6f99a5611e1ff59555f93de88e527070f8548af.zip
u-boot-imx-e6f99a5611e1ff59555f93de88e527070f8548af.tar.gz
u-boot-imx-e6f99a5611e1ff59555f93de88e527070f8548af.tar.bz2
MMC: add erase function to both mmc and sd
Erase is a very basic function since the begin of sd specification is announced. Although we could write a bulk of full 0xff memory to the range to take place of erase, it is more convenient and safe to implement the erase function itself. Signed-off-by: Lei Wen <leiwen@marvell.com> Signed-off-by: Andy Fleming <afleming@freescale.com> Acked-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'common')
-rw-r--r--common/cmd_mmc.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index a645803..7335cdc 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -91,6 +91,7 @@ enum mmc_state {
MMC_INVALID,
MMC_READ,
MMC_WRITE,
+ MMC_ERASE,
};
static void print_mmcinfo(struct mmc *mmc)
{
@@ -252,15 +253,24 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
state = MMC_READ;
else if (strcmp(argv[1], "write") == 0)
state = MMC_WRITE;
+ else if (strcmp(argv[1], "erase") == 0)
+ state = MMC_ERASE;
else
state = MMC_INVALID;
if (state != MMC_INVALID) {
struct mmc *mmc = find_mmc_device(curr_device);
- void *addr = (void *)simple_strtoul(argv[2], NULL, 16);
- u32 blk = simple_strtoul(argv[3], NULL, 16);
- u32 cnt = simple_strtoul(argv[4], NULL, 16);
- u32 n;
+ int idx = 2;
+ u32 blk, cnt, n;
+ void *addr;
+
+ if (state != MMC_ERASE) {
+ addr = (void *)simple_strtoul(argv[idx], NULL, 16);
+ ++idx;
+ } else
+ addr = 0;
+ blk = simple_strtoul(argv[idx], NULL, 16);
+ cnt = simple_strtoul(argv[idx + 1], NULL, 16);
if (!mmc) {
printf("no mmc device at slot %x\n", curr_device);
@@ -283,6 +293,9 @@ int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
n = mmc->block_dev.block_write(curr_device, blk,
cnt, addr);
break;
+ case MMC_ERASE:
+ n = mmc->block_dev.block_erase(curr_device, blk, cnt);
+ break;
default:
BUG();
}
@@ -300,6 +313,7 @@ U_BOOT_CMD(
"MMC sub system",
"read addr blk# cnt\n"
"mmc write addr blk# cnt\n"
+ "mmc erase blk# cnt\n"
"mmc rescan\n"
"mmc part - lists available partition on current mmc device\n"
"mmc dev [dev] [part] - show or set current mmc device [partition]\n"