arm64: dts: rockchip: fix audio on Firefly-RK3399
Subsystems (2)
v2 cover arm64: dts: rockchip: fix audio on Firefly-RK3399
This supersedes my earlier two-patch series [1].
Patch 1/2 there dropped the &i2s0 override outright. That is wrong: the i2s0 pin groups also list GPIO4_A0, which carries SCLK_I2S_8CH_OUT, the codec MCLK. Dropping the override unmuxes that pin and leaves analog audio dead. I have asked for that series to be dropped. The HDMI patch depended on it, so it is not resent on its own but as 3/3 here.
1/3 is independent of the other two and fixes a separate bug: the GPIO that gates the headphone output is muxed by the board file but never claimed or driven, so the jack has never worked with a mainline kernel.
2/3 and 3/3 have to stay in this order; 3/3 needs the pl330 channels that 2/3 frees.
Changes in v2:
- 1/3 is new: model the headphone output enable GPIO as a simple-audio-amplifier aux device, the way rk3399-roc-pc-plus.dts does.
- 2/3 replaces the old 1/2. It now splits GPIO4_A0 into its own pinctrl group and gives it to i2s1 before disabling i2s0, instead of just removing the override.
- 3/3 is the old 2/2, unchanged apart from the commit message.
Tested on a Firefly-RK3399 running 6.18. What was not done: the patched tree was not built as a full kernel, and the DTS was compiled and the resulting DTB inspected instead; the changes were exercised on the board through an equivalent DTB rather than a kernel built from this tree. I have no schematic for the board, so 1/3 relies on measurement rather than on knowing what the GPIO switches.
[1] https://lore.kernel.org/all/[email protected]/
Yaozhong Li (3):
arm64: dts: rockchip: fix analog headphone output on rk3399-firefly
arm64: dts: rockchip: disable unused i2s0 on rk3399-firefly
arm64: dts: rockchip: enable HDMI audio on rk3399-firefly
.../boot/dts/rockchip/rk3399-firefly.dts | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-)
Signature · 7 lines
2.55.0.windows.3 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v2 1/3 arm64: dts: rockchip: fix analog headphone output on rk3399-firefly
The analog headphone jack on this board has never produced any sound with a mainline kernel.
GPIO4_C5 has to be high for audio to reach the jack. The board file muxes the pin to GPIO through the rt5640_hpcon pinctrl group and references that group from the codec node, but nothing ever requests or drives the line:
pin 149 (gpio4-21): 1-001c (GPIO UNCLAIMED) function rt5640 \
group rt5640-hpconIt therefore stays an input and reads low. The vendor tree drives it from a hp-con-gpio property that was dropped during review of the original board submission because it is not part of the RT5640 binding, but the pinmux half was kept, leaving the description incomplete.
Describe it the way rk3399-roc-pc-plus.dts already describes the equivalent signal, as a simple-audio-amplifier auxiliary component, so that DAPM asserts the GPIO while the headphone path is active. That board's DTS carries the same caveat in a comment: the binding is used because it expresses a DAPM-controlled output enable, not because the hardware is necessarily an amplifier.
Measured on a Firefly-RK3399 by toggling only this line while a 1 kHz tone kept playing, with the playback PCM in state: RUNNING throughout:
high -> audible, low -> silent, high -> audible
With this change the line is claimed and follows the audio path:
pin 149 (gpio4-21): headphones-amp gpio4:149
idle: gpio-21 (|enable) out lo
playing: gpio-21 (|enable) out hi
--- .../arm64/boot/dts/rockchip/rk3399-firefly.dts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +14 -4
@@ -96,6 +96,15 @@ key-power { }; }; + /* GPIO that enables the headphone output path */ + headphones_amp: headphones-amp { + compatible = "simple-audio-amplifier"; + pinctrl-names = "default"; + pinctrl-0 = <&rt5640_hpcon>; + enable-gpios = <&gpio4 RK_PC5 GPIO_ACTIVE_HIGH>; + sound-name-prefix = "Headphone Amp"; + }; + ir-receiver { compatible = "gpio-ir-receiver"; gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>;
@@ -132,8 +141,11 @@ rt5640-sound { simple-audio-card,routing = "Mic Jack", "MICBIAS1", "IN1P", "Mic Jack", - "Headphone Jack", "HPOL", - "Headphone Jack", "HPOR"; + "Headphone Amp INL", "HPOL", + "Headphone Amp INR", "HPOR", + "Headphone Jack", "Headphone Amp OUTL", + "Headphone Jack", "Headphone Amp OUTR"; + simple-audio-card,aux-devs = <&headphones_amp>; simple-audio-card,cpu { sound-dai = <&i2s1>;
@@ -547,8 +559,6 @@ rt5640: rt5640@1c { clock-names = "mclk"; realtek,in1-differential; #sound-dai-cells = <0>; - pinctrl-names = "default"; - pinctrl-0 = <&rt5640_hpcon>; }; };
Signature · 7 lines
2.55.0.windows.3 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v2 2/3 arm64: dts: rockchip: disable unused i2s0 on rk3399-firefly
In reply to Yaozhong LiThe board file enables i2s0, but no sound card references it: the on-board RT5640 is wired to i2s1 and the S/PDIF transmitter has its own controller. Keeping it enabled starves the other controllers.
The pl330 instance that serves the audio block has six channels:
dma-pl330 ff6d0000.dma-controller: DBUFF-32x8bytes Num_Chans-6 \
Num_Peri-12 Num_Events-12snd_dmaengine_pcm_register() requests the channels named in "dmas" when the controller probes and holds them until it goes away, so this is decided per controller and not per card. The demand is i2s0 2 + i2s1 2
+ i2s2 2 + spdif 1 = 7, one controller always loses, and which one depends on probe order:
rockchip-spdif ff870000.spdif: Missing dma channel for stream: 0
i2s0 cannot simply be dropped, though. Its pin groups also list GPIO4_A0, which carries SCLK_I2S_8CH_OUT, the MCLK the codec runs on, rather than an i2s0 data, bit clock or frame clock signal:
i2s0-8ch-bus ... <4 RK_PA0 1 &pcfg_pull_none> i2s0-8ch-bus-bclk-off ... <4 RK_PA0 1 &pcfg_pull_none> i2s1-2ch-bus ... GPIO4_A3..A7 only
rt5640: rt5640@1c {
clocks = <&cru SCLK_I2S_8CH_OUT>;
clock-names = "mclk";
};Removing the &i2s0 override on its own would therefore leave that pin unmuxed and analog audio dead. Both changes are required in one step:
disabling i2s0 without splitting out the MCLK pin leaves GPIO4_A0 unmuxed, while giving the new group to i2s1 without disabling i2s0 makes the two controllers contend for the same pin.
rk3399-roc-pc-plus.dts already carries the same i2s_8ch_mclk_pin split.
Measured on a Firefly-RK3399. The pin moves to the controller that actually drives the codec:
pin 128 (gpio4-0): ff890000.i2s function i2s1 group i2s-8ch-mclk-pin
The RT5640 and S/PDIF cards then register with no DMA errors, and a 1 kHz tone measured through the codec's internal HPOL/HPOR loopback is unchanged (L 2135 -> 2138, R 2202 -> 2203), confirming that MCLK still reaches the codec.
--- arch/arm64/boot/dts/rockchip/rk3399-firefly.dts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +8 -6
@@ -628,13 +628,9 @@ accelerometer@68 { }; }; -&i2s0 { - rockchip,playback-channels = <8>; - rockchip,capture-channels = <8>; - status = "okay"; -}; - &i2s1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2s_8ch_mclk_pin>, <&i2s1_2ch_bus>; rockchip,playback-channels = <2>; rockchip,capture-channels = <2>; status = "okay";
@@ -689,6 +685,12 @@ ir_int: ir-int { }; }; + i2s1 { + i2s_8ch_mclk_pin: i2s-8ch-mclk-pin { + rockchip,pins = <4 RK_PA0 1 &pcfg_pull_none>; + }; + }; + lcd-panel { lcd_panel_reset: lcd-panel-reset { rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>;
Signature · 7 lines
2.55.0.windows.3 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
PATCH v2 3/3 arm64: dts: rockchip: enable HDMI audio on rk3399-firefly
In reply to Yaozhong LiThe Firefly-RK3399 carries audio over its HDMI connector, but hdmi_sound is left disabled, so the only outputs are the analog RT5640 jacks and S/PDIF.
Enable it. This needs the previous patch: with i2s0 still holding two pl330 channels there is none left for i2s2 and the card fails to probe.
Tested on a Firefly-RK3399 with a 1920x1080 display attached. All three cards register and the hdmi-sound card plays at both 44.1 and 48 kHz:
0 [hdmisound ]: simple-card - hdmi-sound
1 [rockchiprt5640c]: simple-card - rockchip,rt5640-codec
2 [SPDIF ]: SPDIF - SPDIF
--- arch/arm64/boot/dts/rockchip/rk3399-firefly.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +4 -0
@@ -323,6 +323,10 @@ &hdmi { status = "okay"; }; +&hdmi_sound { + status = "okay"; +}; + &i2c0 { clock-frequency = <400000>; i2c-scl-rising-time-ns = <168>;
Signature · 7 lines
2.55.0.windows.3 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
Quoted 9 lines · Yaozhong Li
This supersedes my earlier two-patch series [1].
Patch 1/2 there dropped the &i2s0 override outright. That is wrong: the i2s0 pin groups also list
GPIO4_A0, which carriesSCLK_I2S_8CH_OUT, the codec MCLK. Dropping the override unmuxes that pin and leaves analog audio dead. I have asked for that series to be dropped. The HDMI patch depended on it, so it is not resent on its own but as 3/3 here.[...]
Applied, thanks!
[1/3] arm64: dts: rockchip: fix analog headphone output on rk3399-firefly
commit: 23eab1a5e36099fd1269f8a18dc389e04dc19011
[2/3] arm64: dts: rockchip: disable unused i2s0 on rk3399-firefly
commit: 9416a641cfe5b75dd9178c15960ee741c1091b45
[3/3] arm64: dts: rockchip: enable HDMI audio on rk3399-firefly
commit: 86936f4c25cdb2d138a09dbcbbdd587c3d73cc1fBest regards,
Signature · 6 lines
Heiko Stuebner <[email protected]> _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip