From patchwork Mon Apr 16 23:50:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob X-Patchwork-Id: 7880 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 2CEFB23E1D for ; Mon, 16 Apr 2012 23:51:07 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id C9B7EA18737 for ; Mon, 16 Apr 2012 23:51:06 +0000 (UTC) Received: by iage36 with SMTP id e36so11132973iag.11 for ; Mon, 16 Apr 2012 16:51:06 -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=kOQSeWX8RTEhYPc5El7ss8X0ufZUXv01VQniOacJd58=; b=bFFe+DSZRo3saNzYtE2J+TTgf7HT39Nh/xalxVat9FAw7NvkdjTqgR2OX4nCSOOJwC 00AlTofjagmNjTGLg6x/93rcQk3+w8iF5LbXLriBnMVoQFxELWV4s5xcybxJ9JuCF9p7 wEHPazf1dmbtxzsbaFKpCYsgZ+Q8mRRI86IghLyG9agfI6MEtObAnzr1ja3CjUemtScW f3RZU0IVJiWfyFIXVCWu8onv3ddp0jlJhaRTUFVm8GXvJLL2+AXY9X4YSg4doSpo8jdw dG1v2igG9TuUnvngsSdBXrZ6LthH8QfN2PO9DqfxHvwrfTyZ7cEZvzg9eXQ2M/h+AShA jWLw== Received: by 10.50.185.233 with SMTP id ff9mr7520780igc.55.1334620266230; Mon, 16 Apr 2012 16:51:06 -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.137.198 with SMTP id x6csp112777ibt; Mon, 16 Apr 2012 16:51:05 -0700 (PDT) Received: by 10.60.9.38 with SMTP id w6mr18210828oea.41.1334620265727; Mon, 16 Apr 2012 16:51:05 -0700 (PDT) Received: from mail-ob0-f178.google.com (mail-ob0-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id i9si10315871oba.66.2012.04.16.16.51.05 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Apr 2012 16:51:05 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of rob.lee@linaro.org) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.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 obfk16 with SMTP id k16so10344661obf.37 for ; Mon, 16 Apr 2012 16:51:05 -0700 (PDT) Received: by 10.182.112.41 with SMTP id in9mr18478388obb.40.1334620265472; Mon, 16 Apr 2012 16:51:05 -0700 (PDT) Received: from localhost.localdomain ([216.59.27.108]) by mx.google.com with ESMTPS id xb7sm21169537obb.10.2012.04.16.16.51.00 (version=SSLv3 cipher=OTHER); Mon, 16 Apr 2012 16:51:05 -0700 (PDT) From: Robert Lee To: kernel@pengutronix.de Cc: shawn.guo@linaro.org, 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 Subject: [PATCH 2/3] ARM: imx: Add imx5 cpuidle driver Date: Mon, 16 Apr 2012 18:50:13 -0500 Message-Id: <1334620214-25803-3-git-send-email-rob.lee@linaro.org> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1334620214-25803-1-git-send-email-rob.lee@linaro.org> References: <1334620214-25803-1-git-send-email-rob.lee@linaro.org> X-Gm-Message-State: ALoCoQnMiObsHy8/MuKdyPV7YGfOAHym1Y0acZLFULrwCbKJUyTuUUkTxQPfbgjz2PDZAY2qgJOl Add imx5 cpuidle driver. Signed-off-by: Robert Lee --- arch/arm/mach-imx/Makefile | 2 +- arch/arm/mach-imx/cpuidle-imx5.c | 55 +++++++++++++++++++++++++++++++ arch/arm/mach-imx/mm-imx5.c | 16 ++++++--- arch/arm/plat-mxc/include/mach/common.h | 1 + 4 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 arch/arm/mach-imx/cpuidle-imx5.c diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index ab939c5..84b8976 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -9,7 +9,7 @@ obj-$(CONFIG_SOC_IMX27) += clock-imx27.o mm-imx27.o ehci-imx27.o obj-$(CONFIG_SOC_IMX31) += mm-imx3.o cpu-imx31.o clock-imx31.o iomux-imx31.o ehci-imx31.o pm-imx3.o obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-imx3.o -obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o +obj-$(CONFIG_SOC_IMX5) += cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o cpuidle-imx5.o # Support for CMOS sensor interface obj-$(CONFIG_MX1_VIDEO) += mx1-camera-fiq.o mx1-camera-fiq-ksym.o diff --git a/arch/arm/mach-imx/cpuidle-imx5.c b/arch/arm/mach-imx/cpuidle-imx5.c new file mode 100644 index 0000000..8f428fc --- /dev/null +++ b/arch/arm/mach-imx/cpuidle-imx5.c @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Freescale Semiconductor, Inc. + * Copyright 2012 Linaro Ltd. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static int imx5_cpuidle_enter(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int idx) +{ + int ret; + + ret = imx5_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 = 20, /* max latency at 160MHz */ + .target_residency = 1, + .flags = CPUIDLE_FLAG_TIME_VALID, + .name = "IMX5 SRPG", + .desc = "CPU state retained,powered off", + }, + .state_count = 1, +}; + +int __init imx5_cpuidle_init(void) +{ + imx_cpuidle_set_driver(&imx5_cpuidle_driver); + + return 0; +} diff --git a/arch/arm/mach-imx/mm-imx5.c b/arch/arm/mach-imx/mm-imx5.c index e10f391..594915b 100644 --- a/arch/arm/mach-imx/mm-imx5.c +++ b/arch/arm/mach-imx/mm-imx5.c @@ -22,22 +22,29 @@ #include #include #include +#include static struct clk *gpc_dvfs_clk; -static void imx5_idle(void) +int imx5_idle(void) { + int ret = 0; + /* gpc clock is needed for SRPG */ if (gpc_dvfs_clk == NULL) { gpc_dvfs_clk = clk_get(NULL, "gpc_dvfs"); if (IS_ERR(gpc_dvfs_clk)) - return; + return -ENODEV; } clk_enable(gpc_dvfs_clk); mx5_cpu_lp_set(WAIT_UNCLOCKED_POWER_OFF); if (!tzic_enable_wake()) cpu_do_idle(); + else + ret = -EBUSY; clk_disable(gpc_dvfs_clk); + + return ret; } /* @@ -103,7 +110,7 @@ void __init imx51_init_early(void) mxc_set_cpu_type(MXC_CPU_MX51); mxc_iomux_v3_init(MX51_IO_ADDRESS(MX51_IOMUXC_BASE_ADDR)); mxc_arch_reset_init(MX51_IO_ADDRESS(MX51_WDOG1_BASE_ADDR)); - arm_pm_idle = imx5_idle; + arm_pm_idle = (void *)imx5_idle; } void __init imx53_init_early(void) @@ -203,7 +210,8 @@ void __init imx51_soc_init(void) /* i.mx51 has the i.mx35 type sdma */ imx_add_imx_sdma("imx35-sdma", MX51_SDMA_BASE_ADDR, MX51_INT_SDMA, &imx51_sdma_pdata); - /* Setup AIPS registers */ + imx5_cpuidle_init(); + imx_set_aips(MX51_IO_ADDRESS(MX51_AIPS1_BASE_ADDR)); imx_set_aips(MX51_IO_ADDRESS(MX51_AIPS2_BASE_ADDR)); diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h index 0319c4a..128a572 100644 --- a/arch/arm/plat-mxc/include/mach/common.h +++ b/arch/arm/plat-mxc/include/mach/common.h @@ -95,6 +95,7 @@ enum mx3_cpu_pwr_mode { extern void mx3_cpu_lp_set(enum mx3_cpu_pwr_mode mode); extern void mx5_cpu_lp_set(enum mxc_cpu_pwr_mode mode); +extern int imx5_idle(void); extern void imx_print_silicon_rev(const char *cpu, int srev); void avic_handle_irq(struct pt_regs *);