From patchwork Mon Jan 9 08:56:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Lin X-Patchwork-Id: 9504203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2115E60710 for ; Mon, 9 Jan 2017 08:57:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1216228462 for ; Mon, 9 Jan 2017 08:57:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0684E2846E; Mon, 9 Jan 2017 08:57:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D72E928462 for ; Mon, 9 Jan 2017 08:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757420AbdAII5x (ORCPT ); Mon, 9 Jan 2017 03:57:53 -0500 Received: from lucky1.263xmail.com ([211.157.147.134]:36284 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751133AbdAII5w (ORCPT ); Mon, 9 Jan 2017 03:57:52 -0500 Received: from shawn.lin?rock-chips.com (unknown [192.168.167.87]) by lucky1.263xmail.com (Postfix) with ESMTP id 62D79FE7; Mon, 9 Jan 2017 16:57:42 +0800 (CST) X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.263.net (Postfix) with ESMTP id E8B0F3A3; Mon, 9 Jan 2017 16:57:41 +0800 (CST) X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: ulf.hansson@linaro.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: X-ATTACHMENT-NUM: 0 X-SENDER: lintao@rock-chips.com X-DNS-TYPE: 0 Received: from unknown (unknown [58.22.7.114]) by smtp.263.net (Postfix) whith SMTP id 24176USM0CU; Mon, 09 Jan 2017 16:57:42 +0800 (CST) From: Shawn Lin To: Ulf Hansson Cc: Adrian Hunter , Jaehoon Chung , linux-mmc@vger.kernel.org, Shawn Lin Subject: [RFC PATCH v2 2/2] mmc: sdio: don't use rocr to check if the card could support UHS mode Date: Mon, 9 Jan 2017 16:56:20 +0800 Message-Id: <1483952180-85063-2-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1483952180-85063-1-git-send-email-shawn.lin@rock-chips.com> References: <1483952180-85063-1-git-send-email-shawn.lin@rock-chips.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Per SDIO Simplified Specification V3, section 3.1.2, A host that supports UHS-I sets S18R to 1 in the argument of CMD5 to request a change of the signal voltage to 1.8V. If the card supports UHS-I and the current signal voltage is 3.3V, S18A is set to 1 in the R4 response. If the signal voltage is already 1.8V, the card sets S18A to 0 so that host maintains the current signal voltage. UHS-I is supported in SD mode and S18A is always 0 in SPI mode. For the current code, if the signaling voltage is fixed 1.8v, so the card will set S18A to 0 for rocr and thus we would clear the R4_18V_PRESENT from ocr, which make core won't try to use uhs mode. To fix it, we expect sdio_read_cccr would fail if the uhs mode won't work at all. Note that it's interesting that some sdio cards still response S18A even the voltage is fixed to 1.8v and the CMD11 will also accepted and finish enabling UHS mode successfully. I guess this is why folks didn't notice this problem. Anyway, fix it. Signed-off-by: Shawn Lin --- Changes in v2: - use the new helper function and improve the retry - fix a typo drivers/mmc/core/sdio.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index f417adc..3af09da 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -633,7 +633,11 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, * to switch to 1.8V signaling level. No 1.8v signalling if * UHS mode is not enabled to maintain compatibility and some * systems that claim 1.8v signalling in fact do not support - * it. + * it. Per SDIO spec v3, section 3.1.2, if the voltage is already + * 1.8v, the card sets S18A to 0 in the R4 response. So it will + * fails to check rocr & R4_18V_PRESENT, but we still need to + * try to init uhs card. sdio_read_cccr will take over this task + * to make sure which speed mode should work. */ if (!powered_resume && (rocr & ocr & R4_18V_PRESENT)) { err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, @@ -645,9 +649,6 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, } else if (err) { ocr &= ~R4_18V_PRESENT; } - err = 0; - } else { - ocr &= ~R4_18V_PRESENT; } /* @@ -704,11 +705,23 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, } /* - * Read the common registers. + * Read the common registers. Note that we should try to + * validate whether UHS would work or not. */ err = sdio_read_cccr(card, ocr); - if (err) - goto remove; + if (err) { + mmc_sdio_resend_if_cond(host, card); + if (ocr & R4_18V_PRESENT) { + /* + * Not retry it but just retring the sequence + * w/o R4_18V_PRESENT. + */ + retries = 0; + goto try_again; + } else { + goto remove; + } + } /* * Read the common CIS tuples.