Skip to content

rockchip64: rk3588: add I2S MCLK output gate clocks for audio codec support#9548

Merged
SuperKali merged 1 commit into
armbian:mainfrom
OpenSource-YYT:yy3588-audio-support
Mar 17, 2026
Merged

rockchip64: rk3588: add I2S MCLK output gate clocks for audio codec support#9548
SuperKali merged 1 commit into
armbian:mainfrom
OpenSource-YYT:yy3588-audio-support

Conversation

@SuperKali
Copy link
Copy Markdown
Member

@SuperKali SuperKali commented Mar 16, 2026

Description

Follow-up to #9534. Replaces the single combined MCLK gate patch with three separate patches matching the upstream series submitted to LKML:

  1. dt-bindings: add clock IDs 722-725 for all four I2S MCLK output gates
  2. clk: rockchip: allow grf_type_sys lookup in aux_grf_table
  3. clk: rockchip: rk3588: add GATE_GRF clock entries and SYS_GRF registration

Key changes from #9534:

  • Use grf_type_sys instead of grf_type_ioc (per upstream review)
  • Add all four I2S MCLK output gates, not just I2S0
  • Place each GATE_GRF after its parent MCLKOUT
  • No subscope in init function

Upstream: https://lore.kernel.org/linux-rockchip/20260316-rk3588-mclk-gate-grf-v1-0-66fb9a246718@superkali.me/

How Has This Been Tested?

  • Built and tested on Youyeetoo YY3588 (RK3588) with ES8388 codec on I2S0
  • Audio playback verified via speaker-test on both headphones and speaker output
  • Kernel build verified for current (6.18) and edge (7.0-rc3)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

Summary by CodeRabbit

Release Notes

  • Chores
    • Added I2S MCLK output gate clock support for RK3588 across kernel 6.18 and 7.0, enabling master clock output control to external IO pins for all I2S channels (I2S0, I2S1, I2S2, I2S3)
    • Enhanced clock branch handling for improved register management
    • Reverted I2S MCLK output gate support in subsequent patches for both kernel versions

Replace the single combined MCLK gate patch with three separate patches
matching the upstream series submitted to LKML:

  1. dt-bindings: add I2S MCLK output to IO clock IDs (722-725)
  2. clk: rockchip: allow grf_type_sys lookup in aux_grf_table
  3. clk: rockchip: rk3588: add GATE_GRF clocks for I2S MCLK output

Key changes from the previous combined patch:
  - Use grf_type_sys instead of grf_type_ioc
  - Add all four I2S MCLK output gates (not just I2S0)
  - Use GFLAGS macro for consistency
  - Place each GATE_GRF after its parent MCLKOUT
  - No subscope in init function

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/20260316-rk3588-mclk-gate-grf-v1-0-66fb9a246718@superkali.me/
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 16, 2026

📝 Walkthrough

Walkthrough

This PR introduces kernel patches for RK3588 I2S MCLK output-to-IO gating control across kernel versions 6.18 and 7.0. Each version includes three feature patches (bindings, clock registration, and GRF gates) followed by a removal patch that retracts all additions, resulting in no net functional changes to the kernel code.

Changes

Cohort / File(s) Summary
Kernel 6.18 I2S MCLK Bindings
patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-1-bindings.patch
Adds four I2S MCLK output-to-IO gate clock macro definitions (I2S0_8CH_MCLKOUT_TO_IO through I2S3_2CH_MCLKOUT_TO_IO, values 722-725) to device tree bindings header.
Kernel 6.18 Clock Registration Logic
patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-2-allow-grf-type-sys.patch
Modifies rockchip_clk_register_branches to permit grf_type_sys lookups via auxiliary GRF table with fallback to ctx->grf, removing exclusion logic and preserving backward compatibility.
Kernel 6.18 GRF Gate Configuration
patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-3-gate-grf-clocks.patch
Adds four GATE_GRF clock entries for I2S MCLK outputs, registers SYS_GRF as auxiliary GRF via syscon lookup, and integrates gates into early clock initialization.
Kernel 6.18 Feature Removal
patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate.patch
Removes all I2S MCLK gating additions: clock macros, GATE_GRF entries, SYS_GRF registration, and syscon includes, reverting to prior state.
Kernel 7.0 I2S MCLK Bindings
patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-1-bindings.patch
Adds four I2S MCLK output-to-IO gate clock macro definitions (I2S0_8CH_MCLKOUT_TO_IO through I2S3_2CH_MCLKOUT_TO_IO) to device tree bindings header.
Kernel 7.0 Clock Registration Logic
patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-2-allow-grf-type-sys.patch
Modifies rockchip_clk_register_branches to allow grf_type_sys branches to lookup auxiliary GRF table before falling back to ctx->grf.
Kernel 7.0 GRF Gate Configuration
patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-3-gate-grf-clocks.patch
Adds four GATE_GRF clock gates for I2S MCLK outputs, registers SYS_GRF as auxiliary GRF, and integrates new gates into RK3588 early clock branches.
Kernel 7.0 Feature Removal
patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate.patch
Removes I2S MCLK gating support additions including clock macros, GATE_GRF entries, SYS_GRF registration, and associated includes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • igorpecovnik
  • paolosabatino
  • catalinii
  • pyavitz
  • rpardini

Poem

🐰 Four I2S gates once danced in morning light,
Through SYS_GRF tubes, they gated MCLK right,
Yet in the twilight patch, they softly fade,
As kernel blooms reset what was made—
A cycle complete, a feature's masquerade! 🎭

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding I2S MCLK output gate clocks to RK3588 for audio codec support, which directly corresponds to the core objective and changes across all patches in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added 05 Milestone: Second quarter release size/large PR with 250 lines or more Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Mar 16, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-3-gate-grf-clocks.patch`:
- Around line 101-109: The current SYS_GRF registration can fail
(syscon_regmap_lookup_by_compatible or kzalloc) but the code still leaves the
four _TO_IO gates using ctx->grf as a fallback; change the logic so SYS_GRF is
treated as an all-or-nothing dependency: allocate and add sys_grf_e (with fields
grf and type = grf_type_sys) to ctx->aux_grf_table only on full success, and
ensure the four _TO_IO gate registrations are not added/registered anywhere
unless that sys_grf registration succeeded — implement this by moving those
_TO_IO gate entries into a small temporary array or deferred registration path
and only register/attach that array after sys_grf_e was successfully created and
hash_add-ed, otherwise skip/leave those gates unregistered so they cannot fall
back to ctx->grf.

In
`@patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-3-gate-grf-clocks.patch`:
- Around line 101-109: The current SYS_GRF setup
(syscon_regmap_lookup_by_compatible -> sys_grf, allocation into sys_grf_e via
kzalloc_obj, and hash_add into ctx->aux_grf_table) can fail and leave the _TO_IO
gates falling back to ctx->grf; instead, ensure the _TO_IO gate registrations
only happen after both lookup and allocation succeed: perform
syscon_regmap_lookup_by_compatible("rockchip,rk3588-sys-grf"), allocate
sys_grf_e, populate sys_grf_e->grf and ->type, and only then register the
related _TO_IO gates (e.g., by adding them into a mini-array and calling the
existing registration path or hash_add into ctx->aux_grf_table); if either
lookup or kzalloc_obj fails, do not register those gates and do not touch
ctx->grf so no fallback occurs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0b3b0ec7-94a0-426a-ae5e-0a07fb4b535f

📥 Commits

Reviewing files that changed from the base of the PR and between a3f8d14 and 306e963.

📒 Files selected for processing (8)
  • patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate-1-bindings.patch
  • 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-3-gate-grf-clocks.patch
  • patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate.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-2-allow-grf-type-sys.patch
  • patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate-3-gate-grf-clocks.patch
  • patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate.patch
💤 Files with no reviewable changes (2)
  • patch/kernel/archive/rockchip64-6.18/general-rk3588-i2s-mclk-output-gate.patch
  • patch/kernel/archive/rockchip64-7.0/general-rk3588-i2s-mclk-output-gate.patch

@github-actions github-actions Bot added the Ready to merge Reviewed, tested and ready for merge label Mar 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

✅ This PR has been reviewed and approved — all set for merge!

@github-actions github-actions Bot removed the Needs review Seeking for review label Mar 16, 2026
@SuperKali SuperKali merged commit ea114db into armbian:main Mar 17, 2026
1 check passed
@SuperKali SuperKali deleted the yy3588-audio-support branch March 17, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... Ready to merge Reviewed, tested and ready for merge size/large PR with 250 lines or more

Development

Successfully merging this pull request may close these issues.

2 participants