summaryrefslogtreecommitdiff
path: root/drivers/mmc/mmc.c
diff options
context:
space:
mode:
authorOliver Metz <oliver@freetz.org>2013-10-01 20:32:07 +0200
committerPantelis Antoniou <panto@antoniou-consulting.com>2013-10-31 09:55:33 +0200
commit1937e5aa3b0ec0767a36580db654ef8918c09b84 (patch)
treeccf28bdc72fb7cf3cb197d4d8d3f4605bd22fc96 /drivers/mmc/mmc.c
parent509dca7a11aad394d781a9d31a7bfa6692562741 (diff)
downloadu-boot-imx-1937e5aa3b0ec0767a36580db654ef8918c09b84.zip
u-boot-imx-1937e5aa3b0ec0767a36580db654ef8918c09b84.tar.gz
u-boot-imx-1937e5aa3b0ec0767a36580db654ef8918c09b84.tar.bz2
mmc: Fix erase_grp_size for partitioned card
EXT_CSD_ERASE_GROUP_DEF is lost every time after a reset or power off. Set it if device has enhanced partitions. Signed-off-by: Oliver Metz <oliver@freetz.org> Acked-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Diffstat (limited to 'drivers/mmc/mmc.c')
-rw-r--r--drivers/mmc/mmc.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 84dae4d..e1461a9 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -960,15 +960,24 @@ static int mmc_startup(struct mmc *mmc)
}
/*
- * Check whether GROUP_DEF is set, if yes, read out
- * group size from ext_csd directly, or calculate
- * the group size from the csd value.
+ * Host needs to enable ERASE_GRP_DEF bit if device is
+ * partitioned. This bit will be lost every time after a reset
+ * or power off. This will affect erase size.
*/
- if (ext_csd[EXT_CSD_ERASE_GROUP_DEF]) {
+ if ((ext_csd[EXT_CSD_PARTITIONING_SUPPORT] & PART_SUPPORT) &&
+ (ext_csd[EXT_CSD_PARTITIONS_ATTRIBUTE] & PART_ENH_ATTRIB)) {
+ err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL,
+ EXT_CSD_ERASE_GROUP_DEF, 1);
+
+ if (err)
+ return err;
+
+ /* Read out group size from ext_csd */
mmc->erase_grp_size =
ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
MMC_MAX_BLOCK_LEN * 1024;
} else {
+ /* Calculate the group size from the csd value. */
int erase_gsz, erase_gmul;
erase_gsz = (mmc->csd[2] & 0x00007c00) >> 10;
erase_gmul = (mmc->csd[2] & 0x000003e0) >> 5;