Re: [PATCH v2 3/3] mmc: core: Add power-off-delay-us support
Ulf Hansson <[email protected]> Tue, 4 Aug 2026 13:02:39 +0200
| Newsgroups | org.kernel.vger.linux-mmc,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAPx+jO_Yc1rBcxatzByy6cWAy6JdXcLXqkOpFbAKTcEsK2ASXA@mail.gmail.com> |
On Mon, Aug 3, 2026 at 4:31=E2=80=AFPM Mendez, Judith <[email protected]> wrote: > > Hi Ulf, > > On 8/3/2026 7:27 AM, Ulf Hansson wrote: > > On Tue, Jul 28, 2026 at 11:56=E2=80=AFPM Judith Mendez <[email protected]> wrot= e: > >> > >> Hi Ulf, > >> > >> On 7/27/26 10:16 AM, Ulf Hansson wrote: > >>> On Wed, Jul 22, 2026 at 10:57=E2=80=AFPM Judith Mendez <[email protected]> wr= ote: > >>>> > >>>> Add support for power-off-delay-us which shall be used to specify > >>>> value of delay after deasserting power during MMC power cycles. > >>>> Default for delay is 1000us but custom delay can be passed in to wor= k > >>>> around hardware issues such as slow RC discharge on MMC VDD rails. > >>>> > >>>> Signed-off-by: Judith Mendez <[email protected]> > >>>> --- > >>>> Changes since v1: > >>>> - Move delay to mmc_power_off > >>>> - Fix dt checks and remove print > >>>> - Move from mmc_host struct to mmc_ios struct > >>>> - Rename post-power-off-delay-ms to power_off_delay_us > >>>> --- > >>>> drivers/mmc/core/core.c | 2 +- > >>>> drivers/mmc/core/host.c | 8 ++++++++ > >>>> include/linux/mmc/host.h | 1 + > >>>> 3 files changed, 10 insertions(+), 1 deletion(-) > >>>> > >>>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c > >>>> index 29e80e5f928e9..9472041fe1c20 100644 > >>>> --- a/drivers/mmc/core/core.c > >>>> +++ b/drivers/mmc/core/core.c > >>>> @@ -1388,7 +1388,7 @@ void mmc_power_off(struct mmc_host *host) > >>>> * XO-1.5, require a short delay after poweroff before the= card > >>>> * can be successfully turned on again. > >>>> */ > >>>> - mmc_delay(1); > >>>> + mmc_delay_us(host->ios.power_off_delay_us); > >>>> } > >>>> > >>>> void mmc_power_cycle(struct mmc_host *host, u32 ocr) > >>>> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c > >>>> index b7ce3137d4529..fac50a2860211 100644 > >>>> --- a/drivers/mmc/core/host.c > >>>> +++ b/drivers/mmc/core/host.c > >>>> @@ -421,6 +421,13 @@ int mmc_of_parse(struct mmc_host *host) > >>>> device_property_read_u32(dev, "post-power-on-delay-ms", > >>>> &host->ios.power_delay_ms); > >>>> > >>>> + device_property_read_u32(dev, "power-off-delay-us", > >>>> + &host->ios.power_off_delay_us); > >>>> + if (host->ios.power_off_delay_us < 1) > >>>> + host->ios.power_off_delay_us =3D 1000; > >>> > >>> If power-off-delay-us is specified and the value >=3D 0, I think we c= an > >>> respect it as is. > >>> > >>> This means we need to treat "0" a bit special and bail out in mmc_del= ay_us(). > >> > >> Ok, just to confirm, then, you want to drop these guards in mmc_of_par= se > >> and instead catch 0 in mmc_power_off? > > > > Not exactly, if mmc_of_parse() doesn't get a valid value (>=3D0) when > > parsing for "power-off-delay-us" it should not set > > host->ios.power_off_delay_us, but rather rely on the default value > > that we have set in mmc_alloc_host(). > > Ok, so > > if power-off-delay-us < 0 -> use host default > else power_off_delay_us =3D power-off-delay-us > > And in mmc_power_off(), if power_off_delay_us =3D 0 > what would you like to do with special case? Well, we need to bail out somewhere. :-) I guess mmc_power_off() will call mmc_delay_us()? In that case, mmc_delay_us() could just return immediately if the delay is 0? Kind regards Uffe