[PATCH 2/2] regulator: stm32-pwr: don't propagate regulator turn-off to supply

Ahmad Fatoum ahmad at a3f.at
Sun Dec 20 19:32:51 EST 2020


Linux walks up the regulator supply chain in the core code, which we
don't do in barebox. Instead the stm32-pwr driver did enable/disable its
parent manually. This is problematic, because it doesn't respect
the regulator-always-on flag the parent supply may have, leading to
prohibited disabling of regulators. Work around this by dropping the
regulator disable altogether and just enable the parent supply
unconditionally.

When we gain proper regulator supply chain handling, this patch can be
reverted.

Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
 drivers/regulator/stm32-pwr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/stm32-pwr.c b/drivers/regulator/stm32-pwr.c
index 7df8074ba78e..4cb46b081abb 100644
--- a/drivers/regulator/stm32-pwr.c
+++ b/drivers/regulator/stm32-pwr.c
@@ -86,8 +86,6 @@ static int stm32_pwr_reg_enable(struct regulator_dev *rdev)
 	int ret;
 	u32 val;
 
-	regulator_enable(priv->supply);
-
 	val = readl(priv->base + REG_PWR_CR3);
 	val |= rdev->desc->enable_mask;
 	writel(val, priv->base + REG_PWR_CR3);
@@ -120,8 +118,6 @@ static int stm32_pwr_reg_disable(struct regulator_dev *rdev)
 		dev_err(rdev->dev, "%s: regulator disable timed out!\n",
 			desc->name);
 
-	regulator_disable(priv->supply);
-
 	return ret;
 }
 
@@ -194,6 +190,8 @@ static int stm32_pwr_regulator_probe(struct device_d *dev)
 				desc->name, ret);
 			goto release_region;
 		}
+
+		regulator_enable(priv->supply);
 	}
 
 	return 0;
-- 
2.29.2




More information about the barebox mailing list