linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64
@ 2020-08-02 15:42 Katsuhiro Suzuki
  2020-08-30 19:16 ` Heiko Stuebner
  2021-01-09 15:39 ` Heiko Stuebner
  0 siblings, 2 replies; 5+ messages in thread
From: Katsuhiro Suzuki @ 2020-08-02 15:42 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: linux-rockchip, linux-arm-kernel, linux-kernel, Katsuhiro Suzuki

This patch enables HDMI sound (I2S0) and Analog sound (I2S1) which
are defined in rk3328.dtsi, and replace SPDIF nodes.

We can use SPDIF pass-through with suitable ALSA settings and on
mpv or other media players.
  - Settings: https://github.com/LibreELEC/LibreELEC.tv/blob/master/projects/Rockchip/filesystem/usr/share/alsa/cards/SPDIF.conf
  - Ex.: mpv foo.ac3 --audio-spdif=ac3 --audio-device='alsa/SPDIF.pcm.iec958.0:SPDIF'

[Why use simple-audio-card for SPDIF?]

For newly adding nodes, ASoC guys recommend to use audio-graph-card.
But all other sound nodes for rk3328 have already been defined by
simple-audio-card. In this time, I chose for consistent sound nodes.

[DMA allocation problem]

After this patch is applied, UART2 will fail to allocate DMA resources
but UART driver can work fine without DMA.

This error is related to the DMAC of rk3328 (pl330 or compatible).
DMAC connected to 16 DMA sources. Each sources have ID number that is
called 'Req number' in rk3328 TRM. After this patch is applied total 7
of DMA sources will be activated as follows:

| Req number | Source | Required  |
|            |        | channels  |
|------------+--------+-----------|
|  8,  9     | SPI0   | 2ch       |
| 11, 12     | I2S0   | 2ch       |
| 14, 15     | I2S1   | 2ch       |
|     10     | SPDIF  | 1ch       |
|------------+--------+-----------|
|            | Total  | 7ch       |
|------------+--------+-----------|
|  6,  7     | UART2  | 2ch       | -> cannot get DMA channels

Due to rk3328 DMAC specification we can use max 8 channels at same
time. If SPI0/I2S0/I2S1/SPDIF will be activated by this patch,
required DMAC channels reach to 7. So the last two channels (for
UART2) cannot get DMA resources.

Virt-dma mechanism for pl0330 DMAC driver is needed to fix this
problem.

Signed-off-by: Katsuhiro Suzuki <katsuhiro@katsuster.net>
---
 .../arm64/boot/dts/rockchip/rk3328-rock64.dts | 56 ++++++++-----------
 1 file changed, 24 insertions(+), 32 deletions(-)

diff --git a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
index 86cfb5c50a94..c984662043da 100644
--- a/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
+++ b/arch/arm64/boot/dts/rockchip/rk3328-rock64.dts
@@ -84,34 +84,32 @@ standby_led: led-1 {
 		};
 	};
 
-	sound {
-		compatible = "audio-graph-card";
-		label = "rockchip,rk3328";
-		dais = <&i2s1_p0
-			&spdif_p0>;
+	spdif_sound: spdif-sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "SPDIF";
+
+		simple-audio-card,cpu {
+			sound-dai = <&spdif>;
+		};
+
+		simple-audio-card,codec {
+			sound-dai = <&spdif_dit>;
+		};
 	};
 
-	spdif-dit {
+	spdif_dit: spdif-dit {
 		compatible = "linux,spdif-dit";
 		#sound-dai-cells = <0>;
-
-		port {
-			dit_p0_0: endpoint {
-				remote-endpoint = <&spdif_p0_0>;
-			};
-		};
 	};
 };
 
+&analog_sound {
+	status = "okay";
+};
+
 &codec {
 	mute-gpios = <&grf_gpio 0 GPIO_ACTIVE_LOW>;
 	status = "okay";
-
-	port@0 {
-		codec_p0_0: endpoint {
-			remote-endpoint = <&i2s1_p0_0>;
-		};
-	};
 };
 
 &cpu0 {
@@ -163,6 +161,10 @@ &hdmi {
 	status = "okay";
 };
 
+&hdmi_sound {
+	status = "okay";
+};
+
 &hdmiphy {
 	status = "okay";
 };
@@ -278,16 +280,12 @@ regulator-state-mem {
 	};
 };
 
-&i2s1 {
+&i2s0 {
 	status = "okay";
+};
 
-	i2s1_p0: port {
-		i2s1_p0_0: endpoint {
-			dai-format = "i2s";
-			mclk-fs = <256>;
-			remote-endpoint = <&codec_p0_0>;
-		};
-	};
+&i2s1 {
+	status = "okay";
 };
 
 &io_domains {
@@ -337,12 +335,6 @@ &sdmmc {
 &spdif {
 	pinctrl-0 = <&spdifm0_tx>;
 	status = "okay";
-
-	spdif_p0: port {
-		spdif_p0_0: endpoint {
-			remote-endpoint = <&dit_p0_0>;
-		};
-	};
 };
 
 &spi0 {
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64
  2020-08-02 15:42 [PATCH v2] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64 Katsuhiro Suzuki
@ 2020-08-30 19:16 ` Heiko Stuebner
  2020-08-31  1:26   ` Katsuhiro Suzuki
  2021-01-09 15:39 ` Heiko Stuebner
  1 sibling, 1 reply; 5+ messages in thread
From: Heiko Stuebner @ 2020-08-30 19:16 UTC (permalink / raw)
  To: Katsuhiro Suzuki
  Cc: linux-rockchip, linux-arm-kernel, linux-kernel, Katsuhiro Suzuki

Hi,

Am Sonntag, 2. August 2020, 17:42:31 CEST schrieb Katsuhiro Suzuki:
> This patch enables HDMI sound (I2S0) and Analog sound (I2S1) which
> are defined in rk3328.dtsi, and replace SPDIF nodes.
> 
> We can use SPDIF pass-through with suitable ALSA settings and on
> mpv or other media players.
>   - Settings: https://github.com/LibreELEC/LibreELEC.tv/blob/master/projects/Rockchip/filesystem/usr/share/alsa/cards/SPDIF.conf
>   - Ex.: mpv foo.ac3 --audio-spdif=ac3 --audio-device='alsa/SPDIF.pcm.iec958.0:SPDIF'
> 
> [Why use simple-audio-card for SPDIF?]
> 
> For newly adding nodes, ASoC guys recommend to use audio-graph-card.
> But all other sound nodes for rk3328 have already been defined by
> simple-audio-card. In this time, I chose for consistent sound nodes.
> 
> [DMA allocation problem]
> 
> After this patch is applied, UART2 will fail to allocate DMA resources
> but UART driver can work fine without DMA.
> 
> This error is related to the DMAC of rk3328 (pl330 or compatible).
> DMAC connected to 16 DMA sources. Each sources have ID number that is
> called 'Req number' in rk3328 TRM. After this patch is applied total 7
> of DMA sources will be activated as follows:
> 
> | Req number | Source | Required  |
> |            |        | channels  |
> |------------+--------+-----------|
> |  8,  9     | SPI0   | 2ch       |
> | 11, 12     | I2S0   | 2ch       |
> | 14, 15     | I2S1   | 2ch       |
> |     10     | SPDIF  | 1ch       |
> |------------+--------+-----------|
> |            | Total  | 7ch       |
> |------------+--------+-----------|
> |  6,  7     | UART2  | 2ch       | -> cannot get DMA channels
> 
> Due to rk3328 DMAC specification we can use max 8 channels at same
> time. If SPI0/I2S0/I2S1/SPDIF will be activated by this patch,
> required DMAC channels reach to 7. So the last two channels (for
> UART2) cannot get DMA resources.

Wouldn't the dma allocation depend on the probe ordering?
Or is this predetermined, so that always uart2 looses its dmas?

Heiko




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64
  2020-08-30 19:16 ` Heiko Stuebner
@ 2020-08-31  1:26   ` Katsuhiro Suzuki
  2020-09-01 12:25     ` Robin Murphy
  0 siblings, 1 reply; 5+ messages in thread
From: Katsuhiro Suzuki @ 2020-08-31  1:26 UTC (permalink / raw)
  To: Heiko Stuebner; +Cc: linux-rockchip, linux-arm-kernel, linux-kernel

On 2020/08/31 4:16, Heiko Stuebner wrote:
> Hi,
> 
> Am Sonntag, 2. August 2020, 17:42:31 CEST schrieb Katsuhiro Suzuki:
>> This patch enables HDMI sound (I2S0) and Analog sound (I2S1) which
>> are defined in rk3328.dtsi, and replace SPDIF nodes.
>>
>> We can use SPDIF pass-through with suitable ALSA settings and on
>> mpv or other media players.
>>    - Settings: https://github.com/LibreELEC/LibreELEC.tv/blob/master/projects/Rockchip/filesystem/usr/share/alsa/cards/SPDIF.conf
>>    - Ex.: mpv foo.ac3 --audio-spdif=ac3 --audio-device='alsa/SPDIF.pcm.iec958.0:SPDIF'
>>
>> [Why use simple-audio-card for SPDIF?]
>>
>> For newly adding nodes, ASoC guys recommend to use audio-graph-card.
>> But all other sound nodes for rk3328 have already been defined by
>> simple-audio-card. In this time, I chose for consistent sound nodes.
>>
>> [DMA allocation problem]
>>
>> After this patch is applied, UART2 will fail to allocate DMA resources
>> but UART driver can work fine without DMA.
>>
>> This error is related to the DMAC of rk3328 (pl330 or compatible).
>> DMAC connected to 16 DMA sources. Each sources have ID number that is
>> called 'Req number' in rk3328 TRM. After this patch is applied total 7
>> of DMA sources will be activated as follows:
>>
>> | Req number | Source | Required  |
>> |            |        | channels  |
>> |------------+--------+-----------|
>> |  8,  9     | SPI0   | 2ch       |
>> | 11, 12     | I2S0   | 2ch       |
>> | 14, 15     | I2S1   | 2ch       |
>> |     10     | SPDIF  | 1ch       |
>> |------------+--------+-----------|
>> |            | Total  | 7ch       |
>> |------------+--------+-----------|
>> |  6,  7     | UART2  | 2ch       | -> cannot get DMA channels
>>
>> Due to rk3328 DMAC specification we can use max 8 channels at same
>> time. If SPI0/I2S0/I2S1/SPDIF will be activated by this patch,
>> required DMAC channels reach to 7. So the last two channels (for
>> UART2) cannot get DMA resources.
> 
> Wouldn't the dma allocation depend on the probe ordering?
> Or is this predetermined, so that always uart2 looses its dmas?
> 

Ah, it's depends on probe ordering when users use kernel modules...

It's better to disable DMA channels for UART2 for avoiding problem.
I'll fix and resend patch.


> Heiko
> 
> 
> 

Best Regards,
Katsuhiro Suzuki

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64
  2020-08-31  1:26   ` Katsuhiro Suzuki
@ 2020-09-01 12:25     ` Robin Murphy
  0 siblings, 0 replies; 5+ messages in thread
From: Robin Murphy @ 2020-09-01 12:25 UTC (permalink / raw)
  To: Katsuhiro Suzuki, Heiko Stuebner
  Cc: linux-rockchip, linux-kernel, linux-arm-kernel

On 2020-08-31 02:26, Katsuhiro Suzuki wrote:
> On 2020/08/31 4:16, Heiko Stuebner wrote:
>> Hi,
>>
>> Am Sonntag, 2. August 2020, 17:42:31 CEST schrieb Katsuhiro Suzuki:
>>> This patch enables HDMI sound (I2S0) and Analog sound (I2S1) which
>>> are defined in rk3328.dtsi, and replace SPDIF nodes.
>>>
>>> We can use SPDIF pass-through with suitable ALSA settings and on
>>> mpv or other media players.
>>>    - Settings: 
>>> https://github.com/LibreELEC/LibreELEC.tv/blob/master/projects/Rockchip/filesystem/usr/share/alsa/cards/SPDIF.conf 
>>>
>>>    - Ex.: mpv foo.ac3 --audio-spdif=ac3 
>>> --audio-device='alsa/SPDIF.pcm.iec958.0:SPDIF'
>>>
>>> [Why use simple-audio-card for SPDIF?]
>>>
>>> For newly adding nodes, ASoC guys recommend to use audio-graph-card.
>>> But all other sound nodes for rk3328 have already been defined by
>>> simple-audio-card. In this time, I chose for consistent sound nodes.
>>>
>>> [DMA allocation problem]
>>>
>>> After this patch is applied, UART2 will fail to allocate DMA resources
>>> but UART driver can work fine without DMA.
>>>
>>> This error is related to the DMAC of rk3328 (pl330 or compatible).
>>> DMAC connected to 16 DMA sources. Each sources have ID number that is
>>> called 'Req number' in rk3328 TRM. After this patch is applied total 7
>>> of DMA sources will be activated as follows:
>>>
>>> | Req number | Source | Required  |
>>> |            |        | channels  |
>>> |------------+--------+-----------|
>>> |  8,  9     | SPI0   | 2ch       |
>>> | 11, 12     | I2S0   | 2ch       |
>>> | 14, 15     | I2S1   | 2ch       |
>>> |     10     | SPDIF  | 1ch       |
>>> |------------+--------+-----------|
>>> |            | Total  | 7ch       |
>>> |------------+--------+-----------|
>>> |  6,  7     | UART2  | 2ch       | -> cannot get DMA channels
>>>
>>> Due to rk3328 DMAC specification we can use max 8 channels at same
>>> time. If SPI0/I2S0/I2S1/SPDIF will be activated by this patch,
>>> required DMAC channels reach to 7. So the last two channels (for
>>> UART2) cannot get DMA resources.
>>
>> Wouldn't the dma allocation depend on the probe ordering?
>> Or is this predetermined, so that always uart2 looses its dmas?
>>
> 
> Ah, it's depends on probe ordering when users use kernel modules...
> 
> It's better to disable DMA channels for UART2 for avoiding problem.
> I'll fix and resend patch.

FWIW it seems that since 089b6d365491, DMA is effectively disabled for 
UART2 anyway (unless the user goes out of their way to repurpose it), so 
maybe this is no longer such an immediate concern?

Robin.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64
  2020-08-02 15:42 [PATCH v2] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64 Katsuhiro Suzuki
  2020-08-30 19:16 ` Heiko Stuebner
@ 2021-01-09 15:39 ` Heiko Stuebner
  1 sibling, 0 replies; 5+ messages in thread
From: Heiko Stuebner @ 2021-01-09 15:39 UTC (permalink / raw)
  To: Katsuhiro Suzuki
  Cc: Heiko Stuebner, linux-rockchip, linux-kernel, linux-arm-kernel

On Mon, 3 Aug 2020 00:42:31 +0900, Katsuhiro Suzuki wrote:
> This patch enables HDMI sound (I2S0) and Analog sound (I2S1) which
> are defined in rk3328.dtsi, and replace SPDIF nodes.
> 
> We can use SPDIF pass-through with suitable ALSA settings and on
> mpv or other media players.
>   - Settings: https://github.com/LibreELEC/LibreELEC.tv/blob/master/projects/Rockchip/filesystem/usr/share/alsa/cards/SPDIF.conf
>   - Ex.: mpv foo.ac3 --audio-spdif=ac3 --audio-device='alsa/SPDIF.pcm.iec958.0:SPDIF'
> 
> [...]

Applied, thanks!

[1/1] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64
      commit: 25572fb5aa986bdbb35d06c0fb52a9b9d9b3b2c9

Best regards,
-- 
Heiko Stuebner <heiko@sntech.de>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-09 15:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-02 15:42 [PATCH v2] arm64: dts: rockchip: enable HDMI sound nodes for rk3328-rock64 Katsuhiro Suzuki
2020-08-30 19:16 ` Heiko Stuebner
2020-08-31  1:26   ` Katsuhiro Suzuki
2020-09-01 12:25     ` Robin Murphy
2021-01-09 15:39 ` Heiko Stuebner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).