aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorSeungwon Jeon <tgih.jun@samsung.com>2011-12-09 03:47:17 -0500
committerChris Ball <cjb@laptop.org>2012-01-12 15:17:14 -0500
commit8bc0678b845531221ba2ea6efe34db66e587705b (patch)
treed0ffa31202536d956de642786d39be023e57c71f /drivers/mmc
parent984589e59f5796b4ef9a778c6a1937fc9319c423 (diff)
mmc: core: Separate the timeout value for cache-ctrl
Turning the cache off implies flushing cache which doesn't define maximum timeout unlike cache-on. This patch will apply the generic CMD6 timeout only for cache-on. Additionally the kernel message is added for checking failure case of cache-on. Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/core.c21
-rw-r--r--drivers/mmc/core/mmc.c13
2 files changed, 23 insertions, 11 deletions
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index be7569f3fb56..1da45e051328 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2321,6 +2321,7 @@ EXPORT_SYMBOL(mmc_flush_cache);
2321int mmc_cache_ctrl(struct mmc_host *host, u8 enable) 2321int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
2322{ 2322{
2323 struct mmc_card *card = host->card; 2323 struct mmc_card *card = host->card;
2324 unsigned int timeout;
2324 int err = 0; 2325 int err = 0;
2325 2326
2326 if (!(host->caps2 & MMC_CAP2_CACHE_CTRL) || 2327 if (!(host->caps2 & MMC_CAP2_CACHE_CTRL) ||
@@ -2331,16 +2332,18 @@ int mmc_cache_ctrl(struct mmc_host *host, u8 enable)
2331 (card->ext_csd.cache_size > 0)) { 2332 (card->ext_csd.cache_size > 0)) {
2332 enable = !!enable; 2333 enable = !!enable;
2333 2334
2334 if (card->ext_csd.cache_ctrl ^ enable) 2335 if (card->ext_csd.cache_ctrl ^ enable) {
2336 timeout = enable ? card->ext_csd.generic_cmd6_time : 0;
2335 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 2337 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
2336 EXT_CSD_CACHE_CTRL, enable, 0); 2338 EXT_CSD_CACHE_CTRL, enable, timeout);
2337 if (err) 2339 if (err)
2338 pr_err("%s: cache %s error %d\n", 2340 pr_err("%s: cache %s error %d\n",
2339 mmc_hostname(card->host), 2341 mmc_hostname(card->host),
2340 enable ? "on" : "off", 2342 enable ? "on" : "off",
2341 err); 2343 err);
2342 else 2344 else
2343 card->ext_csd.cache_ctrl = enable; 2345 card->ext_csd.cache_ctrl = enable;
2346 }
2344 } 2347 }
2345 2348
2346 return err; 2349 return err;
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index f0a9f1fbd1f6..67f346e0d105 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -1077,14 +1077,23 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
1077 if ((host->caps2 & MMC_CAP2_CACHE_CTRL) && 1077 if ((host->caps2 & MMC_CAP2_CACHE_CTRL) &&
1078 card->ext_csd.cache_size > 0) { 1078 card->ext_csd.cache_size > 0) {
1079 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1079 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
1080 EXT_CSD_CACHE_CTRL, 1, 0); 1080 EXT_CSD_CACHE_CTRL, 1,
1081 card->ext_csd.generic_cmd6_time);
1081 if (err && err != -EBADMSG) 1082 if (err && err != -EBADMSG)
1082 goto free_card; 1083 goto free_card;
1083 1084
1084 /* 1085 /*
1085 * Only if no error, cache is turned on successfully. 1086 * Only if no error, cache is turned on successfully.
1086 */ 1087 */
1087 card->ext_csd.cache_ctrl = err ? 0 : 1; 1088 if (err) {
1089 pr_warning("%s: Cache is supported, "
1090 "but failed to turn on (%d)\n",
1091 mmc_hostname(card->host), err);
1092 card->ext_csd.cache_ctrl = 0;
1093 err = 0;
1094 } else {
1095 card->ext_csd.cache_ctrl = 1;
1096 }
1088 } 1097 }
1089 1098
1090 if (!oldcard) 1099 if (!oldcard)