2021-05-22 12:45:33

by Axel Lin

[permalink] [raw]
Subject: [PATCH] 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 <[email protected]>
---
drivers/regulator/bd70528-regulator.c | 37 ++++++++++++---------------
1 file 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,
},
{
--
2.25.1


2021-05-24 05:22:48

by Matti Vaittinen

[permalink] [raw]
Subject: Re: [PATCH] regulator: bd70528: Convert to use regulator_set_ramp_delay_regmap


On Sat, 2021-05-22 at 20:42 +0800, Axel Lin wrote:
> Use regulator_set_ramp_delay_regmap instead of open-coded.
>
> Signed-off-by: Axel Lin <[email protected]>
> ---

As a side-note - yesterday I sent an email asking the fate/status of
BD70528. It may be we can drop whole BD70528 support and that's why I
have more or less neglected the updates (for example the binding docs
are still .txt) - but let's wait for a reply for a little while.
Dropping BD70528 would simplify the RTC driver used by BD71828 and
BD71815.

I won't in any ways object applying this patch though - it looks good
to me.

Reviewed-by: Matti Vaittinen <[email protected]>



2021-05-24 12:01:07

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] regulator: bd70528: Convert to use regulator_set_ramp_delay_regmap

On Sat, 22 May 2021 20:42:50 +0800, Axel Lin wrote:
> Use regulator_set_ramp_delay_regmap instead of open-coded.

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/1] regulator: bd70528: Convert to use regulator_set_ramp_delay_regmap
commit: 7c556aec14099c87c95bb7011c74fafe45d93679

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark