summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/host/sdhci-tegra.c23
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);