From patchwork Tue Aug 4 16:32:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Huang X-Patchwork-Id: 6935121 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 B6807C05AD for ; Tue, 4 Aug 2015 08:44:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A886F2063B for ; Tue, 4 Aug 2015 08:44:06 +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 94FD320638 for ; Tue, 4 Aug 2015 08:44:05 +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 1ZMXnO-0003im-5A; Tue, 04 Aug 2015 08:42:02 +0000 Received: from mail-by2on0137.outbound.protection.outlook.com ([207.46.100.137] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZMXnL-0003cM-89 for linux-arm-kernel@lists.infradead.org; Tue, 04 Aug 2015 08:42:00 +0000 Received: from BN3PR0301CA0057.namprd03.prod.outlook.com (10.160.152.153) by BY2PR03MB492.namprd03.prod.outlook.com (10.141.142.23) with Microsoft SMTP Server (TLS) id 15.1.231.11; Tue, 4 Aug 2015 08:41:37 +0000 Received: from BL2FFO11FD044.protection.gbl (2a01:111:f400:7c09::185) by BN3PR0301CA0057.outlook.office365.com (2a01:111:e400:401e::25) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Tue, 4 Aug 2015 08:41:36 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; pengutronix.de; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.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 BL2FFO11FD044.mail.protection.outlook.com (10.173.161.140) with Microsoft SMTP Server (TLS) id 15.1.243.9 via Frontend Transport; Tue, 4 Aug 2015 08:41:36 +0000 Received: from anson-OptiPlex-790.ap.freescale.net (anson-OptiPlex-790.ap.freescale.net [10.192.242.118]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t748fX5T015890; Tue, 4 Aug 2015 01:41:34 -0700 From: Anson Huang To: Subject: [PATCH] ARM: imx: add cpuidle support for i.mx6ul Date: Wed, 5 Aug 2015 00:32:52 +0800 Message-ID: <1438705972-3082-1-git-send-email-b20788@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD044; 1:XKXAwXeZgwAkrr834z3UNF5xaK/gy0kmhBuKh0EUjQ7shwc9U0a+c60fZhMLmgNUgnG6nGgalEPY6hD1xqq6ixAa1cptbzCa/DoFQ29Zgzek6LcmYBHg6OlkijphqvX1ymNgNvm/s5W4axiC9PXbwO5gAM5eu3vqi+M47J5uWjgspnnsTabReVsi8XK7Jh87x8LFHalTka+9jyyrwbicqGtAmqbN0e3l8RS4sGEujf30kiUzfWCfzhkAbbhpst8xEwVggrNErhP7D4x3Wut/YHtiMkHOfNqEwAuC3yHDFOnc+vV73Oez4MHGMyffcoea X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(85426001)(46102003)(19580395003)(5003940100001)(36756003)(87936001)(106466001)(92566002)(189998001)(6806004)(48376002)(5001960100002)(68736005)(50226001)(33646002)(229853001)(50986999)(77156002)(50466002)(47776003)(62966003)(110136002)(19580405001)(104016003)(64706001)(2351001)(4001540100001)(5001920100001)(5001860100001)(105606002)(5001830100001)(81156007)(77096005)(97736004)(2004002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR03MB492; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB492; 2:+XniNMd9h/3Ld7HCaznxdiOQ8rZ2vZv5yrVHY4GBZoARxo0cHh9PQdiUwrw0SoCuHWE0DDoEXgYu1d8UJ+nExVdZ+/aLgmKq6i/ku4C97+bHFIX6nczUmf7E3FB9ZWiwcUPOkBaq+AMQvUrXBYpJCCvc2hW1ZkhA3krrAZYTQ6M=; 3:KeRKoH2GShdwOiy2NO17Rp9FqUW5XSgUZGA6B/Y2FDBPnLI7CiodP5SwtFDh/H1m2NQcUq646e298j1a5dmQ9Yv7AQ599disbjvPzj1Fn30Tltugjk18Rohiz/nQK06FEyXElQX/u337AIO6lUlu4jTs/r1jgWAmzhCJRWkUolTHPoyCKOM8olbnQ1gYJKPOPcw1DzCH4ghzzNpSS31vrCi3yz+vYmD9Iw02N0OXbnQ=; 25:lx3mKdeBtu0al0wSWMWHUTYsGtUvwxruRSAvAUZeoqsDWbxoy5hotkeW3yi/7KgrMdS8XaoDR/hSAPE56iEs9U6+7pF3WwMS0aD+zvh6Xc+XK+7Z5IXUD3n0bTsyuUChSM7K0eeohCoD8i2B9t4kv1dOK9MFDKSzDlxYGK9re1nlDa2Jm01b5mUEufHWAY5RqHBN0tcNJmwwN5be6Nhvct+iUO9ZPJlPk76owx9VFYH8RKto2uzNNpbW0tnEvRshqBInn+b97tjYVY9AQ3fgAQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB492; X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB492; 20:EdGgf9pCSBSA5EGdE8GeVSZvfFhfR1dkUmA0bv0XaV2KebgU8B+TNE+0uEdRSjs4gcZ8e8WCjK0TCEsAffKzqIKtRkWfJgaTINK8cxzIkbWfnWgZVX1Ao4DAQkFbY92ndhqmP2zwC7oYG79tDnh8OqGptn3lRSyuB+cxWH+6ZsGa/aBCoWwsYGlvXhaaT2ES0e/oA4UVs1grmuHfWtnhgBfAypvNraI/rsdi8UvSNA8XIUiQHiwCsNe6Z9NlUZR/mV86N/Jj8aDLVdLse+/aX5pXP2erJGCfpH21LvTIwAp8PqK0iak9LApOBhTzY5SBkvMjhbgvEWlEa6lpiZTgbK6Ss5mNm7bqUUY4stxqYpc=; 4:cZ8vHfwlX9x6pn9w9ue4X2t6F2EJM2WO3BNhUX5Bj1oszBdsawUtQA5RNgT237XamBD9aWQqUdFy2Cb182CECcvcW5WCB2oBiT/zAVNeD3ibXD1Hpxs2wnxMPqJMzfSZ63Ukw+4b8mGRy2cKRM/YURXM4vTsUTCs3ex3W98sDq2VeOT9dPOaNk2+lD07KkPC69gC/mWE00z9jurrKyEKvaJId67LabcLsCGsmLDnUa8YwxdPK8MTswc3fmNdO/A2WnNhW2e5KcFSdPhS50PJEc2MLqe02qILHWdFzjV1vWE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(3002001); SRVR:BY2PR03MB492; BCL:0; PCL:0; RULEID:; SRVR:BY2PR03MB492; X-Forefront-PRVS: 0658BAF71F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR03MB492; 23:KefDNd3T+wOE7rZsu1RGkjkCW0H3s2aLWSz/hAlSG2?= =?us-ascii?Q?Gjt+ugetpB4XE2Q+TOC9E+r3lAvVPNppqJKUNuN/L9E4P9BBR9/gRWZsZcaa?= =?us-ascii?Q?rvpdkAyMbsjkoL03Q7+u7NzF1nlu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fBvVXRNKhR9nh9dvD3KXur6GDYjsEQEkLRPA1U4VC/SPGnOkUI/Af?= =?us-ascii?Q?qg2eZXC18s7WLNhaqtj5wKzvo/qyMq79OwFa1Ymzzpr5izp3EFoUN50xt5Yn?= =?us-ascii?Q?ZcdJ8OmsA=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR03MB492; 5:1N8LeSSDhDfIj2ZNQQyXkIADcasFLo2KyGheZBZJvwT52BTXcCrJf3KHDohNw76nnB5E10nh4QC1nHvu6m9N+uyo5jmPBtaTMFZCkLYl2FYtyKJdYmE2KvYg5q9BpTxEnXzpaEN5VCUIgxVDDhYElQ==; 24:V6OLF4EmZKX7VWSwlR8069FMqbwovc4KicrIl7UHb2HQMpLUjCsza/Hy34XGk/XgE7Y56uyEo7pv0b/cePuD4GsBz7USZMty1aAm5Y9+HAY=; 20:cF2NTCdxewt0ei7AJ4fh+Lw/EXZ15PJZQgji4FDx7CyB3PBkHPIN9jqy61OkczzUPfZ6JzXlw9QVEzPDH4rsPQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2015 08:41:36.1517 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB492 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150804_014159_341150_696F4A2E X-CRM114-Status: GOOD ( 29.42 ) X-Spam-Score: 0.0 (/) 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: shawnguo@kernel.org, kernel@pengutronix.de Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_MED, 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 This patch introduces an independent cpuidle driver for i.MX6UL, totally 3 levels of cpuidle are supported as below: 1. ARM WFI; 2. SOC in WAIT mode; 3. SOC in WAIT mode + ARM power off. Signed-off-by: Anson Huang --- arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/cpuidle-imx6ul.c | 106 +++++++++++++++++++++++++++++++++++++ arch/arm/mach-imx/cpuidle.h | 5 ++ arch/arm/mach-imx/mach-imx6ul.c | 8 +++ 4 files changed, 120 insertions(+) create mode 100644 arch/arm/mach-imx/cpuidle-imx6ul.c diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index fb689d8..1d7df9c 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -28,6 +28,7 @@ obj-$(CONFIG_SOC_IMX5) += cpuidle-imx5.o obj-$(CONFIG_SOC_IMX6Q) += cpuidle-imx6q.o obj-$(CONFIG_SOC_IMX6SL) += cpuidle-imx6sl.o obj-$(CONFIG_SOC_IMX6SX) += cpuidle-imx6sx.o +obj-$(CONFIG_SOC_IMX6UL) += cpuidle-imx6ul.o endif ifdef CONFIG_SND_IMX_SOC diff --git a/arch/arm/mach-imx/cpuidle-imx6ul.c b/arch/arm/mach-imx/cpuidle-imx6ul.c new file mode 100644 index 0000000..93793a1 --- /dev/null +++ b/arch/arm/mach-imx/cpuidle-imx6ul.c @@ -0,0 +1,106 @@ +/* + * Copyright (C) 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 version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include + +#include "common.h" +#include "cpuidle.h" + +static int imx6ul_idle_finish(unsigned long val) +{ + flush_cache_all(); + cpu_do_idle(); + + return 0; +} + +static int imx6ul_enter_wait(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int index) +{ + imx6_set_lpm(WAIT_UNCLOCKED); + + switch (index) { + case 1: + cpu_do_idle(); + break; + case 2: + imx6_enable_rbc(true); + imx_gpc_set_arm_power_in_lpm(true); + imx_set_cpu_jump(0, v7_cpu_resume); + /* Need to notify there is a cpu pm operation. */ + cpu_pm_enter(); + cpu_cluster_pm_enter(); + + cpu_suspend(0, imx6ul_idle_finish); + + cpu_cluster_pm_exit(); + cpu_pm_exit(); + imx_gpc_set_arm_power_in_lpm(false); + imx6_enable_rbc(false); + break; + default: + break; + } + + imx6_set_lpm(WAIT_CLOCKED); + + return index; +} + +static struct cpuidle_driver imx6ul_cpuidle_driver = { + .name = "imx6ul_cpuidle", + .owner = THIS_MODULE, + .states = { + /* WFI */ + ARM_CPUIDLE_WFI_STATE, + /* WAIT */ + { + .exit_latency = 50, + .target_residency = 75, + .flags = CPUIDLE_FLAG_TIMER_STOP, + .enter = imx6ul_enter_wait, + .name = "WAIT", + .desc = "Clock off", + }, + /* WAIT + ARM power off */ + { + /* + * ARM gating 31us * 5 + RBC clear 65us + * and some margin for SW execution, here set it + * to 300us. + */ + .exit_latency = 300, + .target_residency = 500, + .enter = imx6ul_enter_wait, + .name = "LOW-POWER-IDLE", + .desc = "ARM power off", + }, + }, + .state_count = 3, + .safe_state_index = 0, +}; + +int __init imx6ul_cpuidle_init(void) +{ + imx6_enable_rbc(false); + /* + * set ARM power up/down timing to the fastest, + * sw2iso and sw can be set to one 32K cycle = 31us + * except for power up sw2iso which need to be + * larger than LDO ramp up time. + */ + imx_gpc_set_arm_power_up_timing(2, 1); + imx_gpc_set_arm_power_down_timing(1, 1); + + return cpuidle_register(&imx6ul_cpuidle_driver, NULL); +} diff --git a/arch/arm/mach-imx/cpuidle.h b/arch/arm/mach-imx/cpuidle.h index f914012..4dcf71d 100644 --- a/arch/arm/mach-imx/cpuidle.h +++ b/arch/arm/mach-imx/cpuidle.h @@ -15,6 +15,7 @@ extern int imx5_cpuidle_init(void); extern int imx6q_cpuidle_init(void); extern int imx6sl_cpuidle_init(void); extern int imx6sx_cpuidle_init(void); +extern int imx6ul_cpuidle_init(void); #else static inline int imx5_cpuidle_init(void) { @@ -32,4 +33,8 @@ static inline int imx6sx_cpuidle_init(void) { return 0; } +static inline int imx6ul_cpuidle_init(void) +{ + return 0; +} #endif diff --git a/arch/arm/mach-imx/mach-imx6ul.c b/arch/arm/mach-imx/mach-imx6ul.c index f206506..0f4b95c 100644 --- a/arch/arm/mach-imx/mach-imx6ul.c +++ b/arch/arm/mach-imx/mach-imx6ul.c @@ -11,6 +11,7 @@ #include #include "common.h" +#include "cpuidle.h" static void __init imx6ul_init_machine(void) { @@ -29,6 +30,12 @@ static void __init imx6ul_init_irq(void) imx_init_revision_from_anatop(); imx_src_init(); irqchip_init(); + imx6_pm_ccm_init("fsl,imx6ul-ccm"); +} + +static void __init imx6ul_init_late(void) +{ + imx6ul_cpuidle_init(); } static const char *imx6ul_dt_compat[] __initconst = { @@ -40,4 +47,5 @@ DT_MACHINE_START(IMX6UL, "Freescale i.MX6 Ultralite (Device Tree)") .init_irq = imx6ul_init_irq, .init_machine = imx6ul_init_machine, .dt_compat = imx6ul_dt_compat, + .init_late = imx6ul_init_late, MACHINE_END