]> git.sur5r.net Git - u-boot/commitdiff
mmc: read the high capacity WP group size for eMMC
authorDiego Santa Cruz <Diego.SantaCruz@spinetix.com>
Tue, 23 Dec 2014 09:50:25 +0000 (10:50 +0100)
committerPantelis Antoniou <pantelis.antoniou@konsulko.com>
Mon, 19 Jan 2015 15:02:29 +0000 (17:02 +0200)
Read the eMMC high capacity write protect group size at mmc device
initialization. This is useful to correctly partition an eMMC device,
as partitions need to be aligned to this size.

Signed-off-by: Diego Santa Cruz <Diego.SantaCruz@spinetix.com>
drivers/mmc/mmc.c
include/mmc.h

index be211016cf5df42e95e8365ae5a8ccdde61889d2..16a7a90398fa33e1841d36d73088fdb4d8ad8ee0 100644 (file)
@@ -1065,7 +1065,9 @@ static int mmc_startup(struct mmc *mmc)
                                return err;
                        else
                                ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
+               }
 
+               if (ext_csd[EXT_CSD_ERASE_GROUP_DEF] & 0x01) {
                        /* Read out group size from ext_csd */
                        mmc->erase_grp_size =
                                ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] * 1024;
@@ -1092,6 +1094,10 @@ static int mmc_startup(struct mmc *mmc)
                        mmc->erase_grp_size = (erase_gsz + 1)
                                * (erase_gmul + 1);
                }
+
+               mmc->hc_wp_grp_size = 1024
+                       * ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE]
+                       * ext_csd[EXT_CSD_HC_WP_GRP_SIZE];
        }
 
        err = mmc_set_capacity(mmc, mmc->part_num);
index 6c8bbfc952b4184349010c29a9391cc7c204bcb8..bcaf9f012f0891d664eb7632a530b5c97c9760a4 100644 (file)
@@ -316,6 +316,7 @@ struct mmc {
        uint read_bl_len;
        uint write_bl_len;
        uint erase_grp_size;    /* in 512-byte sectors */
+       uint hc_wp_grp_size;    /* in 512-byte sectors */
        u64 capacity;
        u64 capacity_user;
        u64 capacity_boot;