aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDong Aisheng <aisheng.dong@nxp.com>2016-04-20 12:51:30 -0400
committerUlf Hansson <ulf.hansson@linaro.org>2016-05-10 04:37:01 -0400
commite51534c806609c806d81bfb034f02737461f855c (patch)
treea4cb5c110e891d700b80424c7c2b44a6270fe5af
parent802ac39a55664b15dd162e3444d5be34045abeeb (diff)
mmc: core: fix using wrong io voltage if mmc_select_hs200 fails
Currently MMC core will keep going if HS200/HS timing switch failed with -EBADMSG error by the assumption that the old timing is still valid. However, for mmc_select_hs200 case, the signal voltage may have already been switched. If the timing switch failed, we should fall back to the old voltage in case the card is continue run with legacy timing. If fall back signal voltage failed, we explicitly report an EIO error to force retry during the next power cycle. Signed-off-by: Dong Aisheng <aisheng.dong@nxp.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/mmc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index f99c47e003fe..e0c9a559c5fd 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1244,10 +1244,11 @@ static int mmc_select_hs200(struct mmc_card *card)
1244{ 1244{
1245 struct mmc_host *host = card->host; 1245 struct mmc_host *host = card->host;
1246 bool send_status = true; 1246 bool send_status = true;
1247 unsigned int old_timing; 1247 unsigned int old_timing, old_signal_voltage;
1248 int err = -EINVAL; 1248 int err = -EINVAL;
1249 u8 val; 1249 u8 val;
1250 1250
1251 old_signal_voltage = host->ios.signal_voltage;
1251 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_2V) 1252 if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200_1_2V)
1252 err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); 1253 err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120);
1253 1254
@@ -1256,7 +1257,7 @@ static int mmc_select_hs200(struct mmc_card *card)
1256 1257
1257 /* If fails try again during next card power cycle */ 1258 /* If fails try again during next card power cycle */
1258 if (err) 1259 if (err)
1259 goto err; 1260 return err;
1260 1261
1261 mmc_select_driver_type(card); 1262 mmc_select_driver_type(card);
1262 1263
@@ -1290,9 +1291,14 @@ static int mmc_select_hs200(struct mmc_card *card)
1290 } 1291 }
1291 } 1292 }
1292err: 1293err:
1293 if (err) 1294 if (err) {
1295 /* fall back to the old signal voltage, if fails report error */
1296 if (__mmc_set_signal_voltage(host, old_signal_voltage))
1297 err = -EIO;
1298
1294 pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host), 1299 pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host),
1295 __func__, err); 1300 __func__, err);
1301 }
1296 return err; 1302 return err;
1297} 1303}
1298 1304