summaryrefslogtreecommitdiff
path: root/drivers/mmc/host/tmio_mmc_pio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/tmio_mmc_pio.c')
-rw-r--r--drivers/mmc/host/tmio_mmc_pio.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index f508ecb5b8a7..b72edb72f7d2 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -859,32 +859,45 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
* is kept positive, so no suspending actually takes place.
*/
if (ios->power_mode == MMC_POWER_ON && ios->clock) {
- if (!host->power) {
+ if (host->power != TMIO_MMC_ON_RUN) {
tmio_mmc_clk_update(mmc);
pm_runtime_get_sync(dev);
+ if (host->resuming) {
+ tmio_mmc_reset(host);
+ host->resuming = false;
+ }
}
+ if (host->power == TMIO_MMC_OFF_STOP)
+ tmio_mmc_reset(host);
tmio_mmc_set_clock(host, ios->clock);
- if (!host->power) {
+ if (host->power == TMIO_MMC_OFF_STOP)
/* power up SD card and the bus */
tmio_mmc_power_on(host, ios->vdd);
- host->power = true;
- }
+ host->power = TMIO_MMC_ON_RUN;
/* start bus clock */
tmio_mmc_clk_start(host);
} else if (ios->power_mode != MMC_POWER_UP) {
- if (host->power) {
- struct tmio_mmc_data *pdata = host->pdata;
- if (ios->power_mode == MMC_POWER_OFF)
+ struct tmio_mmc_data *pdata = host->pdata;
+ unsigned int old_power = host->power;
+
+ if (old_power != TMIO_MMC_OFF_STOP) {
+ if (ios->power_mode == MMC_POWER_OFF) {
tmio_mmc_power_off(host);
+ host->power = TMIO_MMC_OFF_STOP;
+ } else {
+ host->power = TMIO_MMC_ON_STOP;
+ }
+ }
+
+ if (old_power == TMIO_MMC_ON_RUN) {
tmio_mmc_clk_stop(host);
- host->power = false;
pm_runtime_put(dev);
if (pdata->clk_disable)
pdata->clk_disable(host->pdev);
}
}
- if (host->power) {
+ if (host->power != TMIO_MMC_OFF_STOP) {
switch (ios->bus_width) {
case MMC_BUS_WIDTH_1:
sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
@@ -988,7 +1001,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
if (!mmc)
return -ENOMEM;
- mmc_of_parse(mmc);
+ ret = mmc_of_parse(mmc);
+ if (ret < 0)
+ goto host_free;
pdata->dev = &pdev->dev;
_host = mmc_priv(mmc);
@@ -1025,7 +1040,7 @@ int tmio_mmc_host_probe(struct tmio_mmc_host **host,
mmc->caps & MMC_CAP_NONREMOVABLE ||
mmc->slot.cd_irq >= 0);
- _host->power = false;
+ _host->power = TMIO_MMC_OFF_STOP;
pm_runtime_enable(&pdev->dev);
ret = pm_runtime_resume(&pdev->dev);
if (ret < 0)
@@ -1154,10 +1169,10 @@ int tmio_mmc_host_resume(struct device *dev)
struct mmc_host *mmc = dev_get_drvdata(dev);
struct tmio_mmc_host *host = mmc_priv(mmc);
- tmio_mmc_reset(host);
tmio_mmc_enable_dma(host, true);
/* The MMC core will perform the complete set up */
+ host->resuming = true;
return mmc_resume_host(mmc);
}
EXPORT_SYMBOL(tmio_mmc_host_resume);
@@ -1175,7 +1190,6 @@ int tmio_mmc_host_runtime_resume(struct device *dev)
struct mmc_host *mmc = dev_get_drvdata(dev);
struct tmio_mmc_host *host = mmc_priv(mmc);
- tmio_mmc_reset(host);
tmio_mmc_enable_dma(host, true);
return 0;