Skip to contentSkip to conversation

ASoC: fsl-asoc-card: add S/PDIF controller support

PATCH Applied Elinor Montmasson 2 participants 4 messages Aug 20, 2024 – Sep 1, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v7 cover ASoC: fsl-asoc-card: add S/PDIF controller support

Hello,

This is the v7 of the series of patches aiming to make the machine driver 'fsl-asoc-card' compatible with S/PDIF controllers on imx boards.

The core of the contribution was merged with v6 of the series. v7 fixes the order of properties for new nodes in device-trees so that compatible is first in the list as recommended.

These two patches update all in-tree device-trees to use the new 'fsl-asoc-card' properties.
Note that as the old properties are still supported by fsl-asoc-card:
- previous versions of in-tree device-trees are still supported.
- out-of-tree device-trees are still supported.

This series of patches was successfully built for arm64 and x86 on top of the latest "for-next" branch of the ASoC git tree on the 19th of August 2024.
These modifications have also been tested on an i.MX8MN evaluation board with a linux kernel RT v6.1.26-rt8.

Best regards,
Elinor Montmasson

Changelog:
v6 -> v7:
- Changed the order of properties in new device-tree spdif-in/out nodes, so that compatible is first.
- v6 patch series at:
https://lore.kernel.org/all/[email protected]/

v5 -> v6:
- Remove applied patch "ASoC: fsl-asoc-card: set priv->pdev before using it".
- Add backward compatibility with imx-spdif DT properties.
- Squash removal of imx-spdif.yaml into patch updating fsl-asoc-card.yaml.
- fsl-asoc-card.yaml: fix indentation, document use of compatible "fsl,imx-audio-spdif" only with "fsl,imx-sabreauto-spdif" or "fsl,imx6sx-sdb-spdif".
- Explain better in commit messages why there are new DT properties that can be used with "fsl,imx-audio-spdif" and what are the benefits to use them.
- v5 patch series at:
https://lore.kernel.org/all/[email protected]/

v4 -> v5:
- Focus the contribution to bringing S/PDIF / ASRC support.
- Instead of creating a new compatible for the S/PDIF fsl-asoc-card support, merge the driver imx-spdif into fsl-asoc-card, and keep the compatible. It preserves the base S/PDIF audio card support but also extends it with the possibility to use an ASRC. It also reduces code and driver duplication.
- Following driver merge, adapt device trees using "fsl,imx-audio-spdif" compatible.
- Use more for_each_codecs macros in fsl-asoc-card when adding multi-codec support.
- Remove patches about new device-tree bindings that were not relevant for an S/PDIF specific support.
- Improve DT schema changes.
- Move priv->pdev assignment earlier in "fsl_asoc_card_probe()" to fix a NULL pointer dereference in "fsl_asoc_card_audmux_init()".
- v4 patch series at:
https://lore.kernel.org/all/[email protected]/

v3 -> v4:
- Use the standard TDM bidings, as defined in "tdm-slot.txt", for the new optional DT bindings setting the TDM slots number and width.
- Use the clock DT bindings to optionally specify the CPU DAI system clock frequency, instead of a dedicated new binding.
- Rename the new DT binding "cpu-sysclk-dir-out" to "cpu-system-clock-direction-out" to better follow the style of the simple-card driver.
- Merge TX an RX bindings for CPU DAI system-clock, to better follow the style of the simple-card driver, and also as there was no use case in fsl-asoc-card where TX and RX settings had to be different.
- Add the documentation for the new bindings in the new DT schema bindings documentation. Also add an example with the generic codec.
- v3 patch series at:
https://lore.kernel.org/alsa-devel/[email protected]/

v2 -> v3:
- When the bitmaster or framemaster are retrieved from the device tree, the driver will now compare them with the two codecs possibly given in
device tree, and not just the first codec.
- Improve driver modifications to use multiple codecs for better integration of future multi-codec use cases:
* Use for_each_codec macros when possible.
* fsl_asoc_card_priv struct now has 2 codec_priv as the driver
* can currently retrieve 2 codec phandles from the device tree.
- Fix subject of patch 10/10 to follow the style of the subsystem
- v2 patch series at:
https://lore.kernel.org/alsa-devel/[email protected]/

v1 -> v2:
- Replace use of the dummy codec by the pair of codecs spdif_receiver / spdif_transmitter.
- Adapt how dai links codecs are used to take into account the possibility for multiple codecs per link.
- Change compatible name.
- Adapt driver to be able to register two codecs given in the device tree.
- v1 patch series at:
https://lore.kernel.org/alsa-devel/[email protected]/

Elinor Montmasson (2):
arm64: dts: imx8m: update spdif sound card node properties
ARM: dts: imx6: update spdif sound card node properties

 arch/arm/boot/dts/nxp/imx/imx6q-cm-fx6.dts    | 15 +++++++++---
 arch/arm/boot/dts/nxp/imx/imx6q-prti6q.dts    | 15 +++++++++---
 arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts   |  9 +++++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-apalis.dtsi | 15 +++++++++---
 .../arm/boot/dts/nxp/imx/imx6qdl-apf6dev.dtsi |  9 +++++--
 .../arm/boot/dts/nxp/imx/imx6qdl-colibri.dtsi | 15 +++++++++---
 .../arm/boot/dts/nxp/imx/imx6qdl-cubox-i.dtsi |  9 +++++--
 .../dts/nxp/imx/imx6qdl-hummingboard.dtsi     |  9 +++++--
 .../boot/dts/nxp/imx/imx6qdl-sabreauto.dtsi   |  9 +++++--
 .../boot/dts/nxp/imx/imx6qdl-wandboard.dtsi   |  9 +++++--
 .../arm/boot/dts/nxp/imx/imx6sx-sabreauto.dts |  9 +++++--
 arch/arm/boot/dts/nxp/imx/imx6sx-sdb.dtsi     |  9 +++++--
 arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi | 15 +++++++++---
 arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi | 15 +++++++++---
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts  | 24 +++++++++++++++----
 15 files changed, 147 insertions(+), 39 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v7 1/2 arm64: dts: imx8m: update spdif sound card node properties

The merge of imx-spdif driver into fsl-asoc-card brought new DT properties that can be used with the "fsl,imx-audio-spdif" compatible:
* The "spdif-controller" property from imx-spdif is named "audio-cpu" in fsl-asoc-card.
* fsl-asoc-card uses codecs explicitly declared in DT
with "audio-codec".
With an S/PDIF, codec drivers spdif_transmitter and spdif_receiver should be used.
Driver imx-spdif used instead the dummy codec and a pair of boolean properties, "spdif-in" and "spdif-out".

While backward compatibility is kept to support properties "spdif-controller", "spdif-in" and "spdif-out", using new properties has several benefits:
* "audio-cpu" and "audio-codec" are more generic names reflecting that the fsl-asoc-card driver supports multiple hardware. They are properties already used by devices using the fsl-asoc-card driver.
They are also similar to properties of simple-card: "cpu" and "codec".
* "spdif-in" and "spdif-out" imply the use of the dummy codec in the driver. However, there are already two codec drivers for the S/PDIF, spdif_transmitter and spdif_receiver.
It is better to declare S/PDIF Tx and Rx devices in a DT, and then reference them with "audio-codec" than using the dummy codec.

For those reasons, this commit updates in-tree DTs to use the new properties:
* Rename "spdif-controller" property to "audio-cpu".
* Declare S/PDIF transmitter and/or receiver devices, and use them with the "audio-codec" property instead of "spdif-out" and/or "spdif-in".

These modifications were tested only on an imx8mn-evk board.

Note that out-of-tree and old DTs are still supported.

---
 arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi | 15 +++++++++---
 arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi | 15 +++++++++---
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts  | 24 +++++++++++++++----
 3 files changed, 43 insertions(+), 11 deletions(-)
arch/arm64/boot/dts/freescale/imx8mm-evk.dtsi +12 -3
index 930e14fec423..5f8336217bb8 100644
@@ -180,12 +180,21 @@ cpu {
 		};
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif1>;
-		spdif-out;
-		spdif-in;
+		audio-cpu = <&spdif1>;
+		audio-codec = <&spdif_out>, <&spdif_in>;
 	};
 };
 
arch/arm64/boot/dts/freescale/imx8mn-evk.dtsi +12 -3
index 9e0259ddf4bc..33d73f3dc187 100644
@@ -124,12 +124,21 @@ sound-wm8524 {
 			"Line Out Jack", "LINEVOUTR";
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif1>;
-		spdif-out;
-		spdif-in;
+		audio-cpu = <&spdif1>;
+		audio-codec = <&spdif_out>, <&spdif_in>;
 	};
 
 	sound-micfil {
arch/arm64/boot/dts/freescale/imx8mq-evk.dts +19 -5
index 7507548cdb16..a87d0692c3bb 100644
@@ -125,19 +125,33 @@ link_codec: simple-audio-card,codec {
 		};
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif1>;
-		spdif-out;
-		spdif-in;
+		audio-cpu = <&spdif1>;
+		audio-codec = <&spdif_out>, <&spdif_in>;
+	};
+
+	hdmi_arc_in: hdmi-arc-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
 	};
 
 	sound-hdmi-arc {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-hdmi-arc";
-		spdif-controller = <&spdif2>;
-		spdif-in;
+		audio-cpu = <&spdif2>;
+		audio-codec = <&hdmi_arc_in>;
 	};
 };
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH v7 2/2 ARM: dts: imx6: update spdif sound card node properties

In reply to Elinor Montmasson

The merge of imx-spdif driver into fsl-asoc-card brought new DT properties that can be used with the "fsl,imx-audio-spdif" compatible:
* The "spdif-controller" property from imx-spdif is named "audio-cpu" in fsl-asoc-card.
* fsl-asoc-card uses codecs explicitly declared in DT
with "audio-codec".
With an S/PDIF, codec drivers spdif_transmitter and spdif_receiver should be used.
Driver imx-spdif used instead the dummy codec and a pair of boolean properties, "spdif-in" and "spdif-out".

While backward compatibility is kept to support properties "spdif-controller", "spdif-in" and "spdif-out", using new properties has several benefits:
* "audio-cpu" and "audio-codec" are more generic names reflecting that the fsl-asoc-card driver supports multiple hardware. They are properties already used by devices using the fsl-asoc-card driver.
They are also similar to properties of simple-card: "cpu" and "codec".
* "spdif-in" and "spdif-out" imply the use of the dummy codec in the driver. However, there are already two codec drivers for the S/PDIF, spdif_transmitter and spdif_receiver.
It is better to declare S/PDIF Tx and Rx devices in a DT, and then reference them with "audio-codec" than using the dummy codec.

For those reasons, this commit updates in-tree DTs to use the new properties:
* Rename "spdif-controller" property to "audio-cpu".
* Declare S/PDIF transmitter and/or receiver devices, and use them with the "audio-codec" property instead of "spdif-out" and/or "spdif-in".

These modifications were tested only on an imx8mn-evk board.

Note that out-of-tree and old DTs are still supported.

---
 arch/arm/boot/dts/nxp/imx/imx6q-cm-fx6.dts        | 15 ++++++++++++---
 arch/arm/boot/dts/nxp/imx/imx6q-prti6q.dts        | 15 ++++++++++++---
 arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts       |  9 +++++++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-apalis.dtsi     | 15 ++++++++++++---
 arch/arm/boot/dts/nxp/imx/imx6qdl-apf6dev.dtsi    |  9 +++++++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-colibri.dtsi    | 15 ++++++++++++---
 arch/arm/boot/dts/nxp/imx/imx6qdl-cubox-i.dtsi    |  9 +++++++--
 .../boot/dts/nxp/imx/imx6qdl-hummingboard.dtsi    |  9 +++++++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-sabreauto.dtsi  |  9 +++++++--
 arch/arm/boot/dts/nxp/imx/imx6qdl-wandboard.dtsi  |  9 +++++++--
 arch/arm/boot/dts/nxp/imx/imx6sx-sabreauto.dts    |  9 +++++++--
 arch/arm/boot/dts/nxp/imx/imx6sx-sdb.dtsi         |  9 +++++++--
 12 files changed, 104 insertions(+), 28 deletions(-)
arch/arm/boot/dts/nxp/imx/imx6q-cm-fx6.dts +12 -3
index 95b49fc83f7b..299106fbe51c 100644
@@ -127,12 +127,21 @@ simple-audio-card,codec {
 		};
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif>;
-		spdif-out;
-		spdif-in;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>, <&spdif_in>;
 	};
 };
 
arch/arm/boot/dts/nxp/imx/imx6q-prti6q.dts +12 -3
index a7d5693c5ab7..8d2b608e0b90 100644
@@ -111,12 +111,21 @@ simple-audio-card,codec {
 		};
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif>;
-		spdif-in;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>, <&spdif_in>;
 	};
 };
 
arch/arm/boot/dts/nxp/imx/imx6q-tbs2910.dts +7 -2
index 7c298d9aa21e..5353a0c24420 100644
@@ -90,11 +90,16 @@ sound-sgtl5000 {
 		ssi-controller = <&ssi1>;
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "On-board SPDIF";
-		spdif-controller = <&spdif>;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>;
 	};
 };
 
arch/arm/boot/dts/nxp/imx/imx6qdl-apalis.dtsi +12 -3
index ea40623d12e5..edf55760a5c1 100644
@@ -197,11 +197,20 @@ sound {
 		ssi-controller = <&ssi1>;
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	sound_spdif: sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
-		spdif-controller = <&spdif>;
-		spdif-in;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>, <&spdif_in>;
 		model = "imx-spdif";
 		status = "disabled";
 	};
arch/arm/boot/dts/nxp/imx/imx6qdl-apf6dev.dtsi +7 -2
index 3a46ade3b6bd..9e97ef5e43f2 100644
@@ -121,11 +121,16 @@ sound {
 		mux-ext-port = <3>;
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif>;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>;
 	};
 };
 
arch/arm/boot/dts/nxp/imx/imx6qdl-colibri.dtsi +12 -3
index d3a7a6eeb8e0..b01670cdd52c 100644
@@ -142,12 +142,21 @@ sound {
 		ssi-controller = <&ssi1>;
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	/* Optional S/PDIF in on SODIMM 88 and out on SODIMM 90, 137 or 168 */
 	sound_spdif: sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
-		spdif-controller = <&spdif>;
-		spdif-in;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>, <&spdif_in>;
 		model = "imx-spdif";
 		status = "disabled";
 	};
arch/arm/boot/dts/nxp/imx/imx6qdl-cubox-i.dtsi +7 -2
index 761566ae3cf5..bd66430c1d78 100644
@@ -100,12 +100,17 @@ v_usb1: regulator-v-usb1 {
 		vin-supply = <&v_5v0>;
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "Integrated SPDIF";
 		/* IMX6 doesn't implement this yet */
-		spdif-controller = <&spdif>;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>;
 	};
 
 	gpio-keys {
arch/arm/boot/dts/nxp/imx/imx6qdl-hummingboard.dtsi +7 -2
index a955c77cd499..d1ad65ab6b72 100644
@@ -140,12 +140,17 @@ sound_codec: simple-audio-card,codec {
 		};
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "On-board SPDIF";
 		/* IMX6 doesn't implement this yet */
-		spdif-controller = <&spdif>;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>;
 	};
 };
 
arch/arm/boot/dts/nxp/imx/imx6qdl-sabreauto.dtsi +7 -2
index 0a3deaf92eea..55fb7b904220 100644
@@ -143,12 +143,17 @@ sound-cs42888 {
 			"AIN2R", "Line In Jack";
 	};
 
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-sabreauto-spdif",
 			     "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif>;
-		spdif-in;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_in>;
 	};
 
 	backlight {
arch/arm/boot/dts/nxp/imx/imx6qdl-wandboard.dtsi +7 -2
index 38abb6b50f6c..7130b9c3b3aa 100644
@@ -26,11 +26,16 @@ sound {
 		mux-ext-port = <3>;
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif>;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>;
 	};
 
 	reg_1p5v: regulator-1p5v {
arch/arm/boot/dts/nxp/imx/imx6sx-sabreauto.dts +7 -2
index b0c27b9b0244..dfbfb8119bf3 100644
@@ -97,11 +97,16 @@ sound-cs42888 {
 			"AIN2R", "Line In Jack";
 	};
 
+	spdif_in: spdif-in {
+		compatible = "linux,spdif-dir";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif>;
-		spdif-in;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_in>;
 	};
 };
 
arch/arm/boot/dts/nxp/imx/imx6sx-sdb.dtsi +7 -2
index 7d4170c27732..277a6e039045 100644
@@ -183,12 +183,17 @@ panel_in: endpoint {
 		};
 	};
 
+	spdif_out: spdif-out {
+		compatible = "linux,spdif-dit";
+		#sound-dai-cells = <0>;
+	};
+
 	sound-spdif {
 		compatible = "fsl,imx6sx-sdb-spdif",
 			     "fsl,imx-audio-spdif";
 		model = "imx-spdif";
-		spdif-controller = <&spdif>;
-		spdif-out;
+		audio-cpu = <&spdif>;
+		audio-codec = <&spdif_out>;
 	};
 
 };
Signature · 1 line
2.34.1
Applied
#3 lore raw
In reply to Elinor Montmasson
Quoted 3 lines · Elinor Montmasson

Elinor Montmasson (2):
arm64: dts: imx8m: update spdif sound card node properties
ARM: dts: imx6: update spdif sound card node properties

Applied both, thanks!