From patchwork Thu Apr 11 14:07:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bastian Hecht X-Patchwork-Id: 2428801 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 0ED3CDF230 for ; Thu, 11 Apr 2013 14:07:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302Ab3DKOHw (ORCPT ); Thu, 11 Apr 2013 10:07:52 -0400 Received: from mail-bk0-f45.google.com ([209.85.214.45]:41493 "EHLO mail-bk0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751787Ab3DKOHw (ORCPT ); Thu, 11 Apr 2013 10:07:52 -0400 Received: by mail-bk0-f45.google.com with SMTP id j10so832023bkw.4 for ; Thu, 11 Apr 2013 07:07:50 -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=l9da6T5LQFgHYHkIQb6WFPPWMrGyfiUyut0lfQWWSy8=; b=UikrS/aePe+ozi6o+AqY3cUEVluerX86/CpW2W6b1nOmPgwoz8RV7Tzqf3vCp22hjP u6zt1ei6UgOswkccSHHhZ/1R8zZ9/cXBUY9i9BRXNKwS5p/1JCUHivTYANFZbax5osdq MynvMFnSCN/DtNufO1F0iwlZ5Y2SNyZb/AE60XtIrMOP5zdy8cgnLaJ8Yg0FBPB6VY1D WSOctu7g6MHCWUFNFSTmOVtcx07SamrPSQ2ZQRbTJQu2puPYq5PenZ8oRQ4MhUoFvh7K IOS8LEz5Xv+yeKhD/gzvTxYFkOYKnwBdV75J3YeyOIFYBAaBgqeFbCFJKyfgmXpwmt61 s8QQ== X-Received: by 10.205.41.72 with SMTP id tt8mr2645830bkb.9.1365689270217; Thu, 11 Apr 2013 07:07:50 -0700 (PDT) Received: from localhost.localdomain (g229146212.adsl.alicedsl.de. [92.229.146.212]) by mx.google.com with ESMTPS id gm14sm2011802bkc.7.2013.04.11.07.07.49 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Apr 2013 07:07:49 -0700 (PDT) From: Bastian Hecht To: linux-sh@vger.kernel.org Cc: Daniel Lezcano , Magnus Damm , Simon Horman , Lorenzo Pieralisi , Jonathan Austin , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/2] ARM: shmobile: r8a7740: Add CPUIdle Date: Thu, 11 Apr 2013 16:07:44 +0200 Message-Id: <1365689264-14410-2-git-send-email-hechtb+renesas@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1365689264-14410-1-git-send-email-hechtb+renesas@gmail.com> References: <1365689264-14410-1-git-send-email-hechtb+renesas@gmail.com> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.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 --- v2: new patch: Moved out the CPUIdle part 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 adadac4..1b1fba2 100644 --- a/arch/arm/mach-shmobile/pm-r8a7740.c +++ b/arch/arm/mach-shmobile/pm-r8a7740.c @@ -240,4 +240,5 @@ static void r8a7740_suspend_init(void) {} void __init r8a7740_pm_init(void) { r8a7740_suspend_init(); + r8a7740_cpuidle_init(); }