Commit e1e8d55b authored by Axel Lin's avatar Axel Lin Committed by Mark Brown

regulator: mp886x: Convert to use regulator_set_ramp_delay_regmap

Use regulator_set_ramp_delay_regmap instead of open-coded.
Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Message-Id: <20210525102708.2519323-1-axel.lin@ingics.com>
Signed-off-by: default avatarMark Brown <broonie@sirena.org.uk>
parent e0f33921
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
struct mp886x_cfg_info { struct mp886x_cfg_info {
const struct regulator_ops *rops; const struct regulator_ops *rops;
const int slew_rates[8]; const unsigned int slew_rates[8];
const int switch_freq[4]; const int switch_freq[4];
const u8 fs_reg; const u8 fs_reg;
const u8 fs_shift; const u8 fs_shift;
...@@ -42,28 +42,6 @@ struct mp886x_device_info { ...@@ -42,28 +42,6 @@ struct mp886x_device_info {
unsigned int sel; 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, static void mp886x_set_switch_freq(struct mp886x_device_info *di,
struct regmap *regmap, struct regmap *regmap,
u32 freq) u32 freq)
...@@ -169,7 +147,7 @@ static const struct regulator_ops mp8869_regulator_ops = { ...@@ -169,7 +147,7 @@ static const struct regulator_ops mp8869_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
.set_mode = mp886x_set_mode, .set_mode = mp886x_set_mode,
.get_mode = mp886x_get_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 = { static const struct mp886x_cfg_info mp8869_ci = {
...@@ -248,7 +226,7 @@ static const struct regulator_ops mp8867_regulator_ops = { ...@@ -248,7 +226,7 @@ static const struct regulator_ops mp8867_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
.set_mode = mp886x_set_mode, .set_mode = mp886x_set_mode,
.get_mode = mp886x_get_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 = { static const struct mp886x_cfg_info mp8867_ci = {
...@@ -290,6 +268,10 @@ static int mp886x_regulator_register(struct mp886x_device_info *di, ...@@ -290,6 +268,10 @@ static int mp886x_regulator_register(struct mp886x_device_info *di,
rdesc->uV_step = 10000; rdesc->uV_step = 10000;
rdesc->vsel_reg = MP886X_VSEL; rdesc->vsel_reg = MP886X_VSEL;
rdesc->vsel_mask = 0x3f; 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; rdesc->owner = THIS_MODULE;
rdev = devm_regulator_register(di->dev, &di->desc, config); rdev = devm_regulator_register(di->dev, &di->desc, config);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment