kernel: bump 4.19 to 4.19.101
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.19 / 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/opp/core.c | 5 +++++
16 1 file changed, 5 insertions(+)
17
18 --- a/drivers/opp/core.c
19 +++ b/drivers/opp/core.c
20 @@ -1669,6 +1669,7 @@ int dev_pm_opp_adjust_voltage(struct dev
21 struct opp_table *opp_table;
22 struct dev_pm_opp *tmp_opp, *opp = ERR_PTR(-ENODEV);
23 int r = 0;
24 + unsigned long tol;
25
26 /* Find the opp_table */
27 opp_table = _find_opp_table(dev);
28 @@ -1698,8 +1699,17 @@ int dev_pm_opp_adjust_voltage(struct dev
29 goto adjust_unlock;
30
31 opp->supplies->u_volt = u_volt;
32 - opp->supplies->u_volt_min = u_volt_min;
33 - opp->supplies->u_volt_max = u_volt_max;
34 +
35 + tol = u_volt * opp_table->voltage_tolerance_v1 / 100;
36 + if ( u_volt_min == u_volt )
37 + opp->supplies->u_volt_min = u_volt - tol;
38 + else
39 + opp->supplies->u_volt_min = u_volt_min;
40 +
41 + if ( u_volt_max == u_volt )
42 + opp->supplies->u_volt_max = u_volt + tol;
43 + else
44 + opp->supplies->u_volt_max = u_volt_max;
45
46 dev_pm_opp_get(opp);
47 mutex_unlock(&opp_table->lock);