[PATCH] mmc: Correct computing the SD capacity

Romain Izard romain.izard.pro at gmail.com
Mon Nov 5 10:52:56 CET 2012


For high-capacity SD cards, the block size is not used to compute the
effective card capacity. Since high capacity MMC cards do not use the
same method, high-capacity SD cards must be adressed separately.

Signed-off-by: Romain Izard <romain.izard.pro at gmail.com>
---
 drivers/mmc/mmc.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 5ffd8c5..209a200 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -976,19 +976,18 @@ static int mmc_startup(struct mmc *mmc)
 	else
 		mmc->write_bl_len = 1 << ((cmd.response[3] >> 22) & 0xf);
 
-	if (mmc->high_capacity) {
+	if (IS_SD(mmc) && mmc->high_capacity) {
 		csize = (mmc->csd[1] & 0x3f) << 16
 			| (mmc->csd[2] & 0xffff0000) >> 16;
-		cmult = 8;
+		mmc->capacity = (csize + 1) << 19;
 	} else {
 		csize = (mmc->csd[1] & 0x3ff) << 2
 			| (mmc->csd[2] & 0xc0000000) >> 30;
 		cmult = (mmc->csd[2] & 0x00038000) >> 15;
+		mmc->capacity = (csize + 1) << (cmult + 2);
+		mmc->capacity *= mmc->read_bl_len;
 	}
 
-	mmc->capacity = (csize + 1) << (cmult + 2);
-	mmc->capacity *= mmc->read_bl_len;
-
 	if (mmc->read_bl_len > 512)
 		mmc->read_bl_len = 512;
 
-- 
1.7.10.4



More information about the U-Boot mailing list