From patchwork Wed Apr 17 10:56:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Hecht X-Patchwork-Id: 2453391 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 7EDC53FC64 for ; Wed, 17 Apr 2013 11:57:14 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1USQz4-0001lH-Gy; Wed, 17 Apr 2013 11:57:06 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1USQz2-0002nK-2Q; Wed, 17 Apr 2013 11:57:04 +0000 Received: from mail-bk0-x22b.google.com ([2a00:1450:4008:c01::22b]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1USQyy-0002mi-7v for linux-arm-kernel@lists.infradead.org; Wed, 17 Apr 2013 11:57:01 +0000 Received: by mail-bk0-f43.google.com with SMTP id jm2so158618bkc.16 for ; Wed, 17 Apr 2013 04:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=zaPRnrFLChPtVVtLo27KyNkz5wdxl2Y6lYK/5wluc6Q=; b=1Bb3XJKdzZReu1E7fwMSICNdKsIJ16ezaK1JsWAymv8aLHDWUotfgvlOIqfTKY/9nQ 1Ee4ZGIs6tkyl6FJcSnq1iadfW+L3eSIJ++MsdrO+485VPJC/vM95Iwy2+XkBmhLEEm9 INncfA0SFae2doJL4kJzCL8wnHgbIHG+V1Ya9IPNpWwq4bvUwiUB7zeXwLiRoxaV5KxB A5y//W5SaidMDcoUjtcZx3m/ceiEQPjs5jcyVXLwB8j2UEg50cQNer3NDt5KKSI0kPAn 2dJP10K/aKMc6JLu/DH5Qhjvne9hC9Atk47jaAUac7LtwU9r5vBXZ4AzAbQNG5UB89hH igAQ== X-Received: by 10.204.98.77 with SMTP id p13mr2130781bkn.86.1366199818175; Wed, 17 Apr 2013 04:56:58 -0700 (PDT) Received: from localhost.localdomain (g229254233.adsl.alicedsl.de. [92.229.254.233]) by mx.google.com with ESMTPS id da16sm2020426bkb.2.2013.04.17.04.56.57 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 17 Apr 2013 04:56:57 -0700 (PDT) From: Bastian Hecht To: linux-sh@vger.kernel.org Subject: [PATCH v3 2/2] ARM: shmobile: r8a7740: Add CPUIdle Date: Wed, 17 Apr 2013 12:56:30 +0200 Message-Id: <1366196190-14011-2-git-send-email-hechtb+renesas@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366196190-14011-1-git-send-email-hechtb+renesas@gmail.com> References: <1366196190-14011-1-git-send-email-hechtb+renesas@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130417_075700_446748_4DE70B8B X-CRM114-Status: GOOD ( 16.42 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (hechtb[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Lorenzo Pieralisi , Jonathan Austin , Daniel Lezcano , Magnus Damm , Simon Horman , 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 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 --- v3: same 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 05551ee..5c3361a 100644 --- a/arch/arm/mach-shmobile/include/mach/r8a7740.h +++ b/arch/arm/mach-shmobile/include/mach/r8a7740.h @@ -542,6 +542,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 b9ca44b..2319aa5 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(); }