Skip to contentSkip to conversation

Enable wm8524 on i.MX8MQ-EVK

PATCH Superseded Daniel Baluta 4 participants 14 messages Feb 27, 2019 – Mar 8, 2019

Subsystems (3)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover Enable wm8524 on i.MX8MQ-EVK

On i.MX8MQ-EVK we can start the party using the wm8524 codec which gets it's data through the SAI2 interface.

In order to make it work this patch series enables the SDMA nodes, sets the correct pinctrl configuration and uses the simple card machine driver to put everything together.

Changes since v3:
- use "arm64: dts: imx8mq-evk" prefix for patches specific to 8MQ-EVK
- squash together patches for setting up SAI (previous 3/5 and 4/5)
- add back and document "fsl, imx8mq-sdma" compatbile string

Changes since v2:
- s/QM/MQ after Chris comments

Changes since v1:
- added cover letter
- remove "fsl,imx8mq-sdma" compatible for sdma.

Daniel Baluta (5):
arm64: dts: imx8mq: Add SDMA nodes
bindings: fsl-imx-sdma: Document fsl,imx8mq-sdma compatbile string
arm64: dts: imx8mq: Add SAI2 node
arm64: dts: imx8mq-evk: Enable SAI2 node
arm64: dts: imx8mq-evk: Enable wm8524 codec

 .../devicetree/bindings/dma/fsl-imx-sdma.txt  |  1 +
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts  | 48 +++++++++++++++++++
 arch/arm64/boot/dts/freescale/imx8mq.dtsi     | 38 +++++++++++++++
 3 files changed, 87 insertions(+)
Signature · 1 line
2.17.1
#1 lore raw

PATCH v4 1/5 arm64: dts: imx8mq: Add SDMA nodes

SDMA1 is part of AIPS-3 region and SDMA2 is part
of AIPS-1 region.

[initial submit in i.MX internal tree]
[adaptation for linux-next]
---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
arch/arm64/boot/dts/freescale/imx8mq.dtsi +22 -0
index 9155bd4784eb..9d48450453fb 100644
@@ -234,6 +234,17 @@
 				status = "disabled";
 			};
 
+			sdma2: sdma@302c0000 {
+				compatible = "fsl,imx8mq-sdma","fsl,imx7d-sdma";
+				reg = <0x302c0000 0x10000>;
+				interrupts = <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MQ_CLK_SDMA2_ROOT>,
+					 <&clk IMX8MQ_CLK_SDMA2_ROOT>;
+				clock-names = "ipg", "ahb";
+				#dma-cells = <3>;
+				fsl,sdma-ram-script-name = "imx/sdma/sdma-imx7d.bin";
+			};
+
 			iomuxc: iomuxc@30330000 {
 				compatible = "fsl,imx8mq-iomuxc";
 				reg = <0x30330000 0x10000>;
@@ -575,6 +586,17 @@
 				status = "disabled";
 			};
 
+			sdma1: sdma@30bd0000 {
+				compatible = "fsl, imx8mq-sdma","fsl,imx7d-sdma";
+				reg = <0x30bd0000 0x10000>;
+				interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MQ_CLK_SDMA1_ROOT>,
+					 <&clk IMX8MQ_CLK_SDMA1_ROOT>;
+				clock-names = "ipg", "ahb";
+				#dma-cells = <3>;
+				fsl,sdma-ram-script-name = "imx/sdma/sdma-imx7d.bin";
+			};
+
 			fec1: ethernet@30be0000 {
 				compatible = "fsl,imx8mq-fec", "fsl,imx6sx-fec";
 				reg = <0x30be0000 0x10000>;
Signature · 1 line
2.17.1
#3 lore raw

PATCH v4 2/5 bindings: fsl-imx-sdma: Document fsl,imx8mq-sdma compatbile string

In reply to Daniel Baluta

Add imx8mq sdma support.

---
 Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/dma/fsl-imx-sdma.txt +1 -0
index 3c9a57a8443b..9d8bbac27d8b 100644
@@ -9,6 +9,7 @@ Required properties:
       "fsl,imx53-sdma"
       "fsl,imx6q-sdma"
       "fsl,imx7d-sdma"
+      "fsl,imx8mq-sdma"
   The -to variants should be preferred since they allow to determine the
   correct ROM script addresses needed for the driver to work without additional
   firmware.
Signature · 1 line
2.17.1
#5 lore raw

PATCH v4 3/5 arm64: dts: imx8mq: Add SAI2 node

In reply to Daniel Baluta

SAI2 is part of AIPS-3 memory region.

---
 arch/arm64/boot/dts/freescale/imx8mq.dtsi | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
arch/arm64/boot/dts/freescale/imx8mq.dtsi +16 -0
index 9d48450453fb..565f4175e73b 100644
@@ -489,6 +489,22 @@
 				status = "disabled";
 			};
 
+			sai2: sai@308b0000 {
+				#sound-dai-cells = <0>;
+				compatible = "fsl,imx8mq-sai",
+					     "fsl,imx6sx-sai";
+				reg = <0x308b0000 0x10000>;
+				interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+				clocks = <&clk IMX8MQ_CLK_SAI2_IPG>,
+					 <&clk IMX8MQ_CLK_DUMMY>,
+					 <&clk IMX8MQ_CLK_SAI2_ROOT>,
+					 <&clk IMX8MQ_CLK_DUMMY>, <&clk IMX8MQ_CLK_DUMMY>;
+				clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
+				dmas = <&sdma1 10 24 0>, <&sdma1 11 24 0>;
+				dma-names = "rx", "tx";
+				status = "disabled";
+			};
+
 			i2c1: i2c@30a20000 {
 				compatible = "fsl,imx8mq-i2c", "fsl,imx21-i2c";
 				reg = <0x30a20000 0x10000>;
Signature · 1 line
2.17.1
#8 lore raw

PATCH v4 4/5 arm64: dts: imx8mq-evk: Enable SAI2 node

In reply to Daniel Baluta

This sets up clock hierarchy and pin configuration.

Use PLL1 to derive a proper rate for playing files with a rate multiple of 8000.

---
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
arch/arm64/boot/dts/freescale/imx8mq-evk.dts +19 -0
index 54737bf1772f..58de4a3d6029 100644
@@ -52,6 +52,15 @@
 	};
 };
 
+&sai2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_sai2>;
+	assigned-clocks = <&clk IMX8MQ_CLK_SAI2>;
+	assigned-clock-parents = <&clk IMX8MQ_AUDIO_PLL1_OUT>;
+	assigned-clock-rates = <24576000>;
+	status = "okay";
+};
+
 &i2c1 {
 	clock-frequency = <100000>;
 	pinctrl-names = "default";
@@ -223,6 +232,16 @@
 		>;
 	};
 
+	pinctrl_sai2: sai2grp {
+		fsl,pins = <
+			MX8MQ_IOMUXC_SAI2_TXFS_SAI2_TX_SYNC     0xd6
+			MX8MQ_IOMUXC_SAI2_TXC_SAI2_TX_BCLK      0xd6
+			MX8MQ_IOMUXC_SAI2_MCLK_SAI2_MCLK        0xd6
+			MX8MQ_IOMUXC_SAI2_TXD0_SAI2_TX_DATA0    0xd6
+			MX8MQ_IOMUXC_GPIO1_IO08_GPIO1_IO8       0xd6
+		>;
+	};
+
 	pinctrl_i2c1: i2c1grp {
 		fsl,pins = <
 			MX8MQ_IOMUXC_I2C1_SCL_I2C1_SCL			0x4000007f
Signature · 1 line
2.17.1
#9 lore raw

PATCH v4 5/5 arm64: dts: imx8mq-evk: Enable wm8524 codec

In reply to Daniel Baluta

This uses simple-audio-card machine driver adding 1 CPU DAI and 1 Codec DAI.

---
 arch/arm64/boot/dts/freescale/imx8mq-evk.dts | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
arch/arm64/boot/dts/freescale/imx8mq-evk.dts +29 -0
index 58de4a3d6029..77f590c13ee0 100644
@@ -31,6 +31,35 @@
 		gpio = <&gpio2 19 GPIO_ACTIVE_HIGH>;
 		enable-active-high;
 	};
+
+	wm8524: audio-codec-0 {
+		#sound-dai-cells = <0>;
+		compatible = "wlf,wm8524";
+		clocks = <&clk IMX8MQ_CLK_SAI2_ROOT>;
+		clock-names = "mclk";
+		wlf,mute-gpios = <&gpio1 8 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 = <&sai2>;
+		};
+		link_codec: simple-audio-card,codec {
+			sound-dai = <&wm8524>;
+			clocks = <&clk IMX8MQ_CLK_SAI2_ROOT>;
+		};
+	};
 };
 
 &fec1 {
Signature · 1 line
2.17.1
reviewer
#6 lore raw

Re: [PATCH v4 3/5] arm64: dts: imx8mq: Add SAI2 node

In reply to Daniel Baluta

arch/arm64/boot/dts/freescale/imx8mq.dtsi line 502

Quoted 11 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mq.dtsi +11 -0
+                       sai2: sai@308b0000 {
+                               #sound-dai-cells = <0>;
+                               compatible = "fsl,imx8mq-sai",
+                                            "fsl,imx6sx-sai";
+                               reg = <0x308b0000 0x10000>;
+                               interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+                               clocks = <&clk IMX8MQ_CLK_SAI2_IPG>,
+                                        <&clk IMX8MQ_CLK_DUMMY>,
+                                        <&clk IMX8MQ_CLK_SAI2_ROOT>,
+                                        <&clk IMX8MQ_CLK_DUMMY>, <&clk IMX8MQ_CLK_DUMMY>;
+                               clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";

mclk0 is not a valid entry as per the binding doc.

reviewer
#10 lore raw

Re: [PATCH v4 5/5] arm64: dts: imx8mq-evk: Enable wm8524 codec

In reply to Daniel Baluta

arch/arm64/boot/dts/freescale/imx8mq-evk.dts line 35

Quoted 2 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mq-evk.dts +2 -0
+
+       wm8524: audio-codec-0 {

This -0 is not needed as we have a single codec on this board.

arch/arm64/boot/dts/freescale/imx8mq-evk.dts line 39

Quoted 4 lines
arch/arm64/boot/dts/freescale/imx8mq-evk.dts +4 -0
+               #sound-dai-cells = <0>;
+               compatible = "wlf,wm8524";
+               clocks = <&clk IMX8MQ_CLK_SAI2_ROOT>;
+               clock-names = "mclk";

The clocks and clock-names properties can be removed, right?

I don't see them defined in the binding doc and the codec driver does not call clk_get(), so there is a mismatch.

Also, I still think this one and the previous patch could be made into a single patch that adds audio support for the board.

#7 lore raw

Re: [PATCH v4 3/5] arm64: dts: imx8mq: Add SAI2 node

In reply to Fabio Estevam
Quoted 15 lines · Fabio Estevam

arch/arm64/boot/dts/freescale/imx8mq.dtsi line 502

Quoted 11 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mq.dtsi +11 -0
+                       sai2: sai@308b0000 {
+                               #sound-dai-cells = <0>;
+                               compatible = "fsl,imx8mq-sai",
+                                            "fsl,imx6sx-sai";
+                               reg = <0x308b0000 0x10000>;
+                               interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+                               clocks = <&clk IMX8MQ_CLK_SAI2_IPG>,
+                                        <&clk IMX8MQ_CLK_DUMMY>,
+                                        <&clk IMX8MQ_CLK_SAI2_ROOT>,
+                                        <&clk IMX8MQ_CLK_DUMMY>, <&clk IMX8MQ_CLK_DUMMY>;
+                               clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
Quoted 1 line

mclk0 is not a valid entry as per the binding doc.

Indeed, will fix in next version. mclk0 is valid in our internal tree because fsl_sai.c supports it.
Will remove mclk0 for now and re-add it when I will upstream the SAI patch.

Thanks Fabio for review!

#11 lore raw

Re: [PATCH v4 5/5] arm64: dts: imx8mq-evk: Enable wm8524 codec

In reply to Fabio Estevam
Quoted 7 lines · Fabio Estevam

arch/arm64/boot/dts/freescale/imx8mq-evk.dts line 35

Quoted 2 lines · Daniel Baluta
arch/arm64/boot/dts/freescale/imx8mq-evk.dts +2 -0
+
+       wm8524: audio-codec-0 {

This -0 is not needed as we have a single codec on this board.

Ok, will fix.

Quoted 10 lines

arch/arm64/boot/dts/freescale/imx8mq-evk.dts line 39

Quoted 5 lines
arch/arm64/boot/dts/freescale/imx8mq-evk.dts +4 -0
+               #sound-dai-cells = <0>;
+               compatible = "wlf,wm8524";
+               clocks = <&clk IMX8MQ_CLK_SAI2_ROOT>;
+               clock-names = "mclk";

The clocks and clock-names properties can be removed, right?

I don't see them defined in the binding doc and the codec driver does not call clk_get(), so there is a mismatch.

They are used by simple-card.c machine driver.

asoc_simple_card_parse_clk
-> /* Parse dai->sysclk come from "clocks = <&xxx>" */ clk = devm_get_clk_from_child(dev, node, NULL);

Quoted 3 lines

Also, I still think this one and the previous patch could be made into a single patch that adds audio support for the board.

Ok.

reviewer
#12 lore raw

Re: [PATCH v4 5/5] arm64: dts: imx8mq-evk: Enable wm8524 codec

Hi Daniel,

Quoted 5 lines · Daniel Baluta

They are used by simple-card.c machine driver.

asoc_simple_card_parse_clk
-> /* Parse dai->sysclk come from "clocks = <&xxx>" */ clk = devm_get_clk_from_child(dev, node, NULL);

The simple-card looks for the "clocks" properties inside the simple-card node, not inside the codec node, right?

#13 lore raw

Re: [PATCH v4 5/5] arm64: dts: imx8mq-evk: Enable wm8524 codec

Quoted 5 lines · Fabio Estevam

Hi Daniel,

On Fri, Mar 1, 2019 at 12:53 PM Daniel Baluta <[email protected]> wrote:

Quoted 8 lines
Quoted 5 lines

They are used by simple-card.c machine driver.

asoc_simple_card_parse_clk
-> /* Parse dai->sysclk come from "clocks = <&xxx>" */ clk = devm_get_clk_from_child(dev, node, NULL);

The simple-card looks for the "clocks" properties inside the simple-card node, not inside the codec node, right?

I see your point now.

Indeed, "clocks" properties is the one inside simple-card.

   sound-wm8524 {
               compatible = "simple-audio-card";
               link_codec: simple-audio-card,codec {
                       sound-dai = <&wm8524>;
                       clocks = <&clk IMX8MQ_CLK_SAI2_ROOT>;

Will remove them from wm8524: audio-codec node because they are useless there.

thanks,
Daniel.