rockchip64: rk3588: update I2S MCLK gate patches to match upstream v3 and add u-boot clock IDs#9568
Conversation
📝 WalkthroughWalkthroughAdds RK3588 I2S MCLK “output-to-IO” support: four new dt-binding clock IDs, a SYS_GRF register offset macro, GRF-backed gate clock entries and syscon regmap initialization in the RK3588 clock driver, and a change to GRF lookup to allow Changes
Sequence Diagram(s)sequenceDiagram
participant Init as rk3588_clk_early_init()
participant Syscon as syscon (rockchip,rk3588-sys-grf)
participant Driver as clk-rk3588
participant DT as Device Tree / bindings
Init->>Syscon: syscon_regmap_lookup_by_compatible("rockchip,rk3588-sys-grf")
Syscon-->>Init: regmap (rk3588_sys_grf)
Init->>Driver: register early branches (GATE_GRF using regmap)
Driver->>DT: reference new clock IDs (I2S*_MCLKOUT_TO_IO)
Driver->>Driver: rockchip_clk_register_branches() consults ctx->aux_grf_table for grf_type_sys
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patch (1)
109-118: Consider adding a warning on SYS_GRF registration failure.If
syscon_regmap_lookup_by_compatible()fails orkzalloc()returns NULL, the SYS_GRF won't be registered inaux_grf_table. TheGATE_GRFclock branches will then silently fail to find the correct GRF, potentially leaving MCLK gates in bootloader-defined state without any indication.Given this is early init context, a
pr_warnwould help diagnose audio issues:Optional: Add warning for registration failure
/* Register SYS_GRF for I2S MCLK output to IO gate clocks */ sys_grf = syscon_regmap_lookup_by_compatible("rockchip,rk3588-sys-grf"); - if (!IS_ERR(sys_grf)) { + if (IS_ERR(sys_grf)) { + pr_warn("%s: failed to lookup SYS_GRF, I2S MCLK gates unavailable\n", __func__); + } else { sys_grf_e = kzalloc(sizeof(*sys_grf_e), GFP_KERNEL); if (sys_grf_e) { sys_grf_e->grf = sys_grf; sys_grf_e->type = grf_type_sys; hash_add(ctx->aux_grf_table, &sys_grf_e->node, grf_type_sys); + } else { + pr_warn("%s: failed to allocate SYS_GRF entry\n", __func__); } }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patch` around lines 109 - 118, When registering SYS_GRF via syscon_regmap_lookup_by_compatible, add diagnostic warnings if the lookup fails or kzalloc returns NULL so failures aren't silent: check the return of syscon_regmap_lookup_by_compatible("rockchip,rk3588-sys-grf") and emit a pr_warn including the error (or that lookup returned NULL/IS_ERR) if it fails, and emit a pr_warn if kzalloc for sys_grf_e returns NULL before attempting to set sys_grf_e->grf/type or hash_add(ctx->aux_grf_table,...); reference the symbols syscon_regmap_lookup_by_compatible, sys_grf, sys_grf_e, kzalloc, aux_grf_table and GATE_GRF in the message to aid diagnosis.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patch`:
- Around line 109-118: When registering SYS_GRF via
syscon_regmap_lookup_by_compatible, add diagnostic warnings if the lookup fails
or kzalloc returns NULL so failures aren't silent: check the return of
syscon_regmap_lookup_by_compatible("rockchip,rk3588-sys-grf") and emit a pr_warn
including the error (or that lookup returned NULL/IS_ERR) if it fails, and emit
a pr_warn if kzalloc for sys_grf_e returns NULL before attempting to set
sys_grf_e->grf/type or hash_add(ctx->aux_grf_table,...); reference the symbols
syscon_regmap_lookup_by_compatible, sys_grf, sys_grf_e, kzalloc, aux_grf_table
and GATE_GRF in the message to aid diagnosis.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 5879aed8-e958-4ff6-89e9-8fad1aa79bb5
📒 Files selected for processing (9)
patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-1-bindings.patchpatch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-2-allow-grf-type-sys.patchpatch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-3-grf-header.patchpatch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patchpatch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-1-bindings.patchpatch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-2-allow-grf-type-sys.patchpatch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-3-grf-header.patchpatch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patchpatch/u-boot/v2026.04/general-rk3588-add-i2s-mclk-output-to-io-clock-ids.patch
Update the I2S MCLK output gate clock patches to match the upstream v3 series. Changes from previous version: - Split into 4 patches (was 3): added separate patch for RK3588_SYSGRF_SOC_CON6 define in rk3588_grf.h - Use named constant RK3588_SYSGRF_SOC_CON6 instead of magic 0x0318 - Add u-boot patch for clock ID bindings (needed by board DTS files) 6.18 uses kzalloc(sizeof(...)) as kzalloc_obj is not available. 7.0 uses kzalloc_obj as recommended by upstream reviewer. Upstream: https://lore.kernel.org/linux-rockchip/20260320-rk3588-mclk-gate-grf-v3-0-980338eacd2c@superkali.me/
0fedc10 to
7e8d363
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patch (1)
109-118: Consider adding a warning on allocation failure.The syscon lookup failure is handled silently, which is reasonable since the GRF may not be present in some DT configurations. However, a
kzallocfailure at this stage would be unexpected and could silently break the GATE_GRF clocks without any indication.An optional improvement would be to log a warning on allocation failure to aid debugging:
📝 Optional: Add warning on kzalloc failure
/* Register SYS_GRF for I2S MCLK output to IO gate clocks */ sys_grf = syscon_regmap_lookup_by_compatible("rockchip,rk3588-sys-grf"); if (!IS_ERR(sys_grf)) { sys_grf_e = kzalloc(sizeof(*sys_grf_e), GFP_KERNEL); if (sys_grf_e) { sys_grf_e->grf = sys_grf; sys_grf_e->type = grf_type_sys; hash_add(ctx->aux_grf_table, &sys_grf_e->node, grf_type_sys); + } else { + pr_warn("%s: failed to allocate aux_grf for sys_grf\n", __func__); } }That said, this is consistent with upstream submission patterns for clock drivers, so keeping it as-is is also acceptable.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patch` around lines 109 - 118, The syscon lookup and kzalloc block silently ignores allocation failure; update the allocation path in the code that calls syscon_regmap_lookup_by_compatible("rockchip,rk3588-sys-grf") so that if kzalloc(sizeof(*sys_grf_e), GFP_KERNEL) returns NULL you emit a warning (e.g., dev_warn/dev_warn_probe or pr_warn) indicating that allocation of sys_grf_e failed and that GATE_GRF clocks may not be registered; keep the current behavior (no further action) after logging, and reference the same symbols sys_grf, sys_grf_e, ctx->aux_grf_table and the existing hash_add call so the only change is adding the warning on kzalloc failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patch`:
- Around line 109-118: The syscon lookup and kzalloc block silently ignores
allocation failure; update the allocation path in the code that calls
syscon_regmap_lookup_by_compatible("rockchip,rk3588-sys-grf") so that if
kzalloc(sizeof(*sys_grf_e), GFP_KERNEL) returns NULL you emit a warning (e.g.,
dev_warn/dev_warn_probe or pr_warn) indicating that allocation of sys_grf_e
failed and that GATE_GRF clocks may not be registered; keep the current behavior
(no further action) after logging, and reference the same symbols sys_grf,
sys_grf_e, ctx->aux_grf_table and the existing hash_add call so the only change
is adding the warning on kzalloc failure.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 609da16c-a29c-4f8a-aa0d-1298eb9c1942
📒 Files selected for processing (9)
patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-1-bindings.patchpatch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-2-allow-grf-type-sys.patchpatch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-3-grf-header.patchpatch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patchpatch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-1-bindings.patchpatch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-2-allow-grf-type-sys.patchpatch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-3-grf-header.patchpatch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patchpatch/u-boot/v2026.04/general-rk3588-add-i2s-mclk-output-to-io-clock-ids.patch
✅ Files skipped from review due to trivial changes (4)
- patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-3-grf-header.patch
- patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-3-grf-header.patch
- patch/u-boot/v2026.04/general-rk3588-add-i2s-mclk-output-to-io-clock-ids.patch
- patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-2-allow-grf-type-sys.patch
🚧 Files skipped from review as they are similar to previous changes (4)
- patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-2-allow-grf-type-sys.patch
- patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-1-bindings.patch
- patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-1-bindings.patch
- patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-4-gate-grf-clocks.patch
|
✅ This PR has been reviewed and approved — all set for merge! |
|
U-boot compiled locally and works: https://paste.armbian.com/jijojowili |
|
Replaced the u-boot DTS symlink with a real copy as discussed with Ricardo. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
patch/u-boot/v2026.04/dt_upstream_rockchip/rk3588-mekotronics-r58x-pro.dts (2)
34-39: TODO: Consider adding wakeup-source for volume button.The comment indicates uncertainty about whether to enable wakeup-source for the volume-up button. If the hardware supports wake from suspend via this button, adding
wakeup-source;would be appropriate.Would you like me to help verify the hardware capability or generate a solution that implements this feature?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@patch/u-boot/v2026.04/dt_upstream_rockchip/rk3588-mekotronics-r58x-pro.dts` around lines 34 - 39, The volume-up button node (vol_up / label "VolumeUp") should be marked as a wake source if the GPIO/controller and board hardware support wake-from-suspend: add the wakeup-source; property to the vol_up node (the same node that contains linux,code = <KEY_VOLUMEUP> and gpios = <&gpio3 RK_PD0 GPIO_ACTIVE_HIGH>). Before committing, verify the GPIO controller (&gpio3 / RK_PD0) and SoC power domain support wake events and test suspend/resume to confirm the button wakes the system.
614-617: TODO: FUSB302 USB Type-C controller support is missing.The pinctrl for
usbc0_intis defined but the actual FUSB302 node is not present. This limits USB-C functionality (no PD negotiation, role switching).Would you like me to help generate a FUSB302 node configuration, or should I open an issue to track this enhancement?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@patch/u-boot/v2026.04/dt_upstream_rockchip/rk3588-mekotronics-r58x-pro.dts` around lines 614 - 617, The pinctrl for usb-typec (symbols: usb-typec, usbc0_int, usbc0-int) declares an interrupt but the FUSB302 device node is missing—add a child node for the FUSB302 controller (name it e.g. fusb302@<reg> or fusb302-usbc0) with the correct compatible string (e.g. "onsemi,fusb302" or the upstream binding name), reg address for its I2C/SPI bus, an interrupt specifier referencing usbc0-int, gpio lines if used for reset/alert, pinctrl-0 = <&usbc0_int> and pinctrl-names = "default", and any vbus-supply or interrupt-parent properties required by the fusb302 binding so the kernel can bind PD/role-switching support; update the bus node (i2c/spi) to include the new device in its children if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@patch/u-boot/v2026.04/dt_upstream_rockchip/rk3588-mekotronics-r58x-pro.dts`:
- Around line 34-39: The volume-up button node (vol_up / label "VolumeUp")
should be marked as a wake source if the GPIO/controller and board hardware
support wake-from-suspend: add the wakeup-source; property to the vol_up node
(the same node that contains linux,code = <KEY_VOLUMEUP> and gpios = <&gpio3
RK_PD0 GPIO_ACTIVE_HIGH>). Before committing, verify the GPIO controller (&gpio3
/ RK_PD0) and SoC power domain support wake events and test suspend/resume to
confirm the button wakes the system.
- Around line 614-617: The pinctrl for usb-typec (symbols: usb-typec, usbc0_int,
usbc0-int) declares an interrupt but the FUSB302 device node is missing—add a
child node for the FUSB302 controller (name it e.g. fusb302@<reg> or
fusb302-usbc0) with the correct compatible string (e.g. "onsemi,fusb302" or the
upstream binding name), reg address for its I2C/SPI bus, an interrupt specifier
referencing usbc0-int, gpio lines if used for reset/alert, pinctrl-0 =
<&usbc0_int> and pinctrl-names = "default", and any vbus-supply or
interrupt-parent properties required by the fusb302 binding so the kernel can
bind PD/role-switching support; update the bus node (i2c/spi) to include the new
device in its children if needed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fcf430d0-5295-4cb2-be9d-9e31108115c9
📒 Files selected for processing (2)
patch/u-boot/v2026.04/dt_upstream_rockchip/rk3588-mekotronics-r58x-pro.dtspatch/u-boot/v2026.04/dt_upstream_rockchip/rk3588-mekotronics-r58x-pro.dts
Description
Follow-up to #9534. Updates the I2S MCLK output gate clock patches to match the upstream v3 series and adds the clock ID bindings for u-boot.
Changes from #9534:
RK3588_SYSGRF_SOC_CON6define inrk3588_grf.hRK3588_SYSGRF_SOC_CON6instead of magic0x0318I2S0_8CH_MCLKOUT_TO_IO)Upstream v3: https://lore.kernel.org/linux-rockchip/20260320-rk3588-mclk-gate-grf-v3-0-980338eacd2c@superkali.me/
How Has This Been Tested?
Checklist:
Summary by CodeRabbit
New Features
Board Support