public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiayu Du <jiayu.riscv@isrc.iscas.ac.cn>
To: Xukai Wang <kingxukai@zohomail.com>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Paul Walmsley <paul.walmsley@sifive.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Conor Dooley <conor@kernel.org>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
	Samuel Holland <samuel.holland@sifive.com>,
	Troy Mitchell <TroyMitchell988@gmail.com>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Subject: Re: [PATCH v9 0/3] riscv: canaan: Add support for K230 clock
Date: Fri, 19 Dec 2025 14:57:33 +0800	[thread overview]
Message-ID: <aUT3XYQmn51tLItg@duge-virtual-machine> (raw)
In-Reply-To: <20251127-b4-k230-clk-v9-0-3aa09e17faf5@zohomail.com>

I'm writing to share test results and the corresponding patch for 
K230 clock configuration issues, covering critical clock flag 
settings and HS/SD subsystem clock adjustments.

1.  Critical Clock Protection for CPU Subsystems
I found that cpu0/cpu1 core-related clocks (src/plic/apb/noc_ddrcp4 
etc.) had no protection, risking accidental disabling and subsystem 
malfunctions. I added the `CLK_IS_CRITICAL` flag to these clock 
nodes to block unintended disable operations.

2.  HS/SD Clock Setting Fixes
Two hardware-spec mismatches were fixed:
- Adjusted `hs_hclk_src_gate` from register bit1 to bit0, and 
  updated its parent clock from `hs_hclk_high_src_rate` to 
  `hs_hclk_high_gate`.
- Corrected `hs_sd_card_src_rate` parent clock from `pll0_div4` to 
  `hs_sd_card_src_gate`, fixing SD controller clock source 
  misconfiguration.

3.  Test Verification
Post-fix on-board testing confirmed all modified clock nodes align 
with K230 hardware specs and the clock tree relationships are 
correct.
The CPU core and HS/SD subsystems run stably without any clock-
related errors or anomalies.

The patch modifies `drivers/clk/clk-k230.c` (19 insertions, 19 
deletions), with the full diff attached below for your review.

Best regards,
Jiayu Du

---
 drivers/clk/clk-k230.c | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/clk/clk-k230.c b/drivers/clk/clk-k230.c
index 8750e9cbac..43a4e61a0c 100644
--- a/drivers/clk/clk-k230.c
+++ b/drivers/clk/clk-k230.c
@@ -317,7 +317,7 @@ struct clk_fixed_factor *k230_pll_divs[] = {
 
 K230_CLK_GATE_FORMAT(cpu0_src_gate,
 		     K230_CPU0_SRC_GATE,
-		     0, 0, 0, 0,
+		     0, 0, CLK_IS_CRITICAL, 0,
 		     &pll0_div2.hw);
 
 K230_CLK_RATE_FORMAT(cpu0_src_rate,
@@ -325,7 +325,7 @@ K230_CLK_RATE_FORMAT(cpu0_src_rate,
 		     1, 16, 1, 0xF,
 		     16, 16, 0, 0x0,
 		     0x0, 31, mul, 0x0,
-		     false, 0,
+		     false, CLK_IS_CRITICAL,
 		     &cpu0_src_gate.clk.hw);
 
 K230_CLK_RATE_FORMAT(cpu0_axi_rate,
@@ -333,12 +333,12 @@ K230_CLK_RATE_FORMAT(cpu0_axi_rate,
 		     1, 1, 0, 0,
 		     1, 8, 6, 0x7,
 		     0x0, 31, div, 0x0,
-		     0, 0,
+		     0, CLK_IS_CRITICAL,
 		     &cpu0_src_rate.clk.hw);
 
 K230_CLK_GATE_FORMAT(cpu0_plic_gate,
 		     K230_CPU0_PLIC_GATE,
-		     0x0, 9, 0, 0,
+		     0x0, 9, CLK_IS_CRITICAL, 0,
 		     &cpu0_src_rate.clk.hw);
 
 K230_CLK_RATE_FORMAT(cpu0_plic_rate,
@@ -346,17 +346,17 @@ K230_CLK_RATE_FORMAT(cpu0_plic_rate,
 		     1, 1, 0, 0,
 		     1, 8, 10, 0x7,
 		     0x0, 31, div, 0x0,
-		     false, 0,
+		     false, CLK_IS_CRITICAL,
 		     &cpu0_plic_gate.clk.hw);
 
 K230_CLK_GATE_FORMAT(cpu0_noc_ddrcp4_gate,
 		     K230_CPU0_NOC_DDRCP4_GATE,
-		     0x60, 7, 0, 0,
+		     0x60, 7, CLK_IS_CRITICAL, 0,
 		     &cpu0_src_rate.clk.hw);
 
 K230_CLK_GATE_FORMAT(cpu0_apb_gate,
 		     K230_CPU0_APB_GATE,
-		     0x0, 13, 0, 0,
+		     0x0, 13, CLK_IS_CRITICAL, 0,
 		     &pll0_div4.hw);
 
 K230_CLK_RATE_FORMAT(cpu0_apb_rate,
@@ -364,7 +364,7 @@ K230_CLK_RATE_FORMAT(cpu0_apb_rate,
 		     1, 1, 0, 0,
 		     1, 8, 15, 0x7,
 		     0x0, 31, div, 0x0,
-		     false, 0,
+		     false, CLK_IS_CRITICAL,
 		     &cpu0_apb_gate.clk.hw);
 
 static const struct clk_parent_data k230_cpu1_src_mux_pdata[] = {
@@ -376,12 +376,12 @@ static const struct clk_parent_data k230_cpu1_src_mux_pdata[] = {
 K230_CLK_MUX_FORMAT(cpu1_src_mux,
 		    K230_CPU1_SRC_MUX,
 		    0x4, 1, 0x3,
-		    0, 0,
+		    CLK_IS_CRITICAL, 0,
 		    k230_cpu1_src_mux_pdata);
 
 K230_CLK_GATE_FORMAT(cpu1_src_gate,
 		     K230_CPU1_SRC_GATE,
-		     0x4, 0, CLK_IGNORE_UNUSED, 0,
+		     0x4, 0, CLK_IS_CRITICAL, 0,
 		     &cpu1_src_mux.clk.hw);
 
 K230_CLK_RATE_FORMAT(cpu1_src_rate,
@@ -389,7 +389,7 @@ K230_CLK_RATE_FORMAT(cpu1_src_rate,
 		     1, 1, 0, 0,
 		     1, 8, 3, 0x7,
 		     0x4, 31, div, 0x0,
-		     false, 0,
+		     false, CLK_IS_CRITICAL,
 		     &cpu1_src_gate.clk.hw);
 
 K230_CLK_RATE_FORMAT(cpu1_axi_rate,
@@ -397,12 +397,12 @@ K230_CLK_RATE_FORMAT(cpu1_axi_rate,
 		     1, 1, 0, 0,
 		     1, 8, 12, 0x7,
 		     0x4, 31, div, 0x0,
-		     false, 0,
+		     false, CLK_IS_CRITICAL,
 		     &cpu1_src_rate.clk.hw);
 
 K230_CLK_GATE_FORMAT(cpu1_plic_gate,
 		     K230_CPU1_PLIC_GATE,
-		     0x4, 15, CLK_IGNORE_UNUSED, 0,
+		     0x4, 15, CLK_IS_CRITICAL, 0,
 		     &cpu1_src_rate.clk.hw);
 
 K230_CLK_RATE_FORMAT(cpu1_plic_rate,
@@ -410,12 +410,12 @@ K230_CLK_RATE_FORMAT(cpu1_plic_rate,
 		     1, 1, 0, 0,
 		     1, 8, 16, 0x7,
 		     0x4, 31, div, 0x0,
-		     false, 0,
+		     false, CLK_IS_CRITICAL,
 		     &cpu1_plic_gate.clk.hw);
 
 K230_CLK_GATE_FORMAT(cpu1_apb_gate,
 		     K230_CPU1_APB_GATE,
-		     0x4, 19, 0, 0,
+		     0x4, 19, CLK_IS_CRITICAL, 0,
 		     &pll0_div4.hw);
 
 K230_CLK_RATE_FORMAT(cpu1_apb_rate,
@@ -423,7 +423,7 @@ K230_CLK_RATE_FORMAT(cpu1_apb_rate,
 		     1, 1, 0, 0,
 		     1, 8, 15, 0x7,
 		     0x0, 31, div, 0x0,
-		     false, 0,
+		     false, CLK_IS_CRITICAL,
 		     &cpu1_apb_gate.clk.hw);
 
 K230_CLK_GATE_FORMAT_PNAME(pmu_apb_gate,
@@ -446,8 +446,8 @@ K230_CLK_GATE_FORMAT(hs_hclk_high_gate,
 
 K230_CLK_GATE_FORMAT(hs_hclk_src_gate,
 		     K230_HS_HCLK_SRC_GATE,
-		     0x18, 1, 0, 0,
-		     &hs_hclk_high_src_rate.clk.hw);
+		     0x18, 0, 0, 0,
+		     &hs_hclk_high_gate.clk.hw);
 
 K230_CLK_RATE_FORMAT(hs_hclk_src_rate,
 		     K230_HS_HCLK_SRC_RATE,
@@ -560,7 +560,7 @@ K230_CLK_RATE_FORMAT(hs_sd_card_src_rate,
 		     2, 8, 12, 0x7,
 		     0x1C, 31, div, 0x0,
 		     false, 0,
-		     &pll0_div4.hw);
+		     &hs_sd_card_src_gate.clk.hw);
 
 K230_CLK_GATE_FORMAT(hs_sd0_card_gate,
 		     K230_HS_SD0_CARD_GATE,


      parent reply	other threads:[~2025-12-19  6:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 12:45 [PATCH v9 0/3] riscv: canaan: Add support for K230 clock Xukai Wang
2025-11-27 12:45 ` [PATCH v9 1/3] dt-bindings: clock: Add bindings for Canaan K230 clock controller Xukai Wang
2025-11-27 12:45 ` [PATCH v9 2/3] clk: canaan: Add clock driver for Canaan K230 Xukai Wang
2025-12-19  8:02   ` Jiayu Du
2025-12-21 15:08     ` Xukai Wang
2025-12-22  4:00     ` Xukai Wang
2025-11-27 12:45 ` [PATCH v9 3/3] riscv: dts: canaan: Add clock definition for K230 Xukai Wang
2025-11-27 17:28 ` [PATCH v9 0/3] riscv: canaan: Add support for K230 clock Conor Dooley
2025-12-19  6:57 ` Jiayu Du [this message]

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=aUT3XYQmn51tLItg@duge-virtual-machine \
    --to=jiayu.riscv@isrc.iscas.ac.cn \
    --cc=TroyMitchell988@gmail.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=conor+dt@kernel.org \
    --cc=conor@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kingxukai@zohomail.com \
    --cc=krzk+dt@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=mturquette@baylibre.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh@kernel.org \
    --cc=samuel.holland@sifive.com \
    --cc=sboyd@kernel.org \
    /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