Commit 4a065193 authored by Ulf Hansson's avatar Ulf Hansson Committed by Chris Ball

mmc: core: Let mmc_power_up|cycle take ocr as parameter

As a step to fixup the setup of the negotiated ocr mask, we need the
mmc_power_up|cycle functions to take the ocr as a parameter.
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 878e200b
...@@ -1479,7 +1479,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage) ...@@ -1479,7 +1479,7 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage)
if (err) { if (err) {
pr_debug("%s: Signal voltage switch failed, " pr_debug("%s: Signal voltage switch failed, "
"power cycling card\n", mmc_hostname(host)); "power cycling card\n", mmc_hostname(host));
mmc_power_cycle(host); mmc_power_cycle(host, host->ocr);
} }
mmc_host_clk_release(host); mmc_host_clk_release(host);
...@@ -1520,22 +1520,14 @@ void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type) ...@@ -1520,22 +1520,14 @@ void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type)
* If a host does all the power sequencing itself, ignore the * If a host does all the power sequencing itself, ignore the
* initial MMC_POWER_UP stage. * initial MMC_POWER_UP stage.
*/ */
void mmc_power_up(struct mmc_host *host) void mmc_power_up(struct mmc_host *host, u32 ocr)
{ {
int bit;
if (host->ios.power_mode == MMC_POWER_ON) if (host->ios.power_mode == MMC_POWER_ON)
return; return;
mmc_host_clk_hold(host); mmc_host_clk_hold(host);
/* If ocr is set, we use it */ host->ios.vdd = fls(ocr) - 1;
if (host->ocr)
bit = ffs(host->ocr) - 1;
else
bit = fls(host->ocr_avail) - 1;
host->ios.vdd = bit;
if (mmc_host_is_spi(host)) if (mmc_host_is_spi(host))
host->ios.chip_select = MMC_CS_HIGH; host->ios.chip_select = MMC_CS_HIGH;
else else
...@@ -1605,12 +1597,12 @@ void mmc_power_off(struct mmc_host *host) ...@@ -1605,12 +1597,12 @@ void mmc_power_off(struct mmc_host *host)
mmc_host_clk_release(host); mmc_host_clk_release(host);
} }
void mmc_power_cycle(struct mmc_host *host) void mmc_power_cycle(struct mmc_host *host, u32 ocr)
{ {
mmc_power_off(host); mmc_power_off(host);
/* Wait at least 1 ms according to SD spec */ /* Wait at least 1 ms according to SD spec */
mmc_delay(1); mmc_delay(1);
mmc_power_up(host); mmc_power_up(host, ocr);
} }
/* /*
...@@ -2309,7 +2301,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq) ...@@ -2309,7 +2301,7 @@ static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
pr_info("%s: %s: trying to init card at %u Hz\n", pr_info("%s: %s: trying to init card at %u Hz\n",
mmc_hostname(host), __func__, host->f_init); mmc_hostname(host), __func__, host->f_init);
#endif #endif
mmc_power_up(host); mmc_power_up(host, host->ocr_avail);
/* /*
* Some eMMCs (with VCCQ always on) may not be reset after power up, so * Some eMMCs (with VCCQ always on) may not be reset after power up, so
...@@ -2479,7 +2471,7 @@ void mmc_start_host(struct mmc_host *host) ...@@ -2479,7 +2471,7 @@ void mmc_start_host(struct mmc_host *host)
if (host->caps2 & MMC_CAP2_NO_PRESCAN_POWERUP) if (host->caps2 & MMC_CAP2_NO_PRESCAN_POWERUP)
mmc_power_off(host); mmc_power_off(host);
else else
mmc_power_up(host); mmc_power_up(host, host->ocr_avail);
mmc_detect_change(host, 0); mmc_detect_change(host, 0);
} }
...@@ -2558,7 +2550,7 @@ int mmc_power_restore_host(struct mmc_host *host) ...@@ -2558,7 +2550,7 @@ int mmc_power_restore_host(struct mmc_host *host)
return -EINVAL; return -EINVAL;
} }
mmc_power_up(host); mmc_power_up(host, host->ocr);
ret = host->bus_ops->power_restore(host); ret = host->bus_ops->power_restore(host);
mmc_bus_put(host); mmc_bus_put(host);
......
...@@ -46,9 +46,9 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); ...@@ -46,9 +46,9 @@ int mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage);
int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage); int __mmc_set_signal_voltage(struct mmc_host *host, int signal_voltage);
void mmc_set_timing(struct mmc_host *host, unsigned int timing); void mmc_set_timing(struct mmc_host *host, unsigned int timing);
void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type); void mmc_set_driver_type(struct mmc_host *host, unsigned int drv_type);
void mmc_power_up(struct mmc_host *host); void mmc_power_up(struct mmc_host *host, u32 ocr);
void mmc_power_off(struct mmc_host *host); void mmc_power_off(struct mmc_host *host);
void mmc_power_cycle(struct mmc_host *host); void mmc_power_cycle(struct mmc_host *host, u32 ocr);
static inline void mmc_delay(unsigned int ms) static inline void mmc_delay(unsigned int ms)
{ {
......
...@@ -1533,7 +1533,7 @@ static int mmc_resume(struct mmc_host *host) ...@@ -1533,7 +1533,7 @@ static int mmc_resume(struct mmc_host *host)
BUG_ON(!host->card); BUG_ON(!host->card);
mmc_claim_host(host); mmc_claim_host(host);
mmc_power_up(host); mmc_power_up(host, host->ocr);
mmc_select_voltage(host, host->ocr); mmc_select_voltage(host, host->ocr);
err = mmc_init_card(host, host->ocr, host->card); err = mmc_init_card(host, host->ocr, host->card);
mmc_release_host(host); mmc_release_host(host);
...@@ -1579,7 +1579,7 @@ static int mmc_runtime_resume(struct mmc_host *host) ...@@ -1579,7 +1579,7 @@ static int mmc_runtime_resume(struct mmc_host *host)
mmc_claim_host(host); mmc_claim_host(host);
mmc_power_up(host); mmc_power_up(host, host->ocr);
err = mmc_resume(host); err = mmc_resume(host);
if (err) if (err)
pr_err("%s: error %d doing aggessive resume\n", pr_err("%s: error %d doing aggessive resume\n",
......
...@@ -1099,7 +1099,7 @@ static int mmc_sd_resume(struct mmc_host *host) ...@@ -1099,7 +1099,7 @@ static int mmc_sd_resume(struct mmc_host *host)
BUG_ON(!host->card); BUG_ON(!host->card);
mmc_claim_host(host); mmc_claim_host(host);
mmc_power_up(host); mmc_power_up(host, host->ocr);
mmc_select_voltage(host, host->ocr); mmc_select_voltage(host, host->ocr);
err = mmc_sd_init_card(host, host->ocr, host->card); err = mmc_sd_init_card(host, host->ocr, host->card);
mmc_release_host(host); mmc_release_host(host);
...@@ -1144,7 +1144,7 @@ static int mmc_sd_runtime_resume(struct mmc_host *host) ...@@ -1144,7 +1144,7 @@ static int mmc_sd_runtime_resume(struct mmc_host *host)
mmc_claim_host(host); mmc_claim_host(host);
mmc_power_up(host); mmc_power_up(host, host->ocr);
err = mmc_sd_resume(host); err = mmc_sd_resume(host);
if (err) if (err)
pr_err("%s: error %d doing aggessive resume\n", pr_err("%s: error %d doing aggessive resume\n",
......
...@@ -981,7 +981,7 @@ static int mmc_sdio_resume(struct mmc_host *host) ...@@ -981,7 +981,7 @@ static int mmc_sdio_resume(struct mmc_host *host)
/* Restore power if needed */ /* Restore power if needed */
if (!mmc_card_keep_power(host)) { if (!mmc_card_keep_power(host)) {
mmc_power_up(host); mmc_power_up(host, host->ocr);
mmc_select_voltage(host, host->ocr); mmc_select_voltage(host, host->ocr);
/* /*
* Tell runtime PM core we just powered up the card, * Tell runtime PM core we just powered up the card,
...@@ -1108,7 +1108,7 @@ static int mmc_sdio_runtime_suspend(struct mmc_host *host) ...@@ -1108,7 +1108,7 @@ static int mmc_sdio_runtime_suspend(struct mmc_host *host)
static int mmc_sdio_runtime_resume(struct mmc_host *host) static int mmc_sdio_runtime_resume(struct mmc_host *host)
{ {
/* Restore power and re-initialize. */ /* Restore power and re-initialize. */
mmc_power_up(host); mmc_power_up(host, host->ocr);
return mmc_sdio_power_restore(host); return mmc_sdio_power_restore(host);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment