2020-03-03 14:31:14

by Anson Huang

[permalink] [raw]
Subject: [PATCH] regulator: anatop: Drop min dropout for bypass mode

Some of anatop regulators support bypass mode, and in bypass mode,
minimum dropout is NOT required, the input voltage will be equal to
the output voltage. The minimum dropout value is ONLY necessary for
LDO enabled mode, so drop the minimum dropout for bypass mode to
avoid unexpected high voltage output from PMIC supplies.

Signed-off-by: Anson Huang <[email protected]>
---
drivers/regulator/anatop-regulator.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c
index ca92b3d..1a775d9 100644
--- a/drivers/regulator/anatop-regulator.c
+++ b/drivers/regulator/anatop-regulator.c
@@ -22,6 +22,7 @@
#define LDO_POWER_GATE 0x00
#define LDO_FET_FULL_ON 0x1f

+#define LDO_MIN_DROPOUT_UV 125000
struct anatop_regulator {
u32 delay_reg;
int delay_bit_shift;
@@ -128,6 +129,10 @@ static int anatop_regmap_set_bypass(struct regulator_dev *reg, bool enable)

sel = enable ? LDO_FET_FULL_ON : anatop_reg->sel;
anatop_reg->bypass = enable;
+ if (anatop_reg->bypass)
+ anatop_reg->rdesc.min_dropout_uV = 0;
+ else
+ anatop_reg->rdesc.min_dropout_uV = LDO_MIN_DROPOUT_UV;

return regulator_set_voltage_sel_regmap(reg, sel);
}
@@ -246,7 +251,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
rdesc->linear_min_sel = min_bit_val;
rdesc->vsel_reg = control_reg;
rdesc->vsel_mask = ((1 << vol_bit_width) - 1) << vol_bit_shift;
- rdesc->min_dropout_uV = 125000;
+ rdesc->min_dropout_uV = LDO_MIN_DROPOUT_UV;

config.dev = &pdev->dev;
config.init_data = initdata;
@@ -268,6 +273,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
if (sreg->sel == LDO_FET_FULL_ON) {
sreg->sel = 0;
sreg->bypass = true;
+ rdesc->min_dropout_uV = 0;
}

/*
--
2.7.4


2020-03-03 17:22:49

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH] regulator: anatop: Drop min dropout for bypass mode

On Tue, Mar 03, 2020 at 10:24:36PM +0800, Anson Huang wrote:
> Some of anatop regulators support bypass mode, and in bypass mode,
> minimum dropout is NOT required, the input voltage will be equal to
> the output voltage. The minimum dropout value is ONLY necessary for
> LDO enabled mode, so drop the minimum dropout for bypass mode to
> avoid unexpected high voltage output from PMIC supplies.

The goal makes sense but I don't think it makes sense to do this in the
driver - changing this without the core knowing is likely to lead to
confusion at some point and also I think this behaviour is likely to be
the same for every regulator that has a bypass mode (at least if it
isn't I'm kind of confused about how it's bypassing, usually the minimum
drop is a function of maintaining regulation). Could you look into
doing something like this in the core instead please?


Attachments:
(No filename) (887.00 B)
signature.asc (499.00 B)
Download all attachments