Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>
Signed-off-by: Chris Ball <chris@printf.net>

authored by

Tim Kryger and committed by
Chris Ball
a6492c02 8d94b54d

+35 -2
+35 -2
drivers/mmc/host/sdhci-bcm-kona.c
··· 54 54 55 55 struct sdhci_bcm_kona_dev { 56 56 struct mutex write_lock; /* protect back to back writes */ 57 + struct clk *external_clk; 57 58 }; 58 59 59 60 ··· 258 257 goto err_pltfm_free; 259 258 } 260 259 260 + /* Get and enable the external clock */ 261 + kona_dev->external_clk = devm_clk_get(dev, NULL); 262 + if (IS_ERR(kona_dev->external_clk)) { 263 + dev_err(dev, "Failed to get external clock\n"); 264 + ret = PTR_ERR(kona_dev->external_clk); 265 + goto err_pltfm_free; 266 + } 267 + 268 + if (clk_set_rate(kona_dev->external_clk, host->mmc->f_max) != 0) { 269 + dev_err(dev, "Failed to set rate external clock\n"); 270 + goto err_pltfm_free; 271 + } 272 + 273 + if (clk_prepare_enable(kona_dev->external_clk) != 0) { 274 + dev_err(dev, "Failed to enable external clock\n"); 275 + goto err_pltfm_free; 276 + } 277 + 261 278 dev_dbg(dev, "non-removable=%c\n", 262 279 (host->mmc->caps & MMC_CAP_NONREMOVABLE) ? 'Y' : 'N'); 263 280 dev_dbg(dev, "cd_gpio %c, wp_gpio %c\n", ··· 290 271 291 272 ret = sdhci_bcm_kona_sd_reset(host); 292 273 if (ret) 293 - goto err_pltfm_free; 274 + goto err_clk_disable; 294 275 295 276 sdhci_bcm_kona_sd_init(host); 296 277 ··· 326 307 err_reset: 327 308 sdhci_bcm_kona_sd_reset(host); 328 309 310 + err_clk_disable: 311 + clk_disable_unprepare(kona_dev->external_clk); 312 + 329 313 err_pltfm_free: 330 314 sdhci_pltfm_free(pdev); 331 315 ··· 338 316 339 317 static int __exit sdhci_bcm_kona_remove(struct platform_device *pdev) 340 318 { 341 - return sdhci_pltfm_unregister(pdev); 319 + struct sdhci_host *host = platform_get_drvdata(pdev); 320 + struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host); 321 + struct sdhci_bcm_kona_dev *kona_dev = sdhci_pltfm_priv(pltfm_priv); 322 + int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); 323 + 324 + sdhci_remove_host(host, dead); 325 + 326 + clk_disable_unprepare(kona_dev->external_clk); 327 + 328 + sdhci_pltfm_free(pdev); 329 + 330 + return 0; 342 331 } 343 332 344 333 static struct platform_driver sdhci_bcm_kona_driver = {