public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH] mmc: Fix missing 1 ms delay after mmc power up
@ 2025-10-31 14:59 Christoph Stoidner
  2025-11-04  8:34 ` Peng Fan
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Christoph Stoidner @ 2025-10-31 14:59 UTC (permalink / raw)
  To: u-boot; +Cc: Christoph Stoidner, Peng Fan, Jaehoon Chung

mmc/sd specification requires a 1 ms delay (stable supply voltage)
after vdd was enabled and before issuing first command.

For most sdcard/soc combinations, the missing delay seems to be not a
problem because the processing time between enabling vdd and the first
command is often hundreds of microseconds or more. However, in our
specific case, some sdcards were not detected by u-boot:
* soc: NXP i.MX 93
* sdcards: SanDisk Ultra, 64GB micro SDXC 1,
           MediaRange, 8GB, SDHC
* measured time between vdd and first command: approx. 784us
* symptom: both sdcards did not respond at all to first commands,
           u-boot mmc subsystem ran into timeout and stops to
           initialize the cards

Signed-off-by: Christoph Stoidner <c.stoidner@phytec.de>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: Jaehoon Chung <jh80.chung@samsung.com>
---
 drivers/mmc/mmc.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index ec61ed92e86..2093d169094 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2878,11 +2878,18 @@ static int mmc_power_cycle(struct mmc *mmc)
 		return ret;
 
 	/*
-	 * SD spec recommends at least 1ms of delay. Let's wait for 2ms
-	 * to be on the safer side.
+	 * SD spec recommends at least 1ms of 'power on' delay.
+	 * Let's wait for 2ms to be on the safer side.
 	 */
 	udelay(2000);
-	return mmc_power_on(mmc);
+	ret = mmc_power_on(mmc);
+
+	/*
+	 * SD spec recommends at least 1ms of 'stable supply voltage' delay.
+	 * Let's wait for 2ms to be on the safer side.
+	 */
+	udelay(2000);
+	return ret;
 }
 
 int mmc_get_op_cond(struct mmc *mmc, bool quiet)
-- 
2.43.0


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

* RE: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
  2025-10-31 14:59 [PATCH] mmc: Fix missing 1 ms delay after mmc power up Christoph Stoidner
@ 2025-11-04  8:34 ` Peng Fan
  2025-11-10 20:46   ` AW: " Christoph Stoidner
       [not found] ` <a41edf4c-39f5-432e-8eeb-9426dba89a17@freeshell.de>
  2026-01-08 13:32 ` Peng Fan
  2 siblings, 1 reply; 8+ messages in thread
From: Peng Fan @ 2025-11-04  8:34 UTC (permalink / raw)
  To: Christoph Stoidner, u-boot@lists.denx.de
  Cc: Christoph Stoidner, Jaehoon Chung

Hi Christoph

Thanks for your patch.

> Subject: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
...
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -2878,11 +2878,18 @@ static int mmc_power_cycle(struct mmc
> *mmc)
>  		return ret;
> 
>  	/*
> -	 * SD spec recommends at least 1ms of delay. Let's wait for
> 2ms
> -	 * to be on the safer side.
> +	 * SD spec recommends at least 1ms of 'power on' delay.
> +	 * Let's wait for 2ms to be on the safer side.
>  	 */
>  	udelay(2000);
> -	return mmc_power_on(mmc);
> +	ret = mmc_power_on(mmc);
> +
> +	/*
> +	 * SD spec recommends at least 1ms of 'stable supply voltage'
> delay.
> +	 * Let's wait for 2ms to be on the safer side.
> +	 */
> +	udelay(2000);

Per spec,                                                                                                  
From Figure 6-4: Power-up Diagram of Card 
the 1ms is voltageSupply ramp up time, so I am thinking the fix 
should be in your regulator side, saying startup-delay-us property
in your regulator node.

Thanks,
Peng.

> +	return ret;
>  }
> 
>  int mmc_get_op_cond(struct mmc *mmc, bool quiet)
> --
> 2.43.0


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

* AW: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
  2025-11-04  8:34 ` Peng Fan
@ 2025-11-10 20:46   ` Christoph Stoidner
  2025-11-18  4:56     ` Peng Fan
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Stoidner @ 2025-11-10 20:46 UTC (permalink / raw)
  To: Peng Fan, u-boot@lists.denx.de; +Cc: Jaehoon Chung

Hi Peng, thanks for your feedback.

> Hi Christoph
> 
> Thanks for your patch.
> 
> > Subject: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
...
> > +     udelay(2000);
> 
> Per spec,
> From Figure 6-4: Power-up Diagram of Card
> the 1ms is voltageSupply ramp up time, so I am thinking the fix
> should be in your regulator side, saying startup-delay-us property
> in your regulator node.

True, this could also be handled via the regulator’s DTS properties, and
some boards already do that. However, from my point of view, that’s not
the right place for this particular delay.

The SD specification distinguishes between two different delays
(see Figure 6-5 “Power-Up Diagram (Host)” in SD Spec 6.00, §6.4.1):

   1) "Power ramp up"
   2) "Stable voltage delay"

The first one (power ramp up) is regulator-specific and should indeed be
covered by the regulator’s startup-delay-us property in the device tree.
But this patch is about the second one - the "stable voltage delay".

That delay is completely independent of any regulator/voltage-supply or
board characteristics; it is a constant 1ms delay by the SD interface itself
to ensure correct card initialization timing. 
Decoupling it from the regulators would make board-code developers
live easier, and can make U-Boot’s MMC initialization more robust across
all boards.

What do you think about that?

Regards,
Christoph

> Thanks,
> Peng.
> 
> > +     return ret;
...

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

* Re: AW: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
       [not found]   ` <DB9P195MB12122313AC9E54232C3B713D97CCA@DB9P195MB1212.EURP195.PROD.OUTLOOK.COM>
@ 2025-11-12 20:25     ` E Shattow
  0 siblings, 0 replies; 8+ messages in thread
From: E Shattow @ 2025-11-12 20:25 UTC (permalink / raw)
  To: Christoph Stoidner; +Cc: U-Boot Mailing List



On 11/12/25 10:13, Christoph Stoidner wrote:
> Hello,  sorry, did you send that mail only direct to me? I cannot find it in the Mailinglist.
> 
> I don't want to bother you. However would you mind to send it also to the list, to have it transparent for all?
> 
> Regards,
> Christoph

Okay, sorry I missed this before. CC: U-Boot Mailing List

-E

> 
> 
> ________________________________
> Von: E Shattow <e@freeshell.de>
> Gesendet: Freitag, 31. Oktober 2025 22:27
> An: Christoph Stoidner <c.stoidner@phytec.de>
> Betreff: Re: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
> 
> 
> On 10/31/25 07:59, Christoph Stoidner wrote:
>> mmc/sd specification requires a 1 ms delay (stable supply voltage)
>> after vdd was enabled and before issuing first command.
>>
>> For most sdcard/soc combinations, the missing delay seems to be not a
>> problem because the processing time between enabling vdd and the first
>> command is often hundreds of microseconds or more. However, in our
>> specific case, some sdcards were not detected by u-boot:
>> * soc: NXP i.MX 93
>> * sdcards: SanDisk Ultra, 64GB micro SDXC 1,
>>            MediaRange, 8GB, SDHC
>> * measured time between vdd and first command: approx. 784us
>> * symptom: both sdcards did not respond at all to first commands,
>>            u-boot mmc subsystem ran into timeout and stops to
>>            initialize the cards
>>
>> Signed-off-by: Christoph Stoidner <c.stoidner@phytec.de>
>> Cc: Peng Fan <peng.fan@nxp.com>
>> Cc: Jaehoon Chung <jh80.chung@samsung.com>
>> ---
>>  drivers/mmc/mmc.c | 13 ++++++++++---
>>  1 file changed, 10 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index ec61ed92e86..2093d169094 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -2878,11 +2878,18 @@ static int mmc_power_cycle(struct mmc *mmc)
>>                return ret;
>>
>>        /*
>> -      * SD spec recommends at least 1ms of delay. Let's wait for 2ms
>> -      * to be on the safer side.
>> +      * SD spec recommends at least 1ms of 'power on' delay.
>> +      * Let's wait for 2ms to be on the safer side.
>>         */
>>        udelay(2000);
>> -     return mmc_power_on(mmc);
>> +     ret = mmc_power_on(mmc);
>> +
>> +     /*
>> +      * SD spec recommends at least 1ms of 'stable supply voltage' delay.
>> +      * Let's wait for 2ms to be on the safer side.
>> +      */
>> +     udelay(2000);
>> +     return ret;
>>  }
>>
>>  int mmc_get_op_cond(struct mmc *mmc, bool quiet)
> 
> Let's do what it says. Would udelay(1000) ever possibly complete faster
> than the recommended time in the specification ?
> 
>          /*
> -        * SD spec recommends at least 1ms of delay. Let's wait for 2ms
> -        * to be on the safer side.
> +        * SD spec requires:
> +        * 1ms of delay 'power on' before power on
> +        * 1ms of 'stable supply voltage' after power on
>           */
>          udelay(1000);
> -       return mmc_power_on(mmc);
> +       ret = mmc_power_on(mmc);
> +       udelay(1000);
> +       return ret;
>  }
> 
> To follow the specification recommendations exactly?
> 
> Also, why add the delay before returning from mmc_power_on() in
> mmc_power_cycle() and not in mmc_power_on() itself?
> 
> -E
> 


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

* Re: AW: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
  2025-11-10 20:46   ` AW: " Christoph Stoidner
@ 2025-11-18  4:56     ` Peng Fan
  2025-11-28 12:38       ` Christoph Stoidner
  0 siblings, 1 reply; 8+ messages in thread
From: Peng Fan @ 2025-11-18  4:56 UTC (permalink / raw)
  To: Christoph Stoidner; +Cc: Peng Fan, u-boot@lists.denx.de, Jaehoon Chung

On Mon, Nov 10, 2025 at 08:46:39PM +0000, Christoph Stoidner wrote:
>Hi Peng, thanks for your feedback.
>
>> Hi Christoph
>> 
>> Thanks for your patch.
>> 
>> > Subject: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
>...
>> > +     udelay(2000);
>> 
>> Per spec,
>> From Figure 6-4: Power-up Diagram of Card
>> the 1ms is voltageSupply ramp up time, so I am thinking the fix
>> should be in your regulator side, saying startup-delay-us property
>> in your regulator node.
>
>True, this could also be handled via the regulator?s DTS properties, and
>some boards already do that. However, from my point of view, that?s not
>the right place for this particular delay.
>
>The SD specification distinguishes between two different delays
>(see Figure 6-5 ?Power-Up Diagram (Host)? in SD Spec 6.00, ?6.4.1):
>
>   1) "Power ramp up"
>   2) "Stable voltage delay"
>
>The first one (power ramp up) is regulator-specific and should indeed be
>covered by the regulator?s startup-delay-us property in the device tree.
>But this patch is about the second one - the "stable voltage delay".
>
>That delay is completely independent of any regulator/voltage-supply or
>board characteristics; it is a constant 1ms delay by the SD interface itself
>to ensure correct card initialization timing. 
>Decoupling it from the regulators would make board-code developers
>live easier, and can make U-Boot?s MMC initialization more robust across
>all boards.
>
>What do you think about that?

Sorry for late.
Thanks for explaining this, this is reasonable. I am thinking it might be better
if we add ios.post_power_delay_ms for your platform.

Regards
Peng

>
>Regards,
>Christoph
>
>> Thanks,
>> Peng.
>> 
>> > +     return ret;
>...

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

* Re: AW: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
  2025-11-18  4:56     ` Peng Fan
@ 2025-11-28 12:38       ` Christoph Stoidner
  2026-01-05  2:49         ` Peng Fan
  0 siblings, 1 reply; 8+ messages in thread
From: Christoph Stoidner @ 2025-11-28 12:38 UTC (permalink / raw)
  To: Peng Fan; +Cc: Peng Fan, u-boot@lists.denx.de, Jaehoon Chung

Hi Peng,

On Di, 2025-11-18 at 12:56 +0800, Peng Fan wrote:
> On Mon, Nov 10, 2025 at 08:46:39PM +0000, Christoph Stoidner wrote:
> > Hi Peng, thanks for your feedback.
> > 
> > > Hi Christoph
> > > 
> > > Thanks for your patch.
> > > 
> > > > Subject: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
> > ...
> > > > +     udelay(2000);
> > > 
> > > Per spec,
> > > From Figure 6-4: Power-up Diagram of Card
> > > the 1ms is voltageSupply ramp up time, so I am thinking the fix
> > > should be in your regulator side, saying startup-delay-us
> > > property
> > > in your regulator node.
> > 
> > True, this could also be handled via the regulator?s DTS
> > properties, and
> > some boards already do that. However, from my point of view, that?s
> > not
> > the right place for this particular delay.
> > 
> > The SD specification distinguishes between two different delays
> > (see Figure 6-5 ?Power-Up Diagram (Host)? in SD Spec 6.00, ?6.4.1):
> > 
> >   1) "Power ramp up"
> >   2) "Stable voltage delay"
> > 
> > The first one (power ramp up) is regulator-specific and should
> > indeed be
> > covered by the regulator?s startup-delay-us property in the device
> > tree.
> > But this patch is about the second one - the "stable voltage
> > delay".
> > 
> > That delay is completely independent of any regulator/voltage-
> > supply or
> > board characteristics; it is a constant 1ms delay by the SD
> > interface itself
> > to ensure correct card initialization timing. 
> > Decoupling it from the regulators would make board-code developers
> > live easier, and can make U-Boot?s MMC initialization more robust
> > across
> > all boards.
> > 
> > What do you think about that?
> 
> Sorry for late.
> Thanks for explaining this, this is reasonable. I am thinking it
> might be better
> if we add ios.post_power_delay_ms for your platform.

you mean we should introduce the DTS property post_power_delay_ms for
mmc and then use it in our platform's DTS?

But a DTS property is actually what I want to avoid, because that delay
is nothing platform-specific and should be solved all for one in the
mmc subsystem drivers/mmc/mmc.c itself.

What's the reason why you prefer a DTS property?

Regards,
Christoph

> 
> Regards
> Peng
> 
> > 
> > Regards,
> > Christoph
> > 
> > > Thanks,
> > > Peng.
> > > 
> > > > +     return ret;
> > ...


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

* RE: AW: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
  2025-11-28 12:38       ` Christoph Stoidner
@ 2026-01-05  2:49         ` Peng Fan
  0 siblings, 0 replies; 8+ messages in thread
From: Peng Fan @ 2026-01-05  2:49 UTC (permalink / raw)
  To: Christoph Stoidner, Peng Fan (OSS); +Cc: u-boot@lists.denx.de, Jaehoon Chung

> Subject: Re: AW: [PATCH] mmc: Fix missing 1 ms delay after mmc
> power up
> 
> Hi Peng,
> 
> On Di, 2025-11-18 at 12:56 +0800, Peng Fan wrote:
> > On Mon, Nov 10, 2025 at 08:46:39PM +0000, Christoph Stoidner
> wrote:
> > > Hi Peng, thanks for your feedback.
> > >
> > > > Hi Christoph
> > > >
> > > > Thanks for your patch.
> > > >
> > > > > Subject: [PATCH] mmc: Fix missing 1 ms delay after mmc power
> up
> > > ...
> > > > > +     udelay(2000);
> > > >
> > > > Per spec,
> > > > From Figure 6-4: Power-up Diagram of Card the 1ms is
> voltageSupply
> > > > ramp up time, so I am thinking the fix should be in your regulator
> > > > side, saying startup-delay-us property in your regulator node.
> > >
> > > True, this could also be handled via the regulator?s DTS properties,
> > > and some boards already do that. However, from my point of view,
> > > that?s not the right place for this particular delay.
> > >
> > > The SD specification distinguishes between two different delays (see
> > > Figure 6-5 ?Power-Up Diagram (Host)? in SD Spec 6.00, ?6.4.1):
> > >
> > >   1) "Power ramp up"
> > >   2) "Stable voltage delay"
> > >
> > > The first one (power ramp up) is regulator-specific and should
> > > indeed be covered by the regulator?s startup-delay-us property in
> > > the device tree.
> > > But this patch is about the second one - the "stable voltage delay".
> > >
> > > That delay is completely independent of any regulator/voltage-
> > > supply or board characteristics; it is a constant 1ms delay by the
> > > SD interface itself to ensure correct card initialization timing.
> > > Decoupling it from the regulators would make board-code
> developers
> > > live easier, and can make U-Boot?s MMC initialization more robust
> > > across all boards.
> > >
> > > What do you think about that?
> >
> > Sorry for late.
> > Thanks for explaining this, this is reasonable. I am thinking it might
> > be better if we add ios.post_power_delay_ms for your platform.
> 
> you mean we should introduce the DTS property
> post_power_delay_ms for mmc and then use it in our platform's DTS?
> 
> But a DTS property is actually what I want to avoid, because that delay
> is nothing platform-specific and should be solved all for one in the
> mmc subsystem drivers/mmc/mmc.c itself.
> 
> What's the reason why you prefer a DTS property?

You message seems breaks the mail thread. So my script not
able to retrieve the message thread from patchwork.

I just don't like to add delays. Reading the spec again,
I am fine with your changes. 

Thanks,
Peng.

> 
> Regards,
> Christoph
> 
> >
> > Regards
> > Peng
> >
> > >
> > > Regards,
> > > Christoph
> > >
> > > > Thanks,
> > > > Peng.
> > > >
> > > > > +     return ret;
> > > ...


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

* Re: [PATCH] mmc: Fix missing 1 ms delay after mmc power up
  2025-10-31 14:59 [PATCH] mmc: Fix missing 1 ms delay after mmc power up Christoph Stoidner
  2025-11-04  8:34 ` Peng Fan
       [not found] ` <a41edf4c-39f5-432e-8eeb-9426dba89a17@freeshell.de>
@ 2026-01-08 13:32 ` Peng Fan
  2 siblings, 0 replies; 8+ messages in thread
From: Peng Fan @ 2026-01-08 13:32 UTC (permalink / raw)
  To: Christoph Stoidner; +Cc: u-boot, Peng Fan, Jaehoon Chung

On Fri, Oct 31, 2025 at 03:59:51PM +0100, Christoph Stoidner wrote:
>mmc/sd specification requires a 1 ms delay (stable supply voltage)
>after vdd was enabled and before issuing first command.
>
>For most sdcard/soc combinations, the missing delay seems to be not a
>problem because the processing time between enabling vdd and the first
>command is often hundreds of microseconds or more. However, in our
>specific case, some sdcards were not detected by u-boot:
>* soc: NXP i.MX 93
>* sdcards: SanDisk Ultra, 64GB micro SDXC 1,
>           MediaRange, 8GB, SDHC
>* measured time between vdd and first command: approx. 784us
>* symptom: both sdcards did not respond at all to first commands,
>           u-boot mmc subsystem ran into timeout and stops to
>           initialize the cards
>
>Signed-off-by: Christoph Stoidner <c.stoidner@phytec.de>
>Cc: Peng Fan <peng.fan@nxp.com>
>Cc: Jaehoon Chung <jh80.chung@samsung.com>
>---

Applied.

Thanks,
Peng

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

end of thread, other threads:[~2026-01-08 13:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-31 14:59 [PATCH] mmc: Fix missing 1 ms delay after mmc power up Christoph Stoidner
2025-11-04  8:34 ` Peng Fan
2025-11-10 20:46   ` AW: " Christoph Stoidner
2025-11-18  4:56     ` Peng Fan
2025-11-28 12:38       ` Christoph Stoidner
2026-01-05  2:49         ` Peng Fan
     [not found] ` <a41edf4c-39f5-432e-8eeb-9426dba89a17@freeshell.de>
     [not found]   ` <DB9P195MB12122313AC9E54232C3B713D97CCA@DB9P195MB1212.EURP195.PROD.OUTLOOK.COM>
2025-11-12 20:25     ` E Shattow
2026-01-08 13:32 ` Peng Fan

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