Some LDOs and DCDCs have a fixed ramp speed of 6.25 mV/µs. This patch adds
the set_voltage_time_sel function to let consumers know about this.

Signed-off-by: Philipp Zabel <[email protected]>
---
 drivers/regulator/da9052-regulator.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/regulator/da9052-regulator.c 
b/drivers/regulator/da9052-regulator.c
index 3adeaef..e0dbfec 100644
--- a/drivers/regulator/da9052-regulator.c
+++ b/drivers/regulator/da9052-regulator.c
@@ -240,6 +240,31 @@ static int da9052_regulator_set_voltage_sel(struct 
regulator_dev *rdev,
        return ret;
 }
 
+static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
+                                                unsigned int old_sel,
+                                                unsigned int new_sel)
+{
+       struct da9052_regulator *regulator = rdev_get_drvdata(rdev);
+       struct da9052_regulator_info *info = regulator->info;
+       int id = rdev_get_id(rdev);
+       int ret = 0;
+
+       /* The DVC controlled LDOs and DCDCs ramp with 6.25mV/µs after enabling
+        * the activate bit.
+        */
+       switch (id) {
+       case DA9052_ID_BUCK1:
+       case DA9052_ID_BUCK2:
+       case DA9052_ID_BUCK3:
+       case DA9052_ID_LDO2:
+       case DA9052_ID_LDO3:
+               ret = (new_sel - old_sel) * info->step_uV / 6250;
+               break;
+       }
+
+       return ret;
+}
+
 static struct regulator_ops da9052_dcdc_ops = {
        .get_current_limit = da9052_dcdc_get_current_limit,
        .set_current_limit = da9052_dcdc_set_current_limit,
@@ -248,6 +273,7 @@ static struct regulator_ops da9052_dcdc_ops = {
        .map_voltage = da9052_map_voltage,
        .get_voltage_sel = regulator_get_voltage_sel_regmap,
        .set_voltage_sel = da9052_regulator_set_voltage_sel,
+       .set_voltage_time_sel = da9052_regulator_set_voltage_time_sel,
        .is_enabled = regulator_is_enabled_regmap,
        .enable = regulator_enable_regmap,
        .disable = regulator_disable_regmap,
@@ -258,6 +284,7 @@ static struct regulator_ops da9052_ldo_ops = {
        .map_voltage = da9052_map_voltage,
        .get_voltage_sel = regulator_get_voltage_sel_regmap,
        .set_voltage_sel = da9052_regulator_set_voltage_sel,
+       .set_voltage_time_sel = da9052_regulator_set_voltage_time_sel,
        .is_enabled = regulator_is_enabled_regmap,
        .enable = regulator_enable_regmap,
        .disable = regulator_disable_regmap,
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to