aboutsummaryrefslogtreecommitdiff
path: root/drivers/base/power
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2016-02-09 10:30:38 +0530
committerAlex Shi <alex.shi@linaro.org>2016-04-01 13:26:23 +0800
commit374312cf8d24adff2f3161e53349d8758614324e (patch)
tree5390c82bff5eece47417eb8494ef3a0f1d5d450c /drivers/base/power
parentd4452ef5398b5671530ee5e88892244869e9b1ae (diff)
PM / OPP: Manage device clk
OPP core has got almost everything now to manage device's OPP transitions, the only thing left is device's clk. Get that as well. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit d54974c2513f487e9e70fbdc79c5da51c53e23da) Signed-off-by: Alex Shi <alex.shi@linaro.org>
Diffstat (limited to 'drivers/base/power')
-rw-r--r--drivers/base/power/opp/core.c15
-rw-r--r--drivers/base/power/opp/opp.h3
2 files changed, 18 insertions, 0 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c
index c2e06f723668..eb7d648d3f79 100644
--- a/drivers/base/power/opp/core.c
+++ b/drivers/base/power/opp/core.c
@@ -13,6 +13,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#include <linux/clk.h>
#include <linux/errno.h>
#include <linux/err.h>
#include <linux/slab.h>
@@ -575,6 +576,7 @@ static struct device_opp *_add_device_opp(struct device *dev)
struct device_opp *dev_opp;
struct device_list_opp *list_dev;
struct device_node *np;
+ int ret;
/* Check for existing list for 'dev' first */
dev_opp = _find_device_opp(dev);
@@ -612,6 +614,15 @@ static struct device_opp *_add_device_opp(struct device *dev)
of_node_put(np);
}
+ /* Find clk for the device */
+ dev_opp->clk = clk_get(dev, NULL);
+ if (IS_ERR(dev_opp->clk)) {
+ ret = PTR_ERR(dev_opp->clk);
+ if (ret != -EPROBE_DEFER)
+ dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__,
+ ret);
+ }
+
srcu_init_notifier_head(&dev_opp->srcu_head);
INIT_LIST_HEAD(&dev_opp->opp_list);
@@ -653,6 +664,10 @@ static void _remove_device_opp(struct device_opp *dev_opp)
if (!IS_ERR_OR_NULL(dev_opp->regulator))
return;
+ /* Release clk */
+ if (!IS_ERR(dev_opp->clk))
+ clk_put(dev_opp->clk);
+
list_dev = list_first_entry(&dev_opp->dev_list, struct device_list_opp,
node);
diff --git a/drivers/base/power/opp/opp.h b/drivers/base/power/opp/opp.h
index d982c61f4f21..d8e3999fbb2c 100644
--- a/drivers/base/power/opp/opp.h
+++ b/drivers/base/power/opp/opp.h
@@ -22,6 +22,7 @@
#include <linux/rcupdate.h>
#include <linux/limits.h>
+struct clk;
struct regulator;
/* Lock to allow exclusive modification to the device and opp lists */
@@ -122,6 +123,7 @@ struct device_list_opp {
* @supported_hw: Array of version number to support.
* @supported_hw_count: Number of elements in supported_hw array.
* @prop_name: A name to postfix to many DT properties, while parsing them.
+ * @clk: Device's clock handle
* @regulator: Supply regulator
* @dentry: debugfs dentry pointer of the real device directory (not links).
* @dentry_name: Name of the real dentry.
@@ -156,6 +158,7 @@ struct device_opp {
unsigned int *supported_hw;
unsigned int supported_hw_count;
const char *prop_name;
+ struct clk *clk;
struct regulator *regulator;
};