]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
mmc: tegra: Ignore err if dvfs overrides are disabled
authorPavan Kunapuli <pkunapuli@nvidia.com>
Tue, 13 May 2014 11:22:42 +0000 (16:52 +0530)
committerSimone Willett <swillett@nvidia.com>
Tue, 10 Jun 2014 02:02:55 +0000 (19:02 -0700)
If dvfs overrides are disabled, continue tuning execution by
treating the dvfs override API return values as expected.

Bug 1516198

Change-Id: I8d27969029ce7b318d23c227e8dfb19793282fea
Signed-off-by: Pavan Kunapuli <pkunapuli@nvidia.com>
Signed-off-by: Naveen Kumar Arepalli <naveenk@nvidia.com>
Reviewed-on: http://git-master/r/413118
(cherry picked from commit 71edeee1a98a8dc7474781689b0859a32f5aca80)
Reviewed-on: http://git-master/r/416564
Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>
drivers/mmc/host/sdhci-tegra.c

index 99d3248964c3934646a5878d0f1f2ec3892a4733..84386f0dee9e25c1875878c23059f33d75ddbbf1 100644 (file)
@@ -2009,8 +2009,10 @@ static int sdhci_tegra_calculate_best_tap(struct sdhci_host *sdhci,
 
        curr_vmin = tegra_dvfs_predict_millivolts(pltfm_host->clk,
                tuning_data->freq_hz);
-       vmin = curr_vmin;
+       if (!curr_vmin)
+               curr_vmin = tegra_host->boot_vcore_mv;
 
+       vmin = curr_vmin;
        do {
                SDHCI_TEGRA_DBG("%s: checking for win opening with vmin %d\n",
                        mmc_hostname(sdhci->mmc), vmin);
@@ -2050,11 +2052,25 @@ static int sdhci_tegra_calculate_best_tap(struct sdhci_host *sdhci,
        tuning_data->best_tap_value = best_tap_value;
        tuning_data->nom_best_tap_value = best_tap_value;
 
-       /* Set the new vmin if there is any change. */
-       if ((tuning_data->best_tap_value >= 0) && (curr_vmin != vmin))
+       /*
+        * Set the new vmin if there is any change. If dvfs overrides are
+        * disabled, then print the error message but continue execution
+        * rather than disabling tuning altogether.
+        */
+       if ((tuning_data->best_tap_value >= 0) && (curr_vmin != vmin)) {
                err = tegra_dvfs_set_fmax_at_vmin(pltfm_host->clk,
                        tuning_data->freq_hz, vmin);
-
+               if ((err == -EPERM) || (err == -ENOSYS)) {
+                       /*
+                        * tegra_dvfs_set_fmax_at_vmin: will return EPERM or
+                        * ENOSYS, when DVFS override is not enabled, continue
+                        * tuning with default core voltage.
+                        */
+                       SDHCI_TEGRA_DBG(
+                               "dvfs overrides disabled. Vmin not updated\n");
+                       err = 0;
+               }
+       }
        kfree(temp_tap_data);
        return err;
 }
@@ -2968,8 +2984,21 @@ static int sdhci_tegra_set_tuning_voltage(struct sdhci_host *sdhci,
 
        SDHCI_TEGRA_DBG("%s: Setting vcore override %d\n",
                mmc_hostname(sdhci->mmc), voltage);
-       /* First clear any previous dvfs override settings */
+       /*
+        * First clear any previous dvfs override settings. If dvfs overrides
+        * are disabled, then print the error message but continue execution
+        * rather than failing tuning altogether.
+        */
        err = tegra_dvfs_override_core_voltage(pltfm_host->clk, 0);
+       if ((err == -EPERM) || (err == -ENOSYS)) {
+               /*
+                * tegra_dvfs_override_core_voltage will return EPERM or ENOSYS,
+                * when DVFS override is not enabled. Continue tuning
+                * with default core voltage
+                */
+               SDHCI_TEGRA_DBG("dvfs overrides disabled. Nothing to clear\n");
+               err = 0;
+       }
        if (!voltage)
                return err;
 
@@ -2986,8 +3015,20 @@ static int sdhci_tegra_set_tuning_voltage(struct sdhci_host *sdhci,
                        nom_emc_freq_set = true;
        }
 
+       /*
+        * If dvfs overrides are disabled, then print the error message but
+        * continue tuning execution rather than failing tuning altogether.
+        */
        err = tegra_dvfs_override_core_voltage(pltfm_host->clk, voltage);
-       if (err)
+       if ((err == -EPERM) || (err == -ENOSYS)) {
+               /*
+                * tegra_dvfs_override_core_voltage will return EPERM or ENOSYS,
+                * when DVFS override is not enabled. Continue tuning
+                * with default core voltage
+                */
+               SDHCI_TEGRA_DBG("dvfs overrides disabled. No overrides set\n");
+               err = 0;
+       } else if (err)
                dev_err(mmc_dev(sdhci->mmc),
                        "failed to set vcore override %dmv\n", voltage);