mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-21 22:51:37 +00:00
MMC: Fix for capacity calculation on eMMC
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 <s-ghorai@ti.com> Acked-by: Steve Sakoman <steve@sakoman.com>
This commit is contained in:
parent
7b7903ec6a
commit
d23e2c09a7
1 changed files with 11 additions and 0 deletions
|
@ -627,6 +627,7 @@ int mmc_startup(struct mmc *mmc)
|
||||||
uint mult, freq;
|
uint mult, freq;
|
||||||
u64 cmult, csize;
|
u64 cmult, csize;
|
||||||
struct mmc_cmd cmd;
|
struct mmc_cmd cmd;
|
||||||
|
char ext_csd[512];
|
||||||
|
|
||||||
/* Put the Card in Identify Mode */
|
/* Put the Card in Identify Mode */
|
||||||
cmd.cmdidx = MMC_CMD_ALL_SEND_CID;
|
cmd.cmdidx = MMC_CMD_ALL_SEND_CID;
|
||||||
|
@ -742,6 +743,16 @@ int mmc_startup(struct mmc *mmc)
|
||||||
if (err)
|
if (err)
|
||||||
return 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))
|
if (IS_SD(mmc))
|
||||||
err = sd_change_freq(mmc);
|
err = sd_change_freq(mmc);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue