From: Marek Vasut Date: Mon, 5 Sep 2011 00:18:27 +0200 Subject: [U-Boot] [PATCH] mmc: retry the cmd8 to meet 74 clocks requirement in the spec In-Reply-To: <1315020857-25322-1-git-send-email-leiwen@marvell.com> References: <1315020857-25322-1-git-send-email-leiwen@marvell.com> Message-ID: <201109050018.27667.marek.vasut@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Saturday, September 03, 2011 05:34:17 AM Lei Wen wrote: > 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 > --- > 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); Hi, maybe this condition might be a bit more readable ... while (--retry) { err = mmc_send_if_conf(mmc); if (!err) break; } > + > + if (err) > + return err; > > /* Now try to get the SD card's operating condition */ > err = sd_send_op_cond(mmc); Otherwise, works on my hardware. Tested-by: Marek Vasut Cheers!