From: Adrian Hunter <adrian.hunter@intel.com>
To: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>,
Michal Simek <michal.simek@amd.com>,
Ulf Hansson <ulf.hansson@linaro.org>
Cc: <linux-mmc@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <git@amd.com>,
<saikrishna12468@gmail.com>
Subject: Re: [PATCH] mmc: sdhci-of-arasan: Ensure CD logic stabilization before power-up
Date: Thu, 24 Jul 2025 19:20:07 +0300 [thread overview]
Message-ID: <cf04326b-4de4-4637-aa3b-fa1c358b9ae4@intel.com> (raw)
In-Reply-To: <20250721095357.3783222-1-sai.krishna.potthuri@amd.com>
On 21/07/2025 12:53, Sai Krishna Potthuri wrote:
> During SD suspend/resume without a full card rescan (when using
> non-removable SD cards for rootfs), the SD card initialization may fail
> after resume. This occurs because, after a host controller reset, the
> card detect logic may take time to stabilize due to debounce logic.
> Without waiting for stabilization, the host may attempt powering up the
> card prematurely, leading to command timeouts during resume flow.
> Add sdhci_arasan_set_power_and_bus_voltage() to wait for the card detect
> stable bit before power up the card. Since the stabilization time
> is not fixed, a maximum timeout of one second is used to ensure
> sufficient wait time for the card detect signal to stabilize.
>
> Signed-off-by: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
> ---
> drivers/mmc/host/sdhci-of-arasan.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
> index 42878474e56e..3ce55009ba4a 100644
> --- a/drivers/mmc/host/sdhci-of-arasan.c
> +++ b/drivers/mmc/host/sdhci-of-arasan.c
> @@ -99,6 +99,9 @@
> #define HIWORD_UPDATE(val, mask, shift) \
> ((val) << (shift) | (mask) << ((shift) + 16))
>
> +#define CD_STABLE_TIMEOUT_US 1000000
> +#define CD_STABLE_MAX_SLEEP_US 10
> +
> /**
> * struct sdhci_arasan_soc_ctl_field - Field used in sdhci_arasan_soc_ctl_map
> *
> @@ -514,6 +517,23 @@ static int sdhci_arasan_voltage_switch(struct mmc_host *mmc,
> return -EINVAL;
> }
>
> +static void sdhci_arasan_set_power_and_bus_voltage(struct sdhci_host *host, unsigned char mode,
> + unsigned short vdd)
> +{
> + u32 reg;
> +
> + /*
> + * Ensure that the card detect logic has stabilized before powering up, this is
> + * necessary after a host controller reset.
> + */
> + if (mode == MMC_POWER_UP) {
> + readl_poll_timeout(host->ioaddr + SDHCI_PRESENT_STATE, reg, reg & SDHCI_CD_STABLE,
> + CD_STABLE_MAX_SLEEP_US, CD_STABLE_TIMEOUT_US);
> + }
Doesn't need {}
Will this work with all Arasan variants?
> +
> + sdhci_set_power_and_bus_voltage(host, mode, vdd);
> +}
> +
> static const struct sdhci_ops sdhci_arasan_ops = {
> .set_clock = sdhci_arasan_set_clock,
> .get_max_clock = sdhci_pltfm_clk_get_max_clock,
> @@ -521,7 +541,7 @@ static const struct sdhci_ops sdhci_arasan_ops = {
> .set_bus_width = sdhci_set_bus_width,
> .reset = sdhci_arasan_reset,
> .set_uhs_signaling = sdhci_set_uhs_signaling,
> - .set_power = sdhci_set_power_and_bus_voltage,
> + .set_power = sdhci_arasan_set_power_and_bus_voltage,
> .hw_reset = sdhci_arasan_hw_reset,
> };
>
> @@ -570,7 +590,7 @@ static const struct sdhci_ops sdhci_arasan_cqe_ops = {
> .set_bus_width = sdhci_set_bus_width,
> .reset = sdhci_arasan_reset,
> .set_uhs_signaling = sdhci_set_uhs_signaling,
> - .set_power = sdhci_set_power_and_bus_voltage,
> + .set_power = sdhci_arasan_set_power_and_bus_voltage,
> .irq = sdhci_arasan_cqhci_irq,
> };
>
next prev parent reply other threads:[~2025-07-24 16:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-21 9:53 [PATCH] mmc: sdhci-of-arasan: Ensure CD logic stabilization before power-up Sai Krishna Potthuri
2025-07-24 16:20 ` Adrian Hunter [this message]
2025-07-25 5:49 ` Potthuri, Sai Krishna
2025-07-25 8:14 ` Adrian Hunter
2025-07-25 10:53 ` Potthuri, Sai Krishna
2025-08-01 13:03 ` Prasanna Kumar T S M
2025-08-04 7:11 ` Potthuri, Sai Krishna
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=cf04326b-4de4-4637-aa3b-fa1c358b9ae4@intel.com \
--to=adrian.hunter@intel.com \
--cc=git@amd.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=sai.krishna.potthuri@amd.com \
--cc=saikrishna12468@gmail.com \
--cc=ulf.hansson@linaro.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