[PATCH v4 0/5] Add RK3576 SAI Audio Controller Support
From: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Date: 2025-05-06 10:43:32
Also in:
linux-clk, linux-devicetree, linux-rockchip, linux-sound, lkml
This series adds support for Rockchip's Serial Audio Interface (SAI) controller, found on SoCs such as the RK3576. The SAI is a flexible controller IP that allows both transmitting and receiving digital audio in the I2S, TDM and PCM formats. Instances of this controller are used both for externally exposed audio interfaces, as well as for audio on video interfaces such as HDMI. Patch 1 and 2 are boring devicetree changes to add the nodes, including an hdmi_sound node in the SoC tree which can be enabled by individual boards that enable HDMI. Patch 3 and 4 enable analog audio and HDMI audio respectively on the ArmSoM Sige5 board. Patch 3 goes into some schematic-derived knowledge about where the audio signal can actually be tapped into in order to test analog audio. Patch 5 enables the driver in the arm64 defconfig for both the SAI audio driver and the ES8328 driver used by the Sige5, as the RK3576 and Sige5 are supported in mainline, so its drivers should be enabled in the defconfig. To test analog audio on the Sige5, I both soldered to the output 2 testpads, as well as fashioned a cable to plug into the headphone header. I do have the necessary materials to to make more such cables, so if you have a Sige5 and want to test this but don't happen to sit on a pile of 03SUR-32S cables, then you may contact me off-list to request I send you such a cable from Switzerland, and I'll see what I can do. HDMI audio is now enabled in this series. Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com> --- Changes in v4: - drop the clock patches Heiko already applied, rebase onto next-20250506. - Squash the defconfig patches into one patch - Link to v3: https://lore.kernel.org/r/20250502-rk3576-sai-v3-0-376cef19dd7c@collabora.com (local) Changes in v3: - Fix auxiliary GRF patch on RK3388 and RV1126, which were unintentionally broken previously because I didn't build 32-bit ARM platforms. Thanks to Heiko for noticing! - Drop "ASoC: dt-bindings: add schema for rockchip SAI controllers" as it was applied already - Drop "ASoC: rockchip: add Serial Audio Interface (SAI) driver" as it was applied already - Add codec driver defconfig patch - Link to v2: https://lore.kernel.org/r/20250410-rk3576-sai-v2-0-c64608346be3@collabora.com (local) Changes in v2: - split rockchip clk changes into 3 separate patches, all of which build on their own - driver: expand Kconfig symbol help text to make checkpatch shut up - driver: remove runtime PM debug messages, as they were redundant - driver: move of_defice_id table and MODULE_DEVICE_TABLE to be above the platform_driver struct and below the probe function, as is done in many other drivers - driver: drop of_match_ptr - driver: drop MODULE_ALIAS - driver: remove the confusing hclk disable comment in the probe function - driver: remove quirks handling, which only existed for rockchip,always-on purposes. Downstream does not appear to need this quirk for any sai implementations. It can always be added back later when the problem, if there is any, is better understood. - driver: fix hw_params when the number of requested channels is lower than twice the number of lanes in non-TDM mode. Without this, playing back stereo audio on an 8-channel SAI would fail to set the hw_params - driver: when in I2S TDM mode, set the XFER delay to 1 aka half a cycle This makes the output waveform line up with both what RK3568 I2S-TDM and the TI TAS6424 codec describe as correct TDM'd I2S in their datasheets, namely that on the first rising SCLK pulse after LRCK is high, there's audio data ready. - driver: treat set_tdm_slot with 0 slots as disabling TDM. This lines up with what the function documentation for ASoC core's snd_soc_dai_set_tdm_slot says it'll do if it's called with 0 slots, but in practice that function seems broken because it'll just pass the signed number of slots to the unsigned parameter of the mask generation function, which treats 0 slots as an error, making the caller snd_soc_dai_set_tdm_slot function bail out before ever giving any driver set_tdm_slot callback the 0 slot number. If that ever gets fixed (I hacked around it to test it), then our driver will be able to turn off TDM mode at runtime. - ASoC bindings: rename bindings file from rockchip,sai.yaml to rockchip,rk3576-sai.yaml - ASoC bindings: remove extraneous blank line - ASoC bindings: change resets property to use an items listing - ASoC bindings: fix rockchip,sai-(t|r)x-route property constraints - ASoC bindings: remove rockchip,always-on - RK3576 dts: add tx/rx-route to all internal SAI nodes. This is needed because they all can do either 8CH TX, 8CH TXRX or 8CH RX, and an absent route property is understood to be just 2CH if the direction is present. - RK3576 dts: add hdmi_sound node - Sige5 dts: enable hdmi_sound - Now based on v6.15-rc1 - Link to v1: https://lore.kernel.org/r/20250305-rk3576-sai-v1-0-64e6cf863e9a@collabora.com (local) --- Nicolas Frattaroli (5): arm64: dts: rockchip: Add RK3576 SAI nodes arm64: dts: rockchip: Add RK3576 HDMI audio arm64: dts: rockchip: Add analog audio on RK3576 Sige5 arm64: dts: rockchip: Enable HDMI audio on Sige5 arm64: defconfig: Enable Rockchip SAI and ES8328 .../boot/dts/rockchip/rk3576-armsom-sige5.dts | 64 ++++++ arch/arm64/boot/dts/rockchip/rk3576.dtsi | 217 +++++++++++++++++++++ arch/arm64/configs/defconfig | 3 + 3 files changed, 284 insertions(+) --- base-commit: 580d4593971087787eb1edddeddf1f33e7d590a8 change-id: 20250305-rk3576-sai-c78e0430898e Best regards, -- Nicolas Frattaroli [off-list ref]