diff options
author | Pavan Kunapuli <pkunapuli@nvidia.com> | 2014-03-24 12:55:31 +0530 |
---|---|---|
committer | Manish Tuteja <mtuteja@nvidia.com> | 2014-03-25 23:46:36 -0700 |
commit | 29f344d9967c751ba78f4613c063a32d79b441cb (patch) | |
tree | 8faca5743322aa454f4187f15ac9acf746504f56 /drivers | |
parent | 09a8fb3d73d276c98db34dc9e4a521f8c24bfc32 (diff) |
mmc: tegra: Abort tuning if device is removed
For removable devices, always check if the device is present before
executing tuning. If the device is removed, abort tuning and return
no medium as error status.
Bug 1486268
Change-Id: Idae1590eaa956bfb1244a5b10cc0ef770f3047ef
Signed-off-by: Pavan Kunapuli <pkunapuli@nvidia.com>
Reviewed-on: http://git-master/r/385852
Tested-by: Ankita Garg <ankitag@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Venu Byravarasu <vbyravarasu@nvidia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mmc/host/sdhci-tegra.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index 0fd3f3317488..e37347005b57 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -1345,6 +1345,10 @@ static int sdhci_tegra_run_frequency_tuning(struct sdhci_host *sdhci) int flags; u32 intstatus; + if (gpio_is_valid(tegra_host->plat->cd_gpio) && + (gpio_get_value(tegra_host->plat->cd_gpio) != 0)) + return -ENOMEDIUM; + mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT; while (sdhci_readl(sdhci, SDHCI_PRESENT_STATE) & mask) { if (timeout == 0) { @@ -1436,6 +1440,8 @@ static int sdhci_tegra_scan_tap_values(struct sdhci_host *sdhci, /* Run frequency tuning */ err = sdhci_tegra_run_frequency_tuning(sdhci); + if (err == -ENOMEDIUM) + return err; if (err && retry) { retry--; continue; @@ -1472,7 +1478,10 @@ static int sdhci_tegra_get_tap_window_data(struct sdhci_host *sdhci, /* Get the partial window data */ tap_value = 0; tap_value = sdhci_tegra_scan_tap_values(sdhci, tap_value, false); - if (!tap_value) { + if (tap_value < 0) { + err = tap_value; + goto out; + } else if (!tap_value) { tap_data->abandon_partial_win = true; tap_data->partial_win = 0; } else if (tap_value > MAX_TAP_VALUES) { @@ -1497,7 +1506,10 @@ static int sdhci_tegra_get_tap_window_data(struct sdhci_host *sdhci, /* Get the full window start */ tap_value++; tap_value = sdhci_tegra_scan_tap_values(sdhci, tap_value, true); - if (tap_value > MAX_TAP_VALUES) { + if (tap_value < 0) { + err = tap_value; + goto out; + } else if (tap_value > MAX_TAP_VALUES) { /* All tap values exhausted. No full window */ tap_data->abandon_full_win = true; goto out; @@ -1517,6 +1529,10 @@ static int sdhci_tegra_get_tap_window_data(struct sdhci_host *sdhci, tap_value++; tap_value = sdhci_tegra_scan_tap_values(sdhci, tap_value, false); + if (tap_value < 0) { + err = tap_value; + goto out; + } tap_data->full_win_end = tap_value - 1; if (tap_value > MAX_TAP_VALUES) tap_data->full_win_end = MAX_TAP_VALUES; @@ -1782,7 +1798,8 @@ out: * for the first time. The override setting will be removed once * retuning is called. */ - if (tegra_host->set_tuning_override) { + if ((tegra_host->set_tuning_override) && + (err != -ENOMEDIUM)) { dev_info(mmc_dev(sdhci->mmc), "Nominal core voltage being set until retuning\n"); spin_unlock(&sdhci->lock); |