public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jaehoon Chung <jh80.chung@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/3] mmc: sdhci: fix the wrong operation when response type is R1b
Date: Fri, 30 Mar 2012 11:39:47 +0900	[thread overview]
Message-ID: <4F751CF3.1090606@samsung.com> (raw)

When response type is R1b, mask value is added the SDHCI_INT_DAT_END.
but in while(), didn't check that flag.
So sdhci controller didn't work fine.
CMD6 didn't always complete.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 drivers/mmc/sdhci.c |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c
index fc904b5..0dd08b9 100644
--- a/drivers/mmc/sdhci.c
+++ b/drivers/mmc/sdhci.c
@@ -124,10 +124,11 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 {
 	struct sdhci_host *host = (struct sdhci_host *)mmc->priv;
 	unsigned int stat = 0;
-	int ret = 0;
+	int i, ret = 0;
 	int trans_bytes = 0, is_aligned = 1;
 	u32 mask, flags, mode;
 	unsigned int timeout, start_addr = 0;
+	unsigned int retry = 10000;
 
 	/* Wait max 10 ms */
 	timeout = 10;
@@ -206,19 +207,31 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd,
 	flush_cache(start_addr, trans_bytes);
 #endif
 	sdhci_writew(host, SDHCI_MAKE_CMD(cmd->cmdidx, flags), SDHCI_COMMAND);
-	do {
+
+	for (i = 0; i < retry; i++) {
 		stat = sdhci_readl(host, SDHCI_INT_STATUS);
-		if (stat & SDHCI_INT_ERROR)
+		if (stat & (SDHCI_INT_RESPONSE | SDHCI_INT_DATA_END)) {
+			sdhci_cmd_done(host, cmd);
+			sdhci_writel(host, mask, SDHCI_INT_STATUS);
+			if (!data) {
+				sdhci_writel(host, stat,  SDHCI_INT_STATUS);
+			}
 			break;
-	} while ((stat & mask) != mask);
+		}
+	}
 
-	if ((stat & (SDHCI_INT_ERROR | mask)) == mask) {
-		sdhci_cmd_done(host, cmd);
-		sdhci_writel(host, mask, SDHCI_INT_STATUS);
-	} else
-		ret = -1;
+	if (i == retry) {
+		printf("%s: waiting for status update\n",__func__);
+		return TIMEOUT;
+	}
+
+	if (stat & SDHCI_INT_TIMEOUT) {
+		return TIMEOUT;
+	} else if (stat & SDHCI_INT_ERROR) {
+		return -1;
+	}
 
-	if (!ret && data)
+	if (data)
 		ret = sdhci_transfer_data(host, data, start_addr);
 
 	stat = sdhci_readl(host, SDHCI_INT_STATUS);

             reply	other threads:[~2012-03-30  2:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-30  2:39 Jaehoon Chung [this message]
2012-03-30  3:33 ` [U-Boot] [PATCH v2 1/3] mmc: sdhci: fix the wrong operation when response type is R1b Lei Wen
2012-03-30  4:36   ` Jaehoon Chung
2012-03-30  5:24     ` Lei Wen
2012-03-30  6:23       ` Jaehoon Chung
2012-03-30 15:54         ` Lei Wen
2012-03-31  6:55           ` Jae hoon Chung
2012-03-31 12:39             ` Lei Wen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F751CF3.1090606@samsung.com \
    --to=jh80.chung@samsung.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox