Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux.git] / drivers / mmc / core / core.c
index 10856ec64412ac21a95f9a5055911a3192af2e92..acbc3f2aaaf9e3adff743de7081e1e6508b6b03c 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include <linux/mmc/sd.h>
+#include <linux/mmc/slot-gpio.h>
 
 #include "core.h"
 #include "bus.h"
@@ -285,7 +286,8 @@ void mmc_start_bkops(struct mmc_card *card, bool from_exception)
        }
 
        err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                       EXT_CSD_BKOPS_START, 1, timeout, use_busy_signal, true);
+                       EXT_CSD_BKOPS_START, 1, timeout,
+                       use_busy_signal, true, false);
        if (err) {
                pr_warn("%s: Error %d starting bkops\n",
                        mmc_hostname(card->host), err);
@@ -1933,7 +1935,7 @@ static int mmc_do_erase(struct mmc_card *card, unsigned int from,
        cmd.opcode = MMC_ERASE;
        cmd.arg = arg;
        cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
-       cmd.cmd_timeout_ms = mmc_erase_timeout(card, arg, qty);
+       cmd.busy_timeout = mmc_erase_timeout(card, arg, qty);
        err = mmc_wait_for_cmd(card->host, &cmd, 0);
        if (err) {
                pr_err("mmc_erase: erase error %d, status %#x\n",
@@ -2120,7 +2122,7 @@ static unsigned int mmc_do_calc_max_discard(struct mmc_card *card,
                y = 0;
                for (x = 1; x && x <= max_qty && max_qty - x >= qty; x <<= 1) {
                        timeout = mmc_erase_timeout(card, arg, qty + x);
-                       if (timeout > host->max_discard_to)
+                       if (timeout > host->max_busy_timeout)
                                break;
                        if (timeout < last_timeout)
                                break;
@@ -2152,7 +2154,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
        struct mmc_host *host = card->host;
        unsigned int max_discard, max_trim;
 
-       if (!host->max_discard_to)
+       if (!host->max_busy_timeout)
                return UINT_MAX;
 
        /*
@@ -2172,7 +2174,7 @@ unsigned int mmc_calc_max_discard(struct mmc_card *card)
                max_discard = 0;
        }
        pr_debug("%s: calculated max. discard sectors %u for timeout %u ms\n",
-                mmc_hostname(host), max_discard, host->max_discard_to);
+                mmc_hostname(host), max_discard, host->max_busy_timeout);
        return max_discard;
 }
 EXPORT_SYMBOL(mmc_calc_max_discard);
@@ -2231,9 +2233,6 @@ static int mmc_do_hw_reset(struct mmc_host *host, int check)
 {
        struct mmc_card *card = host->card;
 
-       if (!host->bus_ops->power_restore)
-               return -EOPNOTSUPP;
-
        if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
                return -EOPNOTSUPP;
 
@@ -2335,7 +2334,7 @@ int _mmc_detect_card_removed(struct mmc_host *host)
 {
        int ret;
 
-       if ((host->caps & MMC_CAP_NONREMOVABLE) || !host->bus_ops->alive)
+       if (host->caps & MMC_CAP_NONREMOVABLE)
                return 0;
 
        if (!host->card || mmc_card_removed(host->card))
@@ -2418,7 +2417,7 @@ void mmc_rescan(struct work_struct *work)
         * if there is a _removable_ card registered, check whether it is
         * still present
         */
-       if (host->bus_ops && host->bus_ops->detect && !host->bus_dead
+       if (host->bus_ops && !host->bus_dead
            && !(host->caps & MMC_CAP_NONREMOVABLE))
                host->bus_ops->detect(host);
 
@@ -2473,6 +2472,7 @@ void mmc_start_host(struct mmc_host *host)
                mmc_power_off(host);
        else
                mmc_power_up(host, host->ocr_avail);
+       mmc_gpiod_request_cd_irq(host);
        _mmc_detect_change(host, 0, false);
 }
 
@@ -2484,6 +2484,8 @@ void mmc_stop_host(struct mmc_host *host)
        host->removed = 1;
        spin_unlock_irqrestore(&host->lock, flags);
 #endif
+       if (host->slot.cd_irq >= 0)
+               disable_irq(host->slot.cd_irq);
 
        host->rescan_disable = 1;
        cancel_delayed_work_sync(&host->detect);
@@ -2520,7 +2522,7 @@ int mmc_power_save_host(struct mmc_host *host)
 
        mmc_bus_get(host);
 
-       if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) {
+       if (!host->bus_ops || host->bus_dead) {
                mmc_bus_put(host);
                return -EINVAL;
        }
@@ -2546,7 +2548,7 @@ int mmc_power_restore_host(struct mmc_host *host)
 
        mmc_bus_get(host);
 
-       if (!host->bus_ops || host->bus_dead || !host->bus_ops->power_restore) {
+       if (!host->bus_ops || host->bus_dead) {
                mmc_bus_put(host);
                return -EINVAL;
        }
@@ -2565,12 +2567,8 @@ EXPORT_SYMBOL(mmc_power_restore_host);
  */
 int mmc_flush_cache(struct mmc_card *card)
 {
-       struct mmc_host *host = card->host;
        int err = 0;
 
-       if (!(host->caps2 & MMC_CAP2_CACHE_CTRL))
-               return err;
-
        if (mmc_card_mmc(card) &&
                        (card->ext_csd.cache_size > 0) &&
                        (card->ext_csd.cache_ctrl & 1)) {
@@ -2585,44 +2583,6 @@ int mmc_flush_cache(struct mmc_card *card)
 }
 EXPORT_SYMBOL(mmc_flush_cache);
 
-/*
- * Turn the cache ON/OFF.
- * Turning the cache OFF shall trigger flushing of the data
- * to the non-volatile storage.
- * This function should be called with host claimed
- */
-int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
-{
-       struct mmc_card *card = host->card;
-       unsigned int timeout;
-       int err = 0;
-
-       if (!(host->caps2 & MMC_CAP2_CACHE_CTRL) ||
-                       mmc_card_is_removable(host))
-               return err;
-
-       if (card && mmc_card_mmc(card) &&
-                       (card->ext_csd.cache_size > 0)) {
-               enable = !!enable;
-
-               if (card->ext_csd.cache_ctrl ^ enable) {
-                       timeout = enable ? card->ext_csd.generic_cmd6_time : 0;
-                       err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                                       EXT_CSD_CACHE_CTRL, enable, timeout);
-                       if (err)
-                               pr_err("%s: cache %s error %d\n",
-                                               mmc_hostname(card->host),
-                                               enable ? "on" : "off",
-                                               err);
-                       else
-                               card->ext_csd.cache_ctrl = enable;
-               }
-       }
-
-       return err;
-}
-EXPORT_SYMBOL(mmc_cache_ctrl);
-
 #ifdef CONFIG_PM
 
 /* Do the card removal on suspend if card is assumed removeable
@@ -2651,7 +2611,7 @@ int mmc_pm_notify(struct notifier_block *notify_block,
                /* Validate prerequisites for suspend */
                if (host->bus_ops->pre_suspend)
                        err = host->bus_ops->pre_suspend(host);
-               if (!err && host->bus_ops->suspend)
+               if (!err)
                        break;
 
                /* Calling bus_ops->remove() with a claimed host can deadlock */