Skip to content

Commit b7737cf

Browse files
vireshkAlex Shi
authored andcommitted
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>
1 parent df8ba0f commit b7737cf

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/base/power/opp/core.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
1515

16+
#include <linux/clk.h>
1617
#include <linux/errno.h>
1718
#include <linux/err.h>
1819
#include <linux/slab.h>
@@ -583,6 +584,7 @@ static struct device_opp *_add_device_opp(struct device *dev)
583584
struct device_opp *dev_opp;
584585
struct device_list_opp *list_dev;
585586
struct device_node *np;
587+
int ret;
586588

587589
/* Check for existing list for 'dev' first */
588590
dev_opp = _find_device_opp(dev);
@@ -620,6 +622,15 @@ static struct device_opp *_add_device_opp(struct device *dev)
620622
of_node_put(np);
621623
}
622624

625+
/* Find clk for the device */
626+
dev_opp->clk = clk_get(dev, NULL);
627+
if (IS_ERR(dev_opp->clk)) {
628+
ret = PTR_ERR(dev_opp->clk);
629+
if (ret != -EPROBE_DEFER)
630+
dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__,
631+
ret);
632+
}
633+
623634
srcu_init_notifier_head(&dev_opp->srcu_head);
624635
INIT_LIST_HEAD(&dev_opp->opp_list);
625636

@@ -661,6 +672,10 @@ static void _remove_device_opp(struct device_opp *dev_opp)
661672
if (!IS_ERR_OR_NULL(dev_opp->regulator))
662673
return;
663674

675+
/* Release clk */
676+
if (!IS_ERR(dev_opp->clk))
677+
clk_put(dev_opp->clk);
678+
664679
list_dev = list_first_entry(&dev_opp->dev_list, struct device_list_opp,
665680
node);
666681

drivers/base/power/opp/opp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/rculist.h>
2323
#include <linux/rcupdate.h>
2424

25+
struct clk;
2526
struct regulator;
2627

2728
/* Lock to allow exclusive modification to the device and opp lists */
@@ -134,6 +135,7 @@ struct device_list_opp {
134135
* @supported_hw: Array of version number to support.
135136
* @supported_hw_count: Number of elements in supported_hw array.
136137
* @prop_name: A name to postfix to many DT properties, while parsing them.
138+
* @clk: Device's clock handle
137139
* @regulator: Supply regulator
138140
* @dentry: debugfs dentry pointer of the real device directory (not links).
139141
* @dentry_name: Name of the real dentry.
@@ -168,6 +170,7 @@ struct device_opp {
168170
unsigned int *supported_hw;
169171
unsigned int supported_hw_count;
170172
const char *prop_name;
173+
struct clk *clk;
171174
struct regulator *regulator;
172175

173176
#ifdef CONFIG_DEBUG_FS

0 commit comments

Comments
 (0)