* [PATCH v2] Recognize CSD structure version 3
@ 2010-06-03 4:20 Kyungmin Park
2010-06-18 9:57 ` zhangfei gao
0 siblings, 1 reply; 2+ messages in thread
From: Kyungmin Park @ 2010-06-03 4:20 UTC (permalink / raw)
To: linux-mmc, akpm, adrian.hunter
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.
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 89f7a25..95c4fb2 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -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.
+ * also support the for 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;
}
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index d02d2c6..c83c7a7 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -24,6 +24,7 @@ struct mmc_cid {
};
struct mmc_csd {
+ unsigned char structure;
unsigned char mmca_vsn;
unsigned short cmdclass;
unsigned short tacc_clks;
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 8a49cbf..52ce988 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] Recognize CSD structure version 3
2010-06-03 4:20 [PATCH v2] Recognize CSD structure version 3 Kyungmin Park
@ 2010-06-18 9:57 ` zhangfei gao
0 siblings, 0 replies; 2+ messages in thread
From: zhangfei gao @ 2010-06-18 9:57 UTC (permalink / raw)
To: Kyungmin Park; +Cc: linux-mmc, akpm, adrian.hunter
Hi, Kyungmin
I have verified on marvell pxa688 platform for sandisk 4.4 emmc, it works.
Thanks for sharing.
Thanks
zhangfei
On Thu, Jun 3, 2010 at 12:20 PM, Kyungmin Park <kmpark@infradead.org> wrote:
> 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.
>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 89f7a25..95c4fb2 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -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.
> + * also support the for 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;
> }
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index d02d2c6..c83c7a7 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -24,6 +24,7 @@ struct mmc_cid {
> };
>
> struct mmc_csd {
> + unsigned char structure;
> unsigned char mmca_vsn;
> unsigned short cmdclass;
> unsigned short tacc_clks;
> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
> index 8a49cbf..52ce988 100644
> --- a/include/linux/mmc/mmc.h
> +++ b/include/linux/mmc/mmc.h
> @@ -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
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-06-18 9:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-03 4:20 [PATCH v2] Recognize CSD structure version 3 Kyungmin Park
2010-06-18 9:57 ` zhangfei gao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox