Devicetree
 help / color / mirror / Atom feed
* [PATCH v4 1/3] dt-bindings: soc: rockchip: Add RK3506 GRF compatibles
       [not found] <cover.1795394137.git.1194781887@qq.com>
@ 2026-11-23  0:38 ` Xiangyu Zhu
  2026-11-23  0:38 ` [PATCH v4 2/3] dt-bindings: clock: rockchip,rk3506-cru: Add SAI MCLK output gate IDs Xiangyu Zhu
  2026-11-23  0:38 ` [PATCH v4 3/3] clk: rockchip: rk3506: Register the SAI MCLK output gates Xiangyu Zhu
  2 siblings, 0 replies; 4+ messages in thread
From: Xiangyu Zhu @ 2026-11-23  0:38 UTC (permalink / raw)
  To: Heiko Stuebner, Stephen Boyd
  Cc: Xiangyu Zhu, Michael Turquette, Krzysztof Kozlowski, Conor Dooley,
	linux-clk, linux-rockchip, linux-arm-kernel, devicetree,
	linux-kernel

Document the RK3506 system, IOC and PMU GRF compatibles.

The PMU GRF is named rockchip,rk3506-pmu-grf to follow the
rockchip,<soc>-pmu-grf convention used by other Rockchip SoCs instead of
the vendor's rockchip,rk3506-grf-pmu ordering.  It also has a
syscon-reboot-mode child, so allow the reboot-mode node for it.

Signed-off-by: Xiangyu Zhu <1194781887@qq.com>
---
 Documentation/devicetree/bindings/soc/rockchip/grf.yaml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/soc/rockchip/grf.yaml b/Documentation/devicetree/bindings/soc/rockchip/grf.yaml
index e94c83d7..1fb1bf87 100644
--- a/Documentation/devicetree/bindings/soc/rockchip/grf.yaml
+++ b/Documentation/devicetree/bindings/soc/rockchip/grf.yaml
@@ -15,6 +15,7 @@ properties:
       - items:
           - enum:
               - rockchip,rk3288-sgrf
+              - rockchip,rk3506-ioc-grf
               - rockchip,rk3528-ioc-grf
               - rockchip,rk3528-pipe-phy-grf
               - rockchip,rk3528-vo-grf
@@ -93,6 +94,8 @@ properties:
               - rockchip,rk3368-pmugrf
               - rockchip,rk3399-grf
               - rockchip,rk3399-pmugrf
+              - rockchip,rk3506-grf
+              - rockchip,rk3506-pmu-grf
               - rockchip,rk3562-pmu-grf
               - rockchip,rk3568-grf
               - rockchip,rk3568-pmugrf
@@ -234,6 +237,7 @@ allOf:
               - rockchip,rk3036-grf
               - rockchip,rk3308-grf
               - rockchip,rk3368-pmugrf
+              - rockchip,rk3506-pmu-grf
               - rockchip,rv1103b-pmu-grf
 
     then:
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v4 2/3] dt-bindings: clock: rockchip,rk3506-cru: Add SAI MCLK output gate IDs
       [not found] <cover.1795394137.git.1194781887@qq.com>
  2026-11-23  0:38 ` [PATCH v4 1/3] dt-bindings: soc: rockchip: Add RK3506 GRF compatibles Xiangyu Zhu
@ 2026-11-23  0:38 ` Xiangyu Zhu
  2026-11-23  0:38 ` [PATCH v4 3/3] clk: rockchip: rk3506: Register the SAI MCLK output gates Xiangyu Zhu
  2 siblings, 0 replies; 4+ messages in thread
From: Xiangyu Zhu @ 2026-11-23  0:38 UTC (permalink / raw)
  To: Heiko Stuebner, Stephen Boyd
  Cc: Xiangyu Zhu, Michael Turquette, Krzysztof Kozlowski, Conor Dooley,
	linux-clk, linux-rockchip, linux-arm-kernel, devicetree,
	linux-kernel

Add clock IDs for the four SAI MCLK output-to-IO gates of the RK3506.
SAI0 and SAI1 are controlled by bits in the PMU GRF, SAI2 and SAI3 by
bits in the system GRF.

Signed-off-by: Xiangyu Zhu <1194781887@qq.com>
---
 include/dt-bindings/clock/rockchip,rk3506-cru.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/dt-bindings/clock/rockchip,rk3506-cru.h b/include/dt-bindings/clock/rockchip,rk3506-cru.h
index 71d7dda2..708502db 100644
--- a/include/dt-bindings/clock/rockchip,rk3506-cru.h
+++ b/include/dt-bindings/clock/rockchip,rk3506-cru.h
@@ -281,5 +281,9 @@
 #define CLK_V0PLL_REF			268
 #define CLK_V1PLL_REF			269
 #define CLK_32K_FRAC_MUX		270
+#define MCLK_OUT_SAI0_TO_IO		271
+#define MCLK_OUT_SAI1_TO_IO		272
+#define MCLK_OUT_SAI2_TO_IO		273
+#define MCLK_OUT_SAI3_TO_IO		274
 
 #endif
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v4 3/3] clk: rockchip: rk3506: Register the SAI MCLK output gates
       [not found] <cover.1795394137.git.1194781887@qq.com>
  2026-11-23  0:38 ` [PATCH v4 1/3] dt-bindings: soc: rockchip: Add RK3506 GRF compatibles Xiangyu Zhu
  2026-11-23  0:38 ` [PATCH v4 2/3] dt-bindings: clock: rockchip,rk3506-cru: Add SAI MCLK output gate IDs Xiangyu Zhu
@ 2026-11-23  0:38 ` Xiangyu Zhu
  2026-11-23  0:49   ` sashiko-bot
  2 siblings, 1 reply; 4+ messages in thread
From: Xiangyu Zhu @ 2026-11-23  0:38 UTC (permalink / raw)
  To: Heiko Stuebner, Stephen Boyd
  Cc: Xiangyu Zhu, Michael Turquette, Krzysztof Kozlowski, Conor Dooley,
	linux-clk, linux-rockchip, linux-arm-kernel, devicetree,
	linux-kernel

The RK3506 has four SAI MCLK output gates in the PMU and system GRFs.
Register them with the existing GRF gate support so the SAI MCLK pin
direction can be controlled through the clock framework, the same way
RK3576 and RK3588 handle their SAI/I2S MCLK output gates.

The SAI2/SAI3 gates sit in the system GRF, which the CRU already has via
its "rockchip,grf" phandle.  The SAI0/SAI1 gates live in the PMU GRF, so
they are kept in a separate branch table that is only registered once
that syscon has been added as an auxiliary GRF.  Registering them
unconditionally would make them fall back to the system GRF and toggle an
unrelated bit there.

The PMU GRF lookup stays non-fatal: it only carries the SAI0/SAI1 gates,
so a missing syscon must not keep the whole CRU from being registered.

Tested on a RK3506B board: the SAI0 MCLK output runs at 12.288 MHz and
drives the ES8388 codec, audio playback works, and the GRF gate bits
were read back from the registers to confirm that they get set.

The PMU GRF is matched by its documented "rockchip,rk3506-pmu-grf" compatible.

Signed-off-by: Xiangyu Zhu <1194781887@qq.com>
---
 drivers/clk/rockchip/clk-rk3506.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/clk/rockchip/clk-rk3506.c b/drivers/clk/rockchip/clk-rk3506.c
index dd59bd60..956d5e92 100644
--- a/drivers/clk/rockchip/clk-rk3506.c
+++ b/drivers/clk/rockchip/clk-rk3506.c
@@ -5,6 +5,7 @@
  */
 
 #include <linux/clk-provider.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -608,6 +609,8 @@ static struct rockchip_clk_branch rk3506_clk_branches[] __initdata = {
 			RK3506_CLKGATE_CON(18), 3, GFLAGS),
 	GATE(MCLK_OUT_SAI2, "mclk_out_sai2", "mclk_sai2", 0,
 			RK3506_CLKGATE_CON(18), 4, GFLAGS),
+	GATE_GRF(MCLK_OUT_SAI2_TO_IO, "mclk_sai2_to_io", "mclk_out_sai2",
+		 0, 0x4, 2, CLK_GATE_HIWORD_MASK, grf_type_sys),
 	COMPOSITE(MCLK_SAI3_SRC, "mclk_sai3_src", mclk_sai_asrc_parents_p, 0,
 			RK3506_CLKSEL_CON(52), 8, 4, MFLAGS, 0, 8, DFLAGS,
 			RK3506_CLKGATE_CON(18), 5, GFLAGS),
@@ -617,6 +620,8 @@ static struct rockchip_clk_branch rk3506_clk_branches[] __initdata = {
 			RK3506_CLKGATE_CON(18), 7, GFLAGS),
 	GATE(MCLK_OUT_SAI3, "mclk_out_sai3", "mclk_sai3_src", 0,
 			RK3506_CLKGATE_CON(18), 8, GFLAGS),
+	GATE_GRF(MCLK_OUT_SAI3_TO_IO, "mclk_sai3_to_io", "mclk_out_sai3",
+		 0, 0x4, 3, CLK_GATE_HIWORD_MASK, grf_type_sys),
 	COMPOSITE(MCLK_SAI4_SRC, "mclk_sai4_src", mclk_sai_asrc_parents_p, 0,
 			RK3506_CLKSEL_CON(53), 8, 4, MFLAGS, 0, 8, DFLAGS,
 			RK3506_CLKGATE_CON(18), 9, GFLAGS),
@@ -782,11 +787,20 @@ static struct rockchip_clk_branch rk3506_clk_branches[] __initdata = {
 			RK3506_CLKGATE_CON(20), 0, GFLAGS),
 };
 
+static struct rockchip_clk_branch rk3506_clk_pmu_grf_branches[] __initdata = {
+	GATE_GRF(MCLK_OUT_SAI0_TO_IO, "mclk_sai0_to_io", "mclk_out_sai0",
+		 0, 0x4, 8, CLK_GATE_HIWORD_MASK, grf_type_pmu0),
+	GATE_GRF(MCLK_OUT_SAI1_TO_IO, "mclk_sai1_to_io", "mclk_out_sai1",
+		 0, 0x4, 9, CLK_GATE_HIWORD_MASK, grf_type_pmu0),
+};
+
 static void __init rk3506_clk_init(struct device_node *np)
 {
 	struct rockchip_clk_provider *ctx;
 	unsigned long clk_nr_clks;
 	void __iomem *reg_base;
+	struct regmap *pmu_grf;
+	bool have_pmu_grf = false;
 
 	clk_nr_clks = rockchip_clk_find_max_clk_id(rk3506_clk_branches,
 						   ARRAY_SIZE(rk3506_clk_branches)) + 1;
@@ -804,6 +818,15 @@ static void __init rk3506_clk_init(struct device_node *np)
 		return;
 	}
 
+	pmu_grf = syscon_regmap_lookup_by_compatible("rockchip,rk3506-pmu-grf");
+	if (IS_ERR(pmu_grf)) {
+		pr_warn("%s: could not get PMU GRF syscon\n", __func__);
+	} else if (rockchip_clk_add_grf(ctx, pmu_grf, grf_type_pmu0)) {
+		pr_warn("%s: could not add PMU GRF\n", __func__);
+	} else {
+		have_pmu_grf = true;
+	}
+
 	rockchip_clk_register_plls(ctx, rk3506_pll_clks,
 				   ARRAY_SIZE(rk3506_pll_clks),
 				   0);
@@ -815,6 +838,10 @@ static void __init rk3506_clk_init(struct device_node *np)
 	rockchip_clk_register_branches(ctx, rk3506_clk_branches,
 				       ARRAY_SIZE(rk3506_clk_branches));
 
+	if (have_pmu_grf)
+		rockchip_clk_register_branches(ctx, rk3506_clk_pmu_grf_branches,
+					       ARRAY_SIZE(rk3506_clk_pmu_grf_branches));
+
 	rk3506_rst_init(np, reg_base);
 
 	rockchip_register_restart_notifier(ctx, RK3506_GLB_SRST_FST, NULL);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v4 3/3] clk: rockchip: rk3506: Register the SAI MCLK output gates
  2026-11-23  0:38 ` [PATCH v4 3/3] clk: rockchip: rk3506: Register the SAI MCLK output gates Xiangyu Zhu
@ 2026-11-23  0:49   ` sashiko-bot
  0 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-23  0:49 UTC (permalink / raw)
  To: Xiangyu Zhu; +Cc: linux-clk, devicetree, robh, conor+dt

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] clk: rockchip: rk3506: missing system GRF lookup in
  rk3506_clk_init()
--

commit a7ec6ea6b886d5202ab753e0b478970ccba36fb0
Author: Xiangyu Zhu <1194781887@qq.com>

clk: rockchip: rk3506: Register the SAI MCLK output gates

This commit registers the four RK3506 SAI MCLK output gates in the system
and PMU GRFs, looking up the PMU GRF syscon by compatible and registering
the SAI0 and SAI1 gates when it is present.

> diff --git a/drivers/clk/rockchip/clk-rk3506.c b/drivers/clk/rockchip/clk-rk3506.c
> index dd59bd60382ef..956d5e9238b9c 100644
> --- a/drivers/clk/rockchip/clk-rk3506.c
> +++ b/drivers/clk/rockchip/clk-rk3506.c
[ ... ]
> @@ -608,6 +609,8 @@ static struct rockchip_clk_branch rk3506_clk_branches[] __initdata = {
>  			RK3506_CLKGATE_CON(18), 3, GFLAGS),
>  	GATE(MCLK_OUT_SAI2, "mclk_out_sai2", "mclk_sai2", 0,
>  			RK3506_CLKGATE_CON(18), 4, GFLAGS),
> +	GATE_GRF(MCLK_OUT_SAI2_TO_IO, "mclk_sai2_to_io", "mclk_out_sai2",
> +		 0, 0x4, 2, CLK_GATE_HIWORD_MASK, grf_type_sys),
>  	COMPOSITE(MCLK_SAI3_SRC, "mclk_sai3_src", mclk_sai_asrc_parents_p, 0,
>  			RK3506_CLKSEL_CON(52), 8, 4, MFLAGS, 0, 8, DFLAGS,
>  			RK3506_CLKGATE_CON(18), 5, GFLAGS),
> @@ -617,6 +620,8 @@ static struct rockchip_clk_branch rk3506_clk_branches[] __initdata = {
>  			RK3506_CLKGATE_CON(18), 7, GFLAGS),
>  	GATE(MCLK_OUT_SAI3, "mclk_out_sai3", "mclk_sai3_src", 0,
>  			RK3506_CLKGATE_CON(18), 8, GFLAGS),
> +	GATE_GRF(MCLK_OUT_SAI3_TO_IO, "mclk_sai3_to_io", "mclk_out_sai3",
> +		 0, 0x4, 3, CLK_GATE_HIWORD_MASK, grf_type_sys),
>  	COMPOSITE(MCLK_SAI4_SRC, "mclk_sai4_src", mclk_sai_asrc_parents_p, 0,
>  			RK3506_CLKSEL_CON(53), 8, 4, MFLAGS, 0, 8, DFLAGS,
>  			RK3506_CLKGATE_CON(18), 9, GFLAGS),
[ ... ]
> @@ -804,6 +818,15 @@ static void __init rk3506_clk_init(struct device_node *np)
>  		return;
>  	}
>  
> +	pmu_grf = syscon_regmap_lookup_by_compatible("rockchip,rk3506-pmu-grf");
> +	if (IS_ERR(pmu_grf)) {
> +		pr_warn("%s: could not get PMU GRF syscon\n", __func__);
> +	} else if (rockchip_clk_add_grf(ctx, pmu_grf, grf_type_pmu0)) {
> +		pr_warn("%s: could not add PMU GRF\n", __func__);
> +	} else {
> +		have_pmu_grf = true;
> +	}
> +

[Severity: Medium]
Does registering MCLK_OUT_SAI2_TO_IO and MCLK_OUT_SAI3_TO_IO fail with
-EOPNOTSUPP on a binding-compliant device tree?

The commit message notes that the CRU already has the system GRF via its
"rockchip,grf" phandle, which rockchip_clk_init_base() uses to populate
ctx->grf.  However,
Documentation/devicetree/bindings/clock/rockchip,rk3506-cru.yaml does not
define "rockchip,grf" and sets "additionalProperties: false", so ctx->grf
is ERR_PTR(-ENODEV).  Because rk3506_clk_init() does not look up
"rockchip,rk3506-grf" or register grf_type_sys via rockchip_clk_add_grf(),
rockchip_clk_register_branches() falls back to ctx->grf and
rockchip_clk_register_gate_grf() fails for both SAI2 and SAI3 gates.

Should rk3506_clk_init() also look up "rockchip,rk3506-grf" by compatible
and register grf_type_sys (and if the SAI2/SAI3 gates are moved to a
separate conditional branch table, include that table when computing
clk_nr_clks since MCLK_OUT_SAI3_TO_IO has the highest clock ID)?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_452BA245FE6A7C7308A5121F5281E9E6A807@qq.com?part=3

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-23  0:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1795394137.git.1194781887@qq.com>
2026-11-23  0:38 ` [PATCH v4 1/3] dt-bindings: soc: rockchip: Add RK3506 GRF compatibles Xiangyu Zhu
2026-11-23  0:38 ` [PATCH v4 2/3] dt-bindings: clock: rockchip,rk3506-cru: Add SAI MCLK output gate IDs Xiangyu Zhu
2026-11-23  0:38 ` [PATCH v4 3/3] clk: rockchip: rk3506: Register the SAI MCLK output gates Xiangyu Zhu
2026-11-23  0:49   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox