Skip to content

Commit 6da24b7

Browse files
Kyungmin Parktorvalds
authored andcommitted
mmc: recognize CSD structure
The eMMC spec 4.4 and 4.3 + additional feature chips has CSD structure version 3 and version 3 have to check the CSD_STRUCTURE byte in the EXT_CSD register. Also fix EXT_CSD revision message. [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: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a892e2d commit 6da24b7

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

drivers/mmc/core/mmc.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,18 @@ static int mmc_decode_cid(struct mmc_card *card)
114114
static int mmc_decode_csd(struct mmc_card *card)
115115
{
116116
struct mmc_csd *csd = &card->csd;
117-
unsigned int e, m, csd_struct;
117+
unsigned int e, m;
118118
u32 *resp = card->raw_csd;
119119

120120
/*
121121
* We only understand CSD structure v1.1 and v1.2.
122122
* v1.2 has extra information in bits 15, 11 and 10.
123+
* We also support eMMC v4.4 & v4.41.
123124
*/
124-
csd_struct = UNSTUFF_BITS(resp, 126, 2);
125-
if (csd_struct != 1 && csd_struct != 2) {
125+
csd->structure = UNSTUFF_BITS(resp, 126, 2);
126+
if (csd->structure == 0) {
126127
printk(KERN_ERR "%s: unrecognised CSD structure version %d\n",
127-
mmc_hostname(card->host), csd_struct);
128+
mmc_hostname(card->host), csd->structure);
128129
return -EINVAL;
129130
}
130131

@@ -207,11 +208,22 @@ static int mmc_read_ext_csd(struct mmc_card *card)
207208
goto out;
208209
}
209210

211+
/* Version is coded in the CSD_STRUCTURE byte in the EXT_CSD register */
212+
if (card->csd.structure == 3) {
213+
int ext_csd_struct = ext_csd[EXT_CSD_STRUCTURE];
214+
if (ext_csd_struct > 2) {
215+
printk(KERN_ERR "%s: unrecognised EXT_CSD structure "
216+
"version %d\n", mmc_hostname(card->host),
217+
ext_csd_struct);
218+
err = -EINVAL;
219+
goto out;
220+
}
221+
}
222+
210223
card->ext_csd.rev = ext_csd[EXT_CSD_REV];
211224
if (card->ext_csd.rev > 5) {
212-
printk(KERN_ERR "%s: unrecognised EXT_CSD structure "
213-
"version %d\n", mmc_hostname(card->host),
214-
card->ext_csd.rev);
225+
printk(KERN_ERR "%s: unrecognised EXT_CSD revision %d\n",
226+
mmc_hostname(card->host), card->ext_csd.rev);
215227
err = -EINVAL;
216228
goto out;
217229
}

include/linux/mmc/card.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct mmc_cid {
2424
};
2525

2626
struct mmc_csd {
27+
unsigned char structure;
2728
unsigned char mmca_vsn;
2829
unsigned short cmdclass;
2930
unsigned short tacc_clks;

include/linux/mmc/mmc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ struct _mmc_csd {
254254
#define EXT_CSD_BUS_WIDTH 183 /* R/W */
255255
#define EXT_CSD_HS_TIMING 185 /* R/W */
256256
#define EXT_CSD_CARD_TYPE 196 /* RO */
257+
#define EXT_CSD_STRUCTURE 194 /* RO */
257258
#define EXT_CSD_REV 192 /* RO */
258259
#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */
259260
#define EXT_CSD_S_A_TIMEOUT 217

0 commit comments

Comments
 (0)