From: sashiko-bot@kernel.org
To: "Xiangyu Zhu" <1194781887@qq.com>
Cc: linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 2/2] clk: rockchip: rk3506: Register the SAI MCLK output gates
Date: Sun, 22 Nov 2026 16:38:32 +0000 [thread overview]
Message-ID: <sashiko-outbox-228112@kernel.org> (raw)
In-Reply-To: <tencent_C39B83AEA61743AAF1CCB394F87DDA05E409@qq.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] clk: rockchip: rk3506: wrong GRF regmap assigned in
rk3506_clk_init()
- [Medium] clk: rockchip: rk3506: undocumented GRF DT bindings in
rk3506_clk_init()
--
commit 844c13fa6f3e153943a1988cd51a8f5b1886cb96
Author: Xiangyu Zhu <1194781887@qq.com>
clk: rockchip: rk3506: Register the SAI MCLK output gates
This commit looks up the RK3506 PMU GRF syscon and registers four SAI MCLK
output GRF gate clocks across the PMU and system GRFs.
> diff --git a/drivers/clk/rockchip/clk-rk3506.c b/drivers/clk/rockchip/clk-rk3506.c
> index dd59bd60382ef..d3c3452e2e68e 100644
> --- a/drivers/clk/rockchip/clk-rk3506.c
> +++ b/drivers/clk/rockchip/clk-rk3506.c
[ ... ]
> @@ -520,6 +521,8 @@ static struct rockchip_clk_branch rk3506_clk_branches[] __initdata = {
> RK3506_CLKGATE_CON(14), 0, GFLAGS),
> GATE(MCLK_OUT_SAI0, "mclk_out_sai0", "mclk_sai0", 0,
> RK3506_CLKGATE_CON(14), 1, GFLAGS),
> + GATE_GRF(MCLK_OUT_SAI0_TO_IO, "mclk_sai0_to_io", "mclk_out_sai0",
> + 0, 0x4, 8, CLK_GATE_HIWORD_MASK, grf_type_pmu0),
> COMPOSITE(MCLK_SAI1, "mclk_sai1", mclk_sai_asrc_parents_p, 0,
> RK3506_CLKSEL_CON(41), 8, 4, MFLAGS, 0, 8, DFLAGS,
> RK3506_CLKGATE_CON(14), 2, GFLAGS),
> @@ -527,6 +530,8 @@ static struct rockchip_clk_branch rk3506_clk_branches[] __initdata = {
> RK3506_CLKGATE_CON(14), 3, GFLAGS),
> GATE(MCLK_OUT_SAI1, "mclk_out_sai1", "mclk_sai1", 0,
> RK3506_CLKGATE_CON(14), 4, GFLAGS),
> + GATE_GRF(MCLK_OUT_SAI1_TO_IO, "mclk_sai1_to_io", "mclk_out_sai1",
> + 0, 0x4, 9, CLK_GATE_HIWORD_MASK, grf_type_pmu0),
> GATE(HCLK_ASRC0, "hclk_asrc0", "hclk_lsperi_root", 0,
> RK3506_CLKGATE_CON(14), 5, GFLAGS),
> COMPOSITE(CLK_ASRC0, "clk_asrc0", gpll_v0pll_v1pll_g_parents_p, 0,
> @@ -608,6 +613,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 +624,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),
> @@ -787,10 +796,20 @@ 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;
>
> clk_nr_clks = rockchip_clk_find_max_clk_id(rk3506_clk_branches,
> ARRAY_SIZE(rk3506_clk_branches)) + 1;
>
> + /*
> + * The PMU GRF only carries the SAI0/SAI1 MCLK output gates, so a
> + * missing (or not yet probed) syscon must not prevent the CRU itself
> + * from being registered.
> + */
> + pmu_grf = syscon_regmap_lookup_by_compatible("rockchip,rk3506-grf-pmu");
> + if (IS_ERR(pmu_grf))
> + pr_warn("%s: could not get PMU GRF syscon\n", __func__);
[Severity: Medium]
Are the GRF DeviceTree bindings used here documented in the RK3506 schemas?
Documentation/devicetree/bindings/clock/rockchip,rk3506-cru.yaml sets
additionalProperties: false and does not define the rockchip,grf phandle
property that rockchip_clk_init_base() uses to populate ctx->grf, so a
conforming DT leaves ctx->grf as ERR_PTR(-ENODEV). In addition,
"rockchip,rk3506-grf-pmu" is not documented in
Documentation/devicetree/bindings/soc/rockchip/grf.yaml.
> +
> reg_base = of_iomap(np, 0);
> if (!reg_base) {
> pr_err("%s: could not map cru region\n", __func__);
> @@ -804,6 +823,10 @@ static void __init rk3506_clk_init(struct device_node *np)
> return;
> }
>
> + if (!IS_ERR(pmu_grf) &&
> + rockchip_clk_add_grf(ctx, pmu_grf, grf_type_pmu0))
> + pr_warn("%s: could not add PMU GRF\n", __func__);
[Severity: High]
Does registering only grf_type_pmu0 in ctx->aux_grf_table cause
MCLK_OUT_SAI2_TO_IO and MCLK_OUT_SAI3_TO_IO to bind to pmu_grf instead of
the system GRF?
In rockchip_clk_register_branches(), grf is initialized to ctx->grf once
before the loop and only updated when list->grf_type matches an entry in
ctx->aux_grf_table:
drivers/clk/rockchip/clk.c:rockchip_clk_register_branches() {
...
struct regmap *grf = ctx->grf;
...
for (idx = 0; idx < nr_clk; idx++, list++) {
flags = list->flags;
clk = NULL;
/* for GRF-dependent branches, choose the right grf first */
if (list->branch_type == branch_grf_mux ||
list->branch_type == branch_grf_gate ||
list->branch_type == branch_grf_mmc) {
hash_for_each_possible(ctx->aux_grf_table, agrf, node, list->grf_type) {
if (agrf->type == list->grf_type) {
grf = agrf->grf;
break;
}
}
}
...
}
After MCLK_OUT_SAI0_TO_IO and MCLK_OUT_SAI1_TO_IO set grf to pmu_grf, the
later MCLK_OUT_SAI2_TO_IO and MCLK_OUT_SAI3_TO_IO entries find no
grf_type_sys entry in ctx->aux_grf_table and retain pmu_grf, so toggling
SAI2 or SAI3 MCLK output writes to offset 0x4 in the PMU GRF instead of the
system GRF. Conversely, if the optional pmu_grf lookup or
rockchip_clk_add_grf() fails while ctx->grf is valid, grf_type_pmu0 is absent
from ctx->aux_grf_table and MCLK_OUT_SAI0_TO_IO and MCLK_OUT_SAI1_TO_IO
silently fall back to ctx->grf (the system GRF).
--
Sashiko AI review · https://sashiko.dev/#/patchset/tencent_93FC4A7191B1BAC63C4DE9C2674660AA7905@qq.com?part=2
prev parent reply other threads:[~2026-11-22 16:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1795363509.git.1194781887@qq.com>
2026-11-22 16:24 ` [PATCH v2 1/2] dt-bindings: clock: rockchip,rk3506-cru: Add SAI MCLK output gate IDs Xiangyu Zhu
2026-11-22 16:24 ` [PATCH v2 2/2] clk: rockchip: rk3506: Register the SAI MCLK output gates Xiangyu Zhu
2026-11-22 16:38 ` sashiko-bot [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=sashiko-outbox-228112@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=1194781887@qq.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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