From patchwork Wed May 16 02:33:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob X-Patchwork-Id: 8668 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 A769B23E37 for ; Wed, 16 May 2012 02:33:55 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 783BDA1826F for ; Wed, 16 May 2012 02:33:55 +0000 (UTC) Received: by mail-gg0-f180.google.com with SMTP id f1so349787ggn.11 for ; Tue, 15 May 2012 19:33:55 -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=yN7OlKYRa/LA/VSsJB7AKeOP7inn9qr3HD8WpEd8K+4=; b=LmwywWpmF3MWFhlFHhiJpT1wp15KTqzUYWBF7GRPNOOiYGXRquVwoPSKwa+ghfFpkV uN7J+NqX842kbzcPSZRMBUpOF/I0SlBd7VOqune5Is1mSYHwT8D51wygtwA0cgxmMmZe fOUXmyjq+4TYk4vf+PPV6olgk2PaoAF+Ow8Jt0b779gsoZArvCLLJLWuDunJ1Ko4OrrA jXWeuMunj2qDu1zy+tjcj0WOAE5dj5Jkion2jgGDY70jfMO0iQDmU/Aon3uve/fY3pCe zeHggSN5Wla6k9ByaAmf9A/sR1PCXVFCMU16IvAB7wogVKvoVZY3qXpALt9VB+i16c56 q7Mg== Received: by 10.50.40.193 with SMTP id z1mr813492igk.0.1337135635139; Tue, 15 May 2012 19:33:55 -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 o8csp460628ibd; Tue, 15 May 2012 19:33:54 -0700 (PDT) Received: by 10.236.191.36 with SMTP id f24mr1412051yhn.100.1337135634234; Tue, 15 May 2012 19:33:54 -0700 (PDT) Received: from mail-gg0-f178.google.com (mail-gg0-f178.google.com [209.85.161.178]) by mx.google.com with ESMTPS id v69si991953yhl.47.2012.05.15.19.33.54 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 15 May 2012 19:33:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.161.178 is neither permitted nor denied by best guess record for domain of rob.lee@linaro.org) client-ip=209.85.161.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.161.178 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-gg0-f178.google.com with SMTP id q6so329325ggc.37 for ; Tue, 15 May 2012 19:33:54 -0700 (PDT) Received: by 10.236.146.1 with SMTP id q1mr1526404yhj.33.1337135633999; Tue, 15 May 2012 19:33:53 -0700 (PDT) Received: from localhost.localdomain ([216.59.27.28]) by mx.google.com with ESMTPS id a68sm4346289yhj.22.2012.05.15.19.33.52 (version=SSLv3 cipher=OTHER); Tue, 15 May 2012 19:33:53 -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 v4 6/7] ARM: imx: Add imx5 cpuidle Date: Tue, 15 May 2012 21:33:35 -0500 Message-Id: <1337135616-8988-7-git-send-email-rob.lee@linaro.org> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1337135616-8988-1-git-send-email-rob.lee@linaro.org> References: <1337135616-8988-1-git-send-email-rob.lee@linaro.org> X-Gm-Message-State: ALoCoQmx5fP2z9Q2tM01DWQRZ7U8uinITUHuE/pFfTcLJX/lCtmocovPLWgjAvOUhMU5WURs5G+h Add cpuidle driver for imx5 platform. Signed-off-by: Robert Lee --- arch/arm/mach-imx/pm-imx5.c | 44 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/pm-imx5.c b/arch/arm/mach-imx/pm-imx5.c index 6e62d79..966c71b 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, +}; + int __init imx5_pm_init(void) { int ret; @@ -160,5 +198,5 @@ int __init imx5_pm_init(void) /* Set the registers to the default cpu idle state. */ mx5_cpu_lp_set(IMX5_DEFAULT_CPU_IDLE_STATE); - return 0; + return imx_cpuidle_init(&imx5_cpuidle_driver); }