From patchwork Tue Sep 15 09:07:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 7182011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 242A6BEEC1 for ; Tue, 15 Sep 2015 09:15:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03490205EA for ; Tue, 15 Sep 2015 09:15:23 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D68F52042C for ; Tue, 15 Sep 2015 09:15:21 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbmIy-00028n-OS; Tue, 15 Sep 2015 09:13:36 +0000 Received: from mail-bn1on0144.outbound.protection.outlook.com ([157.56.110.144] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZbmIu-0001A0-NM for linux-arm-kernel@lists.infradead.org; Tue, 15 Sep 2015 09:13:33 +0000 Received: from BN3PR0301CA0005.namprd03.prod.outlook.com (10.160.180.143) by CY1PR0301MB1291.namprd03.prod.outlook.com (10.161.213.153) with Microsoft SMTP Server (TLS) id 15.1.262.15; Tue, 15 Sep 2015 09:13:07 +0000 Received: from BY2FFO11FD028.protection.gbl (2a01:111:f400:7c0c::171) by BN3PR0301CA0005.outlook.office365.com (2a01:111:e400:4000::15) with Microsoft SMTP Server (TLS) id 15.1.268.17 via Frontend Transport; Tue, 15 Sep 2015 09:13:07 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BY2FFO11FD028.mail.protection.outlook.com (10.1.15.217) with Microsoft SMTP Server (TLS) id 15.1.262.18 via Frontend Transport; Tue, 15 Sep 2015 09:13:06 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t8F9D2k2005573; Tue, 15 Sep 2015 02:13:03 -0700 From: Dongsheng Wang To: Subject: [PATCH v2] arm/ls1021a: Add Sleep feature for ls1021 Date: Tue, 15 Sep 2015 17:07:10 +0800 Message-ID: <1442308030-21231-1-git-send-email-dongsheng.wang@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD028; 1:PwYUeFIDavHr8XYistnYlcecaMdOd9uzPo9a96eRyeOz9+DADiYid9RQCtA7ibleh1Y672n45J7zz0zuXsgnh6QskO2Izx2ZojyEEfiCNusOKw2peHLnO4tZyb3V8ttwep9NXmhhT1pWBmBMfJytXSnGvsA7dWBAGjj3/3eHVdbDtEcLaPpZndeBzRaDDsLEEsOgsIhnlSCfpCrjEBXQlW+8n0KDLmL16Gi7UoTuh/uYWhdkHB6Ox68gmLF/GalBRwHO4fOWgQExj33rTwhnGPVMRKmSxhdUFJ6px18CJWj6cKINCLIj+ZiUbXNpjGzypB7NEuHlUBwsn/EYzlbtJEM1Mizdb4fjv960NLCIdSLRh2IgOa01xgVF0kqvWsT2A5jtnEZnsxV/YFhBQLqzaQ== X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(77156002)(105606002)(106466001)(87936001)(85426001)(189998001)(229853001)(104016003)(86362001)(68736005)(48376002)(5001830100001)(6806004)(69596002)(47776003)(19580405001)(64706001)(5003940100001)(50466002)(46102003)(50986999)(5001960100002)(62966003)(110136002)(107886002)(19580395003)(2351001)(33646002)(77096005)(97736004)(81156007)(50226001)(36756003)(5001860100001)(92566002)(4001540100001)(11100500001)(5007970100001)(2004002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1291; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1291; 2:Nk/uJgO3tvnYecAyUAmNI8n95xW7hAIf6rEZls1VJaQNmQHo2LENdalHdYmj0ILOjCHtit0kLnD1Ye7rN6C/ZvHvys24ba6QDkHbvBgCCKTKeWtdVA7cW1b1JAc9TODFAdBmV1OclbNL1UdxCf0F8N5bjf3ur8OwXssNRYE8jTA=; 3:5+NSAhTZvTo382RjNwbgy3Zwr+vC6lBAmCRBgOyMUM2TqrUYlXqtQjn1Oo92PN390XEDSW5OnZ5U67fMyax2XGqbZ+FMlXQCpMls7edNHKohxMcrQgCquErLhlbHPlLCCSfCjmmXtTuFX6ScRmpu910dcGLnkOXrUrD9C0TYvOLm1IJUIBBwcPHLLDzSBcqpu5aB3WBIUSZTPPsLD3YI2X0OhFbUxbBtWZopI17ajgs=; 25:+v4SwJ6SuiMZKtp1fkqR9t7HmDmqhp5oYLZQlYXEFqKaasEEf5ioyWawhEoUNe5TmWqPAEVPuL+XzIlLIncsUP0Grpo39QxS4KqXTaX32j+L8ZC7+9m7rxekBjWfvC+JRBd7EzMCIZncHocQThmgZezB/e78LPOxaoVlyi9xlJm084R0BlEKPA7gLu3EwrI6xP8lckJ50mS+1URfztzHCZKeCeg6d9FO3Bnc3iMFbG0Gym4puCNcqQNTZb86IoZe X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1291; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1291; 20:SLShELcoOGANNkDu9U8d5Fhhq1bKPCAQON96YwkXN83/6vMFSly78eNy/4FgN87Athq6orcfiVR+xJEJmkDkc8GfVPBM7mv+xM6bNnXG9YZltceZ7Dpb821tktTLYCY/isv+IcFdvI24/XuXl2Y9iC6zMmUgsqN6Qsowy3ovzJ2JtfmSMN1ZRF6RFIrIVNjlBzbNUE77ltOTxNIva+0J4vXNhMRh42695BvgOR4XatTzD+DHdjzgitXD0awAJscggK0+D+OEaC1Tf4kwKOoceXkUTHSuKRwcucAVZ97yzCCyG6BaKXhr0VPh7QAwdgkpYbX6T4nOWuQ9Ts0w4HoU8zkx/Fjdi21qW/arCM97V3Y=; 4:1bOtmz7z0kem0VFjCcXg/cVm5A4qeyiEyUHJ19RCqfy8Z/PDNzPQOmpEJI+GzLKKLwVq9NbP74DnlVZeL8Dhl5b0IGWR56wDK4gSyoPSgd0VoyY+VMzPwqVPfvwJUMtSe0CXqZJ4PHBNlN7vA/y9zHEfFkv/njs/yC/MwsMOkYWx23IY/3W3HVp+T7ksG8JeF2YHED2zvSBmwU6npiBFG4zh+5ylwyIPq4FBJoM11zeQeGFSEiyT65dFYLD+8tjenXhefArSBxee9/P0i2BrsJ62SWfC+EH4tuk+zJLPA9tSLTblGby8OMm7Zq/KN7ybLhOaL3f2Fbq8efh13Q8EnEYKQspQU/SYM/sIA8pdf9I= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(8121501046)(5005006)(520075)(520078)(3002001); SRVR:CY1PR0301MB1291; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1291; X-Forefront-PRVS: 070092A9D3 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CDPEowaFmP5dPF46tnAuzw50U9WrJPFWz2oljzpm7oJGP05VB4bz?= =?us-ascii?Q?SRcfLOUGMSBRrIok012U4jUxeyAkfz2Yr59j8LYdPH+untHZ2CmwpggyCWtI?= =?us-ascii?Q?ICTuzwjZnyQWA6XrGB8MEuvxZnHX2wCS66c8TSIsZfKLhZQGXiMjnXDMPkkd?= =?us-ascii?Q?05h7d7ljQMumuMvDOTAHQMzohjgA1R7/FOzKjMK0k6bkd02+3VDHFXr/8tz3?= =?us-ascii?Q?QOUGExdjlhgvr7O1lDe99D49+9tYLXXdebvrl2D00g21sEV2ZBcZycqiQBCU?= =?us-ascii?Q?eR92ZrzrvFXv2PHerEZIdAZSf963KI9C4uOHsz4fF+yq4iCDsgfg/mKZ/ZSv?= =?us-ascii?Q?iwVJO6TycnoK24FTDq7q+AjJs+ryqgpgHUSmKSnGOgwsVViGV726IT5wbt9S?= =?us-ascii?Q?ruVHaH15E0Q5TigoXH0c=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1291; 5:RwjGDA6p6/S0tXannGHlmfYLT8oEoS7sZyehjxTl62ZhdMMESGK7D+X1vJ74UJPLATEzFSxC0DgL1xNcSOJTnLtP4i8QJl9qcTd4FSKThQ/oAxGizO1xSRd8MUUv5V6ibjF3Vg3Bnic/r5k7XlYlYA==; 24:wFWyNEnS3vgxHCSrKd5ahrX10rc1wgpy0hX1nc2Rs0YIfghi7dkffICTizR/jQZrBNDE2LtsVOg3132KWPCrqnHe8Dhju3sm4ruGuFrq4/8=; 20:PIK1jigCryAlSMYeagwlV8KstPpz/MRt7RtD1NF7UDeazpeDjm/k2ldobK/Lf2CNiEWW1VBjYZq/HRZDKLP+jA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2015 09:13:06.9814 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1291 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150915_021333_065515_EC4D41A2 X-CRM114-Status: GOOD ( 19.93 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Chenhui Zhao , alison.wang@freescale.com, linux-kernel@vger.kernel.org, Wang Dongsheng , jason.jin@freescale.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Dongsheng Add system STANDBY implement for ls1021 platform. Signed-off-by: Chenhui Zhao Signed-off-by: Wang Dongsheng --- *v2*: - Remove PSCI code. Just implement STANDBY in platform code. diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index fb689d8..d7a2d1d 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -90,6 +90,7 @@ ifeq ($(CONFIG_SUSPEND),y) AFLAGS_suspend-imx6.o :=-Wa,-march=armv7-a obj-$(CONFIG_SOC_IMX6) += suspend-imx6.o obj-$(CONFIG_SOC_IMX53) += suspend-imx53.o +obj-$(CONFIG_SOC_LS1021A) += pm-ls1.o endif obj-$(CONFIG_SOC_IMX6) += pm-imx6.o diff --git a/arch/arm/mach-imx/pm-ls1.c b/arch/arm/mach-imx/pm-ls1.c new file mode 100644 index 0000000..90775cf --- /dev/null +++ b/arch/arm/mach-imx/pm-ls1.c @@ -0,0 +1,225 @@ +/* + * Support Power Management Control for LS1 + * + * Copyright 2015 Freescale Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#define FSL_SLEEP 0x1 +#define FSL_DEEP_SLEEP 0x2 + +#define CCSR_SCFG_CLUSTERPMCR 0x904 +#define CCSR_SCFG_CLUSTERPMCR_WFIL2EN 0x80000000 +#define CCSR_SCFG_CLUSTERPM_ENABLE 1 +#define CCSR_SCFG_CLUSTERPM_DISABLE 0 + +#define CCSR_RCPM_POWMGTCSR 0x130 +#define CCSR_RCPM_POWMGTCSR_LPM20_REQ 0x00100000 +#define CCSR_RCPM_IPPDEXPCR0 0x140 +#define CCSR_RCPM_IPPDEXPCR1 0x144 +#define CCSR_RCPM_IPPDEXPCR1_OCRAM1 0x10000000 + +#define SLEEP_ARRAY_SIZE 3 + +static u32 ippdexpcr0, ippdexpcr1; + +struct ls1_pm_baseaddr { + void __iomem *rcpm; + void __iomem *scfg; +}; + +static struct ls1_pm_baseaddr ls1_pm_base; + +static inline void ls1_clrsetbits_be32(void __iomem *addr, u32 clear, u32 set) +{ + u32 val; + + val = ioread32be(addr); + val = (val & ~clear) | set; + iowrite32be(val, addr); +} + +static int ls1_pm_iomap(suspend_state_t state) +{ + struct device_node *np; + void *base; + + np = of_find_compatible_node(NULL, NULL, "fsl,ls1021a-scfg"); + if (!np) { + pr_err("Missing SCFG node in the device tree\n"); + return -EINVAL; + } + + base = of_iomap(np, 0); + of_node_put(np); + if (!base) { + pr_err("Couldn't map SCFG registers\n"); + return -EINVAL; + } + + ls1_pm_base.scfg = base; + + return 0; +} + +static void ls1_pm_uniomap(suspend_state_t state) +{ + iounmap(ls1_pm_base.scfg); +} + +/* set IP powerdown exception, make them work during sleep/deep sleep */ +static void ls1_set_powerdown(void) +{ + iowrite32be(ippdexpcr0, ls1_pm_base.rcpm + CCSR_RCPM_IPPDEXPCR0); + iowrite32be(ippdexpcr1, ls1_pm_base.rcpm + CCSR_RCPM_IPPDEXPCR1); +} + +static void ls1_set_power_except(struct device *dev, int on) +{ + int ret; + u32 value[SLEEP_ARRAY_SIZE]; + + /* + * Get the values in the "rcpm-wakeup" property. There are three values. + * The first points to the RCPM node, the second is the value of + * the ippdexpcr0 register, and the third is the value of + * the ippdexpcr1 register. + */ + ret = of_property_read_u32_array(dev->of_node, "rcpm-wakeup", + value, SLEEP_ARRAY_SIZE); + if (ret) { + dev_err(dev, "%s: Can not find the \"sleep\" property.\n", + __func__); + return; + } + + ippdexpcr0 |= value[1]; + ippdexpcr1 |= value[2]; + + pr_debug("%s: set %s as a wakeup source", __func__, + dev->of_node->full_name); +} + +static void ls1_set_wakeup_device(struct device *dev, void *enable) +{ + /* set each device which can act as wakeup source */ + if (device_may_wakeup(dev)) + ls1_set_power_except(dev, *((int *)enable)); +} + +/* enable cluster to enter the PCL10 state */ +static void ls1_set_clusterpm(int enable) +{ + u32 val = 0; + + if (enable) + val = CCSR_SCFG_CLUSTERPMCR_WFIL2EN; + + iowrite32be(val, ls1_pm_base.scfg + CCSR_SCFG_CLUSTERPMCR); +} + +static int ls1_suspend_enter(suspend_state_t state) +{ + int ret = 0; + + ls1_set_powerdown(); + ls1_set_clusterpm(CCSR_SCFG_CLUSTERPM_ENABLE); + + switch (state) { + case PM_SUSPEND_STANDBY: + flush_cache_louis(); + ls1_clrsetbits_be32(ls1_pm_base.rcpm + CCSR_RCPM_POWMGTCSR, + CCSR_RCPM_POWMGTCSR_LPM20_REQ, + CCSR_RCPM_POWMGTCSR_LPM20_REQ); + cpu_do_idle(); + break; + case PM_SUSPEND_MEM: + default: + ret = -EINVAL; + break; + } + + ls1_set_clusterpm(CCSR_SCFG_CLUSTERPM_DISABLE); + + return ret; +} + +static int ls1_suspend_valid(suspend_state_t state) +{ + if (state == PM_SUSPEND_STANDBY) + return 1; + + return 0; +} + +static int ls1_suspend_begin(suspend_state_t state) +{ + int res = -EINVAL; + + ippdexpcr0 = 0; + ippdexpcr1 = 0; + + if (state == PM_SUSPEND_STANDBY) + res = ls1_pm_iomap(state); + + if (!res) + dpm_for_each_dev(NULL, ls1_set_wakeup_device); + + return res; +} + +static void ls1_suspend_end(void) +{ + ls1_pm_uniomap(PM_SUSPEND_STANDBY); +} + +static const struct platform_suspend_ops ls1_suspend_ops = { + .valid = ls1_suspend_valid, + .enter = ls1_suspend_enter, + .begin = ls1_suspend_begin, + .end = ls1_suspend_end, +}; + +static const struct of_device_id rcpm_matches[] = { + { + .compatible = "fsl,ls1021a-rcpm", + }, + {} +}; + +static int __init ls1_pm_init(void) +{ + const struct of_device_id *match; + struct device_node *np; + + np = of_find_matching_node_and_match(NULL, rcpm_matches, &match); + if (!np) { + pr_err("%s: can't find the rcpm node.\n", __func__); + return -EINVAL; + } + + ls1_pm_base.rcpm = of_iomap(np, 0); + of_node_put(np); + if (!ls1_pm_base.rcpm) + return -ENOMEM; + + suspend_set_ops(&ls1_suspend_ops); + + pr_info("Freescale Power Management Control Registered\n"); + + return 0; +} +arch_initcall(ls1_pm_init);