From patchwork Tue Apr 11 05:10:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9674567 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 9E9F960381 for ; Tue, 11 Apr 2017 05:25:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 908DB28450 for ; Tue, 11 Apr 2017 05:25:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 851A6284D9; Tue, 11 Apr 2017 05:25:23 +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 2089128450 for ; Tue, 11 Apr 2017 05:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753238AbdDKFZW (ORCPT ); Tue, 11 Apr 2017 01:25:22 -0400 Received: from mail-sn1nam01on0085.outbound.protection.outlook.com ([104.47.32.85]:11249 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752179AbdDKFZU (ORCPT ); Tue, 11 Apr 2017 01:25:20 -0400 Received: from BN6PR03CA0044.namprd03.prod.outlook.com (10.175.124.30) by BN3PR03MB2276.namprd03.prod.outlook.com (10.166.74.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17; Tue, 11 Apr 2017 05:25:18 +0000 Received: from BY2FFO11OLC007.protection.gbl (2a01:111:f400:7c0c::121) by BN6PR03CA0044.outlook.office365.com (2603:10b6:404:10c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1019.17 via Frontend Transport; Tue, 11 Apr 2017 05:25:18 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.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 BY2FFO11OLC007.mail.protection.outlook.com (10.1.14.254) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1019.14 via Frontend Transport; Tue, 11 Apr 2017 05:25:17 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v3B5P7pA017167; Mon, 10 Apr 2017 22:25:15 -0700 From: Yangbo Lu To: , , Adrian Hunter CC: Xiaobo Xie , Yangbo Lu Subject: [v4, 3/5] mmc: sdhci-of-esdhc: add tuning support Date: Tue, 11 Apr 2017 13:10:29 +0800 Message-ID: <1491887431-31894-4-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1491887431-31894-1-git-send-email-yangbo.lu@nxp.com> References: <1491887431-31894-1-git-send-email-yangbo.lu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131363619178211852; (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)(336005)(39380400002)(39850400002)(39400400002)(39860400002)(39840400002)(39450400003)(39410400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(50466002)(48376002)(4326008)(104016004)(2906002)(47776003)(38730400002)(50986999)(36756003)(76176999)(105606002)(106466001)(33646002)(189998001)(356003)(86362001)(305945005)(77096006)(53936002)(81166006)(8676002)(8656002)(54906002)(5660300001)(50226002)(8936002)(6666003)(230783001)(2950100002)(5003940100001)(85426001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR03MB2276; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11OLC007; 1:frVanXLojoFguVG7x9rgrrIQ6RRMRLqqTHp/tM19LHi63WRiF4C7doJoADkimDrjIeu1ySgDOrX6cJba7MH/P2lBwL+uMzSqG4Duyewu+d+ymNgYeXt33CR0A3T9WP3wWJftZemxWyCghcY4ftPDnJjeot7nix2YPFvW0smNOJ75ClrQI8/3oHrHrhvbkQB5AbSqGl/AV01UI4gBb5xF//Y3gNfnaQqWRszH1rjADUAfwG+uEv7/uCfv6S00XoU1WE2zUwwBWl05gw0PPNURRk4lxHCEfpInTsGszj18rPRJ3s8SB5iHXbuT264mJBi/Gir1SAEpgpb2ULGlYJyiEsdmOg/5LxjQecHhgJFxbgSyfCWwilG3zxL4Y+l53crYCrUna7mF+9/DHdpu1EDVeAKAFo5bQIe/D6uTWNJutYw3Mn5p5af6Drk/FLjhrm4dqXIdzlJ1S2dybhd96a5eZuQoofgvX1hPhqqd8JmTrnvkcxytkt8OpHK3tFpUK0q5mkfFguiSy72zl3R0zpw5ZOQv3soOCLoJNXN3UHjQVtTY0seKor3c8k3XNqlHXWb6WcFQoiyaEs7PZbUmckldFy9Ny6hW98UqZYP3vKH73AImBk8pPeUsNS1GGdDXuObyMv/n0VxfLKg4GnWsa40d8IZ8tBfyBQxn8rSMR+v2ZlIyk4xGJY6MRUMxm+BO34JVYsKfWOjJxigcjMbvQN+nbgyODqr4sMIBrdoEpzEWmDwiVssUtYeSonKS4pyNNnPbunACpBllY2agtF5l/1O3wQ== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: dbe67f29-4def-47b8-88ad-08d4809b23fb X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:BN3PR03MB2276; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2276; 3:SKKfN7u78Ri40j0dBXaTtMzN9LNFrk5NEcwSJn7HGgfEmHSMD3kQ2GNnUi5GC6/Xwx/7ZkiXH8p/xP8Brw1IfBLiT1AY9q+PZBQYYTNt9Wznho7S/dIYIGHLg3TunkYCtUkKpkytPFgeY1IKhGKcfeftlhaS9IYsWVt3rtiGq+lYuggdp/GWA7BaGYOmqb0P26R7g/xmvyTaEVPXwHBlruLzcQH3xgZMUDRPW6v7px/tHGEBECUXEiNW0OtKodpb7VnZNplItE0lgWo8yCaFTfHx50lASptFkBYQlIEZ40LzLpCc+51eIRrooNCtMn6OezNN4x44z5P6JAHQqtKH/vxDhCSqnkOyMqTkg8KIirtd6uBfkmx37vFZVYidHSvbdZtcH+eoR5fvNJ4pt0VydWYjJN1at7jl4URjzQ2XtJFx8lpWRJjLbTl/TftspNno; 25:t8tP99VELHpoAnh+rouEbcESJhOm3uB09cIpJBKIJQAVXfVyrB5jweq8CqV2Fv/lBZHnPVyjH3KPNK4B92YIuDb1wy4u0vvchk2bKRAkiC/AB47s+RX5wAjmsRYNNCR0nihJqkruSgg1NESzgtKa7zDcswAiPJQ89yksDE4VvbTxRCyvE2uRXmQuuGN3Jw0PIpNfdIfXsEv9ysIOCBX81PqbluPCzYYSkFu1sv7Cb/Sof2qRldBjLEr+kyPq+SaNjI+uFBUyL4SSi1lEmssgBwvMwDYD2OCwcN70dSfxNDAel9HWE/+WzhVdGucVBtKWc4m1W/a7NmPuYvFoApGiepCyTxWdem32YCQ0lTsqjPdVqfn+6sg9Sk/aVJ5CHIxPXeiVYeop4sxG2f+XnJUw94Askq0fZg4ueY8KaAtGj17Wb+P5PuFl6WX9Gw04YUNQcNWZueyL8g81D0pWKfST3Q== X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2276; 31:Av9yv0IWPIrB2F8JxIwH9PFWDO64zt3WMrg6gtGzkcoyvzzPgxeYI7dU7xztQ5RvCBoEP2T3uiDwT68r885hhipbNzcBLIioC9Jft/mRLVwrxMGtuApMD/H1/g9yJgbp8fPbOmLQT2RaYVOBrvt18wvDMQdzWMH8rVWiCU+C5DBCiwVvJ9S5ob65DfSgUdRrXwklCwQrfDWXqrhWOHSrweku+KYVvxrn1cnbd2hEAmmhf5zn4Q/HEnjMkqltNuFKMShUN4yhkTaZWjJOlXbMpWBnowINmZ/7c/aB5ovXscs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(13017025)(13024025)(13023025)(13018025)(13015025)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(6055026)(6096035)(20161123563025)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259075)(20161123556025)(20161123565025)(20161123561025); SRVR:BN3PR03MB2276; BCL:0; PCL:0; RULEID:(400006); SRVR:BN3PR03MB2276; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB2276; 4:Y3yE1++PF6VOBUinrdMxlcE9zB8Zo+SZcr15gFEw4COC95VT6pVDvDm6+imDhNOXWM4+FsLrF9d3Qy+ljKnJ0/iSC5jKcZe1MYDi3xRTI5RDQwmnpKKRkX4MyUCh6eBHc+ZdgiusfulOis02ORnTfxtNZivVVl//9F5R2xcsYUt4UeZlBHORh67No7FWyHXZtk2T1H7fviuwyiKMsD1uOC8b2jV2jzL+5mheH6fhRzBWA0DyC/AhEtwg/0BDNAqUUZjpmPckt3PkUK1Tzi0aDJRz31wmDeKdNXnA+p6uxu8uUEzyuSH2RlzxMNaGXvxI+LVyVSTx9jc+00ogz6C/rMnIOlnbr+5vsMxU5dx+UPzHb0RfhBUozwSs0Fhf0p2a337soPdmaYtnoYxw8rmIlQ8DdttKUV+bO/XhR2vRWPhcFVuDkjHWcPiItkMA3BMDNNmYQ4pFdfurpVu0mH3d2OC4HOd9drzPnC4xmo74dH94xDIMWlNatO/RmauwJltcZnuFATkKMlmGwhAOikaitCkAeMw4czbh8aPuZWlS1fmMKWpUsHDnjq9g9RyCwIveqccDty3orM8Qobd06zWJMw3HaI/rBuHzX4ETB/WbrVpOwRNZXQ7aFIOSJ+MHm9obWVpMzWjlJ0kP7H2cv8O43Kh2OJ//coA6EoLkXlIN2CCXsJ37Z58cSsPuFD5B+317EKUBs4u1KvzzdFOJxN7G8lsADYyS93INNULoP/sducCGmCixreNmEOQThnfrhhaFhGbSlaY3Poa4heCzhZws58njQsUbM2j6JARFYmrGn0fT+xLSoffR0SkD134T76hnxe0nFTYwJqyVRkYIUSOzG4jyWKjp37sxZL+/Eek4mYztcBN8yh35HC3QZuxyISOrndw8XVOOoniwV5pLxj0LfaSzveTBWW7ARoLbFSjwWR c= X-Forefront-PRVS: 0274272F87 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR03MB2276; 23:P1iboEAWyfzqjnYLaGt0Xg7m92eroew6+VGr6GMT5?= =?us-ascii?Q?EWJzz5dqjj6FktQMgxJVvwvDBFNVnUc4b9rE+lC0eArO5mgUyc3tBS5Yakdm?= =?us-ascii?Q?bmp9LQwxg8XhZMo5cp8Bj6G8aA57OTR93bocCisDZSMTUpsCPOoIaw60sFra?= =?us-ascii?Q?dLeGr7pR62HppXSgAAhW9QwBpn/+3QypspX+CFUbP1Iy29iJxXfGV0KNENxU?= =?us-ascii?Q?Og0HWePHsFIvPjsamJrDO8ewNCjuBwiaPcWIW/ABFy3UwoFa/OaZTI9xp5vr?= =?us-ascii?Q?M/L03VWIxcVICYEkB2l1jgiZu5OCvRZ/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DxRmPHWhRyj/J29982CqvL7tEOToyDB8aTvd6Xk4PggGGgkT1ruy2mIBeMvyROoK4krBzjxyOAcpf6ydna2qKGcaFUjNgaJqHtGWnmLX3STEJCwJorSMcnk2qS6+22H3jITFwME3+VGDF166uDBT17liL/u219+Z5JTH3d0oxrikvmOc/XujssuS6OX4zBwl2OCRHuudw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2017 05:25:17.6183 (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: BN3PR03MB2276 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 eSDHC uses tuning block for tuning procedure. So the tuning block control register must be configured properly before tuning. Signed-off-by: Yangbo Lu Acked-by: Adrian Hunter --- Changes for v2: - Replaced old function for mmc_host_ops.execute_tuning with esdhc_execute_tuning to support eSDHC tuning. Changes for v3: - Put .execute_tuning assigning after after IS_ERR(host) check. Changes for v4: - None --- drivers/mmc/host/sdhci-esdhc.h | 5 +++++ drivers/mmc/host/sdhci-of-esdhc.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h index 6869567..c4bbd74 100644 --- a/drivers/mmc/host/sdhci-esdhc.h +++ b/drivers/mmc/host/sdhci-esdhc.h @@ -53,9 +53,14 @@ #define ESDHC_CLOCK_HCKEN 0x00000002 #define ESDHC_CLOCK_IPGEN 0x00000001 +/* Tuning Block Control Register */ +#define ESDHC_TBCTL 0x120 +#define ESDHC_TB_EN 0x00000004 + /* Control Register for DMA transfer */ #define ESDHC_DMA_SYSCTL 0x40c #define ESDHC_PERIPHERAL_CLK_SEL 0x00080000 +#define ESDHC_FLUSH_ASYNC_FIFO 0x00040000 #define ESDHC_DMA_SNOOP 0x00000040 #endif /* _DRIVERS_MMC_SDHCI_ESDHC_H */ diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index 4dd28c3..80dc802 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -630,6 +630,25 @@ static int esdhc_signal_voltage_switch(struct mmc_host *mmc, } } +static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode) +{ + struct sdhci_host *host = mmc_priv(mmc); + u32 val; + + /* Use tuning block for tuning procedure */ + esdhc_clock_enable(host, false); + val = sdhci_readl(host, ESDHC_DMA_SYSCTL); + val |= ESDHC_FLUSH_ASYNC_FIFO; + sdhci_writel(host, val, ESDHC_DMA_SYSCTL); + + val = sdhci_readl(host, ESDHC_TBCTL); + val |= ESDHC_TB_EN; + sdhci_writel(host, val, ESDHC_TBCTL); + esdhc_clock_enable(host, true); + + return sdhci_execute_tuning(mmc, opcode); +} + #ifdef CONFIG_PM_SLEEP static u32 esdhc_proctl; static int esdhc_of_suspend(struct device *dev) @@ -789,6 +808,7 @@ static int sdhci_esdhc_probe(struct platform_device *pdev) host->mmc_host_ops.start_signal_voltage_switch = esdhc_signal_voltage_switch; + host->mmc_host_ops.execute_tuning = esdhc_execute_tuning; esdhc_init(pdev, host);