From patchwork Tue Apr 18 10:05:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 9685269 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 C3FE3602C2 for ; Tue, 18 Apr 2017 09:59:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1D4627C0B for ; Tue, 18 Apr 2017 09:59:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B66E0283FF; Tue, 18 Apr 2017 09:59:18 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 36BF7283FE for ; Tue, 18 Apr 2017 09:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756275AbdDRJ7R (ORCPT ); Tue, 18 Apr 2017 05:59:17 -0400 Received: from mail-db5eur01on0065.outbound.protection.outlook.com ([104.47.2.65]:55661 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756214AbdDRJ7P (ORCPT ); Tue, 18 Apr 2017 05:59:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KBUAMFawO9OLiFQVo1rmUEzAFQHDey9ELgIkQ+uonN0=; b=bdCTvLR7O2pbBy73uVhFBwXr8RspmHQAUXlICMUi31hvAhNQ7jSANFY64GmS1kIRvGGZN9XZKKLkhULRiKE6WTEnSVqbPPGlypJ12zxsiBhnB6vsV65sd91dnl7AU09sY1WHnKZQcAWj0QDCnIlTWqTCVk4MsGbTkTKK/a1eceQ= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none; intel.com; dmarc=none action=none header.from=nxp.com; Received: from b51421-server.ap.freescale.net (199.59.230.102) by AM4PR0401MB2324.eurprd04.prod.outlook.com (2603:10a6:200:50::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Tue, 18 Apr 2017 09:59:09 +0000 From: Haibo Chen To: , , CC: Subject: [PATCH v2] mmc: sdhci-esdhc-imx: reset tuning circuit when power on mmc card Date: Tue, 18 Apr 2017 18:05:31 +0800 Message-ID: <1492509931-3388-1-git-send-email-haibo.chen@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [199.59.230.102] X-ClientProxiedBy: HK2PR02CA0063.apcprd02.prod.outlook.com (2a01:111:e400:79ab::31) To AM4PR0401MB2324.eurprd04.prod.outlook.com (2603:10a6:200:50::23) X-MS-Office365-Filtering-Correlation-Id: f568b35d-321d-4ea5-5a68-08d486419130 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:AM4PR0401MB2324; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0401MB2324; 3:q7ELjITvN1n1Pc42+ziFuyNbbtDIDMKnyeMJAX/Mn437X9JqROUxHPwOuuIPHzFF3AL+1FADe/K5TzE8pRzOSXYQeSseOM2DthO8p1n5AvlN/AhveAmRBNSATkYOTx1J/ypE5CRFYqab2UbbGgWHcwysCyIEPcDKLCBpbdtd7ZXoCdrgUroP48K7MpLSszYyCPHcT7sAnem3E1toDkjBrsY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/Fu0QwgUPDCXLJFH/AHw34dSObT7/joy3W7BXBmMSCwaA2w1IK3iy/Q0odlrKOIx/Fp+ROfbSj8E+5v+05afi5VecqDVxDFF1SBj5s/FmV8vOIO1jGvLtnnXYi7Sirk22/kji+SNr+Sangm2czt2/9jKQzcuT6PUN400Astd+bKwLPhO9zFC4ydJZHTSEo+oJuhh0DQANilkyb6o4KN2P0gap7A0v6A6zPfiomoxPcvZLqTXZjOFp2JE91Q4vgzGBVN3/6Z9ksbjdBAe2afb9tRTRtwoO/qP/uVN1ljd0V1/RphT9KuQpWwv86tyCHaxcypmeOWPO/4FrNoFj X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(20161123560025)(20161123564025)(20161123562025)(20161123555025)(6072148); SRVR:AM4PR0401MB2324; BCL:0; PCL:0; RULEID:; SRVR:AM4PR0401MB2324; X-Microsoft-Exchange-Diagnostics: 1; AM4PR0401MB2324; 4:SCZWBB62cqK2F30/M9b66h7yzLoQ9y1JE3JHqLxSn47IsMt6N5cAOMmCPisxz1zsO7pae+0BS3ejUvIE6aYt+BeMZVPsm2uXtcG66xdTOCGksdGU0n9Y7dLOSJpEIZ/JsjMsDn8PoEnCLETXXZSHX8eAdx2WicJS19tyxpcpdg39aBPucRQ0Yuog9BvP9oHJVul8kJceADBf4YGjpojWykZgWA9v+b1h6cGB7KkEqE1Fe3L1DuwTOmL0W+JtrBcKC/yxUfPSnHEkaSm9aO0UBCyhzxaZVdspWXZxyeh1WfxR2uKgvuaLrn0EDFzhFk/XBTvwymI4u/qE2a+VLKkfKysn8QObHeWQL3q5B3oXdFHkKZgaDuiy3hGc+Syr+Y/Q+ybjN4okwk4gYZn0d6xMRQLlVCSZ7EoBhdEl+TCIKIp2T74oWevCFyOEKdZUPBatGytYbPonauv7N5rOVXufMvH50c8/WMUsP1GbKubHWv2ABqBjGr/xc/dyUyQ2KZsMG6i1lzJI8W29ibaJZ+MdBqPFlYz+dOcygaSnkEDmF0rSU0aNwP3/uu3/U00Ogd8k2fe9QHmax9S24Tfl6WYJ4WUzGj10mX+u8zEdf6ey5P89MLRTGcwu+NndD5eOQUW/dCEmrzjdduDmT0WXdWxLrkbe7CcGQZdRq0A0kSuAisiBpbcVzP109UeDxVIocpWcxoksQZuet9FZSO0kLTJ03Bb4KNavjAXq7AYg4n1VuCTICp5SVVJ1cVOrqxQkV2Vmu8dD42H1RZo/S7N35PGfxg== X-Forefront-PRVS: 028166BF91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(979002)(6009001)(39410400002)(39860400002)(39840400002)(39400400002)(39850400002)(39450400003)(5660300001)(50986999)(36756003)(6636002)(42186005)(50226002)(6512007)(6666003)(53936002)(8676002)(47776003)(6486002)(66066001)(81166006)(33646002)(86362001)(4326008)(48376002)(6506006)(25786009)(5003940100001)(50466002)(6116002)(38730400002)(2201001)(7736002)(3846002)(2906002)(305945005)(230783001)(189998001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR0401MB2324; H:b51421-server.ap.freescale.net; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR0401MB2324; 23:on/I/2DK08f+lZQyqT9EKer1O2ZSqEfUJ7XB2+h?= =?us-ascii?Q?ZvY4roV7Bliq1/uT3B87znJWidMFK9poyoDINmMx1m8RTLxuHWgoI6hV3Gdf?= =?us-ascii?Q?vrkatRQtd0rpotyUU4Gu4J6a+n2o007hLBEzZss349bEQ0qUiobDOZ7ZtD5t?= =?us-ascii?Q?X/DzbSn0UPaTi2Y1t5kJRdwiyQvva6SRM9MmAI1T0CGhKr6td/O9Rr2ygeoN?= =?us-ascii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1e4g=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; AM4PR0401MB2324; 6:uw+ZTwv01XInlJI8yLrBuoJChzclpEu9pq3P2KgFN4iN5k4287RvdaYfLT4tzKBeuBaV/A+I6jZjNASjeq5oQDm1483VUEuSP2SLuJnQCMqpJvGmMbIGlr/98sqMs5dACzOUFEWVjp5eGqEhdQD5H3Wu3cT37u/924pnqcAoBwA3bAp/1KhZsmLdmdszTOek3quZzzvwko2Fhq3cFEu1QcUzlrPkRbk2arYJf66JEqOQW5MmdCbzGdZ2mSEbu76IGzbA1Ndh2oe5oImy+BpwzLD6I+9G6QkdphYeJQzkCnuSxwsoUdy7r3LkSWMbi+Es1PprGxBVJ+EUPh3s1PyRE8KDwPwY/gL6Fdt/LllhYGjbhTtukD9NMzZ3rlYI+PliXRLi52ZHRmd1cISg82T6A7MEf9vxQZZ7o2AxfbDbn4MRn++r2EY/OynLtLbJiSdwU0U5wszv9AOfQ84k5594hptSJl0nFEmfiFmXMcR2H/8=; 5:FJLx3gT2qQH7Gv6QZMsu8c3g1LJvEaIsd5pcHCb60dnSZ+WHBpVuH8Y9CcuUqTlOhoNJzPD0rzkBUoowGFyupQuUouc/SlIElh1ISjjmd5PT52fOtzspFPpMhxAgne/ms3qTQOcJz7AJPhybQ2FBqQ==; 24:57I4x8k/RxqC0OdfHthJ7SednpbEs1wSFqhVEZUC99yJUSAoBt0fL4nKmB2DyuxJ6J31h5S+UWsN2fX1P7UBEsXSxqAZeg+wfeq4sYc6Bgs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR0401MB2324; 7:KSgACONtMF0kjsZHqjXT2qnixYDHqo6oL3kMBCbT4VY5hVT9m2O7+lAbVEP2UzcK6ZIzd5TnHhQnJQxwg/GhBJSGMmfDzzofWyAnEs5nfj2zeXHggpeDXQ944U61BPnHVk6x4tnlQ+6ygPhsZ44n/yVaT53deabyuN/r/wWczy5nI8WMYs23QF1rpArqcQczyKPhLv1r4oB6fVP/SPboEa9cV6tMbuEgaG19M2OcVgcmx0CnD42vbrifC6JxcIBtwuhiyBBxvT6K53CkIa+Hqpu8WG+TdnOiP5msMjOoli/qEUUnyqXQv5jvTdI0sAXxz16KInYMiphjZI23T2i6NA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2017 09:59:09.0348 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0401MB2324 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 USDHC tuning circuit should be reset before every time card enumeration or re-enumeration. SD3.0 card need tuning. For SDR104 card, when system suspend in standby mode, and then resume back, the IO timing is still SDR104(tuned) which may result in card re-enumeration fail in low card speed(400khz) for some cards. And we did meet the issue that in certain probability, SDR104 card meet mmc command CRC/Timeout error when send CMD2 during mmc bus resume. This patch reset the tuning circuit when the ios timing is MMC_TIMING_LEGACY/MMC_TIMING_MMC_HS/MMC_TIMING_SD_HS, which means both mmc_power_up() and mmc_power_off() will reset the tuning circuit. Signed-off-by: Haibo Chen Acked-by: Dong Aisheng Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-esdhc-imx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index abad67a..23d8b8a 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -889,6 +889,28 @@ static void esdhc_set_strobe_dll(struct sdhci_host *host) } } +static void esdhc_reset_tuning(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); + u32 ctrl; + + /* Rest the tuning circurt */ + if (esdhc_is_usdhc(imx_data)) { + if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) { + ctrl = readl(host->ioaddr + ESDHC_MIX_CTRL); + ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; + ctrl &= ~ESDHC_MIX_CTRL_FBCLK_SEL; + writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL); + writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); + } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) { + ctrl = readl(host->ioaddr + SDHCI_ACMD12_ERR); + ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; + writel(ctrl, host->ioaddr + SDHCI_ACMD12_ERR); + } + } +} + static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing) { u32 m; @@ -932,6 +954,10 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing) host->ops->set_clock(host, host->clock); esdhc_set_strobe_dll(host); break; + case MMC_TIMING_LEGACY: + default: + esdhc_reset_tuning(host); + break; } esdhc_change_pinstate(host, timing);