Devicetree
 help / color / mirror / Atom feed
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>
Subject: [PATCH 2/2] mmc: core: Add post-power-off-delay-ms support
Date: Thu, 16 Jul 2026 18:26:41 -0500	[thread overview]
Message-ID: <20260716232641.2659710-3-jm@ti.com> (raw)
In-Reply-To: <20260716232641.2659710-1-jm@ti.com>

Add support for post-power-off-delay-ms which shall be used to insert
a configurable delay post MMC power off.

Signed-off-by: Judith Mendez <jm@ti.com>
---
 drivers/mmc/core/core.c  | 8 ++++++--
 drivers/mmc/core/host.c  | 8 ++++++++
 include/linux/mmc/host.h | 1 +
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 29e80e5f928e9..f9049aaf44394 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1394,8 +1394,12 @@ void mmc_power_off(struct mmc_host *host)
 void mmc_power_cycle(struct mmc_host *host, u32 ocr)
 {
 	mmc_power_off(host);
-	/* Wait at least 1 ms according to SD spec */
-	mmc_delay(1);
+	if (host->post_power_off_delay_ms) {
+		mmc_delay(host->post_power_off_delay_ms);
+	} else {
+		/* Wait at least 1 ms according to SD spec */
+		mmc_delay(1);
+	}
 	mmc_power_up(host, ocr);
 }
 
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index b7ce3137d4529..ea8f36827e41c 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -421,6 +421,14 @@ 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, "post-power-off-delay-ms",
+				 &host->post_power_off_delay_ms);
+	if (host->post_power_off_delay_ms > 10000) {
+		dev_err(dev, "post-power-off-delay-ms %u exceeds max 10000, setting 10000\n",
+			host->post_power_off_delay_ms);
+		host->post_power_off_delay_ms = 10000;
+	}
+
 	return mmc_pwrseq_alloc(host);
 }
 
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index ba84f02c2a101..b751b61b1116e 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -578,6 +578,7 @@ struct mmc_host {
 
 	u32			err_stats[MMC_ERR_MAX];
 	u32			max_sd_hs_hz;
+	u32			post_power_off_delay_ms;
 	unsigned long		private[] ____cacheline_aligned;
 };
 
-- 
2.54.0


  parent reply	other threads:[~2026-07-16 23:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16 23:26 [PATCH 0/2] mmc: Add post-power-off-delay-ms support Judith Mendez
2026-07-16 23:26 ` [PATCH 1/2] dt-bindings: mmc: Add post-power-off-delay-ms property Judith Mendez
2026-07-17  0:35   ` Rob Herring (Arm)
2026-07-16 23:26 ` Judith Mendez [this message]
2026-07-16 23:37   ` [PATCH 2/2] mmc: core: Add post-power-off-delay-ms support sashiko-bot

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=20260716232641.2659710-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=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