mmc: core: Fix HS switch failure in mmc_select_hs400
authorShawn Lin <shawn.lin@rock-chips.com>
Fri, 27 May 2016 06:57:25 +0000 (14:57 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 30 May 2016 09:30:56 +0000 (17:30 +0800)
We should change HS400 mode selection timing to meet JEDEC
specification. The JEDEC 5.1 said that change the frequency to <= 52MHZ
after HS_TIMING switch. Refer to section 6.6.2.3 "HS400" timing mode
selection:

Set the "Timing Interface" parameter in the HS_TIMING[185] field of the
Extended CSD register to 0x1 to switch to High Speed mode and then set
the clock frequency to a value not greater than 52MHZ.

Change-Id: Ia676b8e3ea4a66867372c9719d768a6d4405ff15
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
drivers/mmc/core/mmc.c

index 7dfdd7e6c77e3bc081d1fc45d20dcc3c2ef7a515..14d923216d4a093a16911595ebfa59f9c13f0e52 100644 (file)
@@ -1083,10 +1083,6 @@ static int mmc_select_hs400(struct mmc_card *card)
        if (host->caps & MMC_CAP_WAIT_WHILE_BUSY)
                send_status = false;
 
-       /* Reduce frequency to HS frequency */
-       max_dtr = card->ext_csd.hs_max_dtr;
-       mmc_set_clock(host, max_dtr);
-
        /* Switch card to HS mode */
        val = EXT_CSD_TIMING_HS;
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
@@ -1102,6 +1098,10 @@ static int mmc_select_hs400(struct mmc_card *card)
        /* Set host controller to HS timing */
        mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
 
+       /* Reduce frequency to HS frequency */
+       max_dtr = card->ext_csd.hs_max_dtr;
+       mmc_set_clock(host, max_dtr);
+
        if (!send_status) {
                err = mmc_switch_status(card);
                if (err)