]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
MMC: fix user capacity for partitioned eMMC card
authorMarkus Niebel <Markus.Niebel@tq-group.com>
Tue, 18 Nov 2014 14:11:42 +0000 (15:11 +0100)
committerPantelis Antoniou <pantelis.antoniou@konsulko.com>
Fri, 12 Dec 2014 18:28:04 +0000 (20:28 +0200)
if the card claims to be high capacity and the card
is partitioned the capacity shall still be read from
ext_csd SEC_COUNT even if the resulting capacity is
smaller than 2 GiB

Signed-off-by: Markus Niebel <Markus.Niebel@tq-group.com>
Acked-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/mmc/mmc.c
include/mmc.h

index 9dc924c412651f8b9b270a47dcfa5b0698f4c68c..4a8cf65f792e10189cab438b3f009bcae5643146 100644 (file)
@@ -1022,6 +1022,21 @@ static int mmc_startup(struct mmc *mmc)
                        mmc->erase_grp_size =
                                ext_csd[EXT_CSD_HC_ERASE_GRP_SIZE] *
                                        MMC_MAX_BLOCK_LEN * 1024;
+                       /*
+                        * if high capacity and partition setting completed
+                        * SEC_COUNT is valid even if it is smaller than 2 GiB
+                        * JEDEC Standard JESD84-B45, 6.2.4
+                        */
+                       if (mmc->high_capacity &&
+                           (ext_csd[EXT_CSD_PARTITION_SETTING] &
+                            EXT_CSD_PARTITION_SETTING_COMPLETED)) {
+                               capacity = (ext_csd[EXT_CSD_SEC_CNT]) |
+                                       (ext_csd[EXT_CSD_SEC_CNT + 1] << 8) |
+                                       (ext_csd[EXT_CSD_SEC_CNT + 2] << 16) |
+                                       (ext_csd[EXT_CSD_SEC_CNT + 3] << 24);
+                               capacity *= MMC_MAX_BLOCK_LEN;
+                               mmc->capacity_user = capacity;
+                       }
                } else {
                        /* Calculate the group size from the csd value. */
                        int erase_gsz, erase_gmul;
index adffc35af028fc009bfc2d8619ca3d312073d86b..9b26924f76b4ce31bde2e868513c3c5112bb3205 100644 (file)
  * EXT_CSD fields
  */
 #define EXT_CSD_GP_SIZE_MULT           143     /* R/W */
+#define EXT_CSD_PARTITION_SETTING      155     /* R/W */
 #define EXT_CSD_PARTITIONS_ATTRIBUTE   156     /* R/W */
 #define EXT_CSD_PARTITIONING_SUPPORT   160     /* RO */
 #define EXT_CSD_RST_N_FUNCTION         162     /* R/W */
 #define EXT_CSD_BOOT_BUS_WIDTH_RESET(x)        (x << 2)
 #define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x)        (x)
 
+#define EXT_CSD_PARTITION_SETTING_COMPLETED    (1 << 0)
+
 #define R1_ILLEGAL_COMMAND             (1 << 22)
 #define R1_APP_CMD                     (1 << 5)