From patchwork Sat Sep 5 10:19:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 7127441 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 017779F1D5 for ; Sat, 5 Sep 2015 10:23:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 18D592081D for ; Sat, 5 Sep 2015 10:23:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2DB742081B for ; Sat, 5 Sep 2015 10:23:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750840AbbIEKXT (ORCPT ); Sat, 5 Sep 2015 06:23:19 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:35330 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750810AbbIEKXS (ORCPT ); Sat, 5 Sep 2015 06:23:18 -0400 Received: by pacfv12 with SMTP id fv12so48922198pac.2 for ; Sat, 05 Sep 2015 03:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=zdKvnCxY3ymrkpKjqh1p/yWWQ8yjC5TAxUJOsqxY9Xo=; b=yGUFdVMsHGxeTa3PBAAs4w71B3PYVQBhTHpGpdIP5qx7gELQTUW9VVuKLeLUjG/SEx vYBcFOEJNJ8gw6vO61YwZOZOMNMUxrlc2dk/ogMaaY2R/YOVftk7/+Av+/88BJtvMJ3q fEOqLr0fIY27Rpd2jI29CIOe8hzK+Urb+Ny8Caww/atna0f0dvo2zYCRqk9655GMHHbA gVa2v+/q/fiK3dgqTHMICRqBjrp2N7g6rTwv6AIWxxKe0QatSX1KXi8VSXwf+153EjeK gyMwJQ0m9qSmaf5rxMoOTaMCyLkhj40XA2BISwbjdmHUXE6q8oDfzazTLm2kAMvMF7I7 n6Ow== X-Received: by 10.68.192.9 with SMTP id hc9mr19471142pbc.57.1441448598294; Sat, 05 Sep 2015 03:23:18 -0700 (PDT) Received: from debian.corp.sankuai.com ([103.29.140.56]) by smtp.gmail.com with ESMTPSA id uz5sm5385545pac.1.2015.09.05.03.23.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Sep 2015 03:23:17 -0700 (PDT) From: Yousong Zhou To: Ulf Hansson Cc: Hans de Goede , linux-mmc@vger.kernel.org, dev@linux-sunxi.org, Yousong Zhou Subject: [RFC] mmc: core: Set clock before switching to highspeed mode. Date: Sat, 5 Sep 2015 18:19:18 +0800 Message-Id: <1441448358-13129-1-git-send-email-yszhou4tech@gmail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) &&