mmc: subtract boot sectors from disk size for eMMC 4.3+ devices
authorGary King <gking@nvidia.com>
Fri, 16 Jul 2010 00:11:32 +0000 (17:11 -0700)
committerColin Cross <ccross@android.com>
Thu, 30 Sep 2010 00:49:48 +0000 (17:49 -0700)
the csd sector count reported by eMMC 4.3+ cards includes the boot
partition size; subtract this from the size reported to the disk
since the boot partition is inaccessible

Change-Id: I601b83aa0159b7aa446409ea8c945b256dd0b5b1
Signed-off-by: Gary King <gking@nvidia.com>
drivers/mmc/core/mmc.c
include/linux/mmc/mmc.h

index 6909a54c39beac1a8ca277f317f43c4a4ea9d583..45055c46d954957be5a49196c80be2b21ae6c7a3 100644 (file)
@@ -253,8 +253,13 @@ static int mmc_read_ext_csd(struct mmc_card *card)
                        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) {
+                       unsigned boot_sectors;
+                       /* size is in 256K chunks, i.e. 512 sectors each */
+                       boot_sectors = ext_csd[EXT_CSD_BOOT_SIZE_MULTI] * 512;
+                       card->ext_csd.sectors -= boot_sectors;
                        mmc_card_set_blockaddr(card);
+               }
        }
 
        switch (ext_csd[EXT_CSD_CARD_TYPE] & EXT_CSD_CARD_TYPE_MASK) {
index dd11ae51fb68e8b847300a5fe78ac049c9ef8605..1041cf5220f6d05c51dc8b702849e8a618dcd768 100644 (file)
@@ -266,6 +266,7 @@ struct _mmc_csd {
 #define EXT_CSD_SEC_ERASE_MULT         230     /* RO */
 #define EXT_CSD_SEC_FEATURE_SUPPORT    231     /* RO */
 #define EXT_CSD_TRIM_MULT              232     /* RO */
+#define EXT_CSD_BOOT_SIZE_MULTI                226     /* RO */
 
 /*
  * EXT_CSD field definitions