Skip to content

Commit

Permalink
mmc: sdhci-sprd: Fix the incorrect soft reset operation when runtime …
Browse files Browse the repository at this point in the history
…resuming

The SD host controller specification defines 3 types software reset:
software reset for data line, software reset for command line and software
reset for all. Software reset for all means this reset affects the entire
Host controller except for the card detection circuit.

In sdhci_runtime_resume_host() we always do a software "reset for all",
which causes the Spreadtrum variant controller to work abnormally after
resuming. To fix the problem, let's do a software reset for the data and
the command part, rather than "for all".

However, as sdhci_runtime_resume() is a common sdhci function and we don't
want to change the behaviour for other variants, let's introduce a new
in-parameter for it. This enables the caller to decide if a "reset for all"
shall be done or not.

Signed-off-by: Baolin Wang <[email protected]>
Fixes: fb8bd90 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller")
Cc: [email protected]
Signed-off-by: Ulf Hansson <[email protected]>
  • Loading branch information
wangbaolin719 authored and storulf committed Aug 6, 2019
1 parent e21a712 commit c6303c5
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion drivers/mmc/host/sdhci-acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ static int sdhci_acpi_runtime_resume(struct device *dev)

sdhci_acpi_byt_setting(&c->pdev->dev);

return sdhci_runtime_resume_host(c->host);
return sdhci_runtime_resume_host(c->host, 0);
}

#endif
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/host/sdhci-esdhc-imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,7 @@ static int sdhci_esdhc_runtime_resume(struct device *dev)
esdhc_pltfm_set_clock(host, imx_data->actual_clock);
}

err = sdhci_runtime_resume_host(host);
err = sdhci_runtime_resume_host(host, 0);
if (err)
goto disable_ipg_clk;

Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/host/sdhci-of-at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ static int sdhci_at91_runtime_resume(struct device *dev)
}

out:
return sdhci_runtime_resume_host(host);
return sdhci_runtime_resume_host(host, 0);
}
#endif /* CONFIG_PM */

Expand Down
4 changes: 2 additions & 2 deletions drivers/mmc/host/sdhci-pci-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static int sdhci_pci_runtime_suspend_host(struct sdhci_pci_chip *chip)

err_pci_runtime_suspend:
while (--i >= 0)
sdhci_runtime_resume_host(chip->slots[i]->host);
sdhci_runtime_resume_host(chip->slots[i]->host, 0);
return ret;
}

Expand All @@ -181,7 +181,7 @@ static int sdhci_pci_runtime_resume_host(struct sdhci_pci_chip *chip)
if (!slot)
continue;

ret = sdhci_runtime_resume_host(slot->host);
ret = sdhci_runtime_resume_host(slot->host, 0);
if (ret)
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/host/sdhci-pxav3.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ static int sdhci_pxav3_runtime_resume(struct device *dev)
if (!IS_ERR(pxa->clk_core))
clk_prepare_enable(pxa->clk_core);

return sdhci_runtime_resume_host(host);
return sdhci_runtime_resume_host(host, 0);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/host/sdhci-s3c.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ static int sdhci_s3c_runtime_resume(struct device *dev)
clk_prepare_enable(busclk);
if (ourhost->cur_clk >= 0)
clk_prepare_enable(ourhost->clk_bus[ourhost->cur_clk]);
ret = sdhci_runtime_resume_host(host);
ret = sdhci_runtime_resume_host(host, 0);
return ret;
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/host/sdhci-sprd.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ static int sdhci_sprd_runtime_resume(struct device *dev)
if (ret)
goto clk_disable;

sdhci_runtime_resume_host(host);
sdhci_runtime_resume_host(host, 1);
return 0;

clk_disable:
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/host/sdhci-xenon.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ static int xenon_runtime_resume(struct device *dev)
priv->restore_needed = false;
}

ret = sdhci_runtime_resume_host(host);
ret = sdhci_runtime_resume_host(host, 0);
if (ret)
goto out;
return 0;
Expand Down
4 changes: 2 additions & 2 deletions drivers/mmc/host/sdhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -3320,7 +3320,7 @@ int sdhci_runtime_suspend_host(struct sdhci_host *host)
}
EXPORT_SYMBOL_GPL(sdhci_runtime_suspend_host);

int sdhci_runtime_resume_host(struct sdhci_host *host)
int sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset)
{
struct mmc_host *mmc = host->mmc;
unsigned long flags;
Expand All @@ -3331,7 +3331,7 @@ int sdhci_runtime_resume_host(struct sdhci_host *host)
host->ops->enable_dma(host);
}

sdhci_init(host, 0);
sdhci_init(host, soft_reset);

if (mmc->ios.power_mode != MMC_POWER_UNDEFINED &&
mmc->ios.power_mode != MMC_POWER_OFF) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/mmc/host/sdhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ void sdhci_adma_write_desc(struct sdhci_host *host, void **desc,
int sdhci_suspend_host(struct sdhci_host *host);
int sdhci_resume_host(struct sdhci_host *host);
int sdhci_runtime_suspend_host(struct sdhci_host *host);
int sdhci_runtime_resume_host(struct sdhci_host *host);
int sdhci_runtime_resume_host(struct sdhci_host *host, int soft_reset);
#endif

void sdhci_cqe_enable(struct mmc_host *mmc);
Expand Down

0 comments on commit c6303c5

Please sign in to comment.