Thread (6 messages) 6 messages, 2 authors, 2014-11-28
STALE4216d
Revisions (9)
  1. v1 [diff vs current]
  2. v1 [diff vs current]
  3. v1 [diff vs current]
  4. v2 [diff vs current]
  5. v2 current
  6. v2 [diff vs current]
  7. v3 [diff vs current]
  8. v3 [diff vs current]
  9. v4 [diff vs current]

[PATCH V2 1/3] PM / Domains: Initial PM clock support for genpd

From: Rafael J. Wysocki <hidden>
Date: 2014-11-28 00:05:30
Also in: linux-pm, linux-samsung-soc

On Thursday, November 27, 2014 03:51:49 PM Ulf Hansson wrote:
quoted hunk ↗ jump to hunk
It's quite common for PM domains to use PM clocks. Typically from SOC
specific code, the per device PM clock list is created and
pm_clk_suspend|resume() are invoked to handle clock gating/ungating.

A step towards consolidation is to integrate PM clock support into
genpd, which is what this patch does.

In this initial step, the calls to the pm_clk_suspend|resume() are
handled within genpd, but the per device PM clock list still needs to
be created from SOC specific code. It seems reasonable to have gendp to
handle that as well, but that left to future patches to address.

It's not every users of genpd that are keen on using PM clocks thus we
need to provide this a configuration option for genpd. Therefore let's
add flag field in the genpd struct to keep this information and define
a new PM_DOMAIN_PM_CLK bit can then be set at initialization.

Signed-off-by: Ulf Hansson <redacted>
---

Changes in v2:
	Set ->start() callback to pm_clk_resume() and fixed comment.

---
 drivers/base/power/domain.c | 7 +++++++
 include/linux/pm_domain.h   | 3 +++
 2 files changed, 10 insertions(+)
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 735c473..42ba5a0 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -12,6 +12,7 @@
 #include <linux/pm_runtime.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_qos.h>
+#include <linux/pm_clock.h>
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/sched.h>
@@ -1928,6 +1929,12 @@ void pm_genpd_init(struct generic_pm_domain *genpd,
 	genpd->domain.ops.complete = pm_genpd_complete;
 	genpd->dev_ops.save_state = pm_genpd_default_save_state;
 	genpd->dev_ops.restore_state = pm_genpd_default_restore_state;
+
+	if (genpd->flags & PM_DOMAIN_PM_CLK) {
+		genpd->dev_ops.stop = pm_clk_suspend;
+		genpd->dev_ops.start = pm_clk_resume;
+	}
+
 	mutex_lock(&gpd_list_lock);
 	list_add(&genpd->gpd_list_node, &gpd_list);
 	mutex_unlock(&gpd_list_lock);
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index 8cbd32e..4ba06a4f 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -14,6 +14,7 @@
 #include <linux/pm.h>
 #include <linux/err.h>
 #include <linux/of.h>
+#include <linux/bitops.h>
 #include <linux/notifier.h>
 #include <linux/cpuidle.h>
If you defined the flag as

	#define PM_DOMAIN_FLAGS_PM_CLK	(1U << 0)

(which is a kind of usual way to do that), you wouldn't need the
bitops.h above.

Moreover, I personally don't like #defines in struct definitions.
quoted hunk ↗ jump to hunk
 
@@ -76,6 +77,8 @@ struct generic_pm_domain {
 			  struct device *dev);
 	void (*detach_dev)(struct generic_pm_domain *domain,
 			   struct device *dev);
+	unsigned int flags;		/* Bit field of configs for genpd */
+#define PM_DOMAIN_PM_CLK	BIT(0)	/* PM domain uses PM clk */
 };
 
 static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help