Commit a6609267 authored by Guennadi Liakhovetski's avatar Guennadi Liakhovetski Committed by Chris Ball

mmc: sh_mmcif: re-read the clock frequency every time it is turned on

With aggressive clock gating the clock can be disabled during interface
inactivity. During this time its frequency can be changed by another its
user. Therefore when the interface is activated again and the clock is
re-enabled, its frequency has to be re-read.
Signed-off-by: default avatarGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Reviewed-by: default avatarSimon Horman <horms@verge.net.au>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent b289174f
...@@ -910,6 +910,19 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -910,6 +910,19 @@ static void sh_mmcif_request(struct mmc_host *mmc, struct mmc_request *mrq)
sh_mmcif_start_cmd(host, mrq); sh_mmcif_start_cmd(host, mrq);
} }
static int sh_mmcif_clk_update(struct sh_mmcif_host *host)
{
int ret = clk_enable(host->hclk);
if (!ret) {
host->clk = clk_get_rate(host->hclk);
host->mmc->f_max = host->clk / 2;
host->mmc->f_min = host->clk / 512;
}
return ret;
}
static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{ {
struct sh_mmcif_host *host = mmc_priv(mmc); struct sh_mmcif_host *host = mmc_priv(mmc);
...@@ -955,7 +968,7 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) ...@@ -955,7 +968,7 @@ static void sh_mmcif_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
if (!host->power) { if (!host->power) {
if (p->set_pwr) if (p->set_pwr)
p->set_pwr(host->pd, ios->power_mode); p->set_pwr(host->pd, ios->power_mode);
clk_enable(host->hclk); sh_mmcif_clk_update(host);
pm_runtime_get_sync(&host->pd->dev); pm_runtime_get_sync(&host->pd->dev);
host->power = true; host->power = true;
sh_mmcif_sync_reset(host); sh_mmcif_sync_reset(host);
...@@ -1308,10 +1321,9 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) ...@@ -1308,10 +1321,9 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "cannot get clock \"%s\": %d\n", clk_name, ret); dev_err(&pdev->dev, "cannot get clock \"%s\": %d\n", clk_name, ret);
goto eclkget; goto eclkget;
} }
clk_enable(host->hclk); ret = sh_mmcif_clk_update(host);
host->clk = clk_get_rate(host->hclk); if (ret < 0)
mmc->f_max = host->clk / 2; goto eclkupdate;
mmc->f_min = host->clk / 512;
ret = pm_runtime_resume(&pdev->dev); ret = pm_runtime_resume(&pdev->dev);
if (ret < 0) if (ret < 0)
...@@ -1353,6 +1365,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev) ...@@ -1353,6 +1365,7 @@ static int __devinit sh_mmcif_probe(struct platform_device *pdev)
pm_runtime_suspend(&pdev->dev); pm_runtime_suspend(&pdev->dev);
eresume: eresume:
clk_disable(host->hclk); clk_disable(host->hclk);
eclkupdate:
clk_put(host->hclk); clk_put(host->hclk);
eclkget: eclkget:
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
......
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