From: Steve Sakoman Date: Tue, 28 Sep 2010 15:29:36 -0700 Subject: [U-Boot] [PATCH 1/7] MMC: Fix for capacity calculation on eMMC In-Reply-To: <1285712982-29221-1-git-send-email-steve@sakoman.com> References: <1285712982-29221-1-git-send-email-steve@sakoman.com> Message-ID: <1285712982-29221-2-git-send-email-steve@sakoman.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Sukumar Ghorai The current mmc driver returns erroneous capacity information for eMMC. The capacity of eMMC devices is available only in the ext-CSD register. This patch add code to read the ext-CDSD register and correctly calculate eMMC capacity. Signed-off-by: Sukumar Ghorai Acked-by: Steve Sakoman --- drivers/mmc/mmc.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 80cd9bf..c543d83 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -627,6 +627,7 @@ int mmc_startup(struct mmc *mmc) uint mult, freq; u64 cmult, csize; struct mmc_cmd cmd; + char ext_csd[512]; /* Put the Card in Identify Mode */ cmd.cmdidx = MMC_CMD_ALL_SEND_CID; @@ -742,6 +743,16 @@ int mmc_startup(struct mmc *mmc) if (err) return err; + if (!IS_SD(mmc) && (mmc->version >= MMC_VERSION_4)) { + /* check ext_csd version and capacity */ + err = mmc_send_ext_csd(mmc, ext_csd); + if (!err & (ext_csd[192] >= 2)) { + mmc->capacity = ext_csd[212] << 0 | ext_csd[213] << 8 | + ext_csd[214] << 16 | ext_csd[215] << 24; + mmc->capacity *= 512; + } + } + if (IS_SD(mmc)) err = sd_change_freq(mmc); else -- 1.7.0.4