All of lore.kernel.org
 help / color / mirror / Atom feed
From: Claudiu <claudiu.beznea@tuxon.dev>
To: nobuhiro1.iwamatsu@toshiba.co.jp, pavel@denx.de
Cc: cip-dev@lists.cip-project.org, biju.das.jz@bp.renesas.com,
	prabhakar.mahadev-lad.rj@bp.renesas.com,
	claudiu.beznea@tuxon.dev
Subject: [PATCH 5.10.y-cip 01/53] clk: renesas: rzg2l: Wait for status bit of SD mux before continuing
Date: Fri, 19 Apr 2024 11:16:50 +0300	[thread overview]
Message-ID: <20240419081742.3496709-2-claudiu.beznea.uj@bp.renesas.com> (raw)
In-Reply-To: <20240419081742.3496709-1-claudiu.beznea.uj@bp.renesas.com>

From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>

commit 549f4ae2601f968e2474c6031fb4799468882f64 upstream.

The hardware user manual for RZ/G2L (r01uh0914ej0130-rzg2l-rzg2lc.pdf,
chapter 7.4.7 Procedure for Switching Clocks by the Dynamic Switching
Frequency Selectors) specifies that we need to check CPG_PL2SDHI_DSEL
for SD clock switching status.

Fixes: eaff33646f4cb ("clk: renesas: rzg2l: Add SDHI clk mux support")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/20230929053915.1530607-3-claudiu.beznea@bp.renesas.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
 drivers/clk/renesas/rzg2l-cpg.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/renesas/rzg2l-cpg.c b/drivers/clk/renesas/rzg2l-cpg.c
index 77513ceaaf2d..da81059d4bd8 100644
--- a/drivers/clk/renesas/rzg2l-cpg.c
+++ b/drivers/clk/renesas/rzg2l-cpg.c
@@ -192,7 +192,8 @@ static int rzg2l_cpg_sd_clk_mux_set_parent(struct clk_hw *hw, u8 index)
 	u32 off = GET_REG_OFFSET(hwdata->conf);
 	u32 shift = GET_SHIFT(hwdata->conf);
 	const u32 clk_src_266 = 2;
-	u32 bitmask;
+	u32 msk, val, bitmask;
+	int ret;
 
 	/*
 	 * As per the HW manual, we should not directly switch from 533 MHz to
@@ -206,14 +207,10 @@ static int rzg2l_cpg_sd_clk_mux_set_parent(struct clk_hw *hw, u8 index)
 	 * the index to value mapping is done by adding 1 to the index.
 	 */
 	bitmask = (GENMASK(GET_WIDTH(hwdata->conf) - 1, 0) << shift) << 16;
+	msk = off ? CPG_CLKSTATUS_SELSDHI1_STS : CPG_CLKSTATUS_SELSDHI0_STS;
 	if (index != clk_src_266) {
-		u32 msk, val;
-		int ret;
-
 		writel(bitmask | ((clk_src_266 + 1) << shift), priv->base + off);
 
-		msk = off ? CPG_CLKSTATUS_SELSDHI1_STS : CPG_CLKSTATUS_SELSDHI0_STS;
-
 		ret = readl_poll_timeout(priv->base + CPG_CLKSTATUS, val,
 					 !(val & msk), 100,
 					 CPG_SDHI_CLK_SWITCH_STATUS_TIMEOUT_US);
@@ -225,7 +222,13 @@ static int rzg2l_cpg_sd_clk_mux_set_parent(struct clk_hw *hw, u8 index)
 
 	writel(bitmask | ((index + 1) << shift), priv->base + off);
 
-	return 0;
+	ret = readl_poll_timeout(priv->base + CPG_CLKSTATUS, val,
+				 !(val & msk), 100,
+				 CPG_SDHI_CLK_SWITCH_STATUS_TIMEOUT_US);
+	if (ret)
+		dev_err(priv->dev, "failed to switch clk source\n");
+
+	return ret;
 }
 
 static u8 rzg2l_cpg_sd_clk_mux_get_parent(struct clk_hw *hw)
-- 
2.39.2



  reply	other threads:[~2024-04-19  8:17 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-19  8:16 [PATCH 5.10.y-cip 00/53] Add initial support for the Renesas RZ/G3S SoC Claudiu
2024-04-19  8:16 ` Claudiu [this message]
2024-04-19  8:16 ` [PATCH 5.10.y-cip 02/53] clk: renesas: rzg2l: Lock around writes to mux register Claudiu
2024-04-19  8:16 ` [PATCH 5.10.y-cip 03/53] clk: renesas: rzg2l: Trust value returned by hardware Claudiu
2024-04-21 14:15   ` Pavel Machek
2024-04-19  8:16 ` [PATCH 5.10.y-cip 04/53] clk: renesas: rzg2l: Use FIELD_GET() for PLL register fields Claudiu
2024-04-19  8:16 ` [PATCH 5.10.y-cip 05/53] clk: renesas: rzg2l: Fix computation formula Claudiu
2024-04-19  8:16 ` [PATCH 5.10.y-cip 06/53] clk: renesas: rzg2l-cpg: Reuse code in rzg2l_cpg_reset() Claudiu
2024-04-19  8:16 ` [PATCH 5.10.y-cip 07/53] clk: renesas: rzg2l: Check reset monitor registers Claudiu
2024-04-19  8:16 ` [PATCH 5.10.y-cip 08/53] dt-bindings: soc: renesas: Document Renesas RZ/G3S SoC variants Claudiu
2024-04-19  8:16 ` [PATCH 5.10.y-cip 09/53] dt-bindings: soc: renesas: renesas,rzg2l-sysc: Document RZ/G3S SoC Claudiu
2024-04-19  8:16 ` [PATCH 5.10.y-cip 10/53] clk: renesas: rzg2l: Don't assume all CPG_MOD clocks support PM Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 11/53] clk: renesas: rzg2l: Convert to readl_poll_timeout_atomic() Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 12/53] clk: renesas: rzg2l: Use u32 for flag and mux_flags Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 13/53] clk: renesas: rzg2l: Simplify .determine_rate() Claudiu
2024-04-21 14:17   ` Pavel Machek
2024-04-22  5:13     ` claudiu beznea
2024-04-19  8:17 ` [PATCH 5.10.y-cip 14/53] clk: renesas: rzg2l: Use core->name for clock name Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 15/53] clk: renesas: rzg2l: Simplify the logic in rzg2l_mod_clock_endisable() Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 16/53] clk: renesas: rzg2l: Remove critical area Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 17/53] clk: renesas: rzg2l: Add support for RZ/G3S PLL Claudiu
2024-04-21 14:18   ` Pavel Machek
2024-04-22  4:43     ` claudiu beznea
2024-04-19  8:17 ` [PATCH 5.10.y-cip 18/53] clk: renesas: rzg2l: Add struct clk_hw_data Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 19/53] clk: renesas: rzg2l: Remove CPG_SDHI_DSEL from generic header Claudiu
2024-04-21 14:20   ` Pavel Machek
2024-04-19  8:17 ` [PATCH 5.10.y-cip 20/53] clk: renesas: rzg2l: Refactor SD mux driver Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 21/53] clk: divider: Add re-usable determine_rate implementations Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 22/53] clk: renesas: rzg2l: Add divider clock for RZ/G3S Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 23/53] dt-bindings: clock: renesas,rzg2l-cpg: Document RZ/G3S SoC Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 24/53] clk: renesas: Add minimal boot support for " Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 25/53] clk: renesas: r9a08g045: Add clock and reset support for SDHI1 and SDHI2 Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 26/53] clk: renesas: r9a07g04[34]: Use SEL_SDHI1_STS status configuration for SD1 mux Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 27/53] soc: renesas: Use "#ifdef" for single-symbol definition checks Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 28/53] soc: renesas: Identify RZ/G3S SoC Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 29/53] pinctrl: renesas: rzg2l: Make struct rzg2l_pinctrl_data::dedicated_pins constant Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 30/53] pinctrl: renesas: rzg2l: Make reverse order of enable() for disable() Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 31/53] pinctrl: renesas: rzg2l: Rename rzg2l_gpio_configs[] Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 32/53] pinctrl: renesas: rzg2l: Add validation of GPIO pin in rzg2l_gpio_request() Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 33/53] pinctrl: renesas: rzg2l: Index all registers based on port offset Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 34/53] pinctrl: renesas: rzg2l: Adapt for different SD/PWPR register offsets Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 35/53] pinctrl: renesas: rzg2l: Adapt function number for RZ/G3S Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 36/53] pinctrl: renesas: rzg2l: Move DS and OI to SoC-specific configuration Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 37/53] pinctrl: renesas: rzg2l: Add support for different DS values on different groups Claudiu
2024-04-21 14:24   ` Pavel Machek
2024-04-22  5:09     ` claudiu beznea
2024-04-19  8:17 ` [PATCH 5.10.y-cip 38/53] dt-bindings: pinctrl: renesas: Document RZ/G3S SoC Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 39/53] pinctrl: renesas: rzg2l: Add RZ/G3S support Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 40/53] dt-bindings: mmc: renesas,sdhi: Document " Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 41/53] dt-bindings: serial: renesas,scif: document r9a08g045 support Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 42/53] dt-bindings: soc: renesas: Document RZ/G3S SMARC SoM Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 43/53] dt-bindings: soc: renesas: Document SMARC Carrier-II EVK Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 44/53] arm64: dts: renesas: Add initial DTSI for RZ/G3S SoC Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 45/53] arm64: dts: renesas: Add initial support for RZ/G3S SMARC SoM Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 46/53] arm64: dts: renesas: Add initial device tree for RZ SMARC Carrier-II Board Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 47/53] arm64: dts: renesas: Add initial device tree for RZ/G3S SMARC EVK board Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 48/53] arm64: dts: renesas: r9a08g045: Add nodes for SDHI1 and SDHI2 Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 49/53] arm64: dts: renesas: r9a08g045: Add missing cache-level for L3 cache Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 50/53] arm64: dts: renesas: rzg3s-smarc-som: Spelling s/device-type/device_type/ Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 51/53] arm64: dts: renesas: rzg3s-smarc-som: Enable SDHI2 Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 52/53] arm64: dts: renesas: rzg3s-smarc: Enable SDHI1 Claudiu
2024-04-19  8:17 ` [PATCH 5.10.y-cip 53/53] arm64: defconfig: Enable RZ/G3S (R9A08G045) SoC Claudiu
2024-04-19 10:07 ` [PATCH 5.10.y-cip 00/53] Add initial support for the Renesas RZ/G3S SoC Pavel Machek
2024-04-19 11:28   ` claudiu beznea
2024-04-21 14:14 ` Pavel Machek
2024-04-22 20:38 ` Pavel Machek

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=20240419081742.3496709-2-claudiu.beznea.uj@bp.renesas.com \
    --to=claudiu.beznea@tuxon.dev \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=pavel@denx.de \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.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.