linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yousong Zhou <yszhou4tech-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Ulf Hansson <ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dev-3kdeTeqwOZ9EV1b7eY7vFQ@public.gmane.org,
	Yousong Zhou
	<yszhou4tech-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: [RFC] mmc: core: Set clock before switching to highspeed mode.
Date: Sat,  5 Sep 2015 18:19:18 +0800	[thread overview]
Message-ID: <1441448358-13129-1-git-send-email-yszhou4tech@gmail.com> (raw)

A SD card with sunxi-mmc can fail with the following error message (RCD for
response CRC error) when trying to switch to highspeed mode.  Setting the bus
clock before the access mode switch fixed it.

    [    1.112060] mmc0: host does not support reading read-only switch, assuming write-enable
    [    1.120203] ehci-platform 1c1c000.usb: irq 31, io mem 0x01c1c000
    [    1.126527] sunxi-mmc 1c0f000.mmc: smc 0 err, cmd 6, RD RCE !!
    [    1.132388] sunxi-mmc 1c0f000.mmc: data error, sending stop command
    [    1.139451] sunxi-mmc 1c0f000.mmc: send stop command failed
    [    1.145056] mmc0: error -110 whilst initialising SD card
    [    1.150424] ehci-platform 1c1c000.usb: USB 2.0 started, EHCI 1.00
    [    1.156533] sunxi-mmc 1c0f000.mmc: smc 0 err, cmd 1, RTO !!

Signed-off-by: Yousong Zhou <yszhou4tech-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/mmc/core/sd.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 4e7366a..402a8db 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -366,6 +366,11 @@ int mmc_sd_switch_hs(struct mmc_card *card)
 		return -ENOMEM;
 	}
 
+	/*
+	 * Set bus frequency to match highspeed mode.
+	 */
+	mmc_set_clock(card->host, mmc_sd_get_max_clock(card));
+
 	err = mmc_sd_switch(card, 1, 0, 1, status);
 	if (err)
 		goto out;
@@ -969,11 +974,6 @@ static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
 			goto free_card;
 
 		/*
-		 * Set bus speed.
-		 */
-		mmc_set_clock(host, mmc_sd_get_max_clock(card));
-
-		/*
 		 * Switch to wider bus (if supported).
 		 */
 		if ((host->caps & MMC_CAP_4_BIT_DATA) &&
-- 
1.7.10.4

             reply	other threads:[~2015-09-05 10:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-05 10:19 Yousong Zhou [this message]
     [not found] ` <1441448358-13129-1-git-send-email-yszhou4tech-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-09-05 14:07   ` [RFC] mmc: core: Set clock before switching to highspeed mode Shawn Lin
2015-09-05 14:58     ` [linux-sunxi] " Hans de Goede
     [not found]       ` <55EB02FD.5040403-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-09-06  0:12         ` Shawn Lin
2015-09-06 12:09           ` [linux-sunxi] " Yousong Zhou
     [not found]             ` <CAECwjAhe3g0T2icEExE_tBbZ2D1z+BpVNCd0dGZVNU=7zH-LHw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-06 14:14               ` Shawn Lin
     [not found]                 ` <55EC4A31.4060605-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2015-09-06 14:47                   ` Yousong Zhou
     [not found]                     ` <CAECwjAgLuskgyHv50GOVN8fGOmQz+jo9PLCAr-POpYH6AszWSg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-07  7:02                       ` Hans de Goede
2015-09-07 15:37                         ` [linux-sunxi] " Yousong Zhou
2015-09-08 15:38                         ` Yousong Zhou
     [not found]                           ` <CAECwjAjsi28gQ-iMZbEgFdoDoTcf0khnS0KRrzO1wnL1j0o0vQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-09  8:47                             ` Hans de Goede
2015-09-06 14:51                 ` [linux-sunxi] " Yousong Zhou
2015-09-07  0:16                   ` Shawn Lin

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=1441448358-13129-1-git-send-email-yszhou4tech@gmail.com \
    --to=yszhou4tech-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=dev-3kdeTeqwOZ9EV1b7eY7vFQ@public.gmane.org \
    --cc=hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).