From patchwork Mon May 27 08:59:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 2619011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 3C8EEDF215 for ; Mon, 27 May 2013 10:47:18 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UgtQw-0002pA-Br; Mon, 27 May 2013 09:09:41 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UgtJk-0001na-TO; Mon, 27 May 2013 09:02:12 +0000 Received: from kirsty.vergenet.net ([202.4.237.240]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UgtHc-0001VF-AO for linux-arm-kernel@lists.infradead.org; Mon, 27 May 2013 09:00:10 +0000 Received: from vergenet.net (ac225145.ppp.asahi-net.or.jp [183.77.225.145]) by kirsty.vergenet.net (Postfix) with ESMTP id 7DDB9266CF1; Mon, 27 May 2013 18:59:17 +1000 (EST) Received: by vergenet.net (Postfix, from userid 7100) id A91987C1B5D; Mon, 27 May 2013 17:59:58 +0900 (JST) From: Simon Horman To: Arnd Bergmann , Olof Johansson Subject: [PATCH 10/12] ARM: shmobile: r8a7740: Add CPUIdle Date: Mon, 27 May 2013 17:59:51 +0900 Message-Id: <1369645193-3595-11-git-send-email-horms+renesas@verge.net.au> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1369645193-3595-1-git-send-email-horms+renesas@verge.net.au> References: <1369645193-3595-1-git-send-email-horms+renesas@verge.net.au> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130527_050001_460333_31A39C39 X-CRM114-Status: GOOD ( 17.21 ) X-Spam-Score: -3.7 (---) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-3.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [202.4.237.240 listed in list.dnswl.org] -1.1 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linux-sh@vger.kernel.org, Bastian Hecht , Magnus Damm , Bastian Hecht , arm@kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Bastian Hecht We make use of the r8a7740 Suspend To Ram code to plug together a CPUIdle driver. Signed-off-by: Bastian Hecht Acked-by: Daniel Lezcano --- arch/arm/mach-shmobile/Makefile | 2 +- arch/arm/mach-shmobile/cpuidle-r8a7740.c | 62 +++++++++++++++++++++++++ arch/arm/mach-shmobile/include/mach/r8a7740.h | 1 + arch/arm/mach-shmobile/pm-r8a7740.c | 1 + 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 arch/arm/mach-shmobile/cpuidle-r8a7740.c diff --git a/arch/arm/mach-shmobile/Makefile b/arch/arm/mach-shmobile/Makefile index 0568894..2852dcf 100644 --- a/arch/arm/mach-shmobile/Makefile +++ b/arch/arm/mach-shmobile/Makefile @@ -30,7 +30,7 @@ obj-$(CONFIG_SUSPEND) += suspend.o obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_ARCH_SHMOBILE) += pm-rmobile.o obj-$(CONFIG_ARCH_SH7372) += pm-sh7372.o sleep-sh7372.o -obj-$(CONFIG_ARCH_R8A7740) += pm-r8a7740.o sleep-r8a7740.o +obj-$(CONFIG_ARCH_R8A7740) += pm-r8a7740.o sleep-r8a7740.o cpuidle-r8a7740.o obj-$(CONFIG_ARCH_R8A7779) += pm-r8a7779.o obj-$(CONFIG_ARCH_SH73A0) += pm-sh73a0.o diff --git a/arch/arm/mach-shmobile/cpuidle-r8a7740.c b/arch/arm/mach-shmobile/cpuidle-r8a7740.c new file mode 100644 index 0000000..48c7a6c --- /dev/null +++ b/arch/arm/mach-shmobile/cpuidle-r8a7740.c @@ -0,0 +1,62 @@ +/* + * CPUIdle code for SoC r8a7740 + * + * Copyright (C) 2013 Bastian Hecht + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + */ +#include +#include +#include +#include +#include + +#if defined(CONFIG_SUSPEND) && defined(CONFIG_CPU_IDLE) +static int r8a7740_enter_a3sm_pll_on(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int index) +{ + r8a7740_enter_a3sm_common(1); + return 1; +} + +static int r8a7740_enter_a3sm_pll_off(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int index) +{ + r8a7740_enter_a3sm_common(0); + return 2; +} + +static struct cpuidle_driver r8a7740_cpuidle_driver = { + .name = "r8a7740_cpuidle", + .owner = THIS_MODULE, + .en_core_tk_irqen = 1, + .state_count = 3, + .safe_state_index = 0, /* C1 */ + .states[0] = ARM_CPUIDLE_WFI_STATE, + .states[1] = { + .name = "C2", + .desc = "A3SM PLL ON", + .exit_latency = 40, + .target_residency = 30 + 40, + .flags = CPUIDLE_FLAG_TIME_VALID, + .enter = r8a7740_enter_a3sm_pll_on, + }, + .states[2] = { + .name = "C3", + .desc = "A3SM PLL OFF", + .exit_latency = 120, + .target_residency = 30 + 120, + .flags = CPUIDLE_FLAG_TIME_VALID, + .enter = r8a7740_enter_a3sm_pll_off, + }, +}; + +void r8a7740_cpuidle_init(void) +{ + shmobile_cpuidle_set_driver(&r8a7740_cpuidle_driver); +} +#else +void r8a7740_cpuidle_init(void) {} +#endif diff --git a/arch/arm/mach-shmobile/include/mach/r8a7740.h b/arch/arm/mach-shmobile/include/mach/r8a7740.h index 5cfe5d9..3b538e3 100644 --- a/arch/arm/mach-shmobile/include/mach/r8a7740.h +++ b/arch/arm/mach-shmobile/include/mach/r8a7740.h @@ -545,6 +545,7 @@ extern void r8a7740_pinmux_init(void); extern void r8a7740_pm_init(void); extern void r8a7740_resume(void); extern void r8a7740_shutdown(void); +extern void r8a7740_cpuidle_init(void); extern void r8a7740_enter_a3sm_common(int); #ifdef CONFIG_PM diff --git a/arch/arm/mach-shmobile/pm-r8a7740.c b/arch/arm/mach-shmobile/pm-r8a7740.c index fe3c867..2f196bd 100644 --- a/arch/arm/mach-shmobile/pm-r8a7740.c +++ b/arch/arm/mach-shmobile/pm-r8a7740.c @@ -237,4 +237,5 @@ static void r8a7740_suspend_init(void) {} void __init r8a7740_pm_init(void) { r8a7740_suspend_init(); + r8a7740_cpuidle_init(); }