All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: Biju Das <biju.das.jz@bp.renesas.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	linux-mmc@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Biju Das <biju.das@bp.renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: [PATCH] mmc: renesas_sdhi: Add margins for main clock and hs clock
Date: Tue, 13 Sep 2022 17:15:06 +0100	[thread overview]
Message-ID: <20220913161506.1817432-1-biju.das.jz@bp.renesas.com> (raw)

The SDHI high speed clock is 4 times that of the main clock. Currently,
there is no margin added for setting the rate associated with these
clocks. On RZ/G2L platforms, the lack of these margins leads to the
selection of a clock source with a lower clock rate compared to a higher
one.

RZ/G2L example case:
SD0 hs clock is 533333333 Hz and SD0 main clock is 133333333 Hz.
When we set the rate for the main clock 133333333, the request rate for
the parent becomes 533333332 (133333333 * 4) and the SD0 hs clock is
set as 400000000 Hz.

This patch adds a margin of (1/1024) higher hs clock and main clock rate.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
This patch is tested on RZ/G2{L,UL} platforms. It will be good to test
this patch on RCar Gen3/Gen4 platforms as I don't have the hardware.

Logs:-

Before the change:
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=4266666656
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=2133333328
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=1066666664
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=533333332
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=400000000
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=400000000

After the patch:
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=4270833320
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=2135416660
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=1067708330
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=533854165
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=533333333
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=533333333
 ####rzg2l_cpg_sd_clk_mux_set_parent####### index=0
 ####rzg2l_cpg_sd_clk_mux_determine_rate####### req->rate=533854164
---
 drivers/mmc/host/renesas_sdhi_core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c
index 6edbf5c161ab..e41fbfc6ab7d 100644
--- a/drivers/mmc/host/renesas_sdhi_core.c
+++ b/drivers/mmc/host/renesas_sdhi_core.c
@@ -147,6 +147,7 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
 	}
 
 	new_clock = wanted_clock << clkh_shift;
+	new_clock += new_clock >> 10;
 
 	/*
 	 * We want the bus clock to be as close as possible to, but no
@@ -172,6 +173,7 @@ static unsigned int renesas_sdhi_clk_update(struct tmio_mmc_host *host,
 
 	clk_set_rate(ref_clk, best_freq);
 
+	best_freq += best_freq >> 10;
 	if (priv->clkh)
 		clk_set_rate(priv->clk, best_freq >> clkh_shift);
 
-- 
2.25.1


             reply	other threads:[~2022-09-13 17:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-13 16:15 Biju Das [this message]
2022-09-13 17:12 ` [PATCH] mmc: renesas_sdhi: Add margins for main clock and hs clock Geert Uytterhoeven
2022-09-13 17:31   ` Biju Das
2022-09-14  5:44     ` Biju Das
2022-09-14 15:44       ` Geert Uytterhoeven
2022-09-16 11:47         ` Biju Das
2022-09-16 16:04           ` Biju Das
2022-09-16 18:14             ` Biju Das
2022-09-16 18:40               ` Wolfram Sang
2022-09-19  8:33                 ` Biju Das

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=20220913161506.1817432-1-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=Chris.Paterson2@renesas.com \
    --cc=biju.das@bp.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.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.