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: Robert Lee X-Patchwork-Id: 160498 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 61426B6F77 for ; Tue, 22 May 2012 08:55:17 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SWbSY-0003HF-Hq; Mon, 21 May 2012 22:52:15 +0000 Received: from mail-yx0-f177.google.com ([209.85.213.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SWbRG-0002nk-0m for linux-arm-kernel@lists.infradead.org; Mon, 21 May 2012 22:50:54 +0000 Received: by yenr9 with SMTP id r9so5526718yen.36 for ; Mon, 21 May 2012 15:50:52 -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=3LGs59byksEGZ1iE0mHBXg3NO9YgzuG8u2z6n8AfnD8=; b=YALM1kzHnUOe+ADpSQpPfl8Kf220WnbxWBgutdWtQ3dyF4LIOuwxHotlbF6Uo8puT+ a86wTkZh8MnCWveVWX/L6qJauGW39Q4tgh/BXbcUEGI5I/CCCF/GNVazBSNeZIMZ+nh3 IqTw2y8CaEmmRddkV64ViB/N8FriZP3CbsiTj5P7B9qElybR36c39H6k33qx9AZhQPL3 hNBvc5aCUwFVsreC7By9URGX0I1oPcoOCO+b1mJ4xSTJ7BXcbpR/3bK9m54AMDXB+K4F /F6UtSycy1RYMS3cQPKj6hFT/FIVofVp3WaXahS4JQ/1024paGoyaVADKQ+6TThlvDH0 CthQ== 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 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: ALoCoQllsw/kIfoBtpTnqTBkNgwBg7u9GbSHnAA/vQe8wQNS7Kh12rK1yKkjIDfRyt6OsCTb7Ly5 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.213.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 | 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; }