Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp348070pxu; Thu, 3 Dec 2020 01:37:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8ccygbsjojZ4Ywho9MXdjac3A34DWWSLb2JBXP0bpHQaVBFfpRbMQeSawIP6Os/pzhwhf X-Received: by 2002:a50:fc96:: with SMTP id f22mr2122784edq.162.1606988258833; Thu, 03 Dec 2020 01:37:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606988258; cv=none; d=google.com; s=arc-20160816; b=VC8ainJbGtcddQ4IRzWbGdePInTGk/jTMHnyeRaxZoGx+jXEhFdm/AIC75X0/wYODe Kbw/0Sz4/URgYGQPG/ghhTVSgIP1e0DoKqeoFhFllwHJAx2bmb7KDIGsChsIfgS/mL/h myLGmJ327EcjUCX7qKVcVT0x8yfkgyZEP7yFcM05FB6A+S7sBO0kqkfFvjjz4Hj2c5uj 4FQ8WAU4rgxreYrHb6QEaAU0pVRvocMYLg3osqQsdhs5/W2WOGdQ33g/tiQGlqw75PZt sDHZkE2TDUuyDV+/eOONvq15Ao4d9Ppi9zHRI59jbtxeN41uqP2Cn4zx7Mutxd8yWHtw Ikhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=JGLAiNcnUCo8oJHJgBNVJ7YcPnO3ItZFweoe3OsdjjI=; b=S9FWMoMOMUrNrehYC3NmSmLFggdcKV28MxwUpycPwjwpH0NB0Rz3b6y6AKB6K22jsB o+hAB4hU0V172y8QMKQL9PCgUoqqNMavAUCoz/UpfnN/6baff/NYcARcmfzJqA3RYzKW S4cEPQzj6TUFsc4ZOQTztiNJIRhOzMleEaHqxhAgMe14h9CCg3Zx7oagOuVTJGs1tulq RoOennoh7SGgeRW5748DIqkA1t5gKt7AWe1/yFCpLhB0FvqG698G/5ami+8MTCeTwumt /mjZ1mt0PomW5jYW2yVw97+dLOYIbVL1qLhiNJ6MU7Krsy0hOgCUCfclj6PA1bVaUr6+ jO3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ch11si568673edb.384.2020.12.03.01.37.15; Thu, 03 Dec 2020 01:37:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730111AbgLCJfG (ORCPT + 99 others); Thu, 3 Dec 2020 04:35:06 -0500 Received: from server-x.ipv4.hkg02.ds.network ([27.111.83.178]:37264 "EHLO mail.gtsys.com.hk" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1726070AbgLCJfG (ORCPT ); Thu, 3 Dec 2020 04:35:06 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.gtsys.com.hk (Postfix) with ESMTP id 52A7722EB9E6; Thu, 3 Dec 2020 17:34:19 +0800 (HKT) X-Virus-Scanned: Debian amavisd-new at gtsys.com.hk Received: from mail.gtsys.com.hk ([127.0.0.1]) by localhost (mail.gtsys.com.hk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id louZf-KAolpD; Thu, 3 Dec 2020 17:34:19 +0800 (HKT) Received: from s01.gtsys.com.hk (unknown [10.128.4.2]) by mail.gtsys.com.hk (Postfix) with ESMTP id 3935C20001F5; Thu, 3 Dec 2020 17:34:19 +0800 (HKT) Received: from armhf2.gtsys.com.hk (unknown [10.128.4.15]) by s01.gtsys.com.hk (Postfix) with ESMTP id 31263C019FF; Thu, 3 Dec 2020 17:34:19 +0800 (HKT) Received: by armhf2.gtsys.com.hk (Postfix, from userid 1000) id 3448A200756; Thu, 3 Dec 2020 17:34:19 +0800 (HKT) From: Chris Ruehl To: Avri Altman Cc: Jack , Chris Ruehl , Ulf Hansson , Wolfram Sang , Yoshihiro Shimoda , Baolin Wang , Krishna Konda , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] mmc: core: make hs400 independent from hs200 init Date: Thu, 3 Dec 2020 17:33:28 +0800 Message-Id: <20201203093338.10480-3-chris.ruehl@gtsys.com.hk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201203093338.10480-1-chris.ruehl@gtsys.com.hk> References: <20201203093338.10480-1-chris.ruehl@gtsys.com.hk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move mmc_select_hs400() out from hs200 init path and make hs400 independent. The patch makes quite some changes and needs to be reviewed carefully. In function mmc_select_timing() call for mmc_select_hs400(). HS400 requires a host bus with of 8bit, if not supported we return with -ENOTSUPP, there is no retry. If the host controller can't switch to 8bit (dts: bus-width = <4>) it can't recover on next power-up init failed. Have the controller set to HS mode, make the hs400 tuning prepare if any and run mmc tuning before switching to HS400. This patch resolve the problem if hs400-1_8v is set but extended strobe is not. &sdhci { // eMMC bus-width = <8>; mmc-hs400-1_8v; // mmc-hs400-enhanced-strobe; non-removable; status = "okay"; }; [ 1.775721] mmc1: CQHCI version 5.10 [ 1.802342] mmc1: SDHCI controller on fe330000.sdhci [fe330000.sdhci] using ADMA [ 2.007581] mmc1: mmc_select_hs200 failed, error -110 [ 2.007589] mmc1: error -110 whilst initialising MMC card [ 2.413559] mmc1: mmc_select_hs200 failed, error -110 [ 2.413562] mmc1: error -110 whilst initialising MMC card [ 3.183343] mmc1: Command Queue Engine enabled [ 3.183355] mmc1: new HS400 MMC card at address 0001 [ 3.197163] mmcblk1: mmc1:0001 DG4008 7.28 GiB [ 3.197256] mmcblk1boot0: mmc1:0001 DG4008 partition 1 4.00 MiB [ 3.197360] mmcblk1boot1: mmc1:0001 DG4008 partition 2 4.00 MiB [ 3.197360] mmcblk1boot1: mmc1:0001 DG4008 partition 2 4.00 MiB [ 3.197479] mmcblk1rpmb: mmc1:0001 DG4008 partition 3 4.00 MiB, chardev (242:0) [ 1.743386] mmc1: CQHCI version 5.10 [ 1.769952] mmc1: SDHCI controller on fe330000.sdhci [fe330000.sdhci] using ADMA [ 1.846223] mmc1: Command Queue Engine enabled [ 1.846230] mmc1: new HS400 MMC card at address 0001 [ 1.846557] mmcblk1: mmc1:0001 DG4008 7.28 GiB [ 1.846650] mmcblk1boot0: mmc1:0001 DG4008 partition 1 4.00 MiB [ 1.846742] mmcblk1boot1: mmc1:0001 DG4008 partition 2 4.00 MiB [ 1.846825] mmcblk1rpmb: mmc1:0001 DG4008 partition 3 4.00 MiB, chardev (242:0) Tested with rk3399 customized board. Note: We had 20% failure rate in the current production "not boot" or "reboot issues" this patch solved it. Some boards had been cooled down to -20C have boot failures, after apply the patch they pass the QC. Signed-off-by: Chris Ruehl --- drivers/mmc/core/mmc.c | 59 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 5477786aded8..45db890dee80 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -1337,15 +1337,46 @@ static int mmc_select_hs400(struct mmc_card *card) { struct mmc_host *host = card->host; unsigned int max_dtr; - int err = 0; + int err = -EINVAL; u8 val; /* - * HS400 mode requires 8-bit bus width + * HS400 mode requires host 8-bit bus width */ - if (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400 && - host->ios.bus_width == MMC_BUS_WIDTH_8)) - return 0; + if (!(host->caps & MMC_CAP_8_BIT_DATA)) { + pr_err("%s: host not support hs400 8bit\n", + mmc_hostname(host)); + return -EOPNOTSUPP; + } + + /* + * Below is a change from previous logic. + * mmc_avail_type vccq voltage set in dts, it can be 1_2v or 1_8v + * but not both. + */ + if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_2V) { + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120); + } else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400_1_8V) { + err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180); + } else { + pr_err("%s: hs400 unsupported vccq voltage, err:%d\n", + mmc_hostname(host), -EOPNOTSUPP); + return -EOPNOTSUPP; + } + + /* Failed set 1_2v or 1_8v try again during next card power cycle */ + if (err) + return err; + + mmc_select_driver_type(card); + + err = mmc_select_bus_width(card); + if (err != MMC_BUS_WIDTH_8) { + pr_err("%s: switch to 8bit bus width failed, err:%d\n", + mmc_hostname(host), err); + err = err < 0 ? err : -EOPNOTSUPP; + goto out_err; + } /* Switch card to HS mode */ val = EXT_CSD_TIMING_HS; @@ -1388,6 +1419,18 @@ static int mmc_select_hs400(struct mmc_card *card) return err; } + /* HS400 prepare and execute tuning */ + host->doing_init_tune = 1; + if (host->ops->prepare_hs400_tuning) + host->ops->prepare_hs400_tuning(host, &host->ios); + err = mmc_execute_tuning(card); + host->doing_init_tune = 0; + if (err) { + pr_err("%s: hs400 tuning failed, err:%d\n", + mmc_hostname(host), err); + return err; + } + /* Switch card to HS400 */ val = EXT_CSD_TIMING_HS400 | card->drive_strength << EXT_CSD_DRV_STR_SHIFT; @@ -1496,7 +1539,7 @@ static int mmc_select_hs200(struct mmc_card *card) } /* - * Activate High Speed, HS200 or HS400ES mode if supported. + * Activate High Speed, HS200 ,HS400 or HS400ES mode if supported. */ static int mmc_select_timing(struct mmc_card *card) { @@ -1507,6 +1550,8 @@ static int mmc_select_timing(struct mmc_card *card) if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400ES) err = mmc_select_hs400es(card); + else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS400) + err = mmc_select_hs400(card); else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200) err = mmc_select_hs200(card); else if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS) @@ -1766,8 +1811,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, host->doing_init_tune = 1; err = mmc_hs200_tuning(card); - if (!err) - err = mmc_select_hs400(card); host->doing_init_tune = 0; -- 2.20.1