All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] power: regulator: Fix power on/off delay issue
@ 2026-05-22  7:14 Ye Li
  2026-05-25  6:16 ` Peng Fan
  0 siblings, 1 reply; 2+ messages in thread
From: Ye Li @ 2026-05-22  7:14 UTC (permalink / raw)
  To: jh80.chung, u-boot, peng.fan, jonas; +Cc: festevam, uboot-imx, ye.li

SD initialization failure happens with some UHS-I SD cards on
iMX8MM/iMX93/iMX91 EVK after
commit 4fcba5d556b4 ("regulator: implement basic reference counter").
When sending operation condition to SD card, the OCR does not return
correct status. The root cause is regulator on/off delay is missed
in MMC power cycle with above commit, so SD card is not completely
power off.

When SD startup, the sequence of MMC power cycle is:
mmc_power_init(get vmmc_supply dev) -> mmc_power_off -> udelay(2000)
-> mmc_power_on

Before above commit, as a fixed regulator, the GPIO is set as:
  GPIO inactive (in mmc_power_init) ->
  GPIO inactive and delay off-on-delay-us (in mmc_power_off) ->
  udelay(2000) ->
  GPIO active (in mmc_power_on)

After the commit:
  GPIO inactive (in mmc_power_init) ->
  enable_count is 0, regulator_set_enable returns -EALREADY immediately,
      so GPIO is inactive but No off-on-delay-us (in mmc_power_off) ->
  udelay(2000) ->
  GPIO active (in mmc_power_on)

Move the off-on-delay-us delay before setting GPIO active to fix the issue.

Signed-off-by: Ye Li <ye.li@nxp.com>
---
Changes in v2:
 - move the off-on-delay before enabling the GPIO

 drivers/power/regulator/regulator_common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c
index 85af8d599ad..c0387eff4fc 100644
--- a/drivers/power/regulator/regulator_common.c
+++ b/drivers/power/regulator/regulator_common.c
@@ -87,6 +87,9 @@ int regulator_common_set_enable(const struct udevice *dev,
 			}
 		}
 
+		if (enable && plat->off_on_delay_us)
+			udelay(plat->off_on_delay_us);
+
 		ret = dm_gpio_set_value(&plat->gpio, enable);
 		if (ret) {
 			pr_err("Can't set regulator : %s gpio to: %d\n", dev->name,
@@ -97,9 +100,6 @@ int regulator_common_set_enable(const struct udevice *dev,
 		if (enable && plat->startup_delay_us)
 			udelay(plat->startup_delay_us);
 
-		if (!enable && plat->off_on_delay_us)
-			udelay(plat->off_on_delay_us);
-
 		if (enable)
 			plat->enable_count++;
 		else
-- 
2.37.1


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

* Re: [PATCH v2] power: regulator: Fix power on/off delay issue
  2026-05-22  7:14 [PATCH v2] power: regulator: Fix power on/off delay issue Ye Li
@ 2026-05-25  6:16 ` Peng Fan
  0 siblings, 0 replies; 2+ messages in thread
From: Peng Fan @ 2026-05-25  6:16 UTC (permalink / raw)
  To: Ye Li; +Cc: jh80.chung, u-boot, peng.fan, jonas, festevam, uboot-imx, ye.li

On Fri, May 22, 2026 at 03:14:14PM +0800, Ye Li wrote:
>SD initialization failure happens with some UHS-I SD cards on
>iMX8MM/iMX93/iMX91 EVK after
>commit 4fcba5d556b4 ("regulator: implement basic reference counter").
>When sending operation condition to SD card, the OCR does not return
>correct status. The root cause is regulator on/off delay is missed
>in MMC power cycle with above commit, so SD card is not completely
>power off.
>
>When SD startup, the sequence of MMC power cycle is:
>mmc_power_init(get vmmc_supply dev) -> mmc_power_off -> udelay(2000)
>-> mmc_power_on
>
>Before above commit, as a fixed regulator, the GPIO is set as:
>  GPIO inactive (in mmc_power_init) ->
>  GPIO inactive and delay off-on-delay-us (in mmc_power_off) ->
>  udelay(2000) ->
>  GPIO active (in mmc_power_on)
>
>After the commit:
>  GPIO inactive (in mmc_power_init) ->
>  enable_count is 0, regulator_set_enable returns -EALREADY immediately,
>      so GPIO is inactive but No off-on-delay-us (in mmc_power_off) ->
>  udelay(2000) ->
>  GPIO active (in mmc_power_on)
>
>Move the off-on-delay-us delay before setting GPIO active to fix the issue.
>
>Signed-off-by: Ye Li <ye.li@nxp.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

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

end of thread, other threads:[~2026-05-25  6:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-22  7:14 [PATCH v2] power: regulator: Fix power on/off delay issue Ye Li
2026-05-25  6:16 ` Peng Fan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.