From patchwork Mon Aug 15 10:01:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 9280751 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 BD01760780 for ; Mon, 15 Aug 2016 09:56:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC77328C3A for ; Mon, 15 Aug 2016 09:56:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A04E328C3C; Mon, 15 Aug 2016 09:56:46 +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 63DFE28C3B for ; Mon, 15 Aug 2016 09:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752106AbcHOJ4o (ORCPT ); Mon, 15 Aug 2016 05:56:44 -0400 Received: from mail-ve1eur01on0068.outbound.protection.outlook.com ([104.47.1.68]:48044 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752073AbcHOJ4n (ORCPT ); Mon, 15 Aug 2016 05:56:43 -0400 X-Greylist: delayed 584 seconds by postgrey-1.27 at vger.kernel.org; Mon, 15 Aug 2016 05:56:42 EDT 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=H+m9XnDCOiRwdWKMUTpTbpsZqT10HazsfMdw3xR2zQI=; b=rMKDwY+wQBPgWmLxSoj2xjkjAcOOMTsHvT1c5usopcL83OS9DJP+/c3PL3wILnChERbTi2dkHjBPo/Qps2bc4FgkKBhyeyCP7wlh7w1NuIhmqjDQy9nivHdg9swWBx0BTPFX0zqA6qFIlVBe9Me6OMEQ1gNljK5Mk7iIpTISr1g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=haibo.chen@nxp.com; Received: from b51421-server.ap.freescale.net (199.59.226.141) by VI1PR0401MB2334.eurprd04.prod.outlook.com (10.169.133.149) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.557.8; Mon, 15 Aug 2016 09:56:34 +0000 From: Haibo Chen To: , , , CC: Subject: [PATCH] mmc: sdhci-esdhc-imx: reset tuning circurt when insert sd card Date: Mon, 15 Aug 2016 18:01:58 +0800 Message-ID: <1471255318-10933-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.226.141] X-ClientProxiedBy: SIXPR0301CA0028.apcprd03.prod.outlook.com (10.162.171.166) To VI1PR0401MB2334.eurprd04.prod.outlook.com (10.169.133.149) X-MS-Office365-Filtering-Correlation-Id: 6fd85ee8-7e5d-4d94-dbb5-08d3c4f273df X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2334; 2:jnBB1uSTbwZkFSVXFiPzSYsu3FP8uF12Kbql8v5Nv/nX97Zph2w2PWbEUX/GqUvVnlfI7YAsB92sj42HF453O0QkzjNvWOoKuZPBrqM2jAL4EBn4CswfuF2GbAfi+vk476I7JIe7EvY5g4dKpQ7W3CffCeY+dqgTZZULfkCEc0zabwlwL2I/jYvEorTD0XYF; 3:XquyxUQoKDV0MZY62rV//BCvEGR3vs8JQ1rL7S9XgB/MtwTCc1/zTvjlYaRgu23flzAOss0yjqRo92KttyUccj1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OSgHVT0Ak4A6pDZ+Id35C2FIVaalSaDCtlQFlDq7Fg63mNP6OzvkXfz0ZZ4h+cfb9W5lisD8zemgsyNtOuHA2gmLKDhHtJ4vSw3rCkbmYezr8kSu8bUeAGxVwUKcGjmpC10s0tOly0OF0kvhMSal9e095zAlx5H2s+32+mc8QAeYZrFLEOvUym0FD3tDjoFv6vuCms2a4zGE1wCEULNjwJPCA1lFV7m/m85FY+Gc X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:VI1PR0401MB2334; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0401MB2334; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0401MB2334; 4:4dwrqSEvcMbtH0qAS1iCYIikpAwzfw2ihmup5xaTHrkDcXmdNjh5K2Q6Ru8MOqUVrz/ZPasuIP91GsFKJpw+DiYMZGoNxrJQ45zIoh+rBZrZJDeHadd3l5BN522HYkhdtwGrA2ZoYKlkGNI3d/410vE/iPEwiUCCY5zkLdwqHhnzqMmesaQoqPHbQDKcqSWbJPh0VzzxjxobG0PBw9V0TvKCjIM8PmD2cc7dTWR1a9U1+4khXl86YAoaJdAwiqNUOQX3rOI9PfeClS22rh4GUEnYWz+KVuL4CdEk8uPGR/BEurBPpiYBI4yZ660/CMYiJ1uI1Z+4VM18wxicUSCYV8v2erGD8LnHKsO6VpWx89ftqxcB7dogmkyEahpV3FJYkkViNeuMt5UC1oZhGimapGEsslIju9tgsp4eoNrlpb8jhGuJU2JQqx5SWFZA7/dBo45KNeAR4LsTAjHEiw2RRg== X-Forefront-PRVS: 0035B15214 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(50466002)(230783001)(2201001)(305945005)(42186005)(68736007)(77096005)(36756003)(92566002)(4326007)(586003)(229853001)(106356001)(50226002)(7846002)(48376002)(101416001)(7736002)(3846002)(86362001)(2906002)(50986999)(5001770100001)(47776003)(189998001)(105586002)(66066001)(6116002)(97736004)(81156014)(33646002)(81166006)(8676002)(19580405001)(5003940100001)(19580395003)(7099028); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0401MB2334; H:b51421-server.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0401MB2334; 23:zVbc4MGJTwc5PiamO9GQoD7+zKtcPBvQlNlhHae?= =?us-ascii?Q?2+DdGpIJz4odc1+6Sf4cULWTbyG3TsXbRTFPgtO1CCzsuF8FoE5PB1rLLPpS?= =?us-ascii?Q?3y/c9wVFqg0/0EJgAYDdO9tC5ZOp9l3URAxmvm1c9BtrfsxFxbLWhXrqroWR?= =?us-ascii?Q?69gntFqI/kcqQQDDaUFarJ5cOt7mzHNnwjkSx0vCRUjaIL17YznbvjLaeWVX?= =?us-ascii?Q?GApJzbkLEJTYyj7Ujm0lo8siTKOzSSg9e+LhdZSdJQxifO1b/MlEczdx8ILn?= =?us-ascii?Q?ujwOcBEJhZWRsogVlCA+EWrcJEGZRIanxp2r6b0x2k/shtY3WKym4lRVJMH0?= =?us-ascii?Q?hGorHkL+pJ/p6eYNWw2Jn0HXfuD6EM/dUe4zFHs+hlmurcYscfMbThE3UeSS?= =?us-ascii?Q?QwU8BTeKNNMa0sg26QpvRo7/EbMhx6oqOht9PiuTYimPzSrIrkIu4hyQVNET?= =?us-ascii?Q?RnaP++c7kgPv5IqPnacglWmSeUg3OC/nzjYi9Y6dEVHqoO4pEeO5r1zsTGPB?= =?us-ascii?Q?IkT/tVgFPncF9KP7n+xNkvBdWaaJOCTw471oMGIE04CQ1+hlZxOZ8upB/68g?= =?us-ascii?Q?MSOm6FTSVHSeQZon35YcUjUYDA7q2b1jjBV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ezKduTavaQd3f3TNMy9kvTBGw9T5PmTiHnAU0r1I/Y2LQzk5YlA==; 24:+VsiLstPPQBkDKLXr0FxsnUFGmJiQZicbGWuXWrAwonF17xMdW0B5y3HHXHaxRX2uDXCuNi70rIzHwGmtqpHm/OUaYfTz/5iSbbABj0lxv4=; 7:dBvEztb28Dlkdqsljil+0NfxNSGw6dd8RfQVMLvbjOwKclTdyn8uFzuYts+UokkdaDyx+8wOv76sJuwX3red+nevOevOaIwBOjYLmK1HaOjclqAEepm/ctHWuRT9S+rO2NYPjh+F+oBjrJYuwz+hjiTlR7dZN6deUsbnd6YAFax9vVd57UiuXH+LY1wGRqi0RNel5ouZHOeAnuAq4fgyAGTfpTFhx4qYuHLecl8ISAWx22VVsf7/0j/G8O+PcAWC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2016 09:56:34.4395 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2334 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 Current driver do not clear the tuning related register after plug out SD3.0 card. This will impact the timing and let other SD3.0 card inserted later meet CRC error. e.g., after plug out a SDR104 card, and then plug in a DDR50 card, CRC error shows up: mmc2: new ultra high speed DDR50 SDHC card at address aaaa mmcblk2: mmc2:aaaa SE08G 7.40 GiB mmcblk2: error -84 transferring data, sector 0, nr 8, cmd response 0x900, card status 0xb00 mmc2: tried to reset card mmcblk2: p1 p2 Logictally, we should reset USDHC include tuning circurt first when we plug in a sd/mmc/sdio card. Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci-esdhc-imx.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index ea7d086..2783a4b 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -924,6 +924,30 @@ static void esdhc_reset(struct sdhci_host *host, u8 mask) sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); } +static void esdhc_hw_reset_for_init(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); + u16 ctrl; + + sdhci_reset(host, SDHCI_RESET_ALL); + + /* 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 | + ESDHC_MIX_CTRL_FBCLK_SEL); + writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL); + writel(0 << 8, 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 unsigned int esdhc_get_max_timeout_count(struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); @@ -958,6 +982,7 @@ static struct sdhci_ops sdhci_esdhc_ops = { .set_bus_width = esdhc_pltfm_set_bus_width, .set_uhs_signaling = esdhc_set_uhs_signaling, .reset = esdhc_reset, + .hw_reset = esdhc_hw_reset_for_init, }; static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { @@ -1223,7 +1248,7 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (esdhc_is_usdhc(imx_data)) { host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; - host->mmc->caps |= MMC_CAP_1_8V_DDR; + host->mmc->caps |= MMC_CAP_1_8V_DDR | MMC_CAP_HW_RESET; if (!(imx_data->socdata->flags & ESDHC_FLAG_HS200)) host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200;