Skip to contentSkip to conversation

Enable wm8524 codec on i.MX8MM EVK

PATCH RESEND Applied Daniel Baluta 4 participants 13 messages May 15, 2019 – May 31, 2019

Subsystems (2)

v3 of 4 Applied Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover Enable wm8524 codec on i.MX8MM EVK

This patch series introduces the SAI nodes on i.MX8MM EVK then creates the wm8524 codec node and finally uses simple card machine driver to create a sound card.

Changes since v2:
- place compatible strings one a single lines
- move GPIO pinctrl in a node of its own
- remove codec phandle

Changes since v1:
- use "fsl,imx8mm-sai", "fsl,imx8mq-sai" compatbile strings and remove "fsl,imx6sx-sai" because SAI module on i.MX8M is not compatbile with SAI modules form i.MX6

RESEND to fix email encoding.

Daniel Baluta (2):
arm64: dts: imx8mm: Add SAI nodes
arm64: dts: imx8mm-evk: Enable audio codec wm8524

 arch/arm64/boot/dts/freescale/imx8mm-evk.dts | 55 ++++++++++++++++
 arch/arm64/boot/dts/freescale/imx8mm.dtsi    | 66 ++++++++++++++++++++
 2 files changed, 121 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v3 1/2 arm64: dts: imx8mm: Add SAI nodes

i.MX8MM has 5 SAI instances with the following base addresses according to RM.

SAI1 base address: 3001_0000h
SAI2 base address: 3002_0000h
SAI3 base address: 3003_0000h
SAI5 base address: 3005_0000h
SAI6 base address: 3006_0000h

---
 arch/arm64/boot/dts/freescale/imx8mm.dtsi | 66 +++++++++++++++++++++++
 1 file changed, 66 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm.dtsi +66 -0
index 6b407a94c06e..52abe2d03f31 100644
@@ -201,6 +201,72 @@
 			#size-cells = <1>;
 			ranges;
 
+			sai1: sai@30010000 {
+				compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
+				reg = <0x30010000 0x10000>;
+				interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MM_CLK_SAI1_IPG>,
+					 <&clk IMX8MM_CLK_SAI1_ROOT>,
+					 <&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>;
+				clock-names = "bus", "mclk1", "mclk2", "mclk3";
+				dmas = <&sdma2 0 2 0>, <&sdma2 1 2 0>;
+				dma-names = "rx", "tx";
+				status = "disabled";
+			};
+
+			sai2: sai@30020000 {
+				compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
+				reg = <0x30020000 0x10000>;
+				interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MM_CLK_SAI2_IPG>,
+					<&clk IMX8MM_CLK_SAI2_ROOT>,
+					<&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>;
+				clock-names = "bus", "mclk1", "mclk2", "mclk3";
+				dmas = <&sdma2 2 2 0>, <&sdma2 3 2 0>;
+				dma-names = "rx", "tx";
+				status = "disabled";
+			};
+
+			sai3: sai@30030000 {
+				#sound-dai-cells = <0>;
+				compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
+				reg = <0x30030000 0x10000>;
+				interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MM_CLK_SAI3_IPG>,
+					 <&clk IMX8MM_CLK_SAI3_ROOT>,
+					 <&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>;
+				clock-names = "bus", "mclk1", "mclk2", "mclk3";
+				dmas = <&sdma2 4 2 0>, <&sdma2 5 2 0>;
+				dma-names = "rx", "tx";
+				status = "disabled";
+			};
+
+			sai5: sai@30050000 {
+				compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
+				reg = <0x30050000 0x10000>;
+				interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MM_CLK_SAI5_IPG>,
+					 <&clk IMX8MM_CLK_SAI5_ROOT>,
+					 <&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>;
+				clock-names = "bus", "mclk1", "mclk2", "mclk3";
+				dmas = <&sdma2 8 2 0>, <&sdma2 9 2 0>;
+				dma-names = "rx", "tx";
+				status = "disabled";
+			};
+
+			sai6: sai@30060000 {
+				compatible = "fsl,imx8mm-sai", "fsl,imx8mq-sai";
+				reg = <0x30060000 0x10000>;
+				interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MM_CLK_SAI6_IPG>,
+					 <&clk IMX8MM_CLK_SAI6_ROOT>,
+					 <&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>;
+				clock-names = "bus", "mclk1", "mclk2", "mclk3";
+				dmas = <&sdma2 10 2 0>, <&sdma2 11 2 0>;
+				dma-names = "rx", "tx";
+				status = "disabled";
+			};
+
 			gpio1: gpio@30200000 {
 				compatible = "fsl,imx8mm-gpio", "fsl,imx35-gpio";
 				reg = <0x30200000 0x10000>;
Signature · 1 line
2.17.1
reviewer
#2 lore raw

Re: [PATCH v3 1/2] arm64: dts: imx8mm: Add SAI nodes

Hi Daniel,

Quoted 9 lines · Daniel Baluta

i.MX8MM has 5 SAI instances with the following base addresses according to RM.

SAI1 base address: 3001_0000h
SAI2 base address: 3002_0000h
SAI3 base address: 3003_0000h
SAI5 base address: 3005_0000h
SAI6 base address: 3006_0000h

No SAI4?

I know the RM does not show the SAI4 in the memory map, but the clock driver does show a SAI4 clock gate.

So it seems we have a contradiction in the reference manual. Could you please double check with the internal folks?

reviewer Reviewed-by
#3 lore raw

Re: [PATCH v3 1/2] arm64: dts: imx8mm: Add SAI nodes

Quoted 14 lines · Fabio Estevam

Hi Daniel,

Quoted 9 lines · Daniel Baluta

i.MX8MM has 5 SAI instances with the following base addresses according to RM.

SAI1 base address: 3001_0000h
SAI2 base address: 3002_0000h
SAI3 base address: 3003_0000h
SAI5 base address: 3005_0000h
SAI6 base address: 3006_0000h

Quoted 7 lines

No SAI4?

I know the RM does not show the SAI4 in the memory map, but the clock driver does show a SAI4 clock gate.

So it seems we have a contradiction in the reference manual. Could you please double check with the internal folks?

Despite the SAI4 confusion, the current patch correctly describe the SAI interfaces as per the Reference Manual, so:

Applied
#4 lore raw

Re: [PATCH v3 1/2] arm64: dts: imx8mm: Add SAI nodes

In reply to Daniel Baluta
Quoted 10 lines · Daniel Baluta

i.MX8MM has 5 SAI instances with the following base addresses according to RM.

SAI1 base address: 3001_0000h
SAI2 base address: 3002_0000h
SAI3 base address: 3003_0000h
SAI5 base address: 3005_0000h
SAI6 base address: 3006_0000h

Applied, thanks.

#5 lore raw

PATCH v3 2/2 arm64: dts: imx8mm-evk: Enable audio codec wm8524

In reply to Daniel Baluta

i.MX8MM has one wm8524 audio codec connected with
SAI3 digital audio interface.

This patch uses simple-card machine driver in order to enable wm8524 codec.

We need to set:
* SAI3 pinctrl configuration
* codec reset gpio pinctrl configuration
* clock hierarchy
* codec node
* simple-card configuration

---
 arch/arm64/boot/dts/freescale/imx8mm-evk.dts | 55 ++++++++++++++++++++
 1 file changed, 55 insertions(+)
arch/arm64/boot/dts/freescale/imx8mm-evk.dts +55 -0
index 2d5d89475b76..7c578d8762b9 100644
@@ -37,6 +37,37 @@
 		gpio = <&gpio2 19 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 	};
+
+	wm8524: audio-codec {
+		#sound-dai-cells = <0>;
+		compatible = "wlf,wm8524";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_gpio_wlf>;
+		wlf,mute-gpios = <&gpio5 21 GPIO_ACTIVE_LOW>;
+	};
+
+	sound-wm8524 {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "wm8524-audio";
+		simple-audio-card,format = "i2s";
+		simple-audio-card,frame-master = <&cpudai>;
+		simple-audio-card,bitclock-master = <&cpudai>;
+		simple-audio-card,widgets =
+			"Line", "Left Line Out Jack",
+			"Line", "Right Line Out Jack";
+		simple-audio-card,routing =
+			"Left Line Out Jack", "LINEVOUTL",
+			"Right Line Out Jack", "LINEVOUTR";
+
+		cpudai: simple-audio-card,cpu {
+			sound-dai = <&sai3>;
+		};
+
+		simple-audio-card,codec {
+			sound-dai = <&wm8524>;
+			clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
+		};
+	};
 };
 
 &fec1 {
@@ -61,6 +92,15 @@
 	};
 };
 
+&sai3 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_sai3>;
+	assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
+	assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
+	assigned-clock-rates = <24576000>;
+	status = "okay";
+};
+
 &uart2 { /* console */
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_uart2>;
@@ -124,12 +164,27 @@
 		>;
 	};
 
+	pinctrl_gpio_wlf: gpiowlfgrp {
+		fsl,pins = <
+			MX8MM_IOMUXC_I2C4_SDA_GPIO5_IO21        0xd6
+		>;
+	};
+
 	pinctrl_reg_usdhc2_vmmc: regusdhc2vmmc {
 		fsl,pins = <
 			MX8MM_IOMUXC_SD2_RESET_B_GPIO2_IO19	0x41
 		>;
 	};
 
+	pinctrl_sai3: sai3grp {
+		fsl,pins = <
+			MX8MM_IOMUXC_SAI3_TXFS_SAI3_TX_SYNC     0xd6
+			MX8MM_IOMUXC_SAI3_TXC_SAI3_TX_BCLK      0xd6
+			MX8MM_IOMUXC_SAI3_MCLK_SAI3_MCLK        0xd6
+			MX8MM_IOMUXC_SAI3_TXD_SAI3_TX_DATA0     0xd6
+		>;
+	};
+
 	pinctrl_uart2: uart2grp {
 		fsl,pins = <
 			MX8MM_IOMUXC_UART2_RXD_UART2_DCE_RX	0x140
Signature · 1 line
2.17.1
reviewer
#6 lore raw

Re: [PATCH v3 2/2] arm64: dts: imx8mm-evk: Enable audio codec wm8524

arch/arm64/boot/dts/freescale/imx8mm-evk.dts line 68

Quoted 3 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mm-evk.dts +3 -0
+               simple-audio-card,codec {
+                       sound-dai = <&wm8524>;
+                       clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;

IMX8MM_CLK_SAI3_ROOT is the internal clock that drives the SAI3 interface, not an external clock that feeds the codec.

It seems you should remove this 'clocks' entry.

#7 lore raw

Re: [PATCH v3 2/2] arm64: dts: imx8mm-evk: Enable audio codec wm8524

<reduce audience to linux-imx>

Shengjiu,

Can you help me with this? Specifically: I couldn't find the schematic showing the
exact connection pins between SAI and wm8524 codec.

I looked into our internal tree and the wm8524 codec always handles CLK_SAIX_ROOT
but Fabio has a good point. This clock doesn't feeds the codec.

Unless, we can really look into the schematics and prove it otherwise.

Quoted 11 lines · Fabio Estevam

arch/arm64/boot/dts/freescale/imx8mm-evk.dts line 68

Quoted 3 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mm-evk.dts +3 -0
+               simple-audio-card,codec {
+                       sound-dai = <&wm8524>;
+                       clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;

IMX8MM_CLK_SAI3_ROOT is the internal clock that drives the SAI3 interface, not an external clock that feeds the codec.

It seems you should remove this 'clocks' entry.

reviewer
#8 lore raw

Re: [PATCH v3 2/2] arm64: dts: imx8mm-evk: Enable audio codec wm8524

Quoted 9 lines · Daniel Baluta

<reduce audience to linux-imx>

Shengjiu,

Can you help me with this? Specifically: I couldn't find the schematic showing the
exact connection pins between SAI and wm8524 codec.

Quoted 5 lines

I looked into our internal tree and the wm8524 codec always handles CLK_SAIX_ROOT
but Fabio has a good point. This clock doesn't feeds the codec.

Unless, we can really look into the schematics and prove it otherwise.

Yes, I just checked and the devicetree patch is correct. Sorry for the confusion.

reviewer Reviewed-by
#9 lore raw

Re: [PATCH v3 2/2] arm64: dts: imx8mm-evk: Enable audio codec wm8524

In reply to Fabio Estevam
Quoted 11 lines · Fabio Estevam

arch/arm64/boot/dts/freescale/imx8mm-evk.dts line 68

Quoted 3 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mm-evk.dts +3 -0
+               simple-audio-card,codec {
+                       sound-dai = <&wm8524>;
+                       clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;

IMX8MM_CLK_SAI3_ROOT is the internal clock that drives the SAI3 interface, not an external clock that feeds the codec.

It seems you should remove this 'clocks' entry.

Just checked the schematics and the SAI3_MCLK pin clocks the codec, so the representation is correct:

#10 lore raw

Re: [PATCH v3 2/2] arm64: dts: imx8mm-evk: Enable audio codec wm8524

Quoted 12 lines · Fabio Estevam
Quoted 10 lines · Fabio Estevam

arch/arm64/boot/dts/freescale/imx8mm-evk.dts line 68

Quoted 3 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mm-evk.dts +3 -0
+               simple-audio-card,codec {
+                       sound-dai = <&wm8524>;
+                       clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;

IMX8MM_CLK_SAI3_ROOT is the internal clock that drives the SAI3 interface, not an external clock that feeds the codec.

Quoted 6 lines
Quoted 1 line

It seems you should remove this 'clocks' entry.

Just checked the schematics and the SAI3_MCLK pin clocks the codec, so the representation is correct:

Shawn,

Can you have a look?

#11 lore raw

Re: [PATCH v3 2/2] arm64: dts: imx8mm-evk: Enable audio codec wm8524

Quoted 15 lines · Daniel Baluta
Quoted 14 lines · Fabio Estevam
Quoted 11 lines · Fabio Estevam

arch/arm64/boot/dts/freescale/imx8mm-evk.dts line 68

Quoted 3 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mm-evk.dts +3 -0
+               simple-audio-card,codec {
+                       sound-dai = <&wm8524>;
+                       clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;

IMX8MM_CLK_SAI3_ROOT is the internal clock that drives the SAI3 interface, not an external clock that feeds the codec.

It seems you should remove this 'clocks' entry.

Quoted 8 lines
Quoted 4 lines

Just checked the schematics and the SAI3_MCLK pin clocks the codec, so the representation is correct:

Shawn,

Can you have a look?

I cannot apply this one, because there are '=20' in the patch content.

Shawn

#12 lore raw

Re: [PATCH v3 2/2] arm64: dts: imx8mm-evk: Enable audio codec wm8524

Quoted 19 lines · Shawn Guo
Quoted 18 lines · Daniel Baluta
Quoted 17 lines · Fabio Estevam
Quoted 11 lines · Fabio Estevam

arch/arm64/boot/dts/freescale/imx8mm-evk.dts line 68

Quoted 3 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mm-evk.dts +3 -0
+               simple-audio-card,codec {
+                       sound-dai = <&wm8524>;
+                       clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;

IMX8MM_CLK_SAI3_ROOT is the internal clock that drives the SAI3 interface, not an external clock that feeds the codec.

It seems you should remove this 'clocks' entry.

Just checked the schematics and the SAI3_MCLK pin clocks the codec, so the representation is correct:

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Shawn,

Can you have a look?

I cannot apply this one, because there are '=20' in the patch content.

Talk to NXP colleague Anson Huang <[email protected]> to find out how to fix it.

https://patchwork.kernel.org/patch/10944169/#22656941

Shawn