opp: ti-opp-supply: Dynamically update u_volt_min
authorKeerthy <j-keerthy@ti.com>
Wed, 7 Nov 2018 04:34:22 +0000 (10:04 +0530)
committerViresh Kumar <viresh.kumar@linaro.org>
Tue, 13 Nov 2018 04:09:54 +0000 (09:39 +0530)
The voltage range (min, max) provided in the device tree is from
the data manual and is pretty big, catering to a wide range of devices.
On a i2c read/write failure the regulator_set_voltage_triplet function
falls back to set voltage between min and max. The min value from Device
Tree can be lesser than the optimal value and in that case that can lead
to a hang or crash. Hence set the u_volt_min dynamically to the optimal
voltage value.

Cc: 4.16+ <stable@vger.kernel.org> # v4.16+
Fixes: 9a835fa6e47 ("PM / OPP: Add ti-opp-supply driver")
Signed-off-by: Keerthy <j-keerthy@ti.com>
Acked-by: Dave Gerlach <d-gerlach@ti.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
drivers/opp/ti-opp-supply.c

index 9e5a9a3..29e08a4 100644 (file)
@@ -290,6 +290,9 @@ static int ti_opp_supply_set_opp(struct dev_pm_set_opp_data *data)
        vdd_uv = _get_optimal_vdd_voltage(dev, &opp_data,
                                          new_supply_vbb->u_volt);
 
+       if (new_supply_vdd->u_volt_min < vdd_uv)
+               new_supply_vdd->u_volt_min = vdd_uv;
+
        /* Scaling up? Scale voltage before frequency */
        if (freq > old_freq) {
                ret = _opp_set_voltage(dev, new_supply_vdd, vdd_uv, vdd_reg,