aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Abraham <thomas.abraham@linaro.org>2012-01-27 01:22:07 -0500
committerKukjin Kim <kgene.kim@samsung.com>2012-01-27 01:22:07 -0500
commitc8aa130b74cc5b112cb2b119d3b477abaaf6e5b2 (patch)
tree80ca3b93767b0aec09ed566924c196033ad12b49
parentdcd6c92267155e70a94b3927bce681ce74b80d1f (diff)
PM / Domains: Add OF support
A device node pointer is added to generic pm domain structure to associate the domain with a node in the device tree. The platform code parses the device tree to find available nodes representing the generic power domain, instantiates the available domains and initializes them by calling pm_genpd_init(). Nodes representing the devices include a phandle of the power domain to which it belongs. As these devices get instantiated, the driver code checkes for availability of a power domain phandle, converts the phandle to a device node and uses the new pm_genpd_of_add_device() api to associate the device with a power domain. pm_genpd_of_add_device() runs through its list of registered power domains and matches the OF node of the domain with the one specified as the parameter. If a match is found, the device is associated with the matched domain. Cc: Rob Herring <rob.herring@calxeda.com> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org> Acked-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
-rw-r--r--drivers/base/power/domain.c32
-rw-r--r--include/linux/pm_domain.h12
2 files changed, 44 insertions, 0 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index 978bbf7ac6af..939109b75c9b 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1171,6 +1171,38 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
1171} 1171}
1172 1172
1173/** 1173/**
1174 * __pm_genpd_of_add_device - Add a device to an I/O PM domain.
1175 * @genpd_node: Device tree node pointer representing a PM domain to which the
1176 * the device is added to.
1177 * @dev: Device to be added.
1178 * @td: Set of PM QoS timing parameters to attach to the device.
1179 */
1180int __pm_genpd_of_add_device(struct device_node *genpd_node, struct device *dev,
1181 struct gpd_timing_data *td)
1182{
1183 struct generic_pm_domain *genpd = NULL, *gpd;
1184
1185 dev_dbg(dev, "%s()\n", __func__);
1186
1187 if (IS_ERR_OR_NULL(genpd_node) || IS_ERR_OR_NULL(dev))
1188 return -EINVAL;
1189
1190 mutex_lock(&gpd_list_lock);
1191 list_for_each_entry(gpd, &gpd_list, gpd_list_node) {
1192 if (gpd->of_node == genpd_node) {
1193 genpd = gpd;
1194 break;
1195 }
1196 }
1197 mutex_unlock(&gpd_list_lock);
1198
1199 if (!genpd)
1200 return -EINVAL;
1201
1202 return __pm_genpd_add_device(genpd, dev, td);
1203}
1204
1205/**
1174 * pm_genpd_remove_device - Remove a device from an I/O PM domain. 1206 * pm_genpd_remove_device - Remove a device from an I/O PM domain.
1175 * @genpd: PM domain to remove the device from. 1207 * @genpd: PM domain to remove the device from.
1176 * @dev: Device to be removed. 1208 * @dev: Device to be removed.
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index a03a0ad998b8..e3ff87550eeb 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -11,6 +11,7 @@
11 11
12#include <linux/device.h> 12#include <linux/device.h>
13#include <linux/err.h> 13#include <linux/err.h>
14#include <linux/of.h>
14 15
15enum gpd_status { 16enum gpd_status {
16 GPD_STATE_ACTIVE = 0, /* PM domain is active */ 17 GPD_STATE_ACTIVE = 0, /* PM domain is active */
@@ -70,6 +71,7 @@ struct generic_pm_domain {
70 s64 break_even_ns; /* Power break even for the entire domain. */ 71 s64 break_even_ns; /* Power break even for the entire domain. */
71 s64 max_off_time_ns; /* Maximum allowed "suspended" time. */ 72 s64 max_off_time_ns; /* Maximum allowed "suspended" time. */
72 ktime_t power_off_time; 73 ktime_t power_off_time;
74 struct device_node *of_node; /* Node in device tree */
73}; 75};
74 76
75static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd) 77static inline struct generic_pm_domain *pd_to_genpd(struct dev_pm_domain *pd)
@@ -117,12 +119,22 @@ extern int __pm_genpd_add_device(struct generic_pm_domain *genpd,
117 struct device *dev, 119 struct device *dev,
118 struct gpd_timing_data *td); 120 struct gpd_timing_data *td);
119 121
122extern int __pm_genpd_of_add_device(struct device_node *genpd_node,
123 struct device *dev,
124 struct gpd_timing_data *td);
125
120static inline int pm_genpd_add_device(struct generic_pm_domain *genpd, 126static inline int pm_genpd_add_device(struct generic_pm_domain *genpd,
121 struct device *dev) 127 struct device *dev)
122{ 128{
123 return __pm_genpd_add_device(genpd, dev, NULL); 129 return __pm_genpd_add_device(genpd, dev, NULL);
124} 130}
125 131
132static inline int pm_genpd_of_add_device(struct device_node *genpd_node,
133 struct device *dev)
134{
135 return __pm_genpd_of_add_device(genpd_node, dev, NULL);
136}
137
126extern int pm_genpd_remove_device(struct generic_pm_domain *genpd, 138extern int pm_genpd_remove_device(struct generic_pm_domain *genpd,
127 struct device *dev); 139 struct device *dev);
128extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd, 140extern int pm_genpd_add_subdomain(struct generic_pm_domain *genpd,