From patchwork Mon May 21 22:50:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob X-Patchwork-Id: 8848 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 B90DC23EB5 for ; Mon, 21 May 2012 22:50:53 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8927CA18C20 for ; Mon, 21 May 2012 22:50:53 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so5982798yen.11 for ; Mon, 21 May 2012 15:50:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=3LGs59byksEGZ1iE0mHBXg3NO9YgzuG8u2z6n8AfnD8=; b=UNZ+8lifJEqr0lJ2ThQ310fM/51QPwD4cbCTXoH8FtIobKgdjpGcoW8NcIv8Dou54W IlBOwDE2UoLQNu3gdd3aIwW33yGy/JiBHMQnnvj+sRE/2d+FlMzWl1EFDHb+I4wrYvAf Hu9DNlr/8XIqySPoj+bdJeQbh3v43VUMHoRdihUPkl8tPEibN9gay2QVA3+bbq/I55NF 9QteJrsNXTz0xtnt4ilAKukfJ8kUQn69IA29J13jNLoQPzPhsiIHD3OcUk6SkjB/hN6F Byx74xXpdDWZ8ewGi8PYYFz1LpG7upXgskaxv/n+GA/Wv4mtaZxmUJj9owaLMICUq7Vj MFwg== Received: by 10.50.222.202 with SMTP id qo10mr8141487igc.0.1337640653232; Mon, 21 May 2012 15:50:53 -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.231.35.72 with SMTP id o8csp324881ibd; Mon, 21 May 2012 15:50:52 -0700 (PDT) Received: by 10.236.46.74 with SMTP id q50mr25046302yhb.30.1337640652341; Mon, 21 May 2012 15:50:52 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id r13si7842092ank.106.2012.05.21.15.50.52 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 21 May 2012 15:50:52 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of rob.lee@linaro.org) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.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 mail-yw0-f50.google.com with SMTP id j63so5958556yhj.37 for ; Mon, 21 May 2012 15:50:52 -0700 (PDT) Received: by 10.50.183.162 with SMTP id en2mr7925788igc.44.1337640651947; Mon, 21 May 2012 15:50:51 -0700 (PDT) Received: from localhost.localdomain ([216.59.27.6]) by mx.google.com with ESMTPS id dk9sm8682082igb.13.2012.05.21.15.50.48 (version=SSLv3 cipher=OTHER); Mon, 21 May 2012 15:50:51 -0700 (PDT) From: Robert Lee To: kernel@pengutronix.de Cc: shawn.guo@linaro.org, u.kleine-koenig@pengutronix.de, richard.zhao@freescale.com, amit.kucheria@linaro.org, daniel.lezcano@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org, jj@chaosbits.net Subject: [PATCH v5 6/7] ARM: imx: Add imx5 cpuidle Date: Mon, 21 May 2012 17:50:29 -0500 Message-Id: <1337640630-29176-7-git-send-email-rob.lee@linaro.org> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1337640630-29176-1-git-send-email-rob.lee@linaro.org> References: <1337640630-29176-1-git-send-email-rob.lee@linaro.org> X-Gm-Message-State: ALoCoQkMQfSUxYInf9m58NY8kouggAzb2L+m5MHV8odHM/g4nknvLTzbaME6mnpdS0lE3ZEs3nEv Add cpuidle driver for imx5 platform. Signed-off-by: Robert Lee --- arch/arm/mach-imx/pm-imx5.c | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c index b3dcd8e..19621ed1 100644 --- a/arch/arm/mach-imx/pm-imx5.c +++ b/arch/arm/mach-imx/pm-imx5.c @@ -12,10 +12,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include "crm-regs-imx5.h" @@ -134,12 +136,48 @@ static const struct platform_suspend_ops mx5_suspend_ops = { .enter = mx5_suspend_enter, }; -static void imx5_pm_idle(void) +static inline int imx5_cpu_do_idle(void) { - if (likely(!tzic_enable_wake())) + int ret = tzic_enable_wake(); + + if (likely(!ret)) cpu_do_idle(); + + return ret; +} + +static void imx5_pm_idle(void) +{ + imx5_cpu_do_idle(); +} + +static int imx5_cpuidle_enter(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + int ret; + + ret = imx5_cpu_do_idle(); + if (ret < 0) + return ret; + + return idx; } +static struct cpuidle_driver imx5_cpuidle_driver = { + .name = "imx5_cpuidle", + .owner = THIS_MODULE, + .en_core_tk_irqen = 1, + .states[0] = { + .enter = imx5_cpuidle_enter, + .exit_latency = 2, + .target_residency = 1, + .flags = CPUIDLE_FLAG_TIME_VALID, + .name = "IMX5 SRPG", + .desc = "CPU state retained,powered off", + }, + .state_count = 1, +}; + static int __init imx5_pm_common_init(void) { int ret; @@ -157,6 +195,7 @@ static int __init imx5_pm_common_init(void) /* Set the registers to the default cpu idle state. */ mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE); + imx_cpuidle_init(&imx5_cpuidle_driver); return 0; }