From patchwork Tue Jul 12 07:46:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aisheng Dong X-Patchwork-Id: 9224789 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 A03D260868 for ; Tue, 12 Jul 2016 08:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EB9127E78 for ; Tue, 12 Jul 2016 08:27:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8316227F94; Tue, 12 Jul 2016 08:27:31 +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=unavailable 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 11FE827E78 for ; Tue, 12 Jul 2016 08:27:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751887AbcGLI1a (ORCPT ); Tue, 12 Jul 2016 04:27:30 -0400 Received: from mail-dm3nam03on0066.outbound.protection.outlook.com ([104.47.41.66]:60960 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751694AbcGLI12 (ORCPT ); Tue, 12 Jul 2016 04:27:28 -0400 Received: from DM2PR03CA0045.namprd03.prod.outlook.com (10.141.96.44) by BY2PR0301MB0773.namprd03.prod.outlook.com (10.160.63.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16; Tue, 12 Jul 2016 07:54:40 +0000 Received: from BL2FFO11OLC012.protection.gbl (2a01:111:f400:7c09::123) by DM2PR03CA0045.outlook.office365.com (2a01:111:e400:2428::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.528.16 via Frontend Transport; Tue, 12 Jul 2016 07:54:40 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11OLC012.mail.protection.outlook.com (10.173.160.159) with Microsoft SMTP Server (TLS) id 15.1.534.7 via Frontend Transport; Tue, 12 Jul 2016 07:54:40 +0000 Received: from shlinux2.ap.freescale.net (shlinux2.ap.freescale.net [10.192.224.44]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u6C7rxtj002725; Tue, 12 Jul 2016 00:54:37 -0700 From: Dong Aisheng To: CC: , , , , , , , Subject: [PATCH V2 12/15] mmc: sdhci-esdhc-imx: factor out hw related initialization into function Date: Tue, 12 Jul 2016 15:46:21 +0800 Message-ID: <1468309584-3591-13-git-send-email-aisheng.dong@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468309584-3591-1-git-send-email-aisheng.dong@nxp.com> References: <1468309584-3591-1-git-send-email-aisheng.dong@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131127836807003622; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(2906002)(106466001)(6806005)(48376002)(8676002)(81166006)(8666005)(92566002)(85426001)(50226002)(81156014)(11100500001)(50986999)(230783001)(356003)(47776003)(305945005)(50466002)(7846002)(76176999)(229853001)(104016004)(586003)(2950100001)(2351001)(36756003)(77096005)(86362001)(575784001)(5003940100001)(68736007)(87936001)(33646002)(8936002)(19580405001)(19580395003)(4326007)(105606002)(110136002)(189998001)(97736004)(7059030); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0773; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC012; 1:9eD417IFBJ018wdhA2+p0lxGLaugTm8xRrlokTaz+jQBrF6h2zrEZDUaclUZGIVwbqV14v0i8AJHT0y/AM4Up1TUG9MKLLbHkT1cexkHuLv6knYVS3mbKpHerEXkvwd+K1okG4Bs01BuOfhoBfLrWaq6I/bowCngIpYY68bszaARUDnf50+oE5CJVLPq1BC1vMavXvDP7B4aJUdtKf6UXpE7K7sCudjs9zuyxfV3/xFePVrm4EJZ3TeiErcJkLqTU9ZI6F02ixGv1kPMrFUop/fdMkvZDRzXNM1ZRlbaXGTn+rz9fZ0qEm7GNbHqagm2OX06XzXQrsjMEcmBuLlJ9FBPeFwidJEg+x8RVU9GeU+oM1S0FnAoQZr2tVCr/wkUuM7pLugZ9UDQcxlhqBtHWe4fj+bkqTcAQJUAU6pWllEpRzLpYsNsNeolVojiwC/uX2v9V7cDa61QnCJkIyEkeIt+1QU3MpMsc99va8SH4QB+0DP3GUPRjQ/oHvaqoYwzwfDiKf/ja5k3FqZWVvb+3F0rF4tFkH9HA/S822yJ3sH5iwOOGZyLP8R+lnAW3SQrrJ1zSJQBjQTdD4gnGKf74tAzSvj29aUvRiDu2/q9JuHOf4uXTFmCNvM2KmsgjfAQGovvJekGbljakn65ZdBUUvKO9Lrx+Sxv0gV+G7mXP7w= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: b2f7057b-f998-4f06-9c89-08d3aa29c780 X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0773; 2:zTGjZXqIRwWxH0jN5iVNOIrpuN49mruVQK4GahvkVllt2tu6U3YkTEnUCSn9V0u8xY39qi9ONd8oJVmdYu5QS+r80rS+Qrz1RwYDZn/M090SH6r8RYeKZdcLtlCtQFxDj5/iZTBZATd3N/ItClNpb8ZI4kBqySXhDRmvIqVcKfjK8zrynxh98t/s66JH7pVE; 3:1hRdJY/AJuSLVGK4zN/dZAu3fXfbuv+U4olOBONIaGlWKkGX+DugF7X0sIR4wYqNDL0a+E7VwPw+n8zblCbmS9zkNtralcwaU3IBGYkezi9RUrHy9aTDSjW7ohjSTJU3qCEcDF4D+mDaGALybO3XBVYMF0A3sTTXfQIhAKig552mx30awQqJwXraCLT5glm+ZYtLJK+/NOqTuhpbmqjmZzyedDzp8rjIQoHnGVP7Q4o= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB0773; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0773; 25:C5uW3Y6zh5S35T/S65FzgVCE01kVcs0ENIJhXgM+lZqKpKJKLspMFKkVLDZ/gfJ0xTHBwQj2pHHDmsPTweqR709DWbEp102AiKQYNYm4BsJcWh9TaIxjvZN551A7TLboJpZZOm2scw1+oRuBEg98aOwx485gz+KsC3BtoDNNM5zltEY/pb5w3wgk6FAKg8UGBSOiUnsaVv3sWmZaHEJwcJokdxqJBGGZQ+MbEmr0QlcKGDQA23AUtjMONrQnvr8BgOLVk1F9X5dflsBOz3xemg4uDqTBF7o5XILlaxluhqv5scjsvaZkoMQui9miGQqkJqntpNH5RTmDXFbKfLJSiarT4tb3nrb4TEAtCL3+ZUfTkCU4Arq3oKYhJkPJ58iruH4M3j0QAguzD8WFTgMBCr0BYDA59mLemA7EI7mbKkZgRDcshj6O3VR2AKEPLDz3bJmPOTBIPGdSNrixLz9oaRHRpzcaHPoiVM7jyeXQjWhYl6hYpsrmGc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WhjRpcmn6bNtA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(8121501046)(5005006)(13018025)(13015025)(13017025)(13024025)(3002001)(10201501046)(6055026); SRVR:BY2PR0301MB0773; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0773; X-Forefront-PRVS: 0001227049 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB0773; 23:sDkbXqRj2dKtbgBbOgKqLN5oXhgnb+IZ4lNXbb6?= =?us-ascii?Q?xTRMiZnY/llPcMjvtDAHHNXQu9m1t6GlAhVAd1rihRzp+OP/45btjjPGUJHE?= =?us-ascii?Q?6Sebr0145hNyE2lGBJcKUVqzaUWnDLmdZi5Cewd1/MX6xEOF83Sat9PpLdsm?= =?us-ascii?Q?0KLDKesxx6KO+5brK6ZnDZdsK46rSN32tJiuRYZwXLLSZu4QPOUB6caiWAVd?= =?us-ascii?Q?wrBZYvQ6p9zBkMi5bt4Fghr57C51exR2E5+dJYvmLpIV/ZKD/2oefoqFtgNF?= =?us-ascii?Q?ThgRHyNAKgZKKT1All/PL6fVj3R1dRdE4j/VT+vebTVF/jeW6TD1DrJGIXj3?= =?us-ascii?Q?5o/SU6QfrKU9f/nBMcl5Z3bY1EHT34X1cWqIcvuHGhVuUBB5UPZ5oKKZenr4?= =?us-ascii?Q?o/+PMmU7u7wdy6MRaaKA/tRhrRtdubWkEV7ykwQ8eMbz2sGP3LPJkDoW2iKS?= =?us-ascii?Q?6m64kJ6BhDu9596P9N7jhMpC7hRz8Km06WzUE37gBiu5ELltY6cMHcxs47oS?= =?us-ascii?Q?s/wYH8lrWcMQ8+rn4kgJO7pjAy9iWg9DkgyYOz06gXDl0AzkGrs6yEGwOg1F?= =?us-ascii?Q?7cwbfMAhy2vx4YH6H4vFQySqrmVbBYbDGIbep4weCVjXPxAIksDl851GL6ik?= =?us-ascii?Q?9W8sZxcSG66x3rU2U7a+/rZI7FiFM4hIAKXeQfrgVrAxlKvhvnYdhgeXIwCj?= =?us-ascii?Q?+UEWT55zn5L8tJLC7JCyQzatByPq6GUlfbBLIrJobpLDbBDJeNbPLR/r7m6w?= =?us-ascii?Q?fjC+vPLkhJbvBjQHugm6xG4flTbQuZsVWM9edWRDZLzE8i9A48ncME2DtAFj?= =?us-ascii?Q?RuxvEQkviy9u/zXn56x5foP3xL8axZCR0whLv/y7GIDqlOeoXhkxK0E1cizm?= =?us-ascii?Q?HhmTOpApsMZnG1LpvYI6GAxaASPQp2/Ea6FO5n7Eivy+o/03KEq0MvgWWyPa?= =?us-ascii?Q?ObaPc2Yr96CaPkdd+ApSVbuohw1yOs3v0W3wpEXcLSVLhWZkAIUEVLAEA/Us?= =?us-ascii?Q?RaixpVHEAVkGI9vMJWJ7TfQRasNkZVlf3DaAtFu87mqHg5hI9at+b+bMdDA9?= =?us-ascii?Q?8BF6WmykgCX+fD2gXp10ppr+ReG9XAaUGLoth9YEOSepad9rpUptYdc7N6hl?= =?us-ascii?Q?+oxj7Jsh1cTiwgZCIHb7zgPMP4xufjn28DMynKNPYbo25H3jXFECcIVwp9M8?= =?us-ascii?Q?3iSzwZdFSUHVWeYdHnqBFOSO5khyEaaWVyN7Z?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0773; 6:9haCV0TkRnKZqqpfR3izy7cHZkHyPM/2sjhCDcotV9cZp+icPupciS/UbnIlXSy/A7U5tSJoZtkUEgAOEXzWd/3S4mtmZROusjGuUtgjYSqCgIXNqabsZ3AyN/Z2wZQw9cz8Ztjy6coBXHNNIqclKCL6S7W2S0On6NnOoNeiKKNLkfJb9vc053SNntvFvvcIYi7k1f8JXBK9DHuRZmY+a1zuEqy0/8NEGznEHeZkUw/OwnOzk4WA0c/ruHvxwvQmC+p4ILlzZONcTvmxgraepWFdj7C/tg7zyIP199mCyh8=; 5:TTqCSoMynCfGti6cnheiONbpy2WAg1c3VqN0kxHrENYK3XR4t5g68tJbyRKdz9hdbkDwkbV95+bgQO/f6bqQlrjwCmkPWJEouQTLamJDp5i2BKOUTdaHhBNSeelFOjWo3ZHassphTc47tT2LOy9zw3dqyruDEn4fz9mj/hde6Yg=; 24:esucrvl4t4jKT1mSM90WM3hxYNqQvGwpJQkGNQwvFdsfV0dxSRU5zW966S769HqMV3fGQfXMpd7AQFtC7M0Bh0KdzbNJoligP86yJDyKNLg=; 7:rjWZlp8U+NB4pHC3JZZG6VHivjCY+tYJ1USSTmGtAfEup5vVWkCakW/v0aN6MXGZhbtcMJYyOb4+znGLChldzwzhXMv1KtXoy0ec1FjBV0PC4ARxlCn8HWl4Lrd0nfSPJd+RFHly2NCRyWEPAPO0wLfRXGu+s0GIlVmI8RXLPMOzNUaWUCWNZ4r65RETOfOoDYpzOyNniYkKBLX9uY+9SYMHi3b89Ss3r0Io8AYBMuEtVbj/RipikMXhTvOIB0YG SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2016 07:54:40.4975 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB0773 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 Move all hw related static initializations into a separate function which helps concentrate the hw related initialization code. And that function could also be called by other places later as a basic hw state restore. e.g. suspend/resume where the hw state is possible to lost due to low power mode. Signed-off-by: Dong Aisheng Acked-by: Adrian Hunter --- drivers/mmc/host/sdhci-esdhc-imx.c | 72 +++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index bbb0bd4eac28..5a0e5dee977f 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -979,6 +979,44 @@ static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { .ops = &sdhci_esdhc_ops, }; +static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host) +{ + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); + + if (esdhc_is_usdhc(imx_data)) { + /* + * The imx6q ROM code will change the default watermark + * level setting to something insane. Change it back here. + */ + writel(ESDHC_WTMK_DEFAULT_VAL, host->ioaddr + ESDHC_WTMK_LVL); + + /* + * ROM code will change the bit burst_length_enable setting + * to zero if this usdhc is choosed to boot system. Change + * it back here, otherwise it will impact the performance a + * lot. This bit is used to enable/disable the burst length + * for the external AHB2AXI bridge, it's usefully especially + * for INCR transfer because without burst length indicator, + * the AHB2AXI bridge does not know the burst length in + * advance. And without burst length indicator, AHB INCR + * transfer can only be converted to singles on the AXI side. + */ + writel(readl(host->ioaddr + SDHCI_HOST_CONTROL) + | ESDHC_BURST_LEN_EN_INCR, + host->ioaddr + SDHCI_HOST_CONTROL); + /* + * errata ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL + * TO1.1, it's harmless for MX6SL + */ + writel(readl(host->ioaddr + 0x6c) | BIT(7), + host->ioaddr + 0x6c); + + /* disable DLL_CTRL delay line settings */ + writel(0x0, host->ioaddr + ESDHC_DLL_CTRL); + } +} + #ifdef CONFIG_OF static int sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, @@ -1176,43 +1214,11 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK | SDHCI_QUIRK_BROKEN_ADMA; - /* - * The imx6q ROM code will change the default watermark level setting - * to something insane. Change it back here. - */ if (esdhc_is_usdhc(imx_data)) { - writel(ESDHC_WTMK_DEFAULT_VAL, host->ioaddr + ESDHC_WTMK_LVL); - host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; host->mmc->caps |= MMC_CAP_1_8V_DDR; - - /* - * ROM code will change the bit burst_length_enable setting - * to zero if this usdhc is choosed to boot system. Change - * it back here, otherwise it will impact the performance a - * lot. This bit is used to enable/disable the burst length - * for the external AHB2AXI bridge, it's usefully especially - * for INCR transfer because without burst length indicator, - * the AHB2AXI bridge does not know the burst length in - * advance. And without burst length indicator, AHB INCR - * transfer can only be converted to singles on the AXI side. - */ - writel(readl(host->ioaddr + SDHCI_HOST_CONTROL) - | ESDHC_BURST_LEN_EN_INCR, - host->ioaddr + SDHCI_HOST_CONTROL); - if (!(imx_data->socdata->flags & ESDHC_FLAG_HS200)) host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200; - - /* - * errata ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL - * TO1.1, it's harmless for MX6SL - */ - writel(readl(host->ioaddr + 0x6c) | BIT(7), - host->ioaddr + 0x6c); - - /* disable DLL_CTRL delay line settings */ - writel(0x0, host->ioaddr + ESDHC_DLL_CTRL); } if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) @@ -1237,6 +1243,8 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) if (err) goto disable_clk; + sdhci_esdhc_imx_hwinit(host); + err = sdhci_add_host(host); if (err) goto disable_clk;