From patchwork Tue Aug 4 17:59:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anson Huang X-Patchwork-Id: 6936051 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 1632DC05AC for ; Tue, 4 Aug 2015 10:10:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0B85F2039D for ; Tue, 4 Aug 2015 10:10:43 +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 ED4DF20222 for ; Tue, 4 Aug 2015 10:10:41 +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 1ZMZ98-0007u5-94; Tue, 04 Aug 2015 10:08:34 +0000 Received: from mail-bn1bbn0101.outbound.protection.outlook.com ([157.56.111.101] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZMZ94-0007p3-PE for linux-arm-kernel@lists.infradead.org; Tue, 04 Aug 2015 10:08:32 +0000 Received: from BN3PR0301MB1265.namprd03.prod.outlook.com (10.161.209.145) by BN3PR0301MB1236.namprd03.prod.outlook.com (10.161.207.24) with Microsoft SMTP Server (TLS) id 15.1.225.19; Tue, 4 Aug 2015 10:08:09 +0000 Received: from BN3PR0301CA0058.namprd03.prod.outlook.com (10.160.152.154) by BN3PR0301MB1265.namprd03.prod.outlook.com (10.161.209.145) with Microsoft SMTP Server (TLS) id 15.1.225.19; Tue, 4 Aug 2015 10:08:07 +0000 Received: from BN1AFFO11FD040.protection.gbl (2a01:111:f400:7c10::136) by BN3PR0301CA0058.outlook.office365.com (2a01:111:e400:401e::26) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Tue, 4 Aug 2015 10:08:07 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) 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.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 BN1AFFO11FD040.mail.protection.outlook.com (10.58.52.251) with Microsoft SMTP Server (TLS) id 15.1.243.9 via Frontend Transport; Tue, 4 Aug 2015 10:08:07 +0000 Received: from anson-OptiPlex-790.ap.freescale.net (anson-OptiPlex-790.ap.freescale.net [10.192.242.118]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id t74A84VT031334; Tue, 4 Aug 2015 03:08:05 -0700 From: Anson Huang To: Subject: [PATCH V2] ARM: imx: add cpuidle support for i.mx6ul Date: Wed, 5 Aug 2015 01:59:24 +0800 Message-ID: <1438711164-9106-1-git-send-email-b20788@freescale.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD040; 1:wYg+HxGT5XexNs2ZXKH0550js22vucvTjipN2TsPxqtES1VDgsSmb3aVqST/qhULJZTrt6JAzzl6uyMM6foFcqZ1I5jyQ22tke2wUqU+bsP5noHGgB8AB9LgifuT4yQnqvOfn+CSivlr/5jveMoRdyV1ZbiQjobHtFSa76R1SiTqp9qiEoAMUYMzWil+uItMqUJvU04O+Tx7UxlH6gm08bdN+DRqj6woms3kirqqe74RxBf27Pd/tQpuqqZ2bSBbLi4YtVufb6SX8ic1Gw7lnjNtVbHFj8EJFMMqytv1sUz+5FcVacH7mQhAmfFm1BLS X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(85426001)(48376002)(68736005)(77096005)(69596002)(5001960100002)(5003940100001)(104016003)(229853001)(50226001)(77156002)(50986999)(50466002)(2351001)(62966003)(46102003)(33646002)(105606002)(106466001)(92566002)(189998001)(110136002)(47776003)(87936001)(64706001)(97736004)(36756003)(81156007)(4001540100001)(6806004)(5001830100001)(19580405001)(5001860100001)(19580395003)(2004002)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR0301MB1265; H:az84smr01.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1265; 2:1hzBsDQPRAoafNC3pG4vK+05L3rRWq3qY2GuT234YjwxZ9oQ5Hyrfec1iljTE6Pwhydqc6xT5E/hnnu/N6MJP55M8u9hREepS8ill8ReljceU57kYhNJft0JztHwx6qdGoLoz06vALQxupTLE1c6XdL1fFvF0yB1bEMPTvf3/Ss=; 3:m4ghAz0yEH1ArXDaboJPpQyTWj1b1cmZqCaJyslHvH0BSIkRMU3+I7C0oI4dnmZ8ZlySGmCwV4XftPZ5JFdg669C+4EkpY3iU0uKM/J4ndVWLQBjUte5+KZKn4uoJMspK20AhGgCIbOo1gXLME7J889CJtZP1G8uvQSjHF31ZEG2+ihAC+uW2kgAYp/rkuFSQCgySyh3TkrF5ZLXI7EkTBclwjzFRIMa5+2xRC8DAJ4=; 25:m/xWwW4+JhS6DjvpgAtF3tjv/498fsFA369wAXTytTx3j1L7gpKHAk4cNmlb0cAdOPgRuxGaPb+em1RVPR7rLlsh/I/oZY+4tJOCTq3u5horkmX73/Sqk8b3R0g/N3UGguYbNCE4491Fn5TWr+kIdEIYdK6nkdlS5kJ/gGg+vYMrfG2N6MJFIEvsMXpFMaNc897lmeIFqeIOehf13uEVnMOiMBI1q7E4zgYiEf4MuXcVr72NjqaCaoLoty92P9ty X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0301MB1265; UriScan:; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0301MB1236; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1265; 20:vJrILJqPQoRX2WpXX3lBJeGimYvbsgnO47HwZv67V0Tk6DbKYLbBqP7Ky0x++ndlxyP8aliJWYSCPVj6EK1U2aCAynpXX46S/EVaEmPV/Gj0ckParW9WUQ3HkRxKTa/h91phI+PAA4U+GA4+rLh6RGtqoGa7qjbmQf2QNru5JMMjjHBo9wZedVN17tUxb4vQhKvW5TLTaTrJYnrmaeEDxtXrLJ3xErynD0njgwkVUHqve3H94HlER+tKFeBnpSxR+sylStZLBcO2bqwzXu0KAB5wg5syFOhhNncs+KMRUqY7MYtGeVjj8dYJrYSNynBLXgOjEte3AflvagNxNHtVg4vbeeWfallxxa5U3INH5d4=; 4:AsE3VSITFcSr9DLICnPaf32nYxL2N0ek6D2TbqD9CDkyo38it8MiAcLYh9o5/y1dzJFsRJfzgkTRg97Oh7VaAodAcx39hwvEeOVSIUBXVzB0wnaeC3DOnpRMGMCQuXl2lGoK0TDfwhL1o+7Y2imj8id2gQBofTfwDnvyGGBRh3REIWuDYJEkIXgzXswhw4oBHS+1hNNquuDPbR6N/99p5ZEsLAsDuuDHDkwTwQysKOO1u7dVsRnqWSHXL9h5j+RH/V30hGbA9D19alviHU2gBaRRMvB7fck7VM3T5121WJg= 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:BN3PR0301MB1265; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0301MB1265; X-Forefront-PRVS: 0658BAF71F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0301MB1265; 23:Pfm0Jk/svP81E2ykyFc/av/7yKK3R+0w6UED4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G9zXOKMpL8laJlf2YMeSj6GJ2AtQFflwE?= =?us-ascii?Q?cOTyn9zcNiEmtv8S0aGBZ2F3PIeeOS5UrW/wpgW+5Z6hVR7uw+vUMdlhdC6k?= =?us-ascii?Q?U6hwsOl0xF7Ge0r6143Qg4Q8QhoG3cZuHoOkXpb9M13Ks/VjicXCTOrdxWmB?= =?us-ascii?Q?31ZrU0jVf2DEq9vLQzdHjHC0mKr0fGtJh4+ACWU5B/ApE14fYcQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1265; 5:Oxt1ji748SOEcoWzmLqXhSv9ar0o+NTfcogO22SGk64/j9LEDYfzeazJFWiRpR8Mj9jLPb+GCEWrucDulZOZmAxPALFU2xS1G0d49bA2Ru1o5457BGrlGh7DG4b0hU6/Eu0cs2gaYYGG1neSgocr+A==; 24:2mnzDCr2DCIGojN+qf0w1Dj9QOqkwpX5MHNuucOFKO1VFqJ77Azav5BJyRee4PI+vwHarFkK0FKHa5XMUIVFRk3K0VJpjU5HhXUAF8LM0tg=; 20:MLsfyOqERqfAWPsUmtuEi8lJDnSKnsxYKUSYKiEsbhcEVr+QW0TNp/FV3hFHJerTbC5iRrojXrfjJUuPJcEehQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2015 10:08:07.0466 (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: BN3PR0301MB1265 X-Microsoft-Exchange-Diagnostics: 1; BN3PR0301MB1236; 2:M567VOFWXcaFq8aUYqZ/p6R9EAVxR6TAeUE+EP/oTo6lfojNeY4VtCOvBPgHVDI0bya+/jcmvQMATNZVsPgapFeitZFCjGTqPrW9uRQFZT904ntRrXb5f4ecieataiClg9Ix8duhwsaar0o0y6LT8cB5XBA+XqxxvAAc6ESLcl4=; 3:KsMdJRYqRHkXsp8oC5JsPlBAxeaI1PmQZOmWPLQiZcor/y/0BTHqQc+0ht9Ea6hBmftpMnDeJRDDxAwM1ptHDIgY230YXHYKDHqIqyNOmMRz6b/XLxx2ppONZTmhXowsRDgNbgf2ohXTbdMjRvFKmqeScLQGf2utdSKdCSSfjJTyKMvHsDBxIZb87KcvTBoRCKBhCE2hjtXwzka42Cfvw7n0WLLL02PC2zfqOSWuEMI=; 25:mf3WoPPZa9CmSwjcHLNztSrFexXCBuilwS7zXIdKuH4mbzxls9X3aNUCA++Ns+nm0TpIgw7nGCqWigSN9EDuJLZrtXvLxa5SRO3eOJNRqA7IuUYDqgZMPpCXAcmpVwwBBlnksxcY7BqCrTGrn2P2s7wE3YvlzXs1OkLDeiSUaoj7e05reSITJ1AjQh94ySviauShnYn2RDZSzspbkbdshdeTtIAGB2PKZg1X/EZ0M0hJNbQGFvfZu454oX8rUOQz; 23:0JzAgsdztEkvQBNu89B75KrdH7u3CjPcqFJx1GYhK4uvpdEhfOC0YN0P01delEKh631ECloq00vGX8qFkOlT3op/EqRFm+JsdkfkdHoaXwN+xlFFtrztql/hlrwCvfwqrMpu4UYn1orHYuNGg1mMZjOxJMvt/eysB4spiL5Q0feYZL1O2AbxMHgBSLTaNwCEZWky9sfFS+j9dbjYnrE+oV+PTik4sSO/jXF23DbdzcgNo+iXc1QWyW57oAWSiOlG X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150804_030831_050051_D64FDF9E X-CRM114-Status: GOOD ( 24.67 ) 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 --- change from V1: remove CPUIDLE_FLAG_TIMER_STOP flag as i.MX6UL does NOT use local timer. arch/arm/mach-imx/Makefile | 1 + arch/arm/mach-imx/cpuidle-imx6ul.c | 105 +++++++++++++++++++++++++++++++++++++ arch/arm/mach-imx/cpuidle.h | 5 ++ arch/arm/mach-imx/mach-imx6ul.c | 8 +++ 4 files changed, 119 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..27ab28a --- /dev/null +++ b/arch/arm/mach-imx/cpuidle-imx6ul.c @@ -0,0 +1,105 @@ +/* + * 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, + .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