aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorSeungwon Jeon <tgih.jun@samsung.com>2013-09-04 08:21:05 -0400
committerChris Ball <cjb@laptop.org>2013-09-25 21:40:35 -0400
commita27fbf2f067b0cd6f172c8b696b9a44c58bfaa7a (patch)
tree1b14b3396a09133714e7c0a2b0d5d3d26c178e70 /drivers/mmc
parentaa50f259d65603f40a82ef0d256a6a954a3db283 (diff)
mmc: add ignorance case for CMD13 CRC error
While speed mode is changed, CMD13 cannot be guaranteed. According to the spec., it is not recommended to use CMD13 to check the busy completion of the timing change. If CMD13 is used in this case, CRC error must be ignored. Signed-off-by: Seungwon Jeon <tgih.jun@samsung.com> Acked-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/mmc_ops.c73
1 files changed, 45 insertions, 28 deletions
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index ef183483d5b6..37f7d7059ab7 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -23,6 +23,40 @@
23 23
24#define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */ 24#define MMC_OPS_TIMEOUT_MS (10 * 60 * 1000) /* 10 minute timeout */
25 25
26static inline int __mmc_send_status(struct mmc_card *card, u32 *status,
27 bool ignore_crc)
28{
29 int err;
30 struct mmc_command cmd = {0};
31
32 BUG_ON(!card);
33 BUG_ON(!card->host);
34
35 cmd.opcode = MMC_SEND_STATUS;
36 if (!mmc_host_is_spi(card->host))
37 cmd.arg = card->rca << 16;
38 cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
39 if (ignore_crc)
40 cmd.flags &= ~MMC_RSP_CRC;
41
42 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
43 if (err)
44 return err;
45
46 /* NOTE: callers are required to understand the difference
47 * between "native" and SPI format status words!
48 */
49 if (status)
50 *status = cmd.resp[0];
51
52 return 0;
53}
54
55int mmc_send_status(struct mmc_card *card, u32 *status)
56{
57 return __mmc_send_status(card, status, false);
58}
59
26static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card) 60static int _mmc_select_card(struct mmc_host *host, struct mmc_card *card)
27{ 61{
28 int err; 62 int err;
@@ -380,6 +414,7 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
380 struct mmc_command cmd = {0}; 414 struct mmc_command cmd = {0};
381 unsigned long timeout; 415 unsigned long timeout;
382 u32 status; 416 u32 status;
417 bool ignore_crc = false;
383 418
384 BUG_ON(!card); 419 BUG_ON(!card);
385 BUG_ON(!card->host); 420 BUG_ON(!card->host);
@@ -408,10 +443,18 @@ int __mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
408 if (!use_busy_signal) 443 if (!use_busy_signal)
409 return 0; 444 return 0;
410 445
411 /* Must check status to be sure of no errors */ 446 /*
447 * Must check status to be sure of no errors
448 * If CMD13 is to check the busy completion of the timing change,
449 * disable the check of CRC error.
450 */
451 if (index == EXT_CSD_HS_TIMING &&
452 !(card->host->caps & MMC_CAP_WAIT_WHILE_BUSY))
453 ignore_crc = true;
454
412 timeout = jiffies + msecs_to_jiffies(MMC_OPS_TIMEOUT_MS); 455 timeout = jiffies + msecs_to_jiffies(MMC_OPS_TIMEOUT_MS);
413 do { 456 do {
414 err = mmc_send_status(card, &status); 457 err = __mmc_send_status(card, &status, ignore_crc);
415 if (err) 458 if (err)
416 return err; 459 return err;
417 if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY) 460 if (card->host->caps & MMC_CAP_WAIT_WHILE_BUSY)
@@ -449,32 +492,6 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
449} 492}
450EXPORT_SYMBOL_GPL(mmc_switch); 493EXPORT_SYMBOL_GPL(mmc_switch);
451 494
452int mmc_send_status(struct mmc_card *card, u32 *status)
453{
454 int err;
455 struct mmc_command cmd = {0};
456
457 BUG_ON(!card);
458 BUG_ON(!card->host);
459
460 cmd.opcode = MMC_SEND_STATUS;
461 if (!mmc_host_is_spi(card->host))
462 cmd.arg = card->rca << 16;
463 cmd.flags = MMC_RSP_SPI_R2 | MMC_RSP_R1 | MMC_CMD_AC;
464
465 err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
466 if (err)
467 return err;
468
469 /* NOTE: callers are required to understand the difference
470 * between "native" and SPI format status words!
471 */
472 if (status)
473 *status = cmd.resp[0];
474
475 return 0;
476}
477
478static int 495static int
479mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode, 496mmc_send_bus_test(struct mmc_card *card, struct mmc_host *host, u8 opcode,
480 u8 len) 497 u8 len)