diff options
| author | Viresh Kumar <viresh.kumar@linaro.org> | 2016-02-09 00:00:38 -0500 |
|---|---|---|
| committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-02-09 19:11:54 -0500 |
| commit | d54974c2513f487e9e70fbdc79c5da51c53e23da (patch) | |
| tree | a38d10428beea70b692c2688def69aeb611b117a /drivers/base/power/opp | |
| parent | 50f8cfbd5897ca182d43f4caf19937153f17a604 (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>
Diffstat (limited to 'drivers/base/power/opp')
| -rw-r--r-- | drivers/base/power/opp/core.c | 15 | ||||
| -rw-r--r-- | drivers/base/power/opp/opp.h | 3 |
2 files changed, 18 insertions, 0 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 4fafa733a1c7..7d7749ce1ce4 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | 13 | ||
| 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 14 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
| 15 | 15 | ||
| 16 | #include <linux/clk.h> | ||
| 16 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
| 17 | #include <linux/err.h> | 18 | #include <linux/err.h> |
| 18 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
| @@ -583,6 +584,7 @@ static struct device_opp *_add_device_opp(struct device *dev) | |||
| 583 | struct device_opp *dev_opp; | 584 | struct device_opp *dev_opp; |
| 584 | struct device_list_opp *list_dev; | 585 | struct device_list_opp *list_dev; |
| 585 | struct device_node *np; | 586 | struct device_node *np; |
| 587 | int ret; | ||
| 586 | 588 | ||
| 587 | /* Check for existing list for 'dev' first */ | 589 | /* Check for existing list for 'dev' first */ |
| 588 | dev_opp = _find_device_opp(dev); | 590 | dev_opp = _find_device_opp(dev); |
| @@ -620,6 +622,15 @@ static struct device_opp *_add_device_opp(struct device *dev) | |||
| 620 | of_node_put(np); | 622 | of_node_put(np); |
| 621 | } | 623 | } |
| 622 | 624 | ||
| 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 | |||
| 623 | srcu_init_notifier_head(&dev_opp->srcu_head); | 634 | srcu_init_notifier_head(&dev_opp->srcu_head); |
| 624 | INIT_LIST_HEAD(&dev_opp->opp_list); | 635 | INIT_LIST_HEAD(&dev_opp->opp_list); |
| 625 | 636 | ||
| @@ -661,6 +672,10 @@ static void _remove_device_opp(struct device_opp *dev_opp) | |||
| 661 | if (!IS_ERR_OR_NULL(dev_opp->regulator)) | 672 | if (!IS_ERR_OR_NULL(dev_opp->regulator)) |
| 662 | return; | 673 | return; |
| 663 | 674 | ||
| 675 | /* Release clk */ | ||
| 676 | if (!IS_ERR(dev_opp->clk)) | ||
| 677 | clk_put(dev_opp->clk); | ||
| 678 | |||
| 664 | list_dev = list_first_entry(&dev_opp->dev_list, struct device_list_opp, | 679 | list_dev = list_first_entry(&dev_opp->dev_list, struct device_list_opp, |
| 665 | node); | 680 | node); |
| 666 | 681 | ||
diff --git a/drivers/base/power/opp/opp.h b/drivers/base/power/opp/opp.h index fe44beb404ba..4f1bdfc7da03 100644 --- a/drivers/base/power/opp/opp.h +++ b/drivers/base/power/opp/opp.h | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/rculist.h> | 22 | #include <linux/rculist.h> |
| 23 | #include <linux/rcupdate.h> | 23 | #include <linux/rcupdate.h> |
| 24 | 24 | ||
| 25 | struct clk; | ||
| 25 | struct regulator; | 26 | struct regulator; |
| 26 | 27 | ||
| 27 | /* Lock to allow exclusive modification to the device and opp lists */ | 28 | /* Lock to allow exclusive modification to the device and opp lists */ |
| @@ -134,6 +135,7 @@ struct device_list_opp { | |||
| 134 | * @supported_hw: Array of version number to support. | 135 | * @supported_hw: Array of version number to support. |
| 135 | * @supported_hw_count: Number of elements in supported_hw array. | 136 | * @supported_hw_count: Number of elements in supported_hw array. |
| 136 | * @prop_name: A name to postfix to many DT properties, while parsing them. | 137 | * @prop_name: A name to postfix to many DT properties, while parsing them. |
| 138 | * @clk: Device's clock handle | ||
| 137 | * @regulator: Supply regulator | 139 | * @regulator: Supply regulator |
| 138 | * @dentry: debugfs dentry pointer of the real device directory (not links). | 140 | * @dentry: debugfs dentry pointer of the real device directory (not links). |
| 139 | * @dentry_name: Name of the real dentry. | 141 | * @dentry_name: Name of the real dentry. |
| @@ -168,6 +170,7 @@ struct device_opp { | |||
| 168 | unsigned int *supported_hw; | 170 | unsigned int *supported_hw; |
| 169 | unsigned int supported_hw_count; | 171 | unsigned int supported_hw_count; |
| 170 | const char *prop_name; | 172 | const char *prop_name; |
| 173 | struct clk *clk; | ||
| 171 | struct regulator *regulator; | 174 | struct regulator *regulator; |
| 172 | 175 | ||
| 173 | #ifdef CONFIG_DEBUG_FS | 176 | #ifdef CONFIG_DEBUG_FS |
