public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] power: regulator: stpmu1: add power off delay
@ 2018-06-27  9:59 Patrice Chotard
  2018-07-20 12:35 ` [U-Boot] " Tom Rini
  0 siblings, 1 reply; 2+ messages in thread
From: Patrice Chotard @ 2018-06-27  9:59 UTC (permalink / raw)
  To: u-boot

From: Christophe Kerello <christophe.kerello@st.com>

This patch adds a delay when regulators are disabled.
This delay is set to 5 ms to cover all use cases.
The worst use case actually seen is during a SD card power cycle.

Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---

 drivers/power/regulator/stpmu1.c | 20 ++++++++++++--------
 include/power/stpmu1.h           |  1 +
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/power/regulator/stpmu1.c b/drivers/power/regulator/stpmu1.c
index 2dedb80acc42..6eb2420b6bcb 100644
--- a/drivers/power/regulator/stpmu1.c
+++ b/drivers/power/regulator/stpmu1.c
@@ -183,6 +183,8 @@ static int stpmu1_buck_get_enable(struct udevice *dev)
 static int stpmu1_buck_set_enable(struct udevice *dev, bool enable)
 {
 	struct dm_regulator_uclass_platdata *uc_pdata;
+	int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS :
+			     STPMU1_DEFAULT_STOP_DELAY_MS;
 	int ret, uv;
 
 	/* if regulator is already in the wanted state, nothing to do */
@@ -199,8 +201,7 @@ static int stpmu1_buck_set_enable(struct udevice *dev, bool enable)
 	ret = pmic_clrsetbits(dev->parent,
 			      STPMU1_BUCKX_CTRL_REG(dev->driver_data - 1),
 			      STPMU1_BUCK_EN, enable ? STPMU1_BUCK_EN : 0);
-	if (enable)
-		mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS);
+	mdelay(delay);
 
 	return ret;
 }
@@ -361,6 +362,8 @@ static int stpmu1_ldo_get_enable(struct udevice *dev)
 static int stpmu1_ldo_set_enable(struct udevice *dev, bool enable)
 {
 	struct dm_regulator_uclass_platdata *uc_pdata;
+	int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS :
+			     STPMU1_DEFAULT_STOP_DELAY_MS;
 	int ret, uv;
 
 	/* if regulator is already in the wanted state, nothing to do */
@@ -377,8 +380,7 @@ static int stpmu1_ldo_set_enable(struct udevice *dev, bool enable)
 	ret = pmic_clrsetbits(dev->parent,
 			      STPMU1_LDOX_CTRL_REG(dev->driver_data - 1),
 			      STPMU1_LDO_EN, enable ? STPMU1_LDO_EN : 0);
-	if (enable)
-		mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS);
+	mdelay(delay);
 
 	return ret;
 }
@@ -489,6 +491,8 @@ static int stpmu1_vref_ddr_get_enable(struct udevice *dev)
 
 static int stpmu1_vref_ddr_set_enable(struct udevice *dev, bool enable)
 {
+	int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS :
+			     STPMU1_DEFAULT_STOP_DELAY_MS;
 	int ret;
 
 	/* if regulator is already in the wanted state, nothing to do */
@@ -497,8 +501,7 @@ static int stpmu1_vref_ddr_set_enable(struct udevice *dev, bool enable)
 
 	ret = pmic_clrsetbits(dev->parent, STPMU1_VREF_CTRL_REG,
 			      STPMU1_VREF_EN, enable ? STPMU1_VREF_EN : 0);
-	if (enable)
-		mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS);
+	mdelay(delay);
 
 	return ret;
 }
@@ -610,6 +613,8 @@ static int stpmu1_pwr_sw_get_enable(struct udevice *dev)
 static int stpmu1_pwr_sw_set_enable(struct udevice *dev, bool enable)
 {
 	uint mask = 1 << dev->driver_data;
+	int delay = enable ? STPMU1_DEFAULT_START_UP_DELAY_MS :
+			     STPMU1_DEFAULT_STOP_DELAY_MS;
 	int ret;
 
 	ret = pmic_reg_read(dev->parent, STPMU1_USB_CTRL_REG);
@@ -633,8 +638,7 @@ static int stpmu1_pwr_sw_set_enable(struct udevice *dev, bool enable)
 
 	ret = pmic_clrsetbits(dev->parent, STPMU1_USB_CTRL_REG,
 			      mask, enable ? mask : 0);
-	if (enable)
-		mdelay(STPMU1_DEFAULT_START_UP_DELAY_MS);
+	mdelay(delay);
 
 	return ret;
 }
diff --git a/include/power/stpmu1.h b/include/power/stpmu1.h
index 61c58f3b7009..5906fbf832bf 100644
--- a/include/power/stpmu1.h
+++ b/include/power/stpmu1.h
@@ -44,6 +44,7 @@
 #define STPMU1_NVM_USER_STATUS_ERROR	BIT(1)
 
 #define STPMU1_DEFAULT_START_UP_DELAY_MS	1
+#define STPMU1_DEFAULT_STOP_DELAY_MS		5
 #define STPMU1_USB_BOOST_START_UP_DELAY_MS	10
 
 enum {
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] power: regulator: stpmu1: add power off delay
  2018-06-27  9:59 [U-Boot] [PATCH] power: regulator: stpmu1: add power off delay Patrice Chotard
@ 2018-07-20 12:35 ` Tom Rini
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2018-07-20 12:35 UTC (permalink / raw)
  To: u-boot

On Wed, Jun 27, 2018 at 11:59:47AM +0200, Patrice Chotard wrote:

> From: Christophe Kerello <christophe.kerello@st.com>
> 
> This patch adds a delay when regulators are disabled.
> This delay is set to 5 ms to cover all use cases.
> The worst use case actually seen is during a SD card power cycle.
> 
> Signed-off-by: Christophe Kerello <christophe.kerello@st.com>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180720/dc8aa685/attachment.sig>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-20 12:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-27  9:59 [U-Boot] [PATCH] power: regulator: stpmu1: add power off delay Patrice Chotard
2018-07-20 12:35 ` [U-Boot] " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox