diff options
author | Jon Hunter <jonathanh@nvidia.com> | 2016-06-21 06:33:25 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-06-27 18:42:10 -0400 |
commit | 498b5fdd40dd3881a3119d11bff8441cfd902850 (patch) | |
tree | a6741c5aa077d5d392a5c94470c1c9774dc43524 | |
parent | 29b968b2af7782fe879190cd43c10261506ebc11 (diff) |
PM / clk: Add support for adding a specific clock from device-tree
Some drivers using the PM clocks framework need to add specific clocks
from device-tree using a name by calling the functions
of_clk_get_by_name() and then pm_clk_add_clk(). Rather than having
drivers call both functions, add a helper function of_pm_clk_add_clk()
that will call these functions so drivers can call a single function
to add a specific clock from device-tree.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/base/power/clock_ops.c | 32 | ||||
-rw-r--r-- | include/linux/pm_clock.h | 1 |
2 files changed, 33 insertions, 0 deletions
diff --git a/drivers/base/power/clock_ops.c b/drivers/base/power/clock_ops.c index 761f5c21f9f0..8e2e4757adcb 100644 --- a/drivers/base/power/clock_ops.c +++ b/drivers/base/power/clock_ops.c | |||
@@ -141,6 +141,38 @@ EXPORT_SYMBOL_GPL(pm_clk_add_clk); | |||
141 | 141 | ||
142 | 142 | ||
143 | /** | 143 | /** |
144 | * of_pm_clk_add_clk - Start using a device clock for power management. | ||
145 | * @dev: Device whose clock is going to be used for power management. | ||
146 | * @name: Name of clock that is going to be used for power management. | ||
147 | * | ||
148 | * Add the clock described in the 'clocks' device-tree node that matches | ||
149 | * with the 'name' provided, to the list of clocks used for the power | ||
150 | * management of @dev. On success, returns 0. Returns a negative error | ||
151 | * code if the clock is not found or cannot be added. | ||
152 | */ | ||
153 | int of_pm_clk_add_clk(struct device *dev, const char *name) | ||
154 | { | ||
155 | struct clk *clk; | ||
156 | int ret; | ||
157 | |||
158 | if (!dev || !dev->of_node || !name) | ||
159 | return -EINVAL; | ||
160 | |||
161 | clk = of_clk_get_by_name(dev->of_node, name); | ||
162 | if (IS_ERR(clk)) | ||
163 | return PTR_ERR(clk); | ||
164 | |||
165 | ret = pm_clk_add_clk(dev, clk); | ||
166 | if (ret) { | ||
167 | clk_put(clk); | ||
168 | return ret; | ||
169 | } | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | EXPORT_SYMBOL_GPL(of_pm_clk_add_clk); | ||
174 | |||
175 | /** | ||
144 | * of_pm_clk_add_clks - Start using device clock(s) for power management. | 176 | * of_pm_clk_add_clks - Start using device clock(s) for power management. |
145 | * @dev: Device whose clock(s) is going to be used for power management. | 177 | * @dev: Device whose clock(s) is going to be used for power management. |
146 | * | 178 | * |
diff --git a/include/linux/pm_clock.h b/include/linux/pm_clock.h index 308d6044f153..09779b0ae720 100644 --- a/include/linux/pm_clock.h +++ b/include/linux/pm_clock.h | |||
@@ -42,6 +42,7 @@ extern int pm_clk_create(struct device *dev); | |||
42 | extern void pm_clk_destroy(struct device *dev); | 42 | extern void pm_clk_destroy(struct device *dev); |
43 | extern int pm_clk_add(struct device *dev, const char *con_id); | 43 | extern int pm_clk_add(struct device *dev, const char *con_id); |
44 | extern int pm_clk_add_clk(struct device *dev, struct clk *clk); | 44 | extern int pm_clk_add_clk(struct device *dev, struct clk *clk); |
45 | extern int of_pm_clk_add_clk(struct device *dev, const char *name); | ||
45 | extern int of_pm_clk_add_clks(struct device *dev); | 46 | extern int of_pm_clk_add_clks(struct device *dev); |
46 | extern void pm_clk_remove(struct device *dev, const char *con_id); | 47 | extern void pm_clk_remove(struct device *dev, const char *con_id); |
47 | extern void pm_clk_remove_clk(struct device *dev, struct clk *clk); | 48 | extern void pm_clk_remove_clk(struct device *dev, struct clk *clk); |