diff options
author | Axel Lin <axel.lin@ingics.com> | 2021-05-22 12:08:14 +0800 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-05-24 09:51:34 +0100 |
commit | 8590ccd4dfd207d89c3312cf8a8b25990acaa079 (patch) | |
tree | 345fd6bbcf1815f0e7017a72f6ffa8a728cc489c /drivers | |
parent | 5ba3747dbc9ade2d22a8f5bff3c928cb41d35030 (diff) | |
download | linux-8590ccd4dfd207d89c3312cf8a8b25990acaa079.tar.bz2 |
regulator: max8973: Convert to use regulator_set_ramp_delay_regmap
Use regulator_set_ramp_delay_regmap instead of open-coded.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/20210522040814.2042397-1-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/regulator/max8973-regulator.c | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index 9aee1444181d..8da8f9b6c4fd 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -265,33 +265,6 @@ static unsigned int max8973_dcdc_get_mode(struct regulator_dev *rdev) REGULATOR_MODE_FAST : REGULATOR_MODE_NORMAL; } -static int max8973_set_ramp_delay(struct regulator_dev *rdev, - int ramp_delay) -{ - struct max8973_chip *max = rdev_get_drvdata(rdev); - unsigned int control; - int ret; - - /* Set ramp delay */ - if (ramp_delay <= 12000) - control = MAX8973_RAMP_12mV_PER_US; - else if (ramp_delay <= 25000) - control = MAX8973_RAMP_25mV_PER_US; - else if (ramp_delay <= 50000) - control = MAX8973_RAMP_50mV_PER_US; - else if (ramp_delay <= 200000) - control = MAX8973_RAMP_200mV_PER_US; - else - return -EINVAL; - - ret = regmap_update_bits(max->regmap, MAX8973_CONTROL1, - MAX8973_RAMP_MASK, control); - if (ret < 0) - dev_err(max->dev, "register %d update failed, %d", - MAX8973_CONTROL1, ret); - return ret; -} - static int max8973_set_current_limit(struct regulator_dev *rdev, int min_ua, int max_ua) { @@ -341,6 +314,10 @@ static int max8973_get_current_limit(struct regulator_dev *rdev) return 9000000; } +static const unsigned int max8973_buck_ramp_table[] = { + 12000, 25000, 50000, 200000 +}; + static const struct regulator_ops max8973_dcdc_ops = { .get_voltage_sel = max8973_dcdc_get_voltage_sel, .set_voltage_sel = max8973_dcdc_set_voltage_sel, @@ -348,7 +325,7 @@ static const struct regulator_ops max8973_dcdc_ops = { .set_mode = max8973_dcdc_set_mode, .get_mode = max8973_dcdc_get_mode, .set_voltage_time_sel = regulator_set_voltage_time_sel, - .set_ramp_delay = max8973_set_ramp_delay, + .set_ramp_delay = regulator_set_ramp_delay_regmap, }; static int max8973_init_dcdc(struct max8973_chip *max, @@ -694,6 +671,10 @@ static int max8973_probe(struct i2c_client *client, max->desc.min_uV = MAX8973_MIN_VOLATGE; max->desc.uV_step = MAX8973_VOLATGE_STEP; max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; + max->desc.ramp_reg = MAX8973_CONTROL1; + max->desc.ramp_mask = MAX8973_RAMP_MASK; + max->desc.ramp_delay_table = max8973_buck_ramp_table; + max->desc.n_ramp_values = ARRAY_SIZE(max8973_buck_ramp_table); max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; max->enable_external_control = pdata->enable_ext_control; |