U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sumit Garg <sumit.garg@kernel.org>
To: Loic Poulain <loic.poulain@oss.qualcomm.com>
Cc: lukma@denx.de, casey.connolly@linaro.org,
	neil.armstrong@linaro.org, trini@konsulko.com, peng.fan@nxp.com,
	jh80.chung@samsung.com, u-boot-qcom@groups.io,
	u-boot@lists.denx.de
Subject: Re: [PATCH 1/3] mmc: msm_sdhci: Fix incorrect divider calculation for SDCLK
Date: Fri, 12 Dec 2025 09:59:56 +0900	[thread overview]
Message-ID: <aTtpDCVNZflD-rfi@sumit-X1> (raw)
In-Reply-To: <20251210155454.1561611-1-loic.poulain@oss.qualcomm.com>

On Wed, Dec 10, 2025 at 04:54:52PM +0100, Loic Poulain wrote:
> When 'max-clk' is not specified, the SDHCI core retrieves the base clock
> from the SDHCI_CAPABILITIES register (bits [15:8]). However, this field
> is unreliable on MSM SDHCI controllers, as noted by the Linux driver
> using the SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN flag. In addition, the field
> is only 8 bits wide and cannot represent base clocks above 255 MHz.
> 
> On platforms like Agatti/QCM2290, the firmware sets the SDHCI clock to
> 384 MHz, but the capabilities register reports 200 MHz. As a result,
> the core calculates a divider of 4, producing a 96 MHz SDCLK instead of
> the intended ~52 MHz. This overclocking can cause sporadic CRC errors
> with certain eMMC.
> 
> To fix this, use the actual clock rate reported by the SDHCI core clock
> instead of relying on the capabilities register for divider calculation.
> 
> Signed-off-by: Loic Poulain <loic.poulain@oss.qualcomm.com>
> ---
>  drivers/mmc/msm_sdhci.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Sumit Garg <sumit.garg@oss.qualcomm.com>

-Sumit

> 
> diff --git a/drivers/mmc/msm_sdhci.c b/drivers/mmc/msm_sdhci.c
> index ac77fb06bf7..ec003991928 100644
> --- a/drivers/mmc/msm_sdhci.c
> +++ b/drivers/mmc/msm_sdhci.c
> @@ -114,6 +114,9 @@ static int msm_sdc_clk_init(struct udevice *dev)
>  		return -EINVAL;
>  	}
>  
> +	/* This is the base clock sdhci core will use to configure the SDCLK */
> +	prv->host.max_clk = clk_rate;
> +
>  	writel_relaxed(CORE_VENDOR_SPEC_POR_VAL,
>  		       prv->host.ioaddr + var_info->core_vendor_spec);
>  
> -- 
> 2.34.1
> 

  parent reply	other threads:[~2025-12-12  1:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10 15:54 [PATCH 1/3] mmc: msm_sdhci: Fix incorrect divider calculation for SDCLK Loic Poulain
2025-12-10 15:54 ` [PATCH 2/3] clk/qcom: qcm2290: Add SDCC1 apps clock frequency table Loic Poulain
2025-12-12  1:00   ` Sumit Garg
2025-12-10 15:54 ` [PATCH 3/3] mmc: msm_sdhci: Add DLL control hook to disable DLL below 100 MHz Loic Poulain
2025-12-12  0:59 ` Sumit Garg [this message]
2026-01-16 18:03 ` [PATCH 1/3] mmc: msm_sdhci: Fix incorrect divider calculation for SDCLK Casey Connolly

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=aTtpDCVNZflD-rfi@sumit-X1 \
    --to=sumit.garg@kernel.org \
    --cc=casey.connolly@linaro.org \
    --cc=jh80.chung@samsung.com \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=lukma@denx.de \
    --cc=neil.armstrong@linaro.org \
    --cc=peng.fan@nxp.com \
    --cc=trini@konsulko.com \
    --cc=u-boot-qcom@groups.io \
    --cc=u-boot@lists.denx.de \
    /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