From patchwork Fri Mar 3 08:18:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9602203 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 2E2ED60453 for ; Fri, 3 Mar 2017 08:36:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20AFF28630 for ; Fri, 3 Mar 2017 08:36:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 146E028632; Fri, 3 Mar 2017 08:36:54 +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 64FE628630 for ; Fri, 3 Mar 2017 08:36:53 +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=NPNn+m/hY31bxqYb0rhge6yKuRKx1gGE+Q12EAQpdWY=; b=q307AUY+Ruv9SY 7Pkqzb9AIyiT4IACQp3k4wKrrIrdaznqOFizEC9Zt/KIX4sfauy6u2Gs3AKmNzhDjlYx6/hYuwJFO 60XLj5tiTbZAjjxf9o2DYakMvp1VbERXU4FpUNaO/Vpsb+sjlZY8xNeRJ80/PS2zF6IG2A3SFHPAC hs7LntEdFMFAdJokU9dRSZ23Rv2lNcSqOZg1NwTRZ9ZSPzWHfTJOrle5q6tsF2sU5YjmRG36o+Yg/ 9kIflFLCV7M2L6dxyE4l7KqrelXDF8chP5TBcgGbE5Ni3OlWZXm0HOshfhBTso/xvt/5E7H6K/gHD nuFjkdhng0/d/w1IHpAQ==; 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 1cjiho-0001p1-PP; Fri, 03 Mar 2017 08:36:52 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjifp-0007Xa-IQ for linux-arm-kernel@bombadil.infradead.org; Fri, 03 Mar 2017 08:34:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3VWsumW+uag1eH9HzAlwdJQcSgq675y2+y1ZEWuBwbg=; b=M02pgcZ2l3+f1wPBb8XIRhKlq cZjQ+rk9Y0ZvfPG1oZLH8tuK0VA7tiPIuspuF/+wEtRT9uCz+xMNFCA9IuHToPrJkgJdmXXyZn+lk N54gh+/xUxQO3iavUsrPLzauM+Don3Szk3/vlM8Civ5KXatNEtC2u8tbZKS0OgQx8cdL4w8xLQL34 gy6uY45455bsE8Isj5zqRahaqFZnOBrVRU4XEcdOTpvLq1/+LTB69jlP0s7QPZ8HoAYDW68ADLObB SDUV+sbTiqPgJufB/U6TWbPKNlCbbBsM7VPuTNpdwqk+3WrXIO37FkNW4jUlg8j0PVc25BgBklwNK Z069tkcRQ==; Received: from mail-sn1nam01on0061.outbound.protection.outlook.com ([104.47.32.61] helo=NAM01-SN1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjifm-0007b3-Pt for linux-arm-kernel@lists.infradead.org; Fri, 03 Mar 2017 08:34:48 +0000 Received: from BN6PR03CA0069.namprd03.prod.outlook.com (10.173.137.31) by BN1PR0301MB0721.namprd03.prod.outlook.com (10.160.78.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.947.12; Fri, 3 Mar 2017 08:32:54 +0000 Received: from BY2FFO11FD041.protection.gbl (2a01:111:f400:7c0c::154) by BN6PR03CA0069.outlook.office365.com (2603:10b6:404:4c::31) 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; Fri, 3 Mar 2017 08:32:53 +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 BY2FFO11FD041.mail.protection.outlook.com (10.1.14.226) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.933.11 via Frontend Transport; Fri, 3 Mar 2017 08:32:53 +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 v238WhMl019793; Fri, 3 Mar 2017 01:32:49 -0700 From: Yangbo Lu To: , , Adrian Hunter , Rob Herring , Mark Rutland , Catalin Marinas , "Will Deacon" Subject: [v2, 1/7] mmc: sdhci-of-esdhc: add peripheral clock support Date: Fri, 3 Mar 2017 16:18:43 +0800 Message-ID: <1488529129-23560-2-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1488529129-23560-1-git-send-email-yangbo.lu@nxp.com> References: <1488529129-23560-1-git-send-email-yangbo.lu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131330035737784663; (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)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(9170700003)(305945005)(356003)(7416002)(2906002)(626004)(104016004)(5003940100001)(105606002)(8676002)(81166006)(106466001)(77096006)(47776003)(85426001)(2950100002)(6666003)(86362001)(5660300001)(8656002)(54906002)(33646002)(92566002)(4326008)(76176999)(50986999)(38730400002)(53936002)(189998001)(230783001)(36756003)(48376002)(8936002)(50226002)(50466002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0301MB0721; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD041; 1:U64lS3siSMJKyWvyCw6y+7NUZf3BgzBJNOUwCXyIin3h8pIHxgESrdhGOAGj7SeEPMXYaJiKfnn1SWrweEKK6xghi2RnvT6OSygicWF0TwZncH/1rWEXPS4gARJ7GqV0Zaao/X3fXq65xtUqY9RqelJQiaD8uKmoeDNWzmDMEVX1VNC/87vivcFoD4MUdwdZkddm/sLv8uFnxusempftg3dX4aaxKost6pc78altWcEAFsXfro4wiVg1izL1LJx7wt5KOTxVwjY4ULChiaETQjtXiszQXdAgPK7H8yTiR7hOHEG9KQhnl6qvS97UukKJ7NGcWJUg/5tc0yDazXwoJsx0PVcTmXufc6IADjJ9KPi7pxNO6O1WLGIWnyxtUZHN4mxOiP1orN73TZ24gk78e8yFujHnCUd7cKqAzbvX6YPLOHUF4e74Bz1vOZVr9rdYsSf8WEZW9EtQ/P8jWa3MJqfGNdfhrmx+VS+lwOcPPKmhAepMRPAQOEpWCW/7+yt+8lM3wVaRl2yWK1HYJNvxlLLer9GqVjDOm8VJUoHYiDJLKjbmdixBwRjYaUNYRDsQuR4HIlDuAaodcquTqrI/A8ibY8zIBH4gpSAFkc+SWh+VN5vg28+NwOv1qlQt9+7iybNHVLFpRSGOHEghgOdd0u28u0N8dnq99xoze3AbJ2ok/waOwX/UeNTu5ngc/vk0E3GDEFu5qjhGbVmQDyRHjszp5Ba+IkCbpy66XDMQMoum2codJNIb7ti5qDBYg60F MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 00b7019f-c94f-436b-04f7-08d4620fe2df X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN1PR0301MB0721; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0721; 3:NovoLCVYKrLyPmvhbPX8Q/npHxALNuXd77IfEAgaBD5ABbAYS9zFWLodPyPOJ8MXLMnDdByb+l16Ncj/DTWpqy19dzP8fA/VSisFaGVCciLj6tn5apVBE4hMzgS5AZLLopus/yUbv7sTz4tPo3IUAMm9rv6n8o1hTxGunODHVKPfUthKIL8zFWhHVdqB1IS/DSCbcHF+8lSD0ok+DruEneuGfdLEU+ymINmLAElv7GGV3g6PcWDu0YZu6vs9H0sLmekvyLLt1/dOET2o05ua7sECx5WH5j6idDbGrvAiEe9PCW9rePPdPQsS+uuPPHjnAr9WMBSiel+YZ38z/26mqU5XNot5hV89f0gmPqlfmkaUawzyFHBn3gdwZMeX12RZ; 25:SbpxLvO3oR8JtnsWJz26DtSsazvOhlypp8ufNz4f5/J8u86WLQjXdjjUvJd52BnYwaQP8DCy9RwKtECpgyPcyLCEkVIeSZWU6DGOA7HjSe3zpqsblPorHrqNxcjzXt/sm1KX4cdU8gLnHHuHvpn8b+hqyzysMuy1T+CVO/3eY4m8vnQD3wzuUy8faHvCP/Auo6JivwXvsnAwajW8Ump+JMkQJir26q9qWAhPTYzLUHYAnpr9ZEprrfOsESBfyjMguJp+Q665/RRzPDu+8aU9HLJg7NAQhhHT2c7z/9lKvn231J/2zWPBiFTLaUFuNEX7g1v+xnEZW6ICDZR4loCj+UiRaOTkIbI6LOuWCmEQqqplN3CLKV/TOkcK+lRlZiNJb6fTRGToNzFHEhS+QMMhISLWy8dJ/+M0mTYfmo39cWxJ00DuEDFfgkeuQMfbazoAVUVMSwowBAXUJWFN4lc9qw== X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0721; 31:a7OWqVW9g8YV7ol/TrpPFEVSVUGozdIOry1j9QapPd9uV6K5PPCnKBF1h8miekGNJ4wEZmalm+dWhvbPHjmR/IlIi8LAfQkjeh2pwhk6Phg8mQ6/mugo+NCboRSeO+pJmGz9HSsb8O6esN2SJ5HeMgsUdUOG10qC0SQp95uDyt6Mi92DVvFBR3UrWdZRTCpAh2dk3bv9gq6KP+yNHeglMg5ZkjdwuojSjtuA51VfeNDk9kgr1w/twz0JaR7Gnk081dXWHPfWSjpWLYtVB+VE+A== 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)(13017025)(13023025)(13024025)(13018025)(13015025)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123563025)(20161123561025)(20161123559025)(20161123556025); SRVR:BN1PR0301MB0721; BCL:0; PCL:0; RULEID:(400006); SRVR:BN1PR0301MB0721; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0721; 4:OwEu2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li/l8=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0721; 6:xPHneqLWRg3WX9He+HoHvRDSbjf6Fsu4gn55uFVTKKwZpO+2pzgbRoasre4R2/GVWwIFusJhJ666WALhZmukwJXSBCdMFY4iknIvi3h1mBX9kVhnQxsiP5hAdcjV7E9e7f+2CtJTyjfF5C6PZti5KAzLZ13DgN6qUAWlkXBDUKJWSD+REiBWl5SVXTOoO1CAm6BLbswnguTt7bGVf9aXIfdh1m/OPE+qO0Qs3D0eoKqYEsb8rm8x7mIySNkrVMNQHaf3eKiH5j9BmitpPqOsAqxwXmusO38dJEUa4EVv0sFcFwc1vY3piUsmo3BrkMgutXkmFiMZaMFK+nPX42Om0kKyzme7FQpIBmJrZed0TyR13xDSMZPdwbRcHZRE2jvs/3e0ceKr1NiM2rxphfQqblfsxPghbVMPLBmzWXtmnqA=; 5:Tkz3oMJCvDQmR++tIOC9duj8saz3wPFu7BO+M2yP3OxT03pSL3K5c1z+Nwcv0hSQipp0D1a+ulVOmxkn+qQ98b7hXFNMIU9c5FpGFJF9aRKvWk5wyFm7lRYcK2hpLmO5TtDxrJ2fkDcUtDvtJaLYldcmv2NajmQ2vg5sIJNGLNQKttjY1oHQ7NNZVWlBuOu5; 24:rfje/EiVoMRUqlYKFXcNFG/m666RTBh9gMVinCgs3RZVsMInktcc4MmTgC3OIE0ReHb9ed0fQMVJl60PoHLjykQ8EkGypJIJdN6dA2tdz/4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN1PR0301MB0721; 7:caOXuVMtARxCuQDIhSKj2HwnTjxfOTpxNnbwFJ/X2iKKQApWpWKSloj3rXfcBeKKkag5/LxWDAHSrbCjggUWLXNks27vxgHb2n+uw1o3LDontVewgsrjrKN1spYUXuuQMq3WWlw7AwSDTZ0eiGZ0PrAsT76QkCMt6ogJL26p6ZKOn3NYR2sgl4/TyZHtJ+ZuLUvOfi8j+6kSMGpbygjrXgkN6yjoAFhq2HEH385vMu/O1zFmGmGMV5K98Ixz2hJw2csusICd6B4FvyI/ZtaAg1bBdqSUrkwwZ6FGTMuz4CjifZNlxV5xhbbrlPa96sGHivP7/l8bbwyXOQ7X0pPRHA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2017 08:32:53.4508 (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: BN1PR0301MB0721 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170303_033447_038823_856E1479 X-CRM114-Status: GOOD ( 24.23 ) 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 --- Changes for v2: - None --- 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)