mmc: sdhci-sprd: Add optional gate clock support
For the Spreadtrum SC9860 platform, we should enable another gate clock '2x_enable' to make the SD host controller work well. Signed-off-by: Baolin Wang <baolin.wang@linaro.org> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
334eb9bcb9
commit
ebd88a38db
|
@ -60,6 +60,7 @@ struct sdhci_sprd_host {
|
||||||
u32 version;
|
u32 version;
|
||||||
struct clk *clk_sdio;
|
struct clk *clk_sdio;
|
||||||
struct clk *clk_enable;
|
struct clk *clk_enable;
|
||||||
|
struct clk *clk_2x_enable;
|
||||||
u32 base_rate;
|
u32 base_rate;
|
||||||
int flags; /* backup of host attribute */
|
int flags; /* backup of host attribute */
|
||||||
};
|
};
|
||||||
|
@ -364,6 +365,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
sprd_host->clk_enable = clk;
|
sprd_host->clk_enable = clk;
|
||||||
|
|
||||||
|
clk = devm_clk_get(&pdev->dev, "2x_enable");
|
||||||
|
if (!IS_ERR(clk))
|
||||||
|
sprd_host->clk_2x_enable = clk;
|
||||||
|
|
||||||
ret = clk_prepare_enable(sprd_host->clk_sdio);
|
ret = clk_prepare_enable(sprd_host->clk_sdio);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto pltfm_free;
|
goto pltfm_free;
|
||||||
|
@ -372,6 +377,10 @@ static int sdhci_sprd_probe(struct platform_device *pdev)
|
||||||
if (ret)
|
if (ret)
|
||||||
goto clk_disable;
|
goto clk_disable;
|
||||||
|
|
||||||
|
ret = clk_prepare_enable(sprd_host->clk_2x_enable);
|
||||||
|
if (ret)
|
||||||
|
goto clk_disable2;
|
||||||
|
|
||||||
sdhci_sprd_init_config(host);
|
sdhci_sprd_init_config(host);
|
||||||
host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
|
host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
|
||||||
sprd_host->version = ((host->version & SDHCI_VENDOR_VER_MASK) >>
|
sprd_host->version = ((host->version & SDHCI_VENDOR_VER_MASK) >>
|
||||||
|
@ -408,6 +417,9 @@ pm_runtime_disable:
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
pm_runtime_set_suspended(&pdev->dev);
|
pm_runtime_set_suspended(&pdev->dev);
|
||||||
|
|
||||||
|
clk_disable_unprepare(sprd_host->clk_2x_enable);
|
||||||
|
|
||||||
|
clk_disable2:
|
||||||
clk_disable_unprepare(sprd_host->clk_enable);
|
clk_disable_unprepare(sprd_host->clk_enable);
|
||||||
|
|
||||||
clk_disable:
|
clk_disable:
|
||||||
|
@ -427,6 +439,7 @@ static int sdhci_sprd_remove(struct platform_device *pdev)
|
||||||
mmc_remove_host(mmc);
|
mmc_remove_host(mmc);
|
||||||
clk_disable_unprepare(sprd_host->clk_sdio);
|
clk_disable_unprepare(sprd_host->clk_sdio);
|
||||||
clk_disable_unprepare(sprd_host->clk_enable);
|
clk_disable_unprepare(sprd_host->clk_enable);
|
||||||
|
clk_disable_unprepare(sprd_host->clk_2x_enable);
|
||||||
|
|
||||||
mmc_free_host(mmc);
|
mmc_free_host(mmc);
|
||||||
|
|
||||||
|
@ -449,6 +462,7 @@ static int sdhci_sprd_runtime_suspend(struct device *dev)
|
||||||
|
|
||||||
clk_disable_unprepare(sprd_host->clk_sdio);
|
clk_disable_unprepare(sprd_host->clk_sdio);
|
||||||
clk_disable_unprepare(sprd_host->clk_enable);
|
clk_disable_unprepare(sprd_host->clk_enable);
|
||||||
|
clk_disable_unprepare(sprd_host->clk_2x_enable);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -459,19 +473,28 @@ static int sdhci_sprd_runtime_resume(struct device *dev)
|
||||||
struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
|
struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = clk_prepare_enable(sprd_host->clk_enable);
|
ret = clk_prepare_enable(sprd_host->clk_2x_enable);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
ret = clk_prepare_enable(sprd_host->clk_enable);
|
||||||
|
if (ret)
|
||||||
|
goto clk_2x_disable;
|
||||||
|
|
||||||
ret = clk_prepare_enable(sprd_host->clk_sdio);
|
ret = clk_prepare_enable(sprd_host->clk_sdio);
|
||||||
if (ret) {
|
if (ret)
|
||||||
clk_disable_unprepare(sprd_host->clk_enable);
|
goto clk_disable;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
sdhci_runtime_resume_host(host);
|
sdhci_runtime_resume_host(host);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
clk_disable:
|
||||||
|
clk_disable_unprepare(sprd_host->clk_enable);
|
||||||
|
|
||||||
|
clk_2x_disable:
|
||||||
|
clk_disable_unprepare(sprd_host->clk_2x_enable);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue