linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: khilman@deeprootsystems.com (Kevin Hilman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 08/27] OMAP3: PM: handle PER/NEON/CORE in idle
Date: Wed, 14 Oct 2009 14:57:51 -0700	[thread overview]
Message-ID: <1255557490-16787-9-git-send-email-khilman@deeprootsystems.com> (raw)
In-Reply-To: <1255557490-16787-8-git-send-email-khilman@deeprootsystems.com>

From: Rajendra Nayak <rnayak@ti.com>

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
---
 arch/arm/mach-omap2/pm34xx.c |   64 +++++++++++++++++++++++++++++++++++------
 1 files changed, 54 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index 9dbb5a0..7eab539 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -49,7 +49,10 @@ static LIST_HEAD(pwrst_list);
 
 static void (*_omap_sram_idle)(u32 *addr, int save_state);
 
-static struct powerdomain *mpu_pwrdm;
+static struct powerdomain *mpu_pwrdm, *neon_pwrdm;
+static struct powerdomain *core_pwrdm, *per_pwrdm;
+
+static int set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
 
 /*
  * PRCM Interrupt Handler Helper Function
@@ -169,13 +172,22 @@ static void omap_sram_idle(void)
 	/* save_state = 1 => Only L1 and logic lost */
 	/* save_state = 2 => Only L2 lost */
 	/* save_state = 3 => L1, L2 and logic lost */
-	int save_state = 0, mpu_next_state;
+	int save_state = 0;
+	int mpu_next_state = PWRDM_POWER_ON;
+	int per_next_state = PWRDM_POWER_ON;
+	int core_next_state = PWRDM_POWER_ON;
 
 	if (!_omap_sram_idle)
 		return;
 
+	pwrdm_clear_all_prev_pwrst(mpu_pwrdm);
+	pwrdm_clear_all_prev_pwrst(neon_pwrdm);
+	pwrdm_clear_all_prev_pwrst(core_pwrdm);
+	pwrdm_clear_all_prev_pwrst(per_pwrdm);
+
 	mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
 	switch (mpu_next_state) {
+	case PWRDM_POWER_ON:
 	case PWRDM_POWER_RET:
 		/* No need to save context */
 		save_state = 0;
@@ -187,18 +199,37 @@ static void omap_sram_idle(void)
 	}
 	pwrdm_pre_transition();
 
-	omap2_gpio_prepare_for_retention();
-	omap_uart_prepare_idle(0);
-	omap_uart_prepare_idle(1);
-	omap_uart_prepare_idle(2);
+	/* NEON control */
+	if (pwrdm_read_pwrst(neon_pwrdm) == PWRDM_POWER_ON)
+		set_pwrdm_state(neon_pwrdm, mpu_next_state);
+
+	/* CORE & PER */
+	core_next_state = pwrdm_read_next_pwrst(core_pwrdm);
+	if (core_next_state < PWRDM_POWER_ON) {
+		omap2_gpio_prepare_for_retention();
+		omap_uart_prepare_idle(0);
+		omap_uart_prepare_idle(1);
+		/* PER changes only with core */
+		per_next_state = pwrdm_read_next_pwrst(per_pwrdm);
+		if (per_next_state < PWRDM_POWER_ON)
+			omap_uart_prepare_idle(2);
+		/* Enable IO-PAD wakeup */
+		prm_set_mod_reg_bits(OMAP3430_EN_IO, WKUP_MOD, PM_WKEN);
+	}
 
 	_omap_sram_idle(NULL, save_state);
 	cpu_init();
 
-	omap_uart_resume_idle(2);
-	omap_uart_resume_idle(1);
-	omap_uart_resume_idle(0);
-	omap2_gpio_resume_after_retention();
+	if (core_next_state < PWRDM_POWER_ON) {
+		if (per_next_state < PWRDM_POWER_ON)
+			omap_uart_resume_idle(2);
+		omap_uart_resume_idle(1);
+		omap_uart_resume_idle(0);
+
+		/* Disable IO-PAD wakeup */
+		prm_clear_mod_reg_bits(OMAP3430_EN_IO, WKUP_MOD, PM_WKEN);
+		omap2_gpio_resume_after_retention();
+	}
 
 	pwrdm_post_transition();
 
@@ -791,6 +822,10 @@ static int __init omap3_pm_init(void)
 		goto err2;
 	}
 
+	neon_pwrdm = pwrdm_lookup("neon_pwrdm");
+	per_pwrdm = pwrdm_lookup("per_pwrdm");
+	core_pwrdm = pwrdm_lookup("core_pwrdm");
+
 	omap_push_sram_idle();
 #ifdef CONFIG_SUSPEND
 	suspend_set_ops(&omap_pm_ops);
@@ -798,6 +833,15 @@ static int __init omap3_pm_init(void)
 
 	pm_idle = omap3_pm_idle;
 
+	pwrdm_add_wkdep(neon_pwrdm, mpu_pwrdm);
+	/*
+	 * REVISIT: This wkdep is only necessary when GPIO2-6 are enabled for
+	 * IO-pad wakeup.  Otherwise it will unnecessarily waste power
+	 * waking up PER with every CORE wakeup - see
+	 * http://marc.info/?l=linux-omap&m=121852150710062&w=2
+	*/
+	pwrdm_add_wkdep(per_pwrdm, core_pwrdm);
+
 err1:
 	return ret;
 err2:
-- 
1.6.4.3

  reply	other threads:[~2009-10-14 21:57 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14 21:57 [PATCH 00/27] OMAP3: PM: base off-mode support Kevin Hilman
2009-10-14 21:57 ` [PATCH 01/27] OMAP3: PM: GPMC context save/restore Kevin Hilman
2009-10-14 21:57   ` [PATCH 02/27] OMAP3: PM: GPIO " Kevin Hilman
2009-10-14 21:57     ` [PATCH 03/27] OMAP3: PM: INTC " Kevin Hilman
2009-10-14 21:57       ` [PATCH 04/27] OMAP3: PM: PRCM " Kevin Hilman
2009-10-14 21:57         ` [PATCH 05/27] OMAP3: PM: Populate scratchpad contents Kevin Hilman
2009-10-14 21:57           ` [PATCH 06/27] OMAP3: PM: SCM context save/restore Kevin Hilman
2009-10-14 21:57             ` [PATCH 07/27] OMAP3: PM: SRAM restore function Kevin Hilman
2009-10-14 21:57               ` Kevin Hilman [this message]
2009-10-14 21:57                 ` [PATCH 09/27] OMAP3: PM: Restore MMU table entry Kevin Hilman
2009-10-14 21:57                   ` [PATCH 10/27] OMAP3: PM: MPU off-mode support Kevin Hilman
2009-10-14 21:57                     ` [PATCH 11/27] OMAP3: PM: CORE domain " Kevin Hilman
2009-10-14 21:57                       ` [PATCH 12/27] OMAP: PM: DMA context save/restore for " Kevin Hilman
2009-10-14 21:57                         ` [PATCH 13/27] OMAP3 PM: off-mode support for HS/EMU devices Kevin Hilman
2009-10-14 21:57                           ` [PATCH 14/27] OMAP3: PM: save secure RAM only during init Kevin Hilman
2009-10-14 21:57                             ` [PATCH 15/27] OMAP3: PM: Enable SDRAM auto-refresh during sleep Kevin Hilman
2009-10-14 21:57                               ` [PATCH 16/27] OMAP3: PM: Save and restore also CM_CLKSEL1_PLL_IVA2 Kevin Hilman
2009-10-14 21:58                                 ` [PATCH 17/27] OMAP3: PM: Fix secure SRAM context save/restore Kevin Hilman
2009-10-14 21:58                                   ` [PATCH 18/27] ARM: OMAP: Add missing SMS_SYSCONFIG save/restore Kevin Hilman
2009-10-14 21:58                                     ` [PATCH 19/27] OMAP3: PM: Fix PLL_MOD CLKEN offset in scratchpad Kevin Hilman
2009-10-14 21:58                                       ` [PATCH 20/27] OMAP: PM: Clear DMA channel state after a wakeup Kevin Hilman
2009-10-14 21:58                                         ` [PATCH 21/27] OMAP: Store reboot mode in scratchpad on OMAP34xx Kevin Hilman
2009-10-14 21:58                                           ` [PATCH 22/27] OMAP3: PM: SDRC auto-refresh workaround for off-mode Kevin Hilman
2009-10-14 21:58                                             ` [PATCH 23/27] OMAP3: PM: Fix INTC context save/restore Kevin Hilman
2009-10-14 21:58                                               ` [PATCH 24/27] PM: Disable usb host HW save and restore Kevin Hilman
2009-10-14 21:58                                                 ` [PATCH 25/27] OMAP3: PM: Wait for SDRC ready iso a blind delay Kevin Hilman
2009-10-14 21:58                                                   ` [PATCH 26/27] OMAP3: PM debug: allow runtime toggle of PM features Kevin Hilman
2009-10-14 21:58                                                     ` [PATCH 27/27] PM debug: allow configurable wakeup from suspend on OMAP GPtimer Kevin Hilman
2009-10-14 22:18                 ` [PATCH 08/27] OMAP3: PM: handle PER/NEON/CORE in idle Tony Lindgren
2009-10-14 22:17               ` [PATCH 07/27] OMAP3: PM: SRAM restore function Tony Lindgren
2009-10-14 22:15       ` [PATCH 03/27] OMAP3: PM: INTC context save/restore Tony Lindgren
2009-10-14 22:13     ` [PATCH 02/27] OMAP3: PM: GPIO " Tony Lindgren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1255557490-16787-9-git-send-email-khilman@deeprootsystems.com \
    --to=khilman@deeprootsystems.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).