diff mbox series

[U-Boot,v2] mmc: correct the HS400 initialization process

Message ID 20190326063200.7172-1-haibo.chen@nxp.com
State Accepted
Delegated to: Tom Rini
Headers show
Series [U-Boot,v2] mmc: correct the HS400 initialization process | expand

Commit Message

Bough Chen March 26, 2019, 6:24 a.m. UTC
After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading
HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed()
which indicates that the HS200/HS400 to HS downgrade is happening.

During the HS400 initialization, first select to HS200, and config
the related clock rate, then downgrade to HS mode. So here also need
to config the downgrade value to be true for two reasons. First,
make sure in the function mmc_set_card_speed(), after switch to HS
mode, first config the clock rate, then read the EXT_CSD, avoid
receiving data of EXT_CSD in HS mode at 200MHz. Second, after issue
the MMC_CMD_SWITCH command, it need to wait a bit then switch bus
properties.

Test on i.MX8QM MEK board, some Micron eMMC will stuck in transfer
mode in this case, and USDHC will never get data transfer complete
status, cause the uboot hang.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/mmc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Marek Vasut March 26, 2019, 4:49 p.m. UTC | #1
On 3/26/19 7:24 AM, BOUGH CHEN wrote:
> After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading
> HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed()
> which indicates that the HS200/HS400 to HS downgrade is happening.
> 
> During the HS400 initialization, first select to HS200, and config
> the related clock rate, then downgrade to HS mode. So here also need
> to config the downgrade value to be true for two reasons. First,
> make sure in the function mmc_set_card_speed(), after switch to HS
> mode, first config the clock rate, then read the EXT_CSD, avoid
> receiving data of EXT_CSD in HS mode at 200MHz. Second, after issue
> the MMC_CMD_SWITCH command, it need to wait a bit then switch bus
> properties.
> 
> Test on i.MX8QM MEK board, some Micron eMMC will stuck in transfer
> mode in this case, and USDHC will never get data transfer complete
> status, cause the uboot hang.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>

Acked-by: Marek Vasut <marek.vasut@gmail.com>

> ---
>  drivers/mmc/mmc.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index 89b255daf4..456c1b4cc9 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1892,8 +1892,7 @@ static int mmc_select_hs400(struct mmc *mmc)
>  	}
>  
>  	/* Set back to HS */
> -	mmc_set_card_speed(mmc, MMC_HS, false);
> -	mmc_set_clock(mmc, mmc_mode2freq(mmc, MMC_HS), false);
> +	mmc_set_card_speed(mmc, MMC_HS, true);
>  
>  	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,
>  			 EXT_CSD_BUS_WIDTH_8 | EXT_CSD_DDR_FLAG);
>
Tom Rini March 29, 2019, 8:24 p.m. UTC | #2
On Tue, Mar 26, 2019 at 06:24:17AM +0000, BOUGH CHEN wrote:

> After the commit b9a2a0e2e9c0 ("mmc: Add support for downgrading
> HS200/HS400 to HS mode"), it add a parameter in mmc_set_card_speed()
> which indicates that the HS200/HS400 to HS downgrade is happening.
> 
> During the HS400 initialization, first select to HS200, and config
> the related clock rate, then downgrade to HS mode. So here also need
> to config the downgrade value to be true for two reasons. First,
> make sure in the function mmc_set_card_speed(), after switch to HS
> mode, first config the clock rate, then read the EXT_CSD, avoid
> receiving data of EXT_CSD in HS mode at 200MHz. Second, after issue
> the MMC_CMD_SWITCH command, it need to wait a bit then switch bus
> properties.
> 
> Test on i.MX8QM MEK board, some Micron eMMC will stuck in transfer
> mode in this case, and USDHC will never get data transfer complete
> status, cause the uboot hang.
> 
> Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
> Acked-by: Marek Vasut <marek.vasut@gmail.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 89b255daf4..456c1b4cc9 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1892,8 +1892,7 @@  static int mmc_select_hs400(struct mmc *mmc)
 	}
 
 	/* Set back to HS */
-	mmc_set_card_speed(mmc, MMC_HS, false);
-	mmc_set_clock(mmc, mmc_mode2freq(mmc, MMC_HS), false);
+	mmc_set_card_speed(mmc, MMC_HS, true);
 
 	err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH,
 			 EXT_CSD_BUS_WIDTH_8 | EXT_CSD_DDR_FLAG);