From patchwork Fri Sep 16 17:27:49 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob X-Patchwork-Id: 4142 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id A670F23EF5 for ; Fri, 16 Sep 2011 17:28:01 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9A0C0A18612 for ; Fri, 16 Sep 2011 17:28:01 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 23so2714505fxe.11 for ; Fri, 16 Sep 2011 10:28:01 -0700 (PDT) Received: by 10.223.61.66 with SMTP id s2mr252285fah.27.1316194081202; Fri, 16 Sep 2011 10:28:01 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs135674lab; Fri, 16 Sep 2011 10:28:00 -0700 (PDT) Received: by 10.236.145.161 with SMTP id p21mr16361392yhj.123.1316194078338; Fri, 16 Sep 2011 10:27:58 -0700 (PDT) Received: from mail-gw0-f50.google.com (mail-gw0-f50.google.com [74.125.83.50]) by mx.google.com with ESMTPS id u13si1399002ane.147.2011.09.16.10.27.57 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 16 Sep 2011 10:27:58 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.50 is neither permitted nor denied by best guess record for domain of rob.lee@linaro.org) client-ip=74.125.83.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.50 is neither permitted nor denied by best guess record for domain of rob.lee@linaro.org) smtp.mail=rob.lee@linaro.org Received: by gwj16 with SMTP id 16so4182609gwj.37 for ; Fri, 16 Sep 2011 10:27:57 -0700 (PDT) Received: by 10.101.189.35 with SMTP id r35mr2595647anp.98.1316194076785; Fri, 16 Sep 2011 10:27:56 -0700 (PDT) Received: from b18647-20 ([64.31.34.21]) by mx.google.com with ESMTPS id k12sm24715473anc.19.2011.09.16.10.27.54 (version=SSLv3 cipher=OTHER); Fri, 16 Sep 2011 10:27:55 -0700 (PDT) From: Robert Lee To: linux-arm-kernel@lists.infradead.org, s.hauer@pengutronix.de Cc: patches@linaro.org, amit.kucheria@linaro.org, Shawn.Guo@freescale.com, Hui.Liu@freescale.com Subject: [PATCH v2 2/3] ARM: imx: Add cpuidle for mach-mx5 Date: Fri, 16 Sep 2011 12:27:49 -0500 Message-Id: <1316194070-21889-3-git-send-email-rob.lee@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1316194070-21889-1-git-send-email-rob.lee@linaro.org> References: <1316194070-21889-1-git-send-email-rob.lee@linaro.org> Add functionality for initialization and handling of a cpuidle driver requests entering a cpu idle state. Signed-off-by: Robert Lee --- arch/arm/mach-mx5/system.c | 35 +++++++++++++++++++++++++++++++ arch/arm/plat-mxc/include/mach/system.h | 3 ++ 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-mx5/system.c b/arch/arm/mach-mx5/system.c index 76ae8dc..85d6dd7 100644 --- a/arch/arm/mach-mx5/system.c +++ b/arch/arm/mach-mx5/system.c @@ -12,7 +12,11 @@ */ #include #include +#include +#include +#include #include +#include #include "crm_regs.h" /* set cpu low power mode before WFI instruction. This function is called @@ -82,3 +86,34 @@ void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode) __raw_writel(empgc1, MXC_SRPG_EMPGC1_SRPGCR); } } + +int mx5_cpuidle(struct cpuidle_device *dev, struct cpuidle_state *state) +{ + mx5_cpu_lp_set((enum mxc_cpu_pwr_mode)state->driver_data); + + cpu_do_idle(); + + return 0; +} + +int __init mx5_cpuidle_init(void * init_data) +{ + int ret; + struct clk *gpc_dvfs_clk; + + gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs"); + + if (IS_ERR(gpc_dvfs_clk)) { + pr_err("%s: Failed to get gpc_dvfs clock\n", __func__); + return (int)gpc_dvfs_clk; + } + + ret = clk_enable(gpc_dvfs_clk); + + if (IS_ERR(&ret)) { + pr_err("%s: Failed to enable gpc_dvfs clock\n", __func__); + return ret; + } + + return 0; +} diff --git a/arch/arm/plat-mxc/include/mach/system.h b/arch/arm/plat-mxc/include/mach/system.h index 51f02a9..f7c4be5 100644 --- a/arch/arm/plat-mxc/include/mach/system.h +++ b/arch/arm/plat-mxc/include/mach/system.h @@ -17,10 +17,13 @@ #ifndef __ASM_ARCH_MXC_SYSTEM_H__ #define __ASM_ARCH_MXC_SYSTEM_H__ +#include #include #include extern void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode); +extern int mx5_cpuidle_init(void *init_data); +extern int mx5_cpuidle(struct cpuidle_device *dev, struct cpuidle_state *state); static inline void arch_idle(void) {