From: Judith Mendez <jm@ti.com>
To: Judith Mendez <jm@ti.com>, Ulf Hansson <ulfh@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>
Cc: <linux-mmc@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCH v3 2/2] mmc: core: Add power-off-delay-us support
Date: Thu, 6 Aug 2026 11:22:02 -0500 [thread overview]
Message-ID: <20260806162202.657512-3-jm@ti.com> (raw)
In-Reply-To: <20260806162202.657512-1-jm@ti.com>
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 work
around hardware issues such as slow RC discharge on MMC VDD rails.
Signed-off-by: Judith Mendez <jm@ti.com>
---
Changes since v2:
- Drop < 0 check when parsing DT property, device_property_read_u32
should allow only positive values. Change also per Ulf's review
- Remove upper limit check, also per Ulf's review
- Use fsleep() instead of custom logic in mmc_delay_us(), per
Sebastian's review
- Return immediately if 0 in mmc_delay_us(), since no delay should
now be valid as per Ulf's review
---
drivers/mmc/core/core.c | 2 +-
drivers/mmc/core/core.h | 8 ++++++++
drivers/mmc/core/host.c | 4 ++++
include/linux/mmc/host.h | 1 +
4 files changed, 14 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/core.h b/drivers/mmc/core/core.h
index a028b48be1644..601c73761e886 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -73,6 +73,14 @@ static inline void mmc_delay(unsigned int ms)
msleep(ms);
}
+static inline void mmc_delay_us(unsigned int us)
+{
+ if (us == 0)
+ return;
+
+ fsleep(us);
+}
+
void mmc_rescan(struct work_struct *work);
void mmc_start_host(struct mmc_host *host);
void __mmc_stop_host(struct mmc_host *host);
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index b7ce3137d4529..ac1846e0e7fbd 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -421,6 +421,9 @@ 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);
+
return mmc_pwrseq_alloc(host);
}
@@ -574,6 +577,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
host->fixed_drv_type = -EINVAL;
host->ios.power_delay_ms = 10;
+ host->ios.power_off_delay_us = 1000;
host->ios.power_mode = MMC_POWER_UNDEFINED;
return host;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index ba84f02c2a101..714417466707c 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -23,6 +23,7 @@ struct mmc_ios {
unsigned int clock; /* clock rate */
unsigned short vdd;
unsigned int power_delay_ms; /* waiting for stable power */
+ unsigned int power_off_delay_us; /* waiting for power discharge */
/* vdd stores the bit number of the selected voltage range from below. */
--
2.54.0
prev parent reply other threads:[~2026-08-06 16:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 16:22 [PATCH v3 0/2] mmc: Add power_off_delay_us support Judith Mendez
2026-08-06 16:22 ` [PATCH v3 1/2] dt-bindings: mmc: Add power-off-delay-us property Judith Mendez
2026-08-06 16:22 ` Judith Mendez [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260806162202.657512-3-jm@ti.com \
--to=jm@ti.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=ulfh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox