]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/mmc/core/mmc.c
Merge tag 'spi-v3.15-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi
[karo-tx-linux.git] / drivers / mmc / core / mmc.c
index 072171183d5b781b9d2d0e70b445954dd8bedd74..1ab5f3a0af5b734a1829e732fe91b5bef8f24d2b 100644 (file)
@@ -856,8 +856,10 @@ static int mmc_select_hs200(struct mmc_card *card)
 
        /* switch to HS200 mode if bus width set successfully */
        if (!err)
-               err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                                EXT_CSD_HS_TIMING, 2, 0);
+               err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+                               EXT_CSD_HS_TIMING, 2,
+                               card->ext_csd.generic_cmd6_time,
+                               true, true, true);
 err:
        return err;
 }
@@ -1074,9 +1076,10 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
                    host->caps2 & MMC_CAP2_HS200)
                        err = mmc_select_hs200(card);
                else if (host->caps & MMC_CAP_MMC_HIGHSPEED)
-                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                                        EXT_CSD_HS_TIMING, 1,
-                                        card->ext_csd.generic_cmd6_time);
+                       err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+                                       EXT_CSD_HS_TIMING, 1,
+                                       card->ext_csd.generic_cmd6_time,
+                                       true, true, true);
 
                if (err && err != -EBADMSG)
                        goto free_card;
@@ -1355,6 +1358,7 @@ static int mmc_sleep(struct mmc_host *host)
 {
        struct mmc_command cmd = {0};
        struct mmc_card *card = host->card;
+       unsigned int timeout_ms = DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000);
        int err;
 
        err = mmc_deselect_cards(host);
@@ -1365,7 +1369,19 @@ static int mmc_sleep(struct mmc_host *host)
        cmd.arg = card->rca << 16;
        cmd.arg |= 1 << 15;
 
-       cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
+       /*
+        * If the max_busy_timeout of the host is specified, validate it against
+        * the sleep cmd timeout. A failure means we need to prevent the host
+        * from doing hw busy detection, which is done by converting to a R1
+        * response instead of a R1B.
+        */
+       if (host->max_busy_timeout && (timeout_ms > host->max_busy_timeout)) {
+               cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
+       } else {
+               cmd.flags = MMC_RSP_R1B | MMC_CMD_AC;
+               cmd.busy_timeout = timeout_ms;
+       }
+
        err = mmc_wait_for_cmd(host, &cmd, 0);
        if (err)
                return err;
@@ -1376,8 +1392,8 @@ static int mmc_sleep(struct mmc_host *host)
         * SEND_STATUS command to poll the status because that command (and most
         * others) is invalid while the card sleeps.
         */
-       if (!(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
-               mmc_delay(DIV_ROUND_UP(card->ext_csd.sa_timeout, 10000));
+       if (!cmd.busy_timeout || !(host->caps & MMC_CAP_WAIT_WHILE_BUSY))
+               mmc_delay(timeout_ms);
 
        return err;
 }
@@ -1400,7 +1416,7 @@ static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type)
 
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
                        EXT_CSD_POWER_OFF_NOTIFICATION,
-                       notify_type, timeout, true, false);
+                       notify_type, timeout, true, false, false);
        if (err)
                pr_err("%s: Power Off Notification timed out, %u\n",
                       mmc_hostname(card->host), timeout);