aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Kryger <tim.kryger@linaro.org>2013-10-16 14:47:10 -0700
committerMatt Porter <matt.porter@linaro.org>2013-11-25 09:37:17 -0500
commit8a4515417d27fce3671845d41bfc357e0630d5fe (patch)
tree1318032d4998b8a8c5036b1fb674e46eb1913b3a
parent813117c4837615f6c6a0e7f687add7518451a544 (diff)
mmc: sdhci-bcm-kona: Add basic use of clocks
Enable the external clock needed by the host controller during the probe and disable it during the remove. Signed-off-by: Tim Kryger <tim.kryger@linaro.org> Reviewed-by: Markus Mayer <markus.mayer@linaro.org> Reviewed-by: Matt Porter <matt.porter@linaro.org> Conflicts: drivers/mmc/host/sdhci-bcm-kona.c FIX IS JUST A HACK
-rw-r--r--drivers/mmc/host/sdhci-bcm-kona.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
index 7a190fe4dff..c4d55e3513c 100644
--- a/drivers/mmc/host/sdhci-bcm-kona.c
+++ b/drivers/mmc/host/sdhci-bcm-kona.c
@@ -54,6 +54,7 @@
struct sdhci_bcm_kona_dev {
struct mutex write_lock; /* protect back to back writes */
+ struct clk *external_clk;
};
@@ -252,11 +253,29 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
mmc_of_parse(host->mmc);
if (!host->mmc->f_max) {
- dev_err(&pdev->dev, "Missing max-freq for SDHCI cfg\n");
+ dev_err(dev, "Missing max-freq for SDHCI cfg\n");
ret = -ENXIO;
goto err_pltfm_free;
}
+ /* Get and enable the external clock */
+ kona_dev->external_clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(kona_dev->external_clk)) {
+ dev_err(dev, "Failed to get external clock\n");
+ ret = PTR_ERR(kona_dev->external_clk);
+ goto err_pltfm_free;
+ }
+
+ if (clk_set_rate(kona_dev->external_clk, host->mmc->f_max) != 0) {
+ dev_err(dev, "Failed to set rate external clock\n");
+ goto err_pltfm_free;
+ }
+
+ if (clk_prepare_enable(kona_dev->external_clk) != 0) {
+ dev_err(dev, "Failed to enable external clock\n");
+ goto err_pltfm_free;
+ }
+
dev_dbg(dev, "non-removable=%c\n",
(host->mmc->caps & MMC_CAP_NONREMOVABLE) ? 'Y' : 'N');
dev_dbg(dev, "cd_gpio %c, wp_gpio %c\n",
@@ -271,7 +290,7 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
ret = sdhci_bcm_kona_sd_reset(host);
if (ret)
- goto err_pltfm_free;
+ goto err_clk_disable;
sdhci_bcm_kona_sd_init(host);
@@ -307,6 +326,9 @@ err_remove_host:
err_reset:
sdhci_bcm_kona_sd_reset(host);
+err_clk_disable:
+ clk_disable_unprepare(kona_dev->external_clk);
+
err_pltfm_free:
sdhci_pltfm_free(pdev);
@@ -316,6 +338,7 @@ err_pltfm_free:
static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev)
{
+ /* clk_disable_unprepare(kona_dev->external_clk); */
return sdhci_pltfm_unregister(pdev);
}