From 4cb4e6156fa5f942cf004b3e34677f1ee6f32cab Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Tue, 6 Oct 2015 19:27:48 +0300 Subject: [PATCH] mmc: core: Add a quirk for NVIDIA Tegra EMMC Signed-off-by: Dmitry Osipenko (cherry picked from commit ab6cd574c16380931529501c367ae50a3ee96b3e) Signed-off-by: Sergey Larin --- drivers/mmc/core/mmc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 55997cf84b39..643fbe58eb0f 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -408,8 +408,17 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) ext_csd[EXT_CSD_SEC_CNT + 3] << 24; /* Cards with density > 2GiB are sector addressed */ - if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512) + if (card->ext_csd.sectors > (2u * 1024 * 1024 * 1024) / 512) { + if (card->host->caps & MMC_CAP_NONREMOVABLE) { + /* + * Size is in 256K chunks, i.e. 512 sectors each. + * This algorithm is defined and used by NVIDIA, + * according to eMMC 4.41, size is in 128K chunks. + */ + card->ext_csd.sectors -= ext_csd[EXT_CSD_BOOT_MULT] * 512; + } mmc_card_set_blockaddr(card); + } } card->ext_csd.strobe_support = ext_csd[EXT_CSD_STROBE_SUPPORT]; -- 2.20.1