diff options
Diffstat (limited to 'drivers/mmc/core/core.c')
| -rw-r--r-- | drivers/mmc/core/core.c | 87 | 
1 files changed, 15 insertions, 72 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 098374b1ab2b..acbc3f2aaaf9 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -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" @@ -65,23 +66,6 @@ bool use_spi_crc = 1;  module_param(use_spi_crc, bool, 0);  /* - * We normally treat cards as removed during suspend if they are not - * known to be on a non-removable bus, to avoid the risk of writing - * back data to a different card after resume.  Allow this to be - * overridden if necessary. - */ -#ifdef CONFIG_MMC_UNSAFE_RESUME -bool mmc_assume_removable; -#else -bool mmc_assume_removable = 1; -#endif -EXPORT_SYMBOL(mmc_assume_removable); -module_param_named(removable, mmc_assume_removable, bool, 0644); -MODULE_PARM_DESC( -	removable, -	"MMC/SD cards are removable and may be removed during suspend"); - -/*   * Internal function. Schedule delayed work in the MMC work queue.   */  static int mmc_schedule_delayed_work(struct delayed_work *work, @@ -302,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); @@ -1950,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", @@ -2137,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; @@ -2169,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;  	/* @@ -2189,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); @@ -2248,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; @@ -2352,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)) @@ -2435,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); @@ -2490,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);  } @@ -2501,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); @@ -2537,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;  	} @@ -2563,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;  	} @@ -2582,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)) { @@ -2602,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 @@ -2668,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 */  | 
