From: Adrian Hunter <adrian.hunter@intel.com>
To: <ziniu.wang_1@nxp.com>, <haibo.chen@nxp.com>,
<ulf.hansson@linaro.org>, <linux-mmc@vger.kernel.org>
Cc: <shawnguo@kernel.org>, <s.hauer@pengutronix.de>,
<kernel@pengutronix.de>, <festevam@gmail.com>,
<imx@lists.linux.dev>, <s32@nxp.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] mmc: sdhci-esdhc-imx: refactor clock loopback selection logic
Date: Wed, 28 May 2025 13:34:29 +0300 [thread overview]
Message-ID: <6be8a114-7775-415d-a48f-751466cce44d@intel.com> (raw)
In-Reply-To: <20250521025502.112030-1-ziniu.wang_1@nxp.com>
On 21/05/2025 05:55, ziniu.wang_1@nxp.com wrote:
> From: Luke Wang <ziniu.wang_1@nxp.com>
>
> i.MX reference manual specifies that internal clock loopback should be
> used for SDR104/HS200/HS400 modes. Move ESDHC_MIX_CTRL_FBCLK_SEL
> configuration into the timing selection function to:
>
> 1. Explicitly set internal loopback path for SDR104/HS200/HS400 modes
> 2. Avoid redundant bit manipulation across multiple functions
>
> Preserve ESDHC_MIX_CTRL_FBCLK_SEL during system resume for SDIO devices
> with MMC_PM_KEEP_POWER and MMC_PM_WAKE_SDIO_IRQ flag, as the controller
> might lose register state during suspend while skipping card
> re-initialization.
>
> Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
> drivers/mmc/host/sdhci-esdhc-imx.c | 27 ++++++++++++++-------------
> 1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 7611682f10c3..c448a53530a5 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -728,23 +728,17 @@ static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
> writel(new_val, host->ioaddr + ESDHC_VENDOR_SPEC);
> if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
> u32 v = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS);
> - u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL);
> - if (val & SDHCI_CTRL_TUNED_CLK) {
> + if (val & SDHCI_CTRL_TUNED_CLK)
> v |= ESDHC_MIX_CTRL_SMPCLK_SEL;
> - } else {
> + else
> v &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
> - m &= ~ESDHC_MIX_CTRL_FBCLK_SEL;
> - }
>
> - if (val & SDHCI_CTRL_EXEC_TUNING) {
> + if (val & SDHCI_CTRL_EXEC_TUNING)
> v |= ESDHC_MIX_CTRL_EXE_TUNE;
> - m |= ESDHC_MIX_CTRL_FBCLK_SEL;
> - } else {
> + else
> v &= ~ESDHC_MIX_CTRL_EXE_TUNE;
> - }
>
> writel(v, host->ioaddr + SDHCI_AUTO_CMD_STATUS);
> - writel(m, host->ioaddr + ESDHC_MIX_CTRL);
> }
> return;
> case SDHCI_TRANSFER_MODE:
> @@ -1082,7 +1076,6 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
> ctrl &= ~ESDHC_MIX_CTRL_AUTO_TUNE_EN;
> if (imx_data->socdata->flags & ESDHC_FLAG_MAN_TUNING) {
> ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL;
> - ctrl &= ~ESDHC_MIX_CTRL_FBCLK_SEL;
> writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL);
> writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
> } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) {
> @@ -1177,8 +1170,7 @@ static void esdhc_prepare_tuning(struct sdhci_host *host, u32 val)
> "warning! RESET_ALL never complete before sending tuning command\n");
>
> reg = readl(host->ioaddr + ESDHC_MIX_CTRL);
> - reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL |
> - ESDHC_MIX_CTRL_FBCLK_SEL;
> + reg |= ESDHC_MIX_CTRL_EXE_TUNE | ESDHC_MIX_CTRL_SMPCLK_SEL;
> writel(reg, host->ioaddr + ESDHC_MIX_CTRL);
> writel(FIELD_PREP(ESDHC_TUNE_CTRL_STATUS_DLY_CELL_SET_PRE_MASK, val),
> host->ioaddr + ESDHC_TUNE_CTRL_STATUS);
> @@ -1432,6 +1424,15 @@ static void esdhc_set_uhs_signaling(struct sdhci_host *host, unsigned timing)
> break;
> }
>
> + if (timing == MMC_TIMING_UHS_SDR104 ||
> + timing == MMC_TIMING_MMC_HS200 ||
> + timing == MMC_TIMING_MMC_HS400)
> + m |= ESDHC_MIX_CTRL_FBCLK_SEL;
> + else
> + m &= ~ESDHC_MIX_CTRL_FBCLK_SEL;
> +
> + writel(m, host->ioaddr + ESDHC_MIX_CTRL);
> +
> esdhc_change_pinstate(host, timing);
> }
>
next prev parent reply other threads:[~2025-05-28 10:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 2:55 [PATCH 1/2] mmc: sdhci-esdhc-imx: refactor clock loopback selection logic ziniu.wang_1
2025-05-21 2:55 ` [PATCH 2/2] mmc: sdhci-esdhc-imx: optimize clock loopback selection with dummy pad support ziniu.wang_1
2025-05-21 16:20 ` Frank Li
2025-05-28 10:34 ` Adrian Hunter
2025-06-09 14:24 ` Ulf Hansson
2025-05-21 16:09 ` [PATCH 1/2] mmc: sdhci-esdhc-imx: refactor clock loopback selection logic Frank Li
2025-05-22 3:52 ` Bough Chen
2025-05-22 3:59 ` Bough Chen
2025-05-28 10:34 ` Adrian Hunter [this message]
2025-06-09 14:24 ` Ulf Hansson
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=6be8a114-7775-415d-a48f-751466cce44d@intel.com \
--to=adrian.hunter@intel.com \
--cc=festevam@gmail.com \
--cc=haibo.chen@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=s32@nxp.com \
--cc=shawnguo@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=ziniu.wang_1@nxp.com \
/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