From c99a4a2099b59228f55a3c797fd153a8c70b6b2c Mon Sep 17 00:00:00 2001 From: Vinoth Gnanasekaran Date: Mon, 12 Nov 2018 15:20:51 +0530 Subject: [PATCH] ipq806x: Change the minimum write protect region size for Micron eMMC This change is a workaround for Micron eMMC card. As per the card extended CSD register value, the minimum size of a write protect region is 0x8000 blocks (16MB). So the user should give start address and size to align with 0x8000. But this eMMC part actually does protect 32MB of memory. We changing the minimum write protect region size from 0x8000 to 0x10000 for Micron eMMC card. Change-Id: Id53c337374dfba8adb6bd550826337d8ecfe17f3 Signed-off-by: Vinoth Gnanasekaran --- drivers/mmc/mmc.c | 3 +++ include/mmc.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 34ab73685c..78bbc074ac 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1920,6 +1920,9 @@ int mmc_write_protect(struct mmc *mmc, unsigned int start_blk, } wp_group_size = (mmc->wp_grp_size + 1) * mmc->erase_grp_size; + if ((MMC_GET_MID(mmc->cid[0]) == MMC_MID_MICRON) && + (MMC_GET_PNM(mmc->cid[0], mmc->cid[1], mmc->cid[2]) == MMC_PNM_MICRON)) + wp_group_size *= 2; if (!cnt_blk || start_blk % wp_group_size || cnt_blk % wp_group_size) { printf("Error: Unaligned offset/count. offset/count should be aligned to 0x%x blocks\n", wp_group_size); diff --git a/include/mmc.h b/include/mmc.h index ee18ae34c1..8b706bc8f1 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -14,6 +14,14 @@ #include #include +#define MMC_GET_MID(CID0) (CID0 >> 24) +#define MMC_GET_PNM(CID0, CID1, CID2) (((long long int)(CID0 & 0xff) << 40) | \ + ((long long int)CID1 << 8) | \ + (CID2 >> 24)) + +#define MMC_MID_MICRON 0xFE +#define MMC_PNM_MICRON 0x4D4D43333247 // MMC32G + /* SD/MMC version bits; 8 flags, 8 major, 8 minor, 8 change */ #define SD_VERSION_SD (1U << 31) #define MMC_VERSION_MMC (1U << 30)