mmc: quirks: add new quirk that allows Cache disable

This change allows us to prevent cache enable for certain
cards that have broken cache functionality.

Change-Id: Iea3f8c8f4e5498a8742fa408a19e3e169d1fa8cb
Signed-off-by: Talel Shenhar <tatias@codeaurora.org>
[subhashj@codeaurora.org: fixed trivial merge conflicts]
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
This commit is contained in:
Talel Shenhar 2015-02-04 17:59:23 +02:00 committed by Subhash Jadavani
parent 96c1215f25
commit 4a897cf6aa
3 changed files with 40 additions and 18 deletions

View file

@ -3354,7 +3354,8 @@ int mmc_flush_cache(struct mmc_card *card)
if (mmc_card_mmc(card) &&
(card->ext_csd.cache_size > 0) &&
(card->ext_csd.cache_ctrl & 1)) {
(card->ext_csd.cache_ctrl & 1) &&
(!(card->quirks & MMC_QUIRK_CACHE_DISABLE))) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_FLUSH_CACHE, 1, 0);
if (err == -ETIMEDOUT) {

View file

@ -1816,12 +1816,14 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
* the existence of cache and it can be turned on.
* If HPI is not supported then cache shouldn't be enabled.
*/
if (card->ext_csd.cache_size > 0 && card->ext_csd.hpi_en) {
if (card->ext_csd.cache_size > 0) {
if (card->ext_csd.hpi_en &&
(!(card->quirks & MMC_QUIRK_CACHE_DISABLE))) {
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_CACHE_CTRL, 1,
card->ext_csd.generic_cmd6_time);
if (err && err != -EBADMSG) {
pr_err("%s: %s: mmc_switch() for CACHE_CTRL fails %d\n",
pr_err("%s: %s: fail on CACHE_CTRL ON %d\n",
mmc_hostname(host), __func__, err);
goto free_card;
}
@ -1837,6 +1839,24 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
} else {
card->ext_csd.cache_ctrl = 1;
}
} else {
/*
* mmc standard doesn't say what is the card default
* value for EXT_CSD_CACHE_CTRL.
* Hence, cache may be enabled by default by
* card vendors.
* Thus, it is best to explicitly disable cache in case
* we want to avoid cache.
*/
err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
EXT_CSD_CACHE_CTRL, 0,
card->ext_csd.generic_cmd6_time);
if (err) {
pr_err("%s: %s: fail on CACHE_CTRL OFF %d\n",
mmc_hostname(host), __func__, err);
goto free_card;
}
}
}
/*

View file

@ -308,6 +308,7 @@ struct mmc_card {
#define MMC_QUIRK_INAND_DATA_TIMEOUT (1<<13) /* For incorrect data timeout */
#define MMC_QUIRK_BROKEN_HPI (1 << 14) /* For devices which gets */
/* broken due to HPI feature */
#define MMC_QUIRK_CACHE_DISABLE (1 << 14) /* prevent cache enable */
unsigned int erase_size; /* erase size in sectors */