diff mbox

[04/10] PM / Domain: Allow genpd users to specify default active wakeup behavior

Message ID 1508162116-5043-5-git-send-email-geert+renesas@glider.be (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Geert Uytterhoeven Oct. 16, 2017, 1:55 p.m. UTC
It is quite common for PM Domains to require slave devices to be kept
active during system suspend if they are to be used as wakeup sources.
To enable this, currently each PM Domain or driver has to provide its
own gpd_dev_ops.active_wakeup() callback.

Introduce a new flag GENPD_FLAG_ACTIVE_WAKEUP to consolidate this.
If specified, a default callback that always returns true will be
installed in gpd_dev_ops.active_wakeup().

PM Domains that need more fine-grained controls can still provide their
own callbacks, as before.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/base/power/domain.c | 8 ++++++++
 include/linux/pm_domain.h   | 7 ++++---
 2 files changed, 12 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index e8ca5e2cf1e51e5a..d9670e7752e92994 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1168,6 +1168,11 @@  static void pm_genpd_complete(struct device *dev)
 	genpd_unlock(genpd);
 }
 
+static bool pm_genpd_active_wakeup_true(struct device *dev)
+{
+	return true;
+}
+
 /**
  * genpd_syscore_switch - Switch power during system core suspend or resume.
  * @dev: Device that normally is marked as "always on" to switch power for.
@@ -1214,6 +1219,7 @@  EXPORT_SYMBOL_GPL(pm_genpd_syscore_poweron);
 #define pm_genpd_poweroff_noirq		NULL
 #define pm_genpd_restore_noirq		NULL
 #define pm_genpd_complete		NULL
+#define pm_genpd_active_wakeup_true	NULL
 
 #endif /* CONFIG_PM_SLEEP */
 
@@ -1587,6 +1593,8 @@  int pm_genpd_init(struct generic_pm_domain *genpd,
 		genpd->dev_ops.stop = pm_clk_suspend;
 		genpd->dev_ops.start = pm_clk_resume;
 	}
+	if (genpd->flags & GENPD_FLAG_ACTIVE_WAKEUP)
+		genpd->dev_ops.active_wakeup = pm_genpd_active_wakeup_true;
 
 	/* Always-on domains must be powered on at initialization. */
 	if (genpd_is_always_on(genpd) && !genpd_status_on(genpd))
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 84f423d5633ee996..a6688efb29ee5406 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -18,9 +18,10 @@ 
 #include <linux/spinlock.h>
 
 /* Defines used for the flags field in the struct generic_pm_domain */
-#define GENPD_FLAG_PM_CLK	(1U << 0) /* PM domain uses PM clk */
-#define GENPD_FLAG_IRQ_SAFE	(1U << 1) /* PM domain operates in atomic */
-#define GENPD_FLAG_ALWAYS_ON	(1U << 2) /* PM domain is always powered on */
+#define GENPD_FLAG_PM_CLK	 (1U << 0) /* PM domain uses PM clk */
+#define GENPD_FLAG_IRQ_SAFE	 (1U << 1) /* PM domain operates in atomic */
+#define GENPD_FLAG_ALWAYS_ON	 (1U << 2) /* PM domain is always powered on */
+#define GENPD_FLAG_ACTIVE_WAKEUP (1U << 3) /* Keep devices active if wakeup */
 
 enum gpd_status {
 	GPD_STATE_ACTIVE = 0,	/* PM domain is active */