Skip to contentSkip to conversation

arm64: dts: imx8mm-beacon: Enable Digitial Microphone

PATCH New Adam Ford 3 participants 12 messages Jul 17, 2022 – Mar 2, 2023

Subsystems (2)
lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH 1/1 arm64: dts: imx8mm-beacon: Enable Digitial Microphone

There is a PDM microphone port on the baseboard which is connected to the micfil controller. Create a new sound card to support this interface.

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +30 -1
index 03266bd90a06..16444954f873 100644
@@ -98,7 +98,7 @@ reg_usdhc2_vmmc: regulator-usdhc2 {
 		enable-active-high;
 	};
 
-	sound {
+	sound-codec {
 		compatible = "fsl,imx-audio-wm8962";
 		model = "wm8962-audio";
 		audio-cpu = <&sai3>;
@@ -111,6 +111,18 @@ sound {
 			"AMIC", "MICBIAS",
 			"IN3R", "AMIC";
 	};
+
+	sound-micfil {
+		compatible = "fsl,imx-audio-card";
+		model = "imx-audio-micfil";
+		pri-dai-link {
+			link-name = "micfil hifi";
+			format = "i2s";
+			cpu {
+				sound-dai = <&micfil>;
+			};
+		};
+	};
 };
 
 &csi {
@@ -215,6 +227,16 @@ pca6416_1: gpio@21 {
 	};
 };
 
+&micfil {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_pdm>;
+	assigned-clocks = <&clk IMX8MM_CLK_PDM>;
+	assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
+	assigned-clock-rates = <196608000>;
+	#sound-dai-cells = <0>;
+	status = "okay";
+};
+
 &mipi_csi {
 	status = "okay";
 	ports {
@@ -354,6 +376,13 @@ MX8MM_IOMUXC_SAI2_MCLK_GPIO4_IO27		0x19
 		>;
 	};
 
+	pinctrl_pdm: pdmgrp {
+		fsl,pins = <
+			MX8MM_IOMUXC_SAI5_RXC_PDM_CLK		0xd6
+			MX8MM_IOMUXC_SAI5_RXD0_PDM_DATA0	0xd6
+		>;
+	};
+
 	pinctrl_reg_usb_otg1: usbotg1grp {
 		fsl,pins = <
 			MX8MM_IOMUXC_SAI3_RXC_GPIO4_IO29     0x19
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/6 arm64: dts: imx8mn-beacon: Enable Digitial Microphone

There is a PDM microphone on the baseboard which is connected to the micfil controller. Create a new sound card to support this interface.

arch/arm64/boot/dts/freescale/imx8mn-beacon-baseboard.dtsi +30 -1
index 9e82069c941f..fa66cc9bf455 100644
@@ -63,7 +63,7 @@ reg_usb_otg_vbus: regulator-usb {
 		enable-active-high;
 	};
 
-	sound {
+	sound-codec {
 		compatible = "fsl,imx-audio-wm8962";
 		model = "wm8962-audio";
 		audio-cpu = <&sai3>;
@@ -76,6 +76,18 @@ sound {
 			"AMIC", "MICBIAS",
 			"IN3R", "AMIC";
 	};
+
+	sound-micfil {
+		compatible = "fsl,imx-audio-card";
+		model = "imx-audio-micfil";
+		pri-dai-link {
+			link-name = "micfil hifi";
+			format = "i2s";
+			cpu {
+				sound-dai = <&micfil>;
+			};
+		};
+	};
 };
 
 &ecspi2 {
@@ -150,6 +162,16 @@ &easrc {
 	status = "okay";
 };
 
+&micfil {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_pdm>;
+	assigned-clocks = <&clk IMX8MN_CLK_PDM>;
+	assigned-clock-parents = <&clk IMX8MN_AUDIO_PLL1_OUT>;
+	assigned-clock-rates = <196608000>;
+	status = "okay";
+	#sound-dai-cells = <0>;
+};
+
 &sai3 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_sai3>;
@@ -232,6 +254,13 @@ MX8MN_IOMUXC_SAI2_MCLK_GPIO4_IO27		0x19
 		>;
 	};
 
+	pinctrl_pdm: pdmgrp {
+		fsl,pins = <
+			MX8MN_IOMUXC_SAI5_RXC_PDM_CLK	0xd6
+			MX8MN_IOMUXC_SAI5_RXD0_PDM_BIT_STREAM0	0xd6
+		>;
+	};
+
 	pinctrl_reg_usb_otg: reg-otggrp {
 		fsl,pins = <
 			MX8MN_IOMUXC_SAI3_RXC_GPIO4_IO29     0x19
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/6] arm64: dts: imx8mn-beacon: Enable Digitial Microphone

Hello Adam,

arch/arm64/boot/dts/freescale/imx8mn-beacon-baseboard.dtsi sound { · line 85

Quoted 7 lines · Adam Ford
arch/arm64/boot/dts/freescale/imx8mn-beacon-baseboard.dtsi +7 -0
+
+	sound-micfil {
+		compatible = "fsl,imx-audio-card";
+		model = "imx-audio-micfil";
+		pri-dai-link {
+			link-name = "micfil hifi";
+			format = "i2s";

Given that MICFIL and mic speak PDM with each other, is i2s the correct format here?

Cheers,
Ahmad

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#3 lore raw

Re: [PATCH 1/6] arm64: dts: imx8mn-beacon: Enable Digitial Microphone

Quoted 12 lines · Ahmad Fatoum

Hello Adam,

arch/arm64/boot/dts/freescale/imx8mn-beacon-baseboard.dtsi sound { · line 85

Quoted 7 lines · Adam Ford
arch/arm64/boot/dts/freescale/imx8mn-beacon-baseboard.dtsi +7 -0
+
+     sound-micfil {
+             compatible = "fsl,imx-audio-card";
+             model = "imx-audio-micfil";
+             pri-dai-link {
+                     link-name = "micfil hifi";
+                     format = "i2s";
Quoted 2 lines

Given that MICFIL and mic speak PDM with each other, is i2s the correct format here?

I was basing this off some references from some NXP stuff in their downstream kernel. I know the audio I record with the PDM microphone worked and sounded like I expected when I tested it.

adam

Quoted 9 lines

Cheers,
Ahmad

--

Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#4 lore raw

PATCH 2/6 arm64: dts: imx8mn-beacon: Enable SPDIF Sound card

In reply to Adam Ford

Add a sound card to support SPDIF since the imx8mn-beacon baseboard can support it.

arch/arm64/boot/dts/freescale/imx8mn-beacon-baseboard.dtsi +32 -0
index fa66cc9bf455..224845d24b64 100644
@@ -88,6 +88,14 @@ cpu {
 			};
 		};
 	};
+
+	sound-spdif {
+		compatible = "fsl,imx-audio-spdif";
+		model = "imx-spdif";
+		spdif-controller = <&spdif1>;
+		spdif-out;
+		spdif-in;
+	};
 };
 
 &ecspi2 {
@@ -186,6 +194,23 @@ &snvs_pwrkey {
 	status = "okay";
 };
 
+&spdif1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_spdif1>;
+	assigned-clocks = <&clk IMX8MN_CLK_SPDIF1>;
+	assigned-clock-parents = <&clk IMX8MN_AUDIO_PLL1_OUT>;
+	assigned-clock-rates = <24576000>;
+	clocks = <&clk IMX8MN_CLK_AUDIO_AHB>, <&clk IMX8MN_CLK_24M>,
+		<&clk IMX8MN_CLK_SPDIF1>, <&clk IMX8MN_CLK_DUMMY>,
+		<&clk IMX8MN_CLK_DUMMY>, <&clk IMX8MN_CLK_DUMMY>,
+		<&clk IMX8MN_CLK_AUDIO_AHB>, <&clk IMX8MN_CLK_DUMMY>,
+		<&clk IMX8MN_CLK_DUMMY>, <&clk IMX8MN_CLK_DUMMY>,
+		<&clk IMX8MN_AUDIO_PLL1_OUT>, <&clk IMX8MN_AUDIO_PLL2_OUT>;
+	clock-names = "core", "rxtx0", "rxtx1", "rxtx2", "rxtx3",
+		"rxtx4", "rxtx5", "rxtx6", "rxtx7", "spba", "pll8k", "pll11k";
+	status = "okay";
+};
+
 &uart2 { /* console */
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_uart2>;
@@ -277,6 +302,13 @@ MX8MN_IOMUXC_SAI3_RXD_SAI3_RX_DATA0	0xd6
 		>;
 	};
 
+	pinctrl_spdif1: spdif1grp {
+		fsl,pins = <
+			MX8MN_IOMUXC_SPDIF_TX_SPDIF1_OUT	0xd6
+			MX8MN_IOMUXC_SPDIF_RX_SPDIF1_IN	0xd6
+		>;
+	};
+
 	pinctrl_uart2: uart2grp {
 		fsl,pins = <
 			MX8MN_IOMUXC_UART2_RXD_UART2_DCE_RX	0x140
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH 3/6 arm64: dts: Associate easrc to the audio CODEC

In reply to Adam Ford

There is a wm8962 Audio codec already enabled, and the EASRC is also enabled, but there is nothing connecting them to each other. Set audio-asrc to point to easrc.

arch/arm64/boot/dts/freescale/imx8mn-beacon-baseboard.dtsi +1 -0
index 224845d24b64..f31ba1101a1d 100644
@@ -67,6 +67,7 @@ sound-codec {
 		compatible = "fsl,imx-audio-wm8962";
 		model = "wm8962-audio";
 		audio-cpu = <&sai3>;
+		audio-asrc = <&easrc>;
 		audio-codec = <&wm8962>;
 		audio-routing =
 			"Headphone Jack", "HPOUTL",
Signature · 1 line
2.34.1
author
#6 lore raw

PATCH 4/6 arm64: dts: imx8mm-beacon: Enable Digitial Microphone

In reply to Adam Ford

There is a PDM microphone port on the baseboard which is connected to the micfil controller. Create a new sound card to support this interface.

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +30 -1
index 03266bd90a06..16444954f873 100644
@@ -98,7 +98,7 @@ reg_usdhc2_vmmc: regulator-usdhc2 {
 		enable-active-high;
 	};
 
-	sound {
+	sound-codec {
 		compatible = "fsl,imx-audio-wm8962";
 		model = "wm8962-audio";
 		audio-cpu = <&sai3>;
@@ -111,6 +111,18 @@ sound {
 			"AMIC", "MICBIAS",
 			"IN3R", "AMIC";
 	};
+
+	sound-micfil {
+		compatible = "fsl,imx-audio-card";
+		model = "imx-audio-micfil";
+		pri-dai-link {
+			link-name = "micfil hifi";
+			format = "i2s";
+			cpu {
+				sound-dai = <&micfil>;
+			};
+		};
+	};
 };
 
 &csi {
@@ -215,6 +227,16 @@ pca6416_1: gpio@21 {
 	};
 };
 
+&micfil {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_pdm>;
+	assigned-clocks = <&clk IMX8MM_CLK_PDM>;
+	assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
+	assigned-clock-rates = <196608000>;
+	#sound-dai-cells = <0>;
+	status = "okay";
+};
+
 &mipi_csi {
 	status = "okay";
 	ports {
@@ -354,6 +376,13 @@ MX8MM_IOMUXC_SAI2_MCLK_GPIO4_IO27		0x19
 		>;
 	};
 
+	pinctrl_pdm: pdmgrp {
+		fsl,pins = <
+			MX8MM_IOMUXC_SAI5_RXC_PDM_CLK		0xd6
+			MX8MM_IOMUXC_SAI5_RXD0_PDM_DATA0	0xd6
+		>;
+	};
+
 	pinctrl_reg_usb_otg1: usbotg1grp {
 		fsl,pins = <
 			MX8MM_IOMUXC_SAI3_RXC_GPIO4_IO29     0x19
Signature · 1 line
2.34.1
maintainer
#7 lore raw

Hi Adam,

Quoted 24 lines · Adam Ford

There is a PDM microphone port on the baseboard which is connected to the micfil controller. Create a new sound card to support this interface.

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +3 -1
index 03266bd90a06..16444954f873 100644
@@ -98,7 +98,7 @@ reg_usdhc2_vmmc: regulator-usdhc2 {
 		enable-active-high;
 	};
 
-	sound {
+	sound-codec {
 		compatible = "fsl,imx-audio-wm8962";
 		model = "wm8962-audio";
 		audio-cpu = <&sai3>;
@@ -111,6 +111,18 @@ sound {
 			"AMIC", "MICBIAS",
 			"IN3R", "AMIC";
 	};
+
+	sound-micfil {

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi sound { · line 125

Quoted 10 lines
arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +10 -0
+		compatible = "fsl,imx-audio-card";
+		model = "imx-audio-micfil";
+		pri-dai-link {
+			link-name = "micfil hifi";
+			format = "i2s";
+			cpu {
+				sound-dai = <&micfil>;
+			};
+		};
+	};

Note the micfil works well with the simple-audio-card driver which might be an alternative here.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#8 lore raw
Quoted 33 lines · Sascha Hauer

Hi Adam,

Quoted 29 lines · Adam Ford

There is a PDM microphone port on the baseboard which is connected to the micfil controller. Create a new sound card to support this interface.

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +8 -1
index 03266bd90a06..16444954f873 100644
@@ -98,7 +98,7 @@ reg_usdhc2_vmmc: regulator-usdhc2 {
              enable-active-high;
      };
 
-     sound {
+     sound-codec {
              compatible = "fsl,imx-audio-wm8962";
              model = "wm8962-audio";
              audio-cpu = <&sai3>;
@@ -111,6 +111,18 @@ sound {
                      "AMIC", "MICBIAS",
                      "IN3R", "AMIC";
      };
+
+     sound-micfil {
+             compatible = "fsl,imx-audio-card";
+             model = "imx-audio-micfil";
+             pri-dai-link {
+                     link-name = "micfil hifi";
+                     format = "i2s";
Quoted 8 lines

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi sound { · line 125

Quoted 5 lines
arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +5 -0
+                     cpu {
+                             sound-dai = <&micfil>;
+                     };
+             };
+     };

Note the micfil works well with the simple-audio-card driver which might be an alternative here.

I'll respin it with that and try it. If it works we should be able to drop the last patch enabling the imx-audio-card module.

adam

Quoted 8 lines

Sascha

--

Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#9 lore raw
In reply to Sascha Hauer
Quoted 33 lines · Sascha Hauer

Hi Adam,

Quoted 29 lines · Adam Ford

There is a PDM microphone port on the baseboard which is connected to the micfil controller. Create a new sound card to support this interface.

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +8 -1
index 03266bd90a06..16444954f873 100644
@@ -98,7 +98,7 @@ reg_usdhc2_vmmc: regulator-usdhc2 {
              enable-active-high;
      };
 
-     sound {
+     sound-codec {
              compatible = "fsl,imx-audio-wm8962";
              model = "wm8962-audio";
              audio-cpu = <&sai3>;
@@ -111,6 +111,18 @@ sound {
                      "AMIC", "MICBIAS",
                      "IN3R", "AMIC";
      };
+
+     sound-micfil {
+             compatible = "fsl,imx-audio-card";
+             model = "imx-audio-micfil";
+             pri-dai-link {
+                     link-name = "micfil hifi";
+                     format = "i2s";
Quoted 8 lines

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi sound { · line 125

Quoted 5 lines
arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +5 -0
+                     cpu {
+                             sound-dai = <&micfil>;
+                     };
+             };
+     };

Note the micfil works well with the simple-audio-card driver which might be an alternative here.

Sascha,

Sorry to resurrect an old thread.

I tried using the simple-audio-card, but it doesn't present me with an audio card. I don't get errors, but I don't get a card either. Can you point me to an example where someone did this? I added debug code to the simple-audio-card and I migrated an existing card, and I see the debug code for the wm8962 CODEC, but not the micfil. The Micfil works just fine with the imx-audio-card, but I don't mind using the simple-audio-card if it makes more sense.

adam

Quoted 8 lines

Sascha

--

Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
author
#10 lore raw

PATCH 5/6 arm64: dts: imx8mm-beacon: Enable SPDIF Sound card

In reply to Adam Ford

Add a sound card to support SPDIF since the imx8mn-beacon baseboard can support it.

arch/arm64/boot/dts/freescale/imx8mm-beacon-baseboard.dtsi +33 -0
index 16444954f873..c41359c74c50 100644
@@ -123,6 +123,14 @@ cpu {
 			};
 		};
 	};
+
+	sound-spdif {
+		compatible = "fsl,imx-audio-spdif";
+		model = "imx-spdif";
+		spdif-controller = <&spdif1>;
+		spdif-out;
+		spdif-in;
+	};
 };
 
 &csi {
@@ -289,6 +297,23 @@ &snvs_pwrkey {
 	status = "okay";
 };
 
+&spdif1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_spdif1>;
+	assigned-clocks = <&clk IMX8MM_CLK_SPDIF1>;
+	assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
+	assigned-clock-rates = <24576000>;
+	clocks = <&clk IMX8MM_CLK_AUDIO_AHB>, <&clk IMX8MM_CLK_24M>,
+		<&clk IMX8MM_CLK_SPDIF1>, <&clk IMX8MM_CLK_DUMMY>,
+		<&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>,
+		<&clk IMX8MM_CLK_AUDIO_AHB>, <&clk IMX8MM_CLK_DUMMY>,
+		<&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>,
+		<&clk IMX8MM_AUDIO_PLL1_OUT>, <&clk IMX8MM_AUDIO_PLL2_OUT>;
+	clock-names = "core", "rxtx0", "rxtx1", "rxtx2", "rxtx3",
+		"rxtx4", "rxtx5", "rxtx6", "rxtx7", "spba", "pll8k", "pll11k";
+	status = "okay";
+};
+
 &uart2 { /* console */
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_uart2>;
@@ -405,6 +430,14 @@ MX8MM_IOMUXC_SAI3_RXD_SAI3_RX_DATA0	0xd6
 		>;
 	};
 
+	pinctrl_spdif1: spdif1grp {
+		fsl,pins = <
+			MX8MM_IOMUXC_SPDIF_TX_SPDIF1_OUT	0xd6
+			MX8MM_IOMUXC_SPDIF_RX_SPDIF1_IN		0xd6
+			MX8MM_IOMUXC_SPDIF_EXT_CLK_SPDIF1_EXT_CLK	0xd6
+		>;
+	};
+
 	pinctrl_uart2: uart2grp {
 		fsl,pins = <
 			MX8MM_IOMUXC_UART2_RXD_UART2_DCE_RX	0x140
Signature · 1 line
2.34.1
author
#11 lore raw

PATCH 6/6 arm64: defconfig: Enable imx-audio-card

In reply to Adam Ford

Both the imx8mm-beacon and imx8mn-beacon kits have a PDM microphone port. The PDM is used with micfil driver, and that is associated to imx-audio-card, but that is not currently enabled by default. Enable it as a module.

arch/arm64/configs/defconfig +1 -0
index d3ad1cb2f5eb..2a824590811b 100644
@@ -792,6 +792,7 @@ CONFIG_SND_SOC_IMX_SGTL5000=m
 CONFIG_SND_SOC_IMX_SPDIF=m
 CONFIG_SND_SOC_FSL_ASOC_CARD=m
 CONFIG_SND_SOC_IMX_AUDMIX=m
+CONFIG_SND_SOC_IMX_CARD=m
 CONFIG_SND_MESON_AXG_SOUND_CARD=m
 CONFIG_SND_MESON_GX_SOUND_CARD=m
 CONFIG_SND_SOC_QCOM=m
Signature · 1 line
2.34.1