Skip to contentSkip to conversation

regulator: anatop: Drop min dropout for bypass mode

PATCH In review Anson Huang 2 participants 2 messages Mar 3, 2020 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 drivers/regulator/anatop-regulator.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/regulator/anatop-regulator.c +7 -1
index ca92b3d..1a775d9 100644
@@ -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;
 		}
 
 		/*
Signature · 1 line
2.7.4
maintainer
#1 lore raw
Quoted 5 lines · Anson Huang

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?