6299fcf25783498b859233805651b2ada36e76da
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.14 / 0052-PM-OPP-Update-the-voltage-tolerance-when-adjusting-t.patch
1 From 4533c285c2aedce6d4434d7b877066de3b1ecb33 Mon Sep 17 00:00:00 2001
2 From: Georgi Djakov <georgi.djakov@linaro.org>
3 Date: Thu, 25 Aug 2016 18:43:35 +0300
4 Subject: [PATCH 52/69] PM / OPP: Update the voltage tolerance when adjusting
5 the OPP
6
7 When the voltage is adjusted, the voltage tolerance is not updated.
8 This can lead to situations where the voltage min value is greater
9 than the voltage max value. The final result is triggering a BUG()
10 in the regulator core.
11 Fix this by updating the voltage tolerance values too.
12
13 Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
14 ---
15 drivers/base/power/opp/core.c | 5 +++++
16 1 file changed, 5 insertions(+)
17
18 --- a/drivers/base/power/opp/core.c
19 +++ b/drivers/base/power/opp/core.c
20 @@ -1649,6 +1649,7 @@ int dev_pm_opp_adjust_voltage(struct dev
21 struct opp_table *opp_table;
22 struct dev_pm_opp *new_opp, *tmp_opp, *opp = ERR_PTR(-ENODEV);
23 int r = 0;
24 + unsigned long tol;
25
26 /* keep the node allocated */
27 new_opp = kmalloc(sizeof(*new_opp), GFP_KERNEL);
28 @@ -1685,6 +1686,10 @@ int dev_pm_opp_adjust_voltage(struct dev
29
30 /* plug in new node */
31 new_opp->supplies[0].u_volt = u_volt;
32 + tol = u_volt * opp_table->voltage_tolerance_v1 / 100;
33 + new_opp->supplies[0].u_volt = u_volt;
34 + new_opp->supplies[0].u_volt_min = u_volt - tol;
35 + new_opp->supplies[0].u_volt_max = u_volt + tol;
36
37 list_replace(&opp->node, &new_opp->node);
38 mutex_unlock(&opp_table_lock);