All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lei Wen <leiwen@marvell.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc: retry the cmd8 to meet 74 clocks requirement in the spec
Date: Fri,  2 Sep 2011 20:34:17 -0700	[thread overview]
Message-ID: <1315020857-25322-1-git-send-email-leiwen@marvell.com> (raw)

For some controller it has dynamic clock gating, and only toggle out clk
when the first cmd0 send out, while some card strictly obey the 74
clocks rule, the interval may not be sufficient between the cmd0 and
this cmd8, retry to fulfil the clock requirement.

Signed-off-by: Lei Wen <leiwen@marvell.com>
---
 drivers/mmc/mmc.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 7e703c0..f9b2223 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1178,7 +1178,7 @@ block_dev_desc_t *mmc_get_dev(int dev)
 
 int mmc_init(struct mmc *mmc)
 {
-	int err;
+	int err, retry = 3;
 
 	if (mmc->has_init)
 		return 0;
@@ -1201,7 +1201,19 @@ int mmc_init(struct mmc *mmc)
 	mmc->part_num = 0;
 
 	/* Test for SD version 2 */
-	err = mmc_send_if_cond(mmc);
+	/*
+	 * retry here for 3 times, as for some controller it has dynamic
+	 * clock gating, and only toggle out clk when the first cmd0 send
+	 * out, while some card strictly obey the 74 clocks rule, the interval
+	 * may not be sufficient between the cmd0 and this cmd8, retry to
+	 * fulfil the clock requirement
+	 */
+	do {
+		err = mmc_send_if_cond(mmc);
+	} while (--retry > 0 && err);
+
+	if (err)
+		return err;
 
 	/* Now try to get the SD card's operating condition */
 	err = sd_send_op_cond(mmc);
-- 
1.7.0.4

             reply	other threads:[~2011-09-03  3:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-03  3:34 Lei Wen [this message]
2011-09-04 22:18 ` [U-Boot] [PATCH] mmc: retry the cmd8 to meet 74 clocks requirement in the spec Marek Vasut
2011-09-04 22:45   ` Andy Fleming
2011-09-05  2:50     ` 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=1315020857-25322-1-git-send-email-leiwen@marvell.com \
    --to=leiwen@marvell.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.