From patchwork Thu Mar 2 09:47:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9599793 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 D4D1960414 for ; Thu, 2 Mar 2017 10:03:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C33C92858F for ; Thu, 2 Mar 2017 10:03:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7A792859B; Thu, 2 Mar 2017 10:03: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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 064062858F for ; Thu, 2 Mar 2017 10:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eUzm0r5Op6/BNWaUpoE1jmNoy4mpfckj0nklkGs9s6s=; b=Z5tNKPkmQc6bYx 9Z8etotGWyPyIi1oNi5g8EbKbW6m6N4VZBBL+R/5w3WXYDEVpu1mUhjBSXoSI26HdPDzglBOz6oby Dr1Y8pYM2x83cIWlqhakbEqnRHpU6hNbvqGuWVRKOktzeeRMd40SbFHUCNaL8FJz976pzfjGQGkFv 3brxAkQinuJvzwFol5nd+sCKeFDkS8ytdPkFxUwcMjj4rhfniropgIktZa60cmSGPuY/jgSzNCZQZ OckV5k0e890b5H70aStYbZPXauesF81CXfuDZPQNu7kGCAgePJIOEFjLMOB3enktS82FfrlHwhmRo 9SRTGVPOjGbKtxT4AIFw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cjNZt-0003vp-9b; Thu, 02 Mar 2017 10:03:17 +0000 Received: from mail-sn1nam01on0083.outbound.protection.outlook.com ([104.47.32.83] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjNYf-00037i-2J for linux-arm-kernel@lists.infradead.org; Thu, 02 Mar 2017 10:02:03 +0000 Received: from CY1PR03CA0035.namprd03.prod.outlook.com (10.174.128.45) by BY2PR0301MB0725.namprd03.prod.outlook.com (10.160.63.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.919.13; Thu, 2 Mar 2017 10:01:35 +0000 Received: from BN1BFFO11FD046.protection.gbl (2a01:111:f400:7c10::1:137) by CY1PR03CA0035.outlook.office365.com (2603:10b6:600::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12 via Frontend Transport; Thu, 2 Mar 2017 10:01:34 +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 BN1BFFO11FD046.mail.protection.outlook.com (10.58.145.1) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.933.11 via Frontend Transport; Thu, 2 Mar 2017 10:01:34 +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 v22A1OJ6007146; Thu, 2 Mar 2017 03:01:30 -0700 From: Yangbo Lu To: , , Adrian Hunter , Rob Herring , Mark Rutland , Catalin Marinas , "Will Deacon" Subject: [PATCH 1/9] mmc: sdhci-of-esdhc: add peripheral clock support Date: Thu, 2 Mar 2017 17:47:22 +0800 Message-ID: <1488448050-7574-2-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1488448050-7574-1-git-send-email-yangbo.lu@nxp.com> References: <1488448050-7574-1-git-send-email-yangbo.lu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131329224946794117; (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)(336005)(39400400002)(39850400002)(39860400002)(39410400002)(39380400002)(39840400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(9170700003)(8936002)(50466002)(50226002)(2950100002)(33646002)(81166006)(6666003)(77096006)(48376002)(53936002)(92566002)(47776003)(50986999)(105606002)(106466001)(86362001)(76176999)(38730400002)(626004)(85426001)(5003940100001)(104016004)(8676002)(5660300001)(356003)(230783001)(305945005)(7416002)(54906002)(2906002)(189998001)(4326008)(8656002)(36756003)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0725; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; A:1; MX:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD046; 1:N5grZv3wXDAE1AbRpLsX9joLMmWROcim0wS/pkyrykITDn3UmEHG2I2hc9p978sdgUH8WpAz+UJvnchZMkz9DeHyZ2rq62L+rnpX7lbSUdo1iwx9Wt66GG8QPVvLhdLGnjTPmmfKBtI/orO78R8fXRTfoydYxLvLeVtnjMlGG7iRAc29wjs49E4i2me+Yn8Y2LZwLNv8sN8I+OiXPuWQOkuagPDo5kwFZf8RbJIr6TGlCQnkcMyhw+mlRuF8lMPr8RAxiHsmGzXHrK6b3GIpbZVsRrXaepdaWQlneqa0nRl4+TjTnmXHyxby2Haw6WDBIJzX5xwd4zA8khLcTl0AaSDeum1/zmmvAEMRyTU/y146sZCXAESUXUuOQaYaL9eC76iihN4YECGQPxtgEMhLUEqYS0aghB7VSMnueM+XyB1fG0OnVim5Jzcp3DQk1GSjxCz/bNrKc4zFLRy01BdnprDQbohrqjJmQ2TXKfpexWvxXnjRz0gX6bLCEOqjqYCEwXbs4IHRMA9g2HMgMRa/N3iS/Lp0KGQ6t805LpjvcCJ9PXs09xXzdCxKVS3d9oFwCqoznPnR1IjRAbIYy4HHPMusGbXSs34ztjYhMsJPAQ4cUDU2udd0LzLgZwk/g7ZaTrzcG5nC7/ThobvJE8ylWbB8+Qxw3nCh+39KazeG9gP9BZVzrTXG0XcndNKCmPLtZvnjTE8ZfKa2XmT3B42WgRl9x4yeBEKz1kXkJdeRPuGqS7L0UMtEXwCjWH8bwupk MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e87ee51b-65a1-4bde-5d26-08d461531c09 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BY2PR0301MB0725; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0725; 3:TxluSBzZE8pBal9cyMj0ArSLyfJzV2LYZKLMNf4wA9TTpWdhXou6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qwPQZCF/jTbKh0wbSZ0Siz6AF4Z0pvb2TaMPqYVkcTe5piUOoFAqR7swrmuaWs4A= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095060)(601004)(2401047)(8121501046)(5005006)(13015025)(13017025)(13023025)(13024025)(13018025)(10201501046)(3002001)(6055026)(6096035)(20161123561025)(20161123559025)(20161123556025)(20161123565025)(20161123563025); SRVR:BY2PR0301MB0725; BCL:0; PCL:0; RULEID:(400006); SRVR:BY2PR0301MB0725; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0725; 4:nOO1PUhJvYulvNeAp5YOJt61qJeB7sEhgZ5K2wjIBulR90beWzto9laCeisF8suDQGwqYq2CYUks4X8gIVH2NG9YqjoY6ZVnqE7Kly9Jz5Kn7wOD0VwpGoynS4ZMlQmPi1mW0UNHKWZMPb9q36ObQylQdwT4y+ncJnZU9Ij3WmpZs+TjG+wKnotuFXj3hllFBn2Drv562uXKDiqlcJvwidG5z9GOnlFH6tCo6DMM/BBlzvAzVARMvLHzXMtw0IZmumMcOej1vErTVgmwGzNCjbbdQA8UZT2bgdO88ZTFkfeCyQiNGirrJkDQ0RYVKJZCCaSe8Px8ZwiFEUSw/tcC8w2GeV68nXBIxTTg9x7DuV072YGqloTI5R8aCgNcl8Y2/6fvoglVoYI/dQdKETwv1SJAuYET11KVxTm9hNx6mw4npBTkTj/DLoSOwXCCGqILpoLC/ortEYMnMIo3rdjL6JfaLsN+jsJDbkk2+vIvadSLMAvieYiVyFjBsmatO75h89J4ZLzWf9zFLACcUWInCcAxXZ5zftyO0zX7DE/tar1deqqyVJOE8Xo7R/pG4uPw9pmvtASJz/oNfSPiUI0e0UGDXgCfQDEiNLIS5xl2SYyd+OnMtSlCL/FXQ4nwXF41IHYJ12aSqajzOApPjsJ1f9PqbWRfIbkDIMeSxamem2OTwm9aEunrzHdI7VmtgFv+o2VNPiNkALe3o8pPId3QrV026SWEylJ1OtcCQrnrmj1CZQe+3ZiirWXF+FtYahrk X-Forefront-PRVS: 023495660C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB0725; 23:e+zjrc8B3GZ9kYkS57nPBCcLWVsEgmdr+09Uprd?= =?us-ascii?Q?h76abiscodkdbzN8SYlA3u247dsNEM6/Rn4sXQ63X5KmDoqc2vhDvD/qTl9g?= =?us-ascii?Q?IVY4BRHesZs1Psbohmp1WdSP0UdFnClQFA+aW7/n12Fh2aqB0Db0STFUEL3x?= =?us-ascii?Q?aWO1VS1og7vnsrd62wJHlEzrZelbJ7YkgeYFZInbN/33zFZc/qfyyuGkXte2?= =?us-ascii?Q?nxw8OCd3m9FIbnsFR4Ar61RS15ncr7/AfG0jO6Urab4GTcMh2/+S1CXUtCfE?= =?us-ascii?Q?NvjqkWONmTW8tuzFgKaagPrqdAqpq/HzHhwu5mTzflb8RvpIUINegIQTCBxk?= =?us-ascii?Q?pKyFAAlyjBKtV4RacnqT5O9E+xhsPwa5YHYQ2WzodaOQExLQnTwqPCCLj7Ep?= =?us-ascii?Q?mUaaelHV9rUq/UtOiAg1hs5ucYl5LhcACiJVLFQSV3BJaeOs1r0sbpTlBNVe?= =?us-ascii?Q?RHLCeCk66ITC5TCaHWNvxkRGvQg+yiCSISowtWtY5r2kbgL9zcebwTWMOWhk?= =?us-ascii?Q?tgHObzjaLdsO+jhzE1KY7HH6tgvyAOXNuVJ3Ix8v5QVYn5uP69ATmpzLhCfi?= =?us-ascii?Q?9XZAkpomjPHajIJWZtLb+qXry7pYs7ux3T0n91NzBA3AE+Q3rBKv0cKFcJBH?= =?us-ascii?Q?F4bJkCMT7xRB2LLFbjsjju+Uw0QCr7ISqsTNn1dAZJTlYspjvZr7YuUFgUkB?= =?us-ascii?Q?oawP5+870nnwgwoR83WyMW2j//ufCS3KheqQJ7wTPlHxPW8+qfcLBGOIo4Ll?= =?us-ascii?Q?+iVMVrRDQTHnQwZ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h0tUNWjSngCTbM=; 5:YjRbMwLjJJlnZXv5i8PGaI/LN6R5fi+QHxOsMl95O9TI5p1VQztO2FbAu5IbU/ZvwDxkGNLcwT4VarasBUc16FcWIG3RufIKslAQWdxkdHPdYDAA6PmSJAb+yE+w3B8Z48K96fGPFF4P5pRFyuStTNym66SA1rRVOGY64uW+k+tR4tHl2VKPBSHFk3eBPAvz; 24:k+YoP97iBdVS4RMANGhIbJgYZWVHQqqYgza1YAEp0qfoTUapuOasHLOs+vdRQ9Pe1SaSX8kp855EAZNozr162LXf7sJqsqw+TDpyNAJvgZ8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0725; 7:n57PbxDBEoXIeDPnfkBGXrWl0WoT9qG4kfb0O9UReLNCvAJHnQdvF1liXb4/DTJwiyUwp7Pw+hgk2RtJP47BnFzrw1gicydvyJaecGP4SHxo5kOD+sAWQ/Ku1AZAFeNnisekcPFAOu+EdsPj96mMNYkP776dOijwXvPzrbt9NeSQNVAfJnactKeONSsE9HY4+z++5GxPCa7lmu31FR8vkjwha2nsvsTijp5HAUTC5VMv+VPIu1e8Rr73bvsRf2sTcbob2fKuStm3aF9EUlJZa9SKI9WKfZfONu5Z3atitatTsaHnq6Cbd7D6jU28P112Pq0mTiGyru48PVY9weK/dQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2017 10:01:34.4454 (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: BY2PR0301MB0725 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170302_020201_319361_097F80B4 X-CRM114-Status: GOOD ( 21.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Xiaobo Xie , linux-arm-kernel@lists.infradead.org, Yangbo Lu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP eSDHC could select peripheral clock or platform clock as clock source by the PCS bit of eSDHC Control Register, and this bit couldn't be reset by software reset for all. In default, the platform clock is used. But we have to use peripheral clock since it has a higher frequency to support eMMC HS200 mode and SD UHS-I mode. This patch is to add peripheral clock support and use it instead of platform clock if it's declared in eSDHC dts node. Signed-off-by: Yangbo Lu --- drivers/mmc/host/sdhci-esdhc.h | 1 + drivers/mmc/host/sdhci-of-esdhc.c | 70 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h index ece8b37..5343fc0 100644 --- a/drivers/mmc/host/sdhci-esdhc.h +++ b/drivers/mmc/host/sdhci-esdhc.h @@ -54,6 +54,7 @@ /* Control Register for DMA transfer */ #define ESDHC_DMA_SYSCTL 0x40c +#define ESDHC_PERIPHERAL_CLK_SEL 0x00080000 #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 d3aa671..84865b0 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "sdhci-pltfm.h" #include "sdhci-esdhc.h" @@ -30,6 +31,7 @@ struct sdhci_esdhc { u8 vendor_ver; u8 spec_ver; bool quirk_incorrect_hostver; + unsigned int peripheral_clock; }; /** @@ -414,15 +416,25 @@ static int esdhc_of_enable_dma(struct sdhci_host *host) static unsigned int esdhc_of_get_max_clock(struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); - return pltfm_host->clock; + if (esdhc->peripheral_clock) + return esdhc->peripheral_clock; + else + return pltfm_host->clock; } static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); + struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); + unsigned int clock; - return pltfm_host->clock / 256 / 16; + if (esdhc->peripheral_clock) + clock = esdhc->peripheral_clock; + else + clock = pltfm_host->clock; + return clock / 256 / 16; } static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock) @@ -512,6 +524,33 @@ static void esdhc_pltfm_set_bus_width(struct sdhci_host *host, int width) sdhci_writel(host, ctrl, ESDHC_PROCTL); } +static void esdhc_clock_enable(struct sdhci_host *host, bool enable) +{ + u32 val; + u32 timeout; + + val = sdhci_readl(host, ESDHC_SYSTEM_CONTROL); + + if (enable) + val |= ESDHC_CLOCK_SDCLKEN; + else + val &= ~ESDHC_CLOCK_SDCLKEN; + + sdhci_writel(host, val, ESDHC_SYSTEM_CONTROL); + + timeout = 20; + val = ESDHC_CLOCK_STABLE; + while (!(sdhci_readl(host, ESDHC_PRSSTAT) & val)) { + if (timeout == 0) { + pr_err("%s: Internal clock never stabilised.\n", + mmc_hostname(host->mmc)); + break; + } + timeout--; + mdelay(1); + } +} + static void esdhc_reset(struct sdhci_host *host, u8 mask) { sdhci_reset(host, mask); @@ -610,6 +649,9 @@ static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host; struct sdhci_esdhc *esdhc; + struct device_node *np; + struct clk *clk; + u32 val; u16 host_ver; pltfm_host = sdhci_priv(host); @@ -623,6 +665,30 @@ static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host) esdhc->quirk_incorrect_hostver = true; else esdhc->quirk_incorrect_hostver = false; + + np = pdev->dev.of_node; + clk = of_clk_get(np, 0); + if (!IS_ERR(clk)) { + /* + * esdhc->peripheral_clock would be assigned with a value + * which is eSDHC base clock when use periperal clock. + * For ls1046a, the clock value got by common clk API is + * peripheral clock while the eSDHC base clock is 1/2 + * peripheral clock. + */ + if (of_device_is_compatible(np, "fsl,ls1046a-esdhc")) + esdhc->peripheral_clock = clk_get_rate(clk) / 2; + else + esdhc->peripheral_clock = clk_get_rate(clk); + } + + if (esdhc->peripheral_clock) { + esdhc_clock_enable(host, false); + val = sdhci_readl(host, ESDHC_DMA_SYSCTL); + val |= ESDHC_PERIPHERAL_CLK_SEL; + sdhci_writel(host, val, ESDHC_DMA_SYSCTL); + esdhc_clock_enable(host, true); + } } static int sdhci_esdhc_probe(struct platform_device *pdev)