mmc: tegra: Boost sclk and emc clk's for sdmmc
Naveen Kumar Arepalli [Sun, 19 May 2013 03:42:27 +0000 (08:42 +0530)]
Boost emc, sclk clock to 150 MHz for sdmmc
Boosting emc and sclk helps in sdmmc kpi.

Bug 1276208
Bug 1294076

Reviewed-on: http://git-master/r/230090
(cherry picked from commit d916c03439b91bd68c5ad7f4ac2a0c64a29d417c)
Change-Id: I472e009b369fcaa87b3c44e2c49a86bf1d857b18
Signed-off-by: Naveen Kumar Arepalli <naveenk@nvidia.com>
Reviewed-on: http://git-master/r/232083
Reviewed-by: Riham Haidar <rhaidar@nvidia.com>
Tested-by: Riham Haidar <rhaidar@nvidia.com>

drivers/mmc/host/sdhci-tegra.c

index 2b12b5c..9c0066f 100644 (file)
@@ -93,8 +93,8 @@
 #define TUNING_FREQ_COUNT      2
 #define TUNING_VOLTAGES_COUNT  2
 #define TUNING_RETRIES 1
-#define SDMMC_AHB_MAX_FREQ     80000000
-#define SDMMC_EMC_MAX_FREQ     100000000
+#define SDMMC_AHB_MAX_FREQ     150000000
+#define SDMMC_EMC_MAX_FREQ     150000000
 
 static unsigned int uhs_max_freq_MHz[] = {
        [MMC_TIMING_UHS_SDR50] = 100,
@@ -2598,22 +2598,19 @@ static int __devinit sdhci_tegra_probe(struct platform_device *pdev)
        if (rc != 0)
                goto err_clk_put;
 
-       if (!strcmp(dev_name(mmc_dev(host->mmc)), "sdhci-tegra.3")) {
-               tegra_host->emc_clk = clk_get(mmc_dev(host->mmc), "emc");
-               if (IS_ERR(tegra_host->emc_clk)) {
-                       dev_err(mmc_dev(host->mmc), "Can't get emc clk\n");
-                       rc = PTR_ERR(tegra_host->emc_clk);
-                       goto err_clk_put;
-               }
+       tegra_host->emc_clk = devm_clk_get(mmc_dev(host->mmc), "emc");
+       if (IS_ERR_OR_NULL(tegra_host->emc_clk)) {
+               dev_err(mmc_dev(host->mmc), "Can't get emc clk\n");
+               tegra_host->emc_clk = NULL;
+       } else {
                tegra_host->emc_max_clk =
                        clk_round_rate(tegra_host->emc_clk, ULONG_MAX);
                clk_set_rate(tegra_host->emc_clk, SDMMC_EMC_MAX_FREQ);
        }
 
-       tegra_host->sclk = clk_get(mmc_dev(host->mmc), "sclk");
+       tegra_host->sclk = devm_clk_get(mmc_dev(host->mmc), "sclk");
        if (IS_ERR_OR_NULL(tegra_host->sclk)) {
                dev_err(mmc_dev(host->mmc), "Can't get sclk clock\n");
-               clk_put(tegra_host->sclk);
                tegra_host->sclk = NULL;
        } else {
                clk_set_rate(tegra_host->sclk, SDMMC_AHB_MAX_FREQ);
@@ -2692,7 +2689,6 @@ static int __devinit sdhci_tegra_probe(struct platform_device *pdev)
        return 0;
 
 err_add_host:
-       clk_put(tegra_host->emc_clk);
        clk_disable_unprepare(pltfm_host->clk);
        pm_runtime_put_sync(&pdev->dev);
 err_clk_put:
@@ -2754,16 +2750,10 @@ static int __devexit sdhci_tegra_remove(struct platform_device *pdev)
        }
        clk_put(pltfm_host->clk);
 
-       if (tegra_host->emc_clk) {
-               if (tegra_host->is_sdmmc_emc_clk_on)
-                       clk_disable_unprepare(tegra_host->emc_clk);
-               clk_put(tegra_host->emc_clk);
-       }
-       if (tegra_host->sclk) {
-               if (tegra_host->is_sdmmc_sclk_on)
-                       clk_disable_unprepare(tegra_host->sclk);
-               clk_put(tegra_host->sclk);
-       }
+       if (tegra_host->emc_clk && tegra_host->is_sdmmc_emc_clk_on)
+               clk_disable_unprepare(tegra_host->emc_clk);
+       if (tegra_host->sclk && tegra_host->is_sdmmc_sclk_on)
+               clk_disable_unprepare(tegra_host->sclk);
        if (plat->power_off_rail)
                unregister_reboot_notifier(&tegra_host->reboot_notify);