aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2018-06-29 07:04:31 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2018-07-09 06:11:02 -0400
commit5d6be70add65e3f236642ab0029e356261617cd0 (patch)
treeb385e69e0c3ea5ceb5f43a8c4579fab80e69c32c
parent79a5c45199cd942047b1cf7bb50ff0699c2a3af0 (diff)
PM / Domains: Introduce option to attach a device by name to genpd
For the multiple PM domain case, let's introduce a new function called genpd_dev_pm_attach_by_name(). This allows a device to be associated with its PM domain through genpd, by using a name based lookup. Note that, genpd_dev_pm_attach_by_name() shall only be called by the driver core / PM core, similar to how the existing dev_pm_domain_attach_by_id() makes use of genpd_dev_pm_attach_by_id(). However, this is implemented by following changes on top. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Tested-by: Rajendra Nayak <rnayak@codeaurora.org> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/base/power/domain.c24
-rw-r--r--include/linux/pm_domain.h8
2 files changed, 32 insertions, 0 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 9e8484189034..79bdca70a81a 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -2374,6 +2374,30 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev,
2374} 2374}
2375EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id); 2375EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id);
2376 2376
2377/**
2378 * genpd_dev_pm_attach_by_name - Associate a device with one of its PM domains.
2379 * @dev: The device used to lookup the PM domain.
2380 * @name: The name of the PM domain.
2381 *
2382 * Parse device's OF node to find a PM domain specifier using the
2383 * power-domain-names DT property. For further description see
2384 * genpd_dev_pm_attach_by_id().
2385 */
2386struct device *genpd_dev_pm_attach_by_name(struct device *dev, char *name)
2387{
2388 int index;
2389
2390 if (!dev->of_node)
2391 return NULL;
2392
2393 index = of_property_match_string(dev->of_node, "power-domain-names",
2394 name);
2395 if (index < 0)
2396 return NULL;
2397
2398 return genpd_dev_pm_attach_by_id(dev, index);
2399}
2400
2377static const struct of_device_id idle_state_match[] = { 2401static const struct of_device_id idle_state_match[] = {
2378 { .compatible = "domain-idle-state", }, 2402 { .compatible = "domain-idle-state", },
2379 { } 2403 { }
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index cb8d84090cfb..03e14a38462d 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -239,6 +239,8 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev,
239int genpd_dev_pm_attach(struct device *dev); 239int genpd_dev_pm_attach(struct device *dev);
240struct device *genpd_dev_pm_attach_by_id(struct device *dev, 240struct device *genpd_dev_pm_attach_by_id(struct device *dev,
241 unsigned int index); 241 unsigned int index);
242struct device *genpd_dev_pm_attach_by_name(struct device *dev,
243 char *name);
242#else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ 244#else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
243static inline int of_genpd_add_provider_simple(struct device_node *np, 245static inline int of_genpd_add_provider_simple(struct device_node *np,
244 struct generic_pm_domain *genpd) 246 struct generic_pm_domain *genpd)
@@ -290,6 +292,12 @@ static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev,
290 return NULL; 292 return NULL;
291} 293}
292 294
295static inline struct device *genpd_dev_pm_attach_by_name(struct device *dev,
296 char *name)
297{
298 return NULL;
299}
300
293static inline 301static inline
294struct generic_pm_domain *of_genpd_remove_last(struct device_node *np) 302struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
295{ 303{