diff options
author | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
---|---|---|
committer | Scott Wood <scottwood@freescale.com> | 2014-04-07 23:49:35 (GMT) |
commit | 62b8c978ee6b8d135d9e7953221de58000dba986 (patch) | |
tree | 683b04b2e627f6710c22c151b23c8cc9a165315e /drivers/mmc/core/mmc.c | |
parent | 78fd82238d0e5716578c326404184a27ba67fd6e (diff) | |
download | linux-fsl-qoriq-62b8c978ee6b8d135d9e7953221de58000dba986.tar.xz |
Rewind v3.13-rc3+ (78fd82238d0e5716) to v3.12
Diffstat (limited to 'drivers/mmc/core/mmc.c')
-rw-r--r-- | drivers/mmc/core/mmc.c | 127 |
1 files changed, 51 insertions, 76 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index f631f5a..6d02012 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -13,7 +13,6 @@ #include <linux/err.h> #include <linux/slab.h> #include <linux/stat.h> -#include <linux/pm_runtime.h> #include <linux/mmc/host.h> #include <linux/mmc/card.h> @@ -935,7 +934,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, goto err; } - card->ocr = ocr; card->type = MMC_TYPE_MMC; card->rca = 1; memcpy(card->raw_cid, cid, sizeof(card->raw_cid)); @@ -1406,9 +1404,9 @@ static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type) if (notify_type == EXT_CSD_POWER_OFF_LONG) timeout = card->ext_csd.power_off_longtime; - err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, - EXT_CSD_POWER_OFF_NOTIFICATION, - notify_type, timeout, true, false); + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_POWER_OFF_NOTIFICATION, + notify_type, timeout); if (err) pr_err("%s: Power Off Notification timed out, %u\n", mmc_hostname(card->host), timeout); @@ -1479,9 +1477,6 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) mmc_claim_host(host); - if (mmc_card_suspended(host->card)) - goto out; - if (mmc_card_doing_bkops(host->card)) { err = mmc_stop_bkops(host->card); if (err) @@ -1501,93 +1496,51 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) err = mmc_deselect_cards(host); host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); - if (!err) { + if (!err) mmc_power_off(host); - mmc_card_set_suspended(host->card); - } out: mmc_release_host(host); return err; } /* - * Suspend callback + * Suspend callback from host. */ static int mmc_suspend(struct mmc_host *host) { - int err; - - err = _mmc_suspend(host, true); - if (!err) { - pm_runtime_disable(&host->card->dev); - pm_runtime_set_suspended(&host->card->dev); - } + return _mmc_suspend(host, true); +} - return err; +/* + * Shutdown callback + */ +static int mmc_shutdown(struct mmc_host *host) +{ + return _mmc_suspend(host, false); } /* + * Resume callback from host. + * * This function tries to determine if the same card is still present * and, if so, restore all state to it. */ -static int _mmc_resume(struct mmc_host *host) +static int mmc_resume(struct mmc_host *host) { - int err = 0; + int err; BUG_ON(!host); BUG_ON(!host->card); mmc_claim_host(host); - - if (!mmc_card_suspended(host->card)) - goto out; - - mmc_power_up(host, host->card->ocr); - err = mmc_init_card(host, host->card->ocr, host->card); - mmc_card_clr_suspended(host->card); - -out: + mmc_power_up(host); + mmc_select_voltage(host, host->ocr); + err = mmc_init_card(host, host->ocr, host->card); mmc_release_host(host); - return err; -} - -/* - * Shutdown callback - */ -static int mmc_shutdown(struct mmc_host *host) -{ - int err = 0; - - /* - * In a specific case for poweroff notify, we need to resume the card - * before we can shutdown it properly. - */ - if (mmc_can_poweroff_notify(host->card) && - !(host->caps2 & MMC_CAP2_FULL_PWR_CYCLE)) - err = _mmc_resume(host); - - if (!err) - err = _mmc_suspend(host, false); return err; } -/* - * Callback for resume. - */ -static int mmc_resume(struct mmc_host *host) -{ - int err = 0; - - if (!(host->caps & MMC_CAP_RUNTIME_RESUME)) { - err = _mmc_resume(host); - pm_runtime_set_active(&host->card->dev); - pm_runtime_mark_last_busy(&host->card->dev); - } - pm_runtime_enable(&host->card->dev); - - return err; -} /* * Callback for runtime_suspend. @@ -1599,11 +1552,18 @@ static int mmc_runtime_suspend(struct mmc_host *host) if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = _mmc_suspend(host, true); - if (err) + mmc_claim_host(host); + + err = mmc_suspend(host); + if (err) { pr_err("%s: error %d doing aggessive suspend\n", mmc_hostname(host), err); + goto out; + } + mmc_power_off(host); +out: + mmc_release_host(host); return err; } @@ -1614,14 +1574,18 @@ static int mmc_runtime_resume(struct mmc_host *host) { int err; - if (!(host->caps & (MMC_CAP_AGGRESSIVE_PM | MMC_CAP_RUNTIME_RESUME))) + if (!(host->caps & MMC_CAP_AGGRESSIVE_PM)) return 0; - err = _mmc_resume(host); + mmc_claim_host(host); + + mmc_power_up(host); + err = mmc_resume(host); if (err) pr_err("%s: error %d doing aggessive resume\n", mmc_hostname(host), err); + mmc_release_host(host); return 0; } @@ -1631,7 +1595,7 @@ static int mmc_power_restore(struct mmc_host *host) host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); mmc_claim_host(host); - ret = mmc_init_card(host, host->card->ocr, host->card); + ret = mmc_init_card(host, host->ocr, host->card); mmc_release_host(host); return ret; @@ -1676,7 +1640,7 @@ static void mmc_attach_bus_ops(struct mmc_host *host) int mmc_attach_mmc(struct mmc_host *host) { int err; - u32 ocr, rocr; + u32 ocr; BUG_ON(!host); WARN_ON(!host->claimed); @@ -1702,12 +1666,23 @@ int mmc_attach_mmc(struct mmc_host *host) goto err; } - rocr = mmc_select_voltage(host, ocr); + /* + * Sanity check the voltages that the card claims to + * support. + */ + if (ocr & 0x7F) { + pr_warning("%s: card claims to support voltages " + "below the defined range. These will be ignored.\n", + mmc_hostname(host)); + ocr &= ~0x7F; + } + + host->ocr = mmc_select_voltage(host, ocr); /* * Can we support the voltage of the card? */ - if (!rocr) { + if (!host->ocr) { err = -EINVAL; goto err; } @@ -1715,7 +1690,7 @@ int mmc_attach_mmc(struct mmc_host *host) /* * Detect and init the card. */ - err = mmc_init_card(host, rocr, NULL); + err = mmc_init_card(host, host->ocr, NULL); if (err) goto err; |