regulator: mp886x: 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>
Message-Id: <20210525102708.2519323-1-axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@sirena.org.uk>
This commit is contained in:
Axel Lin 2021-05-25 18:27:08 +08:00 committed by Mark Brown
parent e0f339213c
commit e1e8d55bb9
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -26,7 +26,7 @@
struct mp886x_cfg_info {
const struct regulator_ops *rops;
const int slew_rates[8];
const unsigned int slew_rates[8];
const int switch_freq[4];
const u8 fs_reg;
const u8 fs_shift;
@ -42,28 +42,6 @@ struct mp886x_device_info {
unsigned int sel;
};
static int mp886x_set_ramp(struct regulator_dev *rdev, int ramp)
{
struct mp886x_device_info *di = rdev_get_drvdata(rdev);
const struct mp886x_cfg_info *ci = di->ci;
int reg = -1, i;
for (i = 0; i < ARRAY_SIZE(ci->slew_rates); i++) {
if (ramp <= ci->slew_rates[i])
reg = i;
else
break;
}
if (reg < 0) {
dev_err(di->dev, "unsupported ramp value %d\n", ramp);
return -EINVAL;
}
return regmap_update_bits(rdev->regmap, MP886X_SYSCNTLREG1,
MP886X_SLEW_MASK, reg << MP886X_SLEW_SHIFT);
}
static void mp886x_set_switch_freq(struct mp886x_device_info *di,
struct regmap *regmap,
u32 freq)
@ -169,7 +147,7 @@ static const struct regulator_ops mp8869_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap,
.set_mode = mp886x_set_mode,
.get_mode = mp886x_get_mode,
.set_ramp_delay = mp886x_set_ramp,
.set_ramp_delay = regulator_set_ramp_delay_regmap,
};
static const struct mp886x_cfg_info mp8869_ci = {
@ -248,7 +226,7 @@ static const struct regulator_ops mp8867_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap,
.set_mode = mp886x_set_mode,
.get_mode = mp886x_get_mode,
.set_ramp_delay = mp886x_set_ramp,
.set_ramp_delay = regulator_set_ramp_delay_regmap,
};
static const struct mp886x_cfg_info mp8867_ci = {
@ -290,6 +268,10 @@ static int mp886x_regulator_register(struct mp886x_device_info *di,
rdesc->uV_step = 10000;
rdesc->vsel_reg = MP886X_VSEL;
rdesc->vsel_mask = 0x3f;
rdesc->ramp_reg = MP886X_SYSCNTLREG1;
rdesc->ramp_mask = MP886X_SLEW_MASK;
rdesc->ramp_delay_table = di->ci->slew_rates;
rdesc->n_ramp_values = ARRAY_SIZE(di->ci->slew_rates);
rdesc->owner = THIS_MODULE;
rdev = devm_regulator_register(di->dev, &di->desc, config);