All of lore.kernel.org
 help / color / mirror / Atom feed
From: haibo.chen@nxp.com
To: peng.fan@nxp.com, jh80.chung@samsung.com, festevam@gmail.com,
	sean.anderson@seco.com, u-boot@lists.denx.de, marex@denx.de,
	aford173@gmail.com, tharvey@gateworks.com,
	andrey.zhizhikin@leica-geosystems.com
Cc: uboot-imx@nxp.com, haibo.chen@nxp.com
Subject: [PATCH 3/3] mmc: fsl_esdhc_imx: correct the actual card clock
Date: Fri, 11 Feb 2022 19:16:57 +0800	[thread overview]
Message-ID: <1644578217-8947-3-git-send-email-haibo.chen@nxp.com> (raw)
In-Reply-To: <1644578217-8947-1-git-send-email-haibo.chen@nxp.com>

From: Haibo Chen <haibo.chen@nxp.com>

The original code logic can not show the correct card clock, and also
has one risk when the div is 0. Because there is div -=1 before.

So move the operation before div -=1, and also involve ddr_pre_div
to get the correct value.

Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
---
 drivers/mmc/fsl_esdhc_imx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/fsl_esdhc_imx.c b/drivers/mmc/fsl_esdhc_imx.c
index 0be7cae1e5..0ea7b0b50c 100644
--- a/drivers/mmc/fsl_esdhc_imx.c
+++ b/drivers/mmc/fsl_esdhc_imx.c
@@ -609,6 +609,8 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	while (sdhc_clk / (div * pre_div * ddr_pre_div) > clock && div < 16)
 		div++;
 
+	mmc->clock = sdhc_clk / pre_div / div / ddr_pre_div;
+
 	pre_div >>= 1;
 	div -= 1;
 
@@ -630,7 +632,6 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	else
 		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
 
-	mmc->clock = sdhc_clk / pre_div / div;
 	priv->clock = clock;
 }
 
-- 
2.17.1


  parent reply	other threads:[~2022-02-11 11:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 11:16 [PATCH 1/3] mmc: fsl_esdhc_imx: use VENDORSPEC_FRC_SDCLK_ON when necessary haibo.chen
2022-02-11 11:16 ` [PATCH 2/3] mmc: fsl_esdhc_imx: remove redundant ARCH_MXC haibo.chen
2022-02-13 21:53   ` Marek Vasut
2022-02-19 13:07   ` sbabic
2022-02-11 11:16 ` haibo.chen [this message]
2022-02-13 21:54   ` [PATCH 3/3] mmc: fsl_esdhc_imx: correct the actual card clock Marek Vasut
2022-02-19 13:08   ` sbabic
2022-07-23  2:23   ` Tim Harvey
2022-07-27 12:44     ` Bough Chen
2022-02-13 21:52 ` [PATCH 1/3] mmc: fsl_esdhc_imx: use VENDORSPEC_FRC_SDCLK_ON when necessary Marek Vasut
2022-02-14  2:58   ` Bough Chen
2022-02-17  0:15     ` Fabio Estevam

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=1644578217-8947-3-git-send-email-haibo.chen@nxp.com \
    --to=haibo.chen@nxp.com \
    --cc=aford173@gmail.com \
    --cc=andrey.zhizhikin@leica-geosystems.com \
    --cc=festevam@gmail.com \
    --cc=jh80.chung@samsung.com \
    --cc=marex@denx.de \
    --cc=peng.fan@nxp.com \
    --cc=sean.anderson@seco.com \
    --cc=tharvey@gateworks.com \
    --cc=u-boot@lists.denx.de \
    --cc=uboot-imx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.