From: Reinhard Meyer Date: Mon, 06 Sep 2010 16:07:14 +0200 Subject: [U-Boot] [PATCH] mmc: fix capacity calculation with high capacity mmc In-Reply-To: <1283781548-13961-1-git-send-email-leiwen@marvell.com> References: <1283781548-13961-1-git-send-email-leiwen@marvell.com> Message-ID: <4C84F592.4060905@emk-elektronik.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Lei Wen, > According spec, high capacity mmc should be calculated by sector > number multiply by sector size. > > Signed-off-by: Lei Wen > --- > drivers/mmc/mmc.c | 5 +++++ > 1 files changed, 5 insertions(+), 0 deletions(-) > > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c > index ea398a5..bb97171 100644 > --- a/drivers/mmc/mmc.c > +++ b/drivers/mmc/mmc.c > @@ -441,6 +441,11 @@ int mmc_change_freq(struct mmc *mmc) > if (!ext_csd[185]) > return 0; > > + if (!IS_SD(mmc) && mmc->high_capacity) { > + mmc->capacity = ext_csd[212] | (ext_csd[213] << 8) > + | (ext_csd[214] << 16) | (ext_csd[215] << 24); > + mmc->capacity *= mmc->read_bl_len; > + } > /* High Speed is set, there are two types: 52MHz and 26MHz */ > if (cardtype & MMC_HS_52MHZ) > mmc->card_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS; Sorry to kick in again... a) this calculation is already done in line 717, and certainly does not belong in a function called "mmc_change_freq". b) the current Top-Of-Tree code already calculates the capacity correctly: 32GB SDHC Card: Device: mci Manufacturer ID: 3 OEM: 5344 Name: SD32G Tran Speed: 25000000 Rd Block Len: 512 SD version 2.0 High Capacity: Yes Capacity: 31914983424 Bus Width: 4-bit c) is that now an incremental patch to the one you sent previously? Best Regards, Reinhard