aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Nilsson XK <stefan.xk.nilsson@stericsson.com>2011-11-03 04:44:12 -0400
committerChris Ball <cjb@laptop.org>2011-12-10 16:18:35 -0500
commit6de5fc9cf7de334912de4cfd2d06eb2d744d2afe (patch)
tree473198b98663f0e84fc69b70f2fca12dad7f9b9c
parent7833c66b2d764a3c883c2f5cc60cd8a6266dae15 (diff)
mmc: core: Add quirk for long data read time
Adds a quirk that sets the data read timeout to a fixed value instead of relying on the information in the CSD. The timeout value chosen is 300ms since that has proven enough for the problematic cards found, but could be increased if other cards require this. This patch also enables this quirk for certain Micron cards known to have this problem. Signed-off-by: Stefan Nilsson XK <stefan.xk.nilsson@stericsson.com> Signed-off-by: Ulf Hansson <ulf.hansson@stericsson.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Cc: <stable@kernel.org> Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r--drivers/mmc/card/block.c8
-rw-r--r--drivers/mmc/core/core.c12
-rw-r--r--include/linux/mmc/card.h6
3 files changed, 26 insertions, 0 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index a1cb21f9530..1e0e27cbe98 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1606,6 +1606,14 @@ static const struct mmc_fixup blk_fixups[] =
1606 MMC_QUIRK_BLK_NO_CMD23), 1606 MMC_QUIRK_BLK_NO_CMD23),
1607 MMC_FIXUP("MMC32G", 0x11, CID_OEMID_ANY, add_quirk_mmc, 1607 MMC_FIXUP("MMC32G", 0x11, CID_OEMID_ANY, add_quirk_mmc,
1608 MMC_QUIRK_BLK_NO_CMD23), 1608 MMC_QUIRK_BLK_NO_CMD23),
1609
1610 /*
1611 * Some Micron MMC cards needs longer data read timeout than
1612 * indicated in CSD.
1613 */
1614 MMC_FIXUP(CID_NAME_ANY, 0x13, 0x200, add_quirk_mmc,
1615 MMC_QUIRK_LONG_READ_TIME),
1616
1609 END_FIXUP 1617 END_FIXUP
1610}; 1618};
1611 1619
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 5278ffb20e7..74a012ad2ba 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -529,6 +529,18 @@ void mmc_set_data_timeout(struct mmc_data *data, const struct mmc_card *card)
529 data->timeout_clks = 0; 529 data->timeout_clks = 0;
530 } 530 }
531 } 531 }
532
533 /*
534 * Some cards require longer data read timeout than indicated in CSD.
535 * Address this by setting the read timeout to a "reasonably high"
536 * value. For the cards tested, 300ms has proven enough. If necessary,
537 * this value can be increased if other problematic cards require this.
538 */
539 if (mmc_card_long_read_time(card) && data->flags & MMC_DATA_READ) {
540 data->timeout_ns = 300000000;
541 data->timeout_clks = 0;
542 }
543
532 /* 544 /*
533 * Some cards need very high timeouts if driven in SPI mode. 545 * Some cards need very high timeouts if driven in SPI mode.
534 * The worst observed timeout was 900ms after writing a 546 * The worst observed timeout was 900ms after writing a
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index 415f2db414e..c8ef9bc54d5 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -218,6 +218,7 @@ struct mmc_card {
218#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */ 218#define MMC_QUIRK_INAND_CMD38 (1<<6) /* iNAND devices have broken CMD38 */
219#define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */ 219#define MMC_QUIRK_BLK_NO_CMD23 (1<<7) /* Avoid CMD23 for regular multiblock */
220#define MMC_QUIRK_BROKEN_BYTE_MODE_512 (1<<8) /* Avoid sending 512 bytes in */ 220#define MMC_QUIRK_BROKEN_BYTE_MODE_512 (1<<8) /* Avoid sending 512 bytes in */
221#define MMC_QUIRK_LONG_READ_TIME (1<<9) /* Data read time > CSD says */
221 /* byte mode */ 222 /* byte mode */
222 unsigned int poweroff_notify_state; /* eMMC4.5 notify feature */ 223 unsigned int poweroff_notify_state; /* eMMC4.5 notify feature */
223#define MMC_NO_POWER_NOTIFICATION 0 224#define MMC_NO_POWER_NOTIFICATION 0
@@ -433,6 +434,11 @@ static inline int mmc_card_broken_byte_mode_512(const struct mmc_card *c)
433 return c->quirks & MMC_QUIRK_BROKEN_BYTE_MODE_512; 434 return c->quirks & MMC_QUIRK_BROKEN_BYTE_MODE_512;
434} 435}
435 436
437static inline int mmc_card_long_read_time(const struct mmc_card *c)
438{
439 return c->quirks & MMC_QUIRK_LONG_READ_TIME;
440}
441
436#define mmc_card_name(c) ((c)->cid.prod_name) 442#define mmc_card_name(c) ((c)->cid.prod_name)
437#define mmc_card_id(c) (dev_name(&(c)->dev)) 443#define mmc_card_id(c) (dev_name(&(c)->dev))
438 444