mmc: core: fix UHS-I card invalid allocation unit issue
PATCH 1/1 mmc: core: fix UHS-I card invalid allocation unit issue
From: Kevin Liu <[email protected]>
For UHS-I card, UHS_AU_SIZE rather than AU_SIZE should be referred. And since SD spec3.0, the valid value for AU_SIZE is changed from 0x1~0x9 to 0x1~0xF.
Signed-off-by Dingyong Hu <[email protected]>
Signed-off-by Kevin Liu <[email protected]>
--- drivers/mmc/core/sd.c | 18 +++++++++++------- drivers/mmc/core/sd.h | 2 +- drivers/mmc/core/sdio.c | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-)
drivers/mmc/core/sd.c +11 -7
@@ -212,9 +212,9 @@ static int mmc_decode_scr(struct mmc_card *card)/* * Fetch and process SD Status register. */ -static int mmc_read_ssr (struct mmc_card *card) +static int mmc_read_ssr (struct mmc_card *card,bool uhs_card) { -unsigned int au, es, et, eo; +unsigned int au, es, et, eo, au_min, au_max;int err, i;u32 *ssr;
@@ -243,8 +243,11 @@ static int mmc_read_ssr(struct mmc_card *card)* UNSTUFF_BITS only works with four u32s so we have to offset the * bitfield positions accordingly. */ - au =UNSTUFF_BITS (ssr,428 -384 ,4 ); -if (au >0 && au <=9 ) { + au_min = uhs_card ?0x7 :0x1 ; + au_max = card->scr.sda_spec3 ?0xF :0x9 ; + au = uhs_card ?UNSTUFF_BITS (ssr,392 -384 ,4 ) : +UNSTUFF_BITS (ssr,428 -384 ,4 ); +if (au >= au_min && au <= au_max) { card->ssr.au =1 << (au +4 ); es =UNSTUFF_BITS (ssr,408 -384 ,16 ); et =UNSTUFF_BITS (ssr,402 -384 ,6 );
@@ -793,7 +796,7 @@ int mmc_sd_get_csd(struct mmc_host *host, struct mmc_card *card) }int mmc_sd_setup_card (struct mmc_host *host,struct mmc_card *card, -bool reinit) +bool reinit,bool uhs_card) {int err;
@@ -812,7 +815,7 @@ int mmc_sd_setup_card(struct mmc_host *host, struct mmc_card *card,/* * Fetch and process SD Status register. */ - err =mmc_read_ssr (card); + err =mmc_read_ssr (card, uhs_card);if (err)return err;
@@ -948,7 +951,8 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,return err; } - err =mmc_sd_setup_card (host, card, oldcard !=NULL ); + err =mmc_sd_setup_card (host, card, oldcard !=NULL , + rocr &SD_ROCR_S18A );if (err) goto free_card;
drivers/mmc/core/sd.h +1 -1
@@ -9,7 +9,7 @@ int mmc_sd_get_cid(struct mmc_host *host, u32 ocr, u32 *cid, u32 *rocr);int mmc_sd_get_csd (struct mmc_host *host,struct mmc_card *card);void mmc_decode_cid (struct mmc_card *card);int mmc_sd_setup_card (struct mmc_host *host,struct mmc_card *card, -bool reinit); +bool reinit,bool uhs_card);unsigned mmc_sd_get_max_clock (struct mmc_card *card);int mmc_sd_switch_hs (struct mmc_card *card);void mmc_sd_go_highspeed (struct mmc_card *card);
drivers/mmc/core/sdio.c +2 -1
@@ -742,7 +742,8 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,mmc_fixup_device (card,NULL );if (card->type ==MMC_TYPE_SD_COMBO ) { - err =mmc_sd_setup_card (host, card, oldcard !=NULL ); + err =mmc_sd_setup_card (host, card, oldcard !=NULL , + ocr &R4_18V_PRESENT );/* handle as SDIO-only card if memory init failed */ if (err) {mmc_go_idle (host);
Signature · 1 line
1.7.0.4