@@ -636,6 +636,11 @@ static struct device_opp *_add_device_opp(struct device *dev, int supply_count,
if (supply_count == 1)
*dev_opp->supply_names = dev_name(dev);
+ /* Find clk for the device */
+ dev_opp->clk = clk_get(dev, NULL);
+ if (IS_ERR(dev_opp->clk))
+ dev_dbg(dev, "%s: Couldn't find clock\n", __func__);
+
srcu_init_notifier_head(&dev_opp->srcu_head);
INIT_LIST_HEAD(&dev_opp->opp_list);
@@ -669,6 +674,10 @@ static void _remove_device_opp(struct device_opp *dev_opp)
if (!list_empty(&dev_opp->opp_list))
return;
+ /* Release clk */
+ if (!IS_ERR(dev_opp->clk))
+ clk_put(dev_opp->clk);
+
/* Release regulators */
for (count = dev_opp->supply_count - 1; count >= 0; count--)
regulator_put(dev_opp->regulators[count]);
@@ -14,6 +14,7 @@
#ifndef __DRIVER_OPP_H__
#define __DRIVER_OPP_H__
+#include <linux/clk.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/list.h>
@@ -135,6 +136,7 @@ struct device_list_opp {
* @dev_list: list of devices that share these OPPs
* @opp_list: list of opps
* @np: struct device_node pointer for opp's DT node.
+ * @clk: struct clk pointer
* @supply_count: Number of power-supplies
* @regulators: Array of regulators
* @supply_names: Array of strings containing names of the power-supplies
@@ -163,6 +165,7 @@ struct device_opp {
struct device_node *np;
unsigned long clock_latency_ns_max;
+ struct clk *clk;
unsigned int supply_count;
struct regulator **regulators;
const char **supply_names;
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> --- drivers/base/power/opp/core.c | 9 +++++++++ drivers/base/power/opp/opp.h | 3 +++ 2 files changed, 12 insertions(+)