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: Robert Lee X-Patchwork-Id: 159494 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 45BB2B6FAC for ; Wed, 16 May 2012 12:36:55 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SUU4q-0002bB-9m; Wed, 16 May 2012 02:35:00 +0000 Received: from mail-gg0-f177.google.com ([209.85.161.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SUU3m-0002Dm-6K for linux-arm-kernel@lists.infradead.org; Wed, 16 May 2012 02:33:54 +0000 Received: by mail-gg0-f177.google.com with SMTP id s5so326572ggc.36 for ; Tue, 15 May 2012 19:33:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=yN7OlKYRa/LA/VSsJB7AKeOP7inn9qr3HD8WpEd8K+4=; b=FhCwDhlXpiLB3b3si4sLskIfw9oB25luT8UuVfOPi3tDrL4XHAjMThnj20mspSCd0r Aov+u9s/BAccSf58g50B27IaVupT1fOjwznvrl3FgoopYqubdYPPJUG65phUnmLkJ1fj 5YQMB1Q0VBd2qRvkAU2ebkp9C5NcDCnBkaxGLmGqQSLXhSjJhzxRE4mOz2/YtXEuUTXo n1g3zvx9NYbWarnrRx8tC4YUA6P/35jZYUmKYF5GE8BfNw+tb8M5oHgGGflACGwNbDXO itZdgBOIGILQo104N+SldYQ31Qj1kZOYZ94Uptlwp8go9DCClW7Nr93TvDM26QbV/pUR WKIw== 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 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: ALoCoQlRRQTiSiS5Elgbq7WWY9hdzbPnFSA8gE8ysD29Mp0NBltHmb6AcUBPj31iCkOZ+cFqQSaC X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.161.177 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-dev@lists.linaro.org, patches@linaro.org, daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org, amit.kucheria@linaro.org, jj@chaosbits.net, richard.zhao@freescale.com, u.kleine-koenig@pengutronix.de, shawn.guo@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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); }