diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2016-02-09 00:00:37 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2016-02-09 19:11:54 -0500 |
commit | 50f8cfbd5897ca182d43f4caf19937153f17a604 (patch) | |
tree | dc7452a65bc38875f6015a9a63d86a98bbdc66de | |
parent | 2174344765f472895c076d703c9cdc58215e1393 (diff) |
PM / OPP: Parse clock-latency and voltage-tolerance for v1 bindings
V2 bindings have better support for clock-latency and voltage-tolerance
and doesn't need special care. To use callbacks, like
dev_pm_opp_get_max_{transition|volt}_latency(), irrespective of the
bindings, the core needs to know clock-latency/voltage-tolerance for the
earlier bindings.
This patch reads clock-latency/voltage-tolerance from the device node,
irrespective of the bindings (to keep it simple) and use them only for
V1 bindings.
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>
-rw-r--r-- | drivers/base/power/opp/core.c | 20 | ||||
-rw-r--r-- | drivers/base/power/opp/opp.h | 6 |
2 files changed, 26 insertions, 0 deletions
diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index b0f5c72f0fc3..4fafa733a1c7 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c | |||
@@ -582,6 +582,7 @@ static struct device_opp *_add_device_opp(struct device *dev) | |||
582 | { | 582 | { |
583 | struct device_opp *dev_opp; | 583 | struct device_opp *dev_opp; |
584 | struct device_list_opp *list_dev; | 584 | struct device_list_opp *list_dev; |
585 | struct device_node *np; | ||
585 | 586 | ||
586 | /* Check for existing list for 'dev' first */ | 587 | /* Check for existing list for 'dev' first */ |
587 | dev_opp = _find_device_opp(dev); | 588 | dev_opp = _find_device_opp(dev); |
@@ -604,6 +605,21 @@ static struct device_opp *_add_device_opp(struct device *dev) | |||
604 | return NULL; | 605 | return NULL; |
605 | } | 606 | } |
606 | 607 | ||
608 | /* | ||
609 | * Only required for backward compatibility with v1 bindings, but isn't | ||
610 | * harmful for other cases. And so we do it unconditionally. | ||
611 | */ | ||
612 | np = of_node_get(dev->of_node); | ||
613 | if (np) { | ||
614 | u32 val; | ||
615 | |||
616 | if (!of_property_read_u32(np, "clock-latency", &val)) | ||
617 | dev_opp->clock_latency_ns_max = val; | ||
618 | of_property_read_u32(np, "voltage-tolerance", | ||
619 | &dev_opp->voltage_tolerance_v1); | ||
620 | of_node_put(np); | ||
621 | } | ||
622 | |||
607 | srcu_init_notifier_head(&dev_opp->srcu_head); | 623 | srcu_init_notifier_head(&dev_opp->srcu_head); |
608 | INIT_LIST_HEAD(&dev_opp->opp_list); | 624 | INIT_LIST_HEAD(&dev_opp->opp_list); |
609 | 625 | ||
@@ -861,6 +877,7 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, | |||
861 | { | 877 | { |
862 | struct device_opp *dev_opp; | 878 | struct device_opp *dev_opp; |
863 | struct dev_pm_opp *new_opp; | 879 | struct dev_pm_opp *new_opp; |
880 | unsigned long tol; | ||
864 | int ret; | 881 | int ret; |
865 | 882 | ||
866 | /* Hold our list modification lock here */ | 883 | /* Hold our list modification lock here */ |
@@ -874,7 +891,10 @@ static int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, | |||
874 | 891 | ||
875 | /* populate the opp table */ | 892 | /* populate the opp table */ |
876 | new_opp->rate = freq; | 893 | new_opp->rate = freq; |
894 | tol = u_volt * dev_opp->voltage_tolerance_v1 / 100; | ||
877 | new_opp->u_volt = u_volt; | 895 | new_opp->u_volt = u_volt; |
896 | new_opp->u_volt_min = u_volt - tol; | ||
897 | new_opp->u_volt_max = u_volt + tol; | ||
878 | new_opp->available = true; | 898 | new_opp->available = true; |
879 | new_opp->dynamic = dynamic; | 899 | new_opp->dynamic = dynamic; |
880 | 900 | ||
diff --git a/drivers/base/power/opp/opp.h b/drivers/base/power/opp/opp.h index 416293b7da23..fe44beb404ba 100644 --- a/drivers/base/power/opp/opp.h +++ b/drivers/base/power/opp/opp.h | |||
@@ -138,6 +138,8 @@ struct device_list_opp { | |||
138 | * @dentry: debugfs dentry pointer of the real device directory (not links). | 138 | * @dentry: debugfs dentry pointer of the real device directory (not links). |
139 | * @dentry_name: Name of the real dentry. | 139 | * @dentry_name: Name of the real dentry. |
140 | * | 140 | * |
141 | * @voltage_tolerance_v1: In percentage, for v1 bindings only. | ||
142 | * | ||
141 | * This is an internal data structure maintaining the link to opps attached to | 143 | * This is an internal data structure maintaining the link to opps attached to |
142 | * a device. This structure is not meant to be shared to users as it is | 144 | * a device. This structure is not meant to be shared to users as it is |
143 | * meant for book keeping and private to OPP library. | 145 | * meant for book keeping and private to OPP library. |
@@ -156,6 +158,10 @@ struct device_opp { | |||
156 | 158 | ||
157 | struct device_node *np; | 159 | struct device_node *np; |
158 | unsigned long clock_latency_ns_max; | 160 | unsigned long clock_latency_ns_max; |
161 | |||
162 | /* For backward compatibility with v1 bindings */ | ||
163 | unsigned int voltage_tolerance_v1; | ||
164 | |||
159 | bool shared_opp; | 165 | bool shared_opp; |
160 | struct dev_pm_opp *suspend_opp; | 166 | struct dev_pm_opp *suspend_opp; |
161 | 167 | ||