All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rickard Andersson <rickard.andersson@stericsson.com>
To: rjw@sisk.pl, linux-pm@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: hongbo.zhang@linaro.org, ulf.hansson@linaro.org,
	khilman@linaro.org, linus.walleij@stericsson.com,
	daniel.lezcano@linaro.org, rickard.andersson@stericsson.com
Subject: [PATCH V2 08/12] ARM: ux500: Add ApSleep state to suspend
Date: Thu, 28 Mar 2013 17:11:34 +0100	[thread overview]
Message-ID: <1364487098-10319-9-git-send-email-rickard.andersson@stericsson.com> (raw)
In-Reply-To: <1364487098-10319-1-git-send-email-rickard.andersson@stericsson.com>

Support for power save state ApSleep is
added to the platform suspend operation
hook.

Signed-off-by: Rickard Andersson <rickard.andersson@stericsson.com>
---
 arch/arm/mach-ux500/suspend.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-ux500/suspend.c b/arch/arm/mach-ux500/suspend.c
index d1ac203..875a92d 100644
--- a/arch/arm/mach-ux500/suspend.c
+++ b/arch/arm/mach-ux500/suspend.c
@@ -10,11 +10,60 @@
  */
 
 #include <linux/suspend.h>
+#include <linux/pm_domain.h>
+#include <linux/mfd/dbx500-prcmu.h>
+
+static u32 suspend_wakeups;
+static u32 running_wakeups;
+static struct generic_pm_domain *ape_domain;
 
 static int ux500_suspend_enter(suspend_state_t state)
 {
+	int ret = 0;
+
+	/* Configure the PRCMU for a sleep wakeup */
+	prcmu_enable_wakeups(suspend_wakeups);
+
+	pm_genpd_notify_power_on_off(ape_domain, false);
+
+	prcmu_gic_decouple();
+
+	/* Copy GIC interrupt settings to PRCMU interrupt settings */
+	prcmu_copy_gic_settings();
+
+	if (prcmu_gic_pending_irq()) {
+		pr_info("suspend/resume: pending interrupt\n");
+
+		/* Recouple GIC with the interrupt bus */
+		prcmu_gic_recouple();
+		ret = -EBUSY;
+		goto exit;
+	}
+
+	if (prcmu_pending_irq()) {
+		pr_info("suspend/resume: pending interrupt prcmu\n");
+
+		/* Recouple GIC with the interrupt bus */
+		prcmu_gic_recouple();
+		ret = -EBUSY;
+		goto exit;
+	}
+
+	prcmu_set_ioforce(true);
+
+	prcmu_set_power_state(PRCMU_AP_SLEEP, false, false);
+
 	cpu_do_idle();
-	return 0;
+
+	pm_genpd_notify_power_on_off(ape_domain, true);
+
+	prcmu_set_ioforce(false);
+
+ exit:
+	/* Configure the prcmu with the wake-ups that cpuidle needs */
+	prcmu_enable_wakeups(running_wakeups);
+
+	return ret;
 }
 
 static int ux500_suspend_valid(suspend_state_t state)
@@ -29,6 +78,12 @@ static const struct platform_suspend_ops ux500_suspend_ops = {
 
 static __init int ux500_suspend_init(void)
 {
+	suspend_wakeups = PRCMU_WAKEUP(ABB) | PRCMU_WAKEUP(RTC);
+	running_wakeups = (PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) |
+				   PRCMU_WAKEUP(ABB));
+
+	ape_domain = pm_genpd_lookup_name("APE");
+
 	suspend_set_ops(&ux500_suspend_ops);
 	return 0;
 }
-- 
1.8.2

WARNING: multiple messages have this Message-ID (diff)
From: rickard.andersson@stericsson.com (Rickard Andersson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V2 08/12] ARM: ux500: Add ApSleep state to suspend
Date: Thu, 28 Mar 2013 17:11:34 +0100	[thread overview]
Message-ID: <1364487098-10319-9-git-send-email-rickard.andersson@stericsson.com> (raw)
In-Reply-To: <1364487098-10319-1-git-send-email-rickard.andersson@stericsson.com>

Support for power save state ApSleep is
added to the platform suspend operation
hook.

Signed-off-by: Rickard Andersson <rickard.andersson@stericsson.com>
---
 arch/arm/mach-ux500/suspend.c | 57 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-ux500/suspend.c b/arch/arm/mach-ux500/suspend.c
index d1ac203..875a92d 100644
--- a/arch/arm/mach-ux500/suspend.c
+++ b/arch/arm/mach-ux500/suspend.c
@@ -10,11 +10,60 @@
  */
 
 #include <linux/suspend.h>
+#include <linux/pm_domain.h>
+#include <linux/mfd/dbx500-prcmu.h>
+
+static u32 suspend_wakeups;
+static u32 running_wakeups;
+static struct generic_pm_domain *ape_domain;
 
 static int ux500_suspend_enter(suspend_state_t state)
 {
+	int ret = 0;
+
+	/* Configure the PRCMU for a sleep wakeup */
+	prcmu_enable_wakeups(suspend_wakeups);
+
+	pm_genpd_notify_power_on_off(ape_domain, false);
+
+	prcmu_gic_decouple();
+
+	/* Copy GIC interrupt settings to PRCMU interrupt settings */
+	prcmu_copy_gic_settings();
+
+	if (prcmu_gic_pending_irq()) {
+		pr_info("suspend/resume: pending interrupt\n");
+
+		/* Recouple GIC with the interrupt bus */
+		prcmu_gic_recouple();
+		ret = -EBUSY;
+		goto exit;
+	}
+
+	if (prcmu_pending_irq()) {
+		pr_info("suspend/resume: pending interrupt prcmu\n");
+
+		/* Recouple GIC with the interrupt bus */
+		prcmu_gic_recouple();
+		ret = -EBUSY;
+		goto exit;
+	}
+
+	prcmu_set_ioforce(true);
+
+	prcmu_set_power_state(PRCMU_AP_SLEEP, false, false);
+
 	cpu_do_idle();
-	return 0;
+
+	pm_genpd_notify_power_on_off(ape_domain, true);
+
+	prcmu_set_ioforce(false);
+
+ exit:
+	/* Configure the prcmu with the wake-ups that cpuidle needs */
+	prcmu_enable_wakeups(running_wakeups);
+
+	return ret;
 }
 
 static int ux500_suspend_valid(suspend_state_t state)
@@ -29,6 +78,12 @@ static const struct platform_suspend_ops ux500_suspend_ops = {
 
 static __init int ux500_suspend_init(void)
 {
+	suspend_wakeups = PRCMU_WAKEUP(ABB) | PRCMU_WAKEUP(RTC);
+	running_wakeups = (PRCMU_WAKEUP(ARM) | PRCMU_WAKEUP(RTC) |
+				   PRCMU_WAKEUP(ABB));
+
+	ape_domain = pm_genpd_lookup_name("APE");
+
 	suspend_set_ops(&ux500_suspend_ops);
 	return 0;
 }
-- 
1.8.2

  parent reply	other threads:[~2013-03-28 16:11 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-28 16:11 [PATCH V2 00/12] ux500 suspend-resume Rickard Andersson
2013-03-28 16:11 ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 01/12] mfd: db8500: Add IO force function Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 02/12] ARM: ux500: Add platform suspend ops Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 03/12] PM / Domains: Add on-off notifiers Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-30 23:17   ` Rafael J. Wysocki
2013-03-30 23:17     ` Rafael J. Wysocki
2013-04-23 12:26     ` Rickard Andersson
2013-04-23 12:26       ` Rickard Andersson
2013-04-29 12:14       ` Linus Walleij
2013-04-29 12:14         ` Linus Walleij
2013-04-30 12:55         ` Rickard Andersson
2013-04-30 12:55           ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 04/12] PM / Domains: Lookup domain by name Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 05/12] ARM: ux500: Create APE generic power domain Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 06/12] clk: ux500: Add PRCC power management Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 07/12] ARM: ux500: Create u8500-clk device Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` Rickard Andersson [this message]
2013-03-28 16:11   ` [PATCH V2 08/12] ARM: ux500: Add ApSleep state to suspend Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 09/12] drivers: bus: ux500: Add ICN driver Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 10/12] ARM: ux500: Create ICN device Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 11/12] misc: ux500: Add TPIU driver Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson
2013-03-28 16:11 ` [PATCH V2 12/12] ARM: ux500: Create TPIU device Rickard Andersson
2013-03-28 16:11   ` Rickard Andersson

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=1364487098-10319-9-git-send-email-rickard.andersson@stericsson.com \
    --to=rickard.andersson@stericsson.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=hongbo.zhang@linaro.org \
    --cc=khilman@linaro.org \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    --cc=ulf.hansson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.