From patchwork Thu Sep 10 09:36:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 7153081 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 2F9DEBEEC1 for ; Thu, 10 Sep 2015 09:45:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 20E6A20914 for ; Thu, 10 Sep 2015 09:45:00 +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 EF984208C4 for ; Thu, 10 Sep 2015 09:44:58 +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 1ZZyNZ-0003MF-3G; Thu, 10 Sep 2015 09:42:53 +0000 Received: from mail-bl2on0115.outbound.protection.outlook.com ([65.55.169.115] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZyNV-00032X-Pl for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2015 09:42:51 +0000 Received: from BN3PR0301CA0033.namprd03.prod.outlook.com (10.160.180.171) by DM2PR0301MB1295.namprd03.prod.outlook.com (10.160.222.149) with Microsoft SMTP Server (TLS) id 15.1.262.15; Thu, 10 Sep 2015 09:42:26 +0000 Received: from BL2FFO11FD047.protection.gbl (2a01:111:f400:7c09::161) by BN3PR0301CA0033.outlook.office365.com (2a01:111:e400:4000::43) with Microsoft SMTP Server (TLS) id 15.1.262.15 via Frontend Transport; Thu, 10 Sep 2015 09:42:26 +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 BL2FFO11FD047.mail.protection.outlook.com (10.173.161.209) with Microsoft SMTP Server (TLS) id 15.1.262.18 via Frontend Transport; Thu, 10 Sep 2015 09:42:25 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t8A9gLXN009238; Thu, 10 Sep 2015 02:42:22 -0700 From: Dongsheng Wang To: Subject: [PATCH] arm/ls1021a: Add Sleep feature for ls1021 Date: Thu, 10 Sep 2015 17:36:36 +0800 Message-ID: <1441877796-32232-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; BL2FFO11FD047; 1:eFbpels2HKgc7wV8/arLCijDAUF8E9n6jUnJEAR29WWHketQG6A/lDOD/yyWaO8xkttgt5Udm6PDj9nbUFwXyH97iZhNPbAoXsmQ0b+2i0b0N4Z86CkkP51vtYly3ASMRxK3Adv2axFFGYPyMVqYa8TN9rPQo686aBLs45j73u/mECyIUdQG33MRNr6kczCSnOKmnusfNkjwtKFkS4GwJ5/1ij7e4ivXMeiFgxBiM4LzkC+JViJoM8DetAlFVpVniw2uX6/e3HFFAXxJQ7CTC1UQ0NccaGKJ5rpFa7agkgMWm7Ly2220tTgVnF3uDRGpOvRUruclg9xV8LJxEtiP7ddrl2GjWXt4laAoH0aEhk471VNsjRqTtWKrkwwJMDVwkYy0utmGnYjpilTnoiPGgQ== 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)(104016003)(2351001)(81156007)(48376002)(110136002)(189998001)(33646002)(5001830100001)(87936001)(19580395003)(50226001)(5001960100002)(5003940100001)(4001540100001)(97736004)(36756003)(5001860100001)(106466001)(11100500001)(77156002)(46102003)(107886002)(86362001)(229853001)(92566002)(19580405001)(85426001)(50986999)(5007970100001)(105606002)(50466002)(6806004)(64706001)(69596002)(68736005)(77096005)(62966003)(47776003)(2004002)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM2PR0301MB1295; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1295; 2:iTvQHz1zTRT6o7Dj4VhkVWo410Dxjqpr6WaKpoZm8Dzuxk8TPhH3wHqxez+JAWUpW4mRa46aJnwBTgHs/8Wn34VjxWRW9Du5L8t+1+6wMCzsN/Ia8r3qbhwxIQVDQiuNy1n8W4GF4QEVn43Zh3uGlgy2uYbYN5t3U+cJoRkAPG4=; 3:pyedgjpIg/OL+NYjDXNB/GiIKHvF4nxy91RRCQPqzIiK1oPmxW5VIWhaY6nrmOO0+yGzHSPJgJzSrg7/NfqX+rRJEOFhYXFa5TRzgjrKDpMT8yoGHl+F8HsP8tSQE+t/BnowlngnSm6q0jQPNiUWOyE4bLd76QtnRQqQSeBbt3TYYF9uEuowVuUTTw4wrTKvXxSMazLTnctsGO/dWolppz33Nn4usNktBiQqT8bK9+g=; 25:86AZakYN9/Uq7PuH9Vvfsb3Kio4wbr6Od8W0VPHgozDNjRd2xwHWQNs6xXuaSJgCnud7HoJlsiHKyuoW9nNR82Yjdr1ixTEvRmmQYhJtbb49CTWZG1UkvyFLsC9fgBPJn1RiTXvBMmAyDH7BhngSxstoR6q8ETHFjDAVQvhjrWgwh2w5EoccqL+QPR+mTmX/bQoLfQIK/894nXmk8frBncDGTSPwyfqCax2QT42vswMELIaHBu2KCxgq6+LDcGg6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0301MB1295; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1295; 20:iU6Fw7eJ6v6CD+X7hLVubDz9KZGQx7WYCJyfZS51iRVGIVAPGNZAoy8el1LmMmCbpbdJ0VTLD98Q4b9kWnSKhZS6Scoq9pEw+lgdnZLMq2iESSoJTULkCtbd5qrnv+6wnepl+rDu5ahkEifJ2kAXat8pai9MnoK9OOQ8O8v+OSyTq083yOyp4Hv88zOvMhKirNBRodzqtAkqu2lIFiRlNHOMZJrxzBwQV/5yhxd4ClbiFSUwut28FjfNe94IAnQea+WnxqmFGO5Rj9/y3aAt8+OnlKBuAkWDlp5EblS98f3csheLmrthYglBAjb901R8PRTDY4LsyU8SYkz3d7AXUkvUSiz1DnNhr0FsrC8QLZg=; 4:d/RXEnrrAyjfhfqtdU8i6NklYvl+0BAjEA6YzTw8usv28TFJM5GVrvFVgQ6kHmlT9xnLm6Ws10XGT0DwZW9otNrTj5SjK3Xyl47QRcB/6jelkreh3h+ZC6gaeGlSmWxeoW1eqGPZzZKs55CZN2/PHci8MITfprDXMuLPhQaToV4KaVuf1VqxUnw21qfIronscvn6HixrQtEwzeLq5zVBYsHj/HVNhuNeHlrQzkxy5t1FNazgYUE50LwRuKGRGxcZs5x2XoqURHrxGLxxd1jjbA4yTeHLq7ZoRqO9WULZlBufSkHYlI8OV09Kl302qdYl X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(8121501046)(5005006)(3002001); SRVR:DM2PR0301MB1295; BCL:0; PCL:0; RULEID:; SRVR:DM2PR0301MB1295; X-Forefront-PRVS: 06952FC175 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0301MB1295; 23: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?Q?pXP8zByip8vc+z4EwYuu8O/snY5kq/6avIedSsl4DVPCffPkboZ989i0tqLo?= =?us-ascii?Q?1ojA6bfo9LuYwFrqfuiRJjwKnyMMTSCBNZtSsI2nyRp+w02pKLaas5URU3HT?= =?us-ascii?Q?fGsA4kQ3xAC5h5Lny+PDrFJ3V/qjF4TOxc+dz/qXJdtElew1F73TG/mxSrGe?= =?us-ascii?Q?nANrF63aCLMx03tGGIzbs8lhSN1w1cdkd+kBNKO4zB7gH17qG12MUjqIVrjG?= =?us-ascii?Q?pKg1JeE6ZgY1v5UxdHaOex1k35ShznJZNiIDSO+sTK6PzH9+/dNSzn8pCYTK?= =?us-ascii?Q?hHzmPTA/FTDp9ikQyK5XLSUQ8nSBnycBaxR52EysYJB/QfWVSJsDl6aaWooi?= =?us-ascii?Q?elhmQrtoZqWecwbOOgDQ=3D?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR0301MB1295; 5:FP+CHN3Nqrrfx4Nms1oA0yIxl4imuucy+rt0E9u1CrGC33WF5qCQ7r5yM/Gad3rrkDv5vWo1T44QIHxwkRo7Cr0jlkctCnFi/6rIZ4WMLkwIYcFIoiVDMXrcRoK2wX/FVY7/FuhSIIr/XUaKc+kqiQ==; 24:88cV7t4lkSyZft9lLPCglLdzm5ScwYHTaq2iGZLXZpwdMVA5BEhS+gy3GBT8bE8Y8VBeUMa7ql8OIiWqp3CUOW+gUmMypCmhsIuhGXrPT3Q=; 20:mQbrKBi4wcZUmbb92pT96PrttyYKisDk7JOaLMdM/17q5vIQjhAZIM4LlrpV0OVRYNX4FvVSyrI674BkJ96M3A== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2015 09:42:25.8852 (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: DM2PR0301MB1295 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150910_024250_207247_9AFB0859 X-CRM114-Status: GOOD ( 21.05 ) 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@freescale.com, alison.wang@freescale.com, catalin.marinas@arm.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 Based on PSCI framework, add system STANDBY implement for ls1021 platform. Signed-off-by: Chenhui Zhao Signed-off-by: Wang Dongsheng 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..f80b24d --- /dev/null +++ b/arch/arm/mach-imx/pm-ls1.c @@ -0,0 +1,222 @@ +/* + * 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 + +#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_IPPDEXPCR0 0x140 +#define CCSR_RCPM_IPPDEXPCR1 0x144 +#define CCSR_RCPM_IPPDEXPCR1_OCRAM1 0x10000000 + +#define SLEEP_ARRAY_SIZE 3 + +#define LS1_SLEEP_PARAM \ + (PSCI_POWER_STATE_TYPE_STANDBY << PSCI_0_2_POWER_STATE_TYPE_SHIFT) + +static u32 ippdexpcr0, ippdexpcr1; + +struct ls1_pm_baseaddr { + void __iomem *rcpm; + void __iomem *scfg; +}; + +static struct ls1_pm_baseaddr ls1_pm_base; + +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 */ +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 = -EINVAL; + u32 psci_state = 0; + + ls1_set_powerdown(); + ls1_set_clusterpm(CCSR_SCFG_CLUSTERPM_ENABLE); + + switch (state) { + case PM_SUSPEND_STANDBY: + psci_state |= LS1_SLEEP_PARAM; + + flush_cache_louis(); + if (psci_ops.cpu_suspend) + ret = psci_ops.cpu_suspend(psci_state, + __pa(secondary_startup)); + break; + case PM_SUSPEND_MEM: + default: + 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);