OSDN Git Service

The eMMC spec 4.4 and 4.3 + additional feature chips has CSD structure
authorKyungmin Park <kmpark@infradead.org>
Tue, 7 Sep 2010 18:06:32 +0000 (11:06 -0700)
committerColin Cross <ccross@android.com>
Tue, 7 Sep 2010 18:10:34 +0000 (11:10 -0700)
version 3 and version 3 have to check the CSD_STRUCTURE byte in the
EXT_CSD register.

Also fix EXT_CSD revision message.

Change-Id: Ic5d3a1893d6c5d238e1f59fa1f2307e75d76bf96
[akpm@linux-foundation.org: fix comment, per Chris Ball]
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Adrian Hunter <adrian.hunter@nokia.com>
Cc: Chris Ball <cjb@laptop.org>
Cc: <linux-mmc@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Colin Cross <ccross@android.com>
drivers/mmc/core/mmc.c
include/linux/mmc/card.h
include/linux/mmc/mmc.h

index d65cf24..98cd0e5 100644 (file)
@@ -114,17 +114,18 @@ static int mmc_decode_cid(struct mmc_card *card)
 static int mmc_decode_csd(struct mmc_card *card)
 {
        struct mmc_csd *csd = &card->csd;
-       unsigned int e, m, csd_struct;
+       unsigned int e, m;
        u32 *resp = card->raw_csd;
 
        /*
         * We only understand CSD structure v1.1 and v1.2.
         * v1.2 has extra information in bits 15, 11 and 10.
+        * We also support eMMC v4.4 & v4.41.
         */
-       csd_struct = UNSTUFF_BITS(resp, 126, 2);
-       if (csd_struct != 1 && csd_struct != 2) {
+       csd->structure = UNSTUFF_BITS(resp, 126, 2);
+       if (csd->structure == 0) {
                printk(KERN_ERR "%s: unrecognised CSD structure version %d\n",
-                       mmc_hostname(card->host), csd_struct);
+                       mmc_hostname(card->host), csd->structure);
                return -EINVAL;
        }
 
@@ -207,11 +208,22 @@ static int mmc_read_ext_csd(struct mmc_card *card)
                goto out;
        }
 
+       /* Version is coded in the CSD_STRUCTURE byte in the EXT_CSD register */
+       if (card->csd.structure == 3) {
+               int ext_csd_struct = ext_csd[EXT_CSD_STRUCTURE];
+               if (ext_csd_struct > 2) {
+                       printk(KERN_ERR "%s: unrecognised EXT_CSD structure "
+                               "version %d\n", mmc_hostname(card->host),
+                                       ext_csd_struct);
+                       err = -EINVAL;
+                       goto out;
+               }
+       }
+
        card->ext_csd.rev = ext_csd[EXT_CSD_REV];
        if (card->ext_csd.rev > 5) {
-               printk(KERN_ERR "%s: unrecognised EXT_CSD structure "
-                       "version %d\n", mmc_hostname(card->host),
-                       card->ext_csd.rev);
+               printk(KERN_ERR "%s: unrecognised EXT_CSD revision %d\n",
+                       mmc_hostname(card->host), card->ext_csd.rev);
                err = -EINVAL;
                goto out;
        }
index d02d2c6..c83c7a7 100644 (file)
@@ -24,6 +24,7 @@ struct mmc_cid {
 };
 
 struct mmc_csd {
+       unsigned char           structure;
        unsigned char           mmca_vsn;
        unsigned short          cmdclass;
        unsigned short          tacc_clks;
index 3a27330..5414fa6 100644 (file)
@@ -254,6 +254,7 @@ struct _mmc_csd {
 #define EXT_CSD_BUS_WIDTH      183     /* R/W */
 #define EXT_CSD_HS_TIMING      185     /* R/W */
 #define EXT_CSD_CARD_TYPE      196     /* RO */
+#define EXT_CSD_STRUCTURE      194     /* RO */
 #define EXT_CSD_REV            192     /* RO */
 #define EXT_CSD_SEC_CNT                212     /* RO, 4 bytes */
 #define EXT_CSD_S_A_TIMEOUT    217