diff options
author | Axel Lin <axel.lin@ingics.com> | 2021-05-22 14:42:50 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2021-05-24 10:51:35 +0200 |
commit | 7c556aec14099c87c95bb7011c74fafe45d93679 (patch) | |
tree | 1f3a310f6cfa06dae67bd50cd47ed1cb5f498876 /drivers/regulator | |
parent | regulator: max8973: Convert to use regulator_set_ramp_delay_regmap (diff) | |
download | linux-7c556aec14099c87c95bb7011c74fafe45d93679.tar.xz linux-7c556aec14099c87c95bb7011c74fafe45d93679.zip |
regulator: bd70528: 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>
Reviewed-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Link: https://lore.kernel.org/r/20210522124250.2121076-1-axel.lin@ingics.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/bd70528-regulator.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/regulator/bd70528-regulator.c b/drivers/regulator/bd70528-regulator.c index 1f5f9482b209..e6fec70fabfa 100644 --- a/drivers/regulator/bd70528-regulator.c +++ b/drivers/regulator/bd70528-regulator.c @@ -16,10 +16,6 @@ #include <linux/regulator/of_regulator.h> #include <linux/slab.h> -#define BUCK_RAMPRATE_250MV 0 -#define BUCK_RAMPRATE_125MV 1 -#define BUCK_RAMP_MAX 250 - static const struct linear_range bd70528_buck1_volts[] = { REGULATOR_LINEAR_RANGE(1200000, 0x00, 0x1, 600000), REGULATOR_LINEAR_RANGE(2750000, 0x2, 0xf, 50000), @@ -47,22 +43,9 @@ static const unsigned int led_volts[] = { 20000, 30000 }; -static int bd70528_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay) -{ - if (ramp_delay > 0 && ramp_delay <= BUCK_RAMP_MAX) { - unsigned int ramp_value = BUCK_RAMPRATE_250MV; - - if (ramp_delay <= 125) - ramp_value = BUCK_RAMPRATE_125MV; - - return regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg, - BD70528_MASK_BUCK_RAMP, - ramp_value << BD70528_SIFT_BUCK_RAMP); - } - dev_err(&rdev->dev, "%s: ramp_delay: %d not supported\n", - rdev->desc->name, ramp_delay); - return -EINVAL; -} +static const unsigned int bd70528_buck_ramp_table[] = { + 250, 125 +}; static int bd70528_led_set_voltage_sel(struct regulator_dev *rdev, unsigned int sel) @@ -90,7 +73,7 @@ static const struct regulator_ops bd70528_buck_ops = { .set_voltage_sel = regulator_set_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap, .set_voltage_time_sel = regulator_set_voltage_time_sel, - .set_ramp_delay = bd70528_set_ramp_delay, + .set_ramp_delay = regulator_set_ramp_delay_regmap, }; static const struct regulator_ops bd70528_ldo_ops = { @@ -127,6 +110,10 @@ static const struct regulator_desc bd70528_desc[] = { .enable_mask = BD70528_MASK_RUN_EN, .vsel_reg = BD70528_REG_BUCK1_VOLT, .vsel_mask = BD70528_MASK_BUCK_VOLT, + .ramp_reg = BD70528_REG_BUCK1_VOLT, + .ramp_mask = BD70528_MASK_BUCK_RAMP, + .ramp_delay_table = bd70528_buck_ramp_table, + .n_ramp_values = ARRAY_SIZE(bd70528_buck_ramp_table), .owner = THIS_MODULE, }, { @@ -143,6 +130,10 @@ static const struct regulator_desc bd70528_desc[] = { .enable_mask = BD70528_MASK_RUN_EN, .vsel_reg = BD70528_REG_BUCK2_VOLT, .vsel_mask = BD70528_MASK_BUCK_VOLT, + .ramp_reg = BD70528_REG_BUCK2_VOLT, + .ramp_mask = BD70528_MASK_BUCK_RAMP, + .ramp_delay_table = bd70528_buck_ramp_table, + .n_ramp_values = ARRAY_SIZE(bd70528_buck_ramp_table), .owner = THIS_MODULE, }, { @@ -159,6 +150,10 @@ static const struct regulator_desc bd70528_desc[] = { .enable_mask = BD70528_MASK_RUN_EN, .vsel_reg = BD70528_REG_BUCK3_VOLT, .vsel_mask = BD70528_MASK_BUCK_VOLT, + .ramp_reg = BD70528_REG_BUCK3_VOLT, + .ramp_mask = BD70528_MASK_BUCK_RAMP, + .ramp_delay_table = bd70528_buck_ramp_table, + .n_ramp_values = ARRAY_SIZE(bd70528_buck_ramp_table), .owner = THIS_MODULE, }, { |