Skip to contentSkip to conversation

arm64: dts: librem5-devkit: Improve audio support

PATCH Applied Guido Günther 2 participants 8 messages Feb 21, 2021 – Mar 7, 2021

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

cover arm64: dts: librem5-devkit: Improve audio support

So far only headphone output worked. Thesse patches add support for the built in speaker and mic, allow a headset microphone to work and wire up jack detection so audio output can switch to headphones automatically. They also adjust the card name to match the board not the codec, similar what's done for the Librem 5.

Patches are against next-20210210 but also apply against Shawn's imx-dt64-5.12

Guido Günther (6):
arm64: dts: librem5-devkit: Use a less generic codec name
arm64: dts: librem5-devkit: Add speaker amplifier
arm64: dts: librem5-devkit: "Drop Line In Jack"
arm64: defconfig: Enable asoc simple mux
arm64: dts: librem5-devkit: Add mux for built-in vs headset mic
arm64: dts: librem5-devkit: Move headphone detection to sound card

 .../dts/freescale/imx8mq-librem5-devkit.dts   | 69 ++++++++++++++-----
 arch/arm64/configs/defconfig                  |  1 +
 2 files changed, 52 insertions(+), 18 deletions(-)
Signature · 1 line
2.30.0
#1 lore raw

PATCH 1/6 arm64: dts: librem5-devkit: Use a less generic codec name

The codec is currently named after the chip but it should be named like the device itself since otherwise it's impossible to distinguish it from other devices using the same codec (e.g. in alsa's UCM).

---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts +1 -1
index dd217a0760e9..0c0b12c90363 100644
@@ -165,7 +165,7 @@ wwan_codec: sound-wwan-codec {
 
 	sound {
 		compatible = "simple-audio-card";
-		simple-audio-card,name = "sgtl5000";
+		simple-audio-card,name = "Librem 5 Devkit";
 		simple-audio-card,format = "i2s";
 		simple-audio-card,widgets =
 			"Microphone", "Microphone Jack",
Signature · 1 line
2.30.0
#2 lore raw

PATCH 2/6 arm64: dts: librem5-devkit: Add speaker amplifier

In reply to Guido Günther

Wire up the amplifier that drives the builtin speaker.

---
 .../dts/freescale/imx8mq-librem5-devkit.dts   | 21 +++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts +19 -2
index 0c0b12c90363..d01bed5eb9e0 100644
@@ -165,19 +165,21 @@ wwan_codec: sound-wwan-codec {
 
 	sound {
 		compatible = "simple-audio-card";
+		simple-audio-card,aux-devs = <&speaker_amp>;
 		simple-audio-card,name = "Librem 5 Devkit";
 		simple-audio-card,format = "i2s";
 		simple-audio-card,widgets =
 			"Microphone", "Microphone Jack",
 			"Headphone", "Headphone Jack",
-			"Speaker", "Speaker Ext",
+			"Speaker", "Builtin Speaker",
 			"Line", "Line In Jack";
 		simple-audio-card,routing =
 			"MIC_IN", "Microphone Jack",
 			"Microphone Jack", "Mic Bias",
 			"LINE_IN", "Line In Jack",
 			"Headphone Jack", "HP_OUT",
-			"Speaker Ext", "LINE_OUT";
+			"Builtin Speaker", "Speaker Amp OUTR",
+			"Speaker Amp INR", "LINE_OUT";
 
 		simple-audio-card,cpu {
 			sound-dai = <&sai2>;
@@ -207,6 +209,15 @@ telephony_link_master: simple-audio-card,codec {
 		};
 	};
 
+	speaker_amp: speaker-amp {
+		compatible = "simple-audio-amplifier";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_spkamp>;
+		VCC-supply = <&reg_3v3_p>;
+		sound-name-prefix = "Speaker Amp";
+		enable-gpios = <&gpio5 3 GPIO_ACTIVE_HIGH>;
+	};
+
 	vibrator {
 		compatible = "gpio-vibrator";
 		pinctrl-names = "default";
@@ -641,6 +652,12 @@ MX8MQ_IOMUXC_SAI5_RXFS_GPIO3_IO19	0x8  /* IMU_INT */
 		>;
 	};
 
+	pinctrl_spkamp: spkamp {
+		fsl,pins = <
+			MX8MQ_IOMUXC_SPDIF_TX_GPIO5_IO3		0x81  /* MUTE */
+		>;
+	};
+
 	pinctrl_pmic: pmicgrp {
 		fsl,pins = <
 			MX8MQ_IOMUXC_GPIO1_IO03_GPIO1_IO3	0x80  /* PMIC intr */
Signature · 1 line
2.30.0
#3 lore raw

PATCH 3/6 arm64: dts: librem5-devkit: "Drop Line In Jack"

In reply to Guido Günther

The SGTL500s LINEINL and LINEINR are N/C.

---
 arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts +1 -3
index d01bed5eb9e0..aac05bbaa001 100644
@@ -171,12 +171,10 @@ sound {
 		simple-audio-card,widgets =
 			"Microphone", "Microphone Jack",
 			"Headphone", "Headphone Jack",
-			"Speaker", "Builtin Speaker",
-			"Line", "Line In Jack";
+			"Speaker", "Builtin Speaker";
 		simple-audio-card,routing =
 			"MIC_IN", "Microphone Jack",
 			"Microphone Jack", "Mic Bias",
-			"LINE_IN", "Line In Jack",
 			"Headphone Jack", "HP_OUT",
 			"Builtin Speaker", "Speaker Amp OUTR",
 			"Speaker Amp INR", "LINE_OUT";
Signature · 1 line
2.30.0
#4 lore raw

PATCH 4/6 arm64: defconfig: Enable asoc simple mux

In reply to Guido Günther

This is needed to model the mic input mux on the Librem 5 devkit.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index e830d1be6f27..762fb6a132df 100644
@@ -790,6 +790,7 @@ CONFIG_SND_SOC_GTM601=m
 CONFIG_SND_SOC_PCM3168A_I2C=m
 CONFIG_SND_SOC_RT5659=m
 CONFIG_SND_SOC_SIMPLE_AMPLIFIER=m
+CONFIG_SND_SOC_SIMPLE_MUX=m
 CONFIG_SND_SOC_TAS571X=m
 CONFIG_SND_SOC_WCD934X=m
 CONFIG_SND_SOC_WM8904=m
Signature · 1 line
2.30.0
#5 lore raw

PATCH 5/6 arm64: dts: librem5-devkit: Add mux for built-in vs headset mic

In reply to Guido Günther

Add mux so we can select either headset or built-in microphone input.

---
 .../dts/freescale/imx8mq-librem5-devkit.dts   | 25 ++++++++++++++++---
 1 file changed, 21 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts +21 -4
index aac05bbaa001..f818af592046 100644
@@ -163,18 +163,29 @@ wwan_codec: sound-wwan-codec {
 		#sound-dai-cells = <0>;
 	};
 
+	mic_mux: mic-mux {
+		compatible = "simple-audio-mux";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_micsel>;
+		mux-gpios = <&gpio5 5 GPIO_ACTIVE_LOW>;
+		sound-name-prefix = "Mic Mux";
+	};
+
 	sound {
 		compatible = "simple-audio-card";
-		simple-audio-card,aux-devs = <&speaker_amp>;
+		simple-audio-card,aux-devs = <&speaker_amp>, <&mic_mux>;
 		simple-audio-card,name = "Librem 5 Devkit";
 		simple-audio-card,format = "i2s";
 		simple-audio-card,widgets =
-			"Microphone", "Microphone Jack",
+			"Microphone", "Builtin Microphone",
+			"Microphone", "Headset Microphone",
 			"Headphone", "Headphone Jack",
 			"Speaker", "Builtin Speaker";
 		simple-audio-card,routing =
-			"MIC_IN", "Microphone Jack",
-			"Microphone Jack", "Mic Bias",
+			"MIC_IN", "Mic Mux OUT",
+			"Mic Mux IN1", "Headset Microphone",
+			"Mic Mux IN2", "Builtin Microphone",
+			"Mic Mux OUT", "Mic Bias",
 			"Headphone Jack", "HP_OUT",
 			"Builtin Speaker", "Speaker Amp OUTR",
 			"Speaker Amp INR", "LINE_OUT";
@@ -650,6 +661,12 @@ MX8MQ_IOMUXC_SAI5_RXFS_GPIO3_IO19	0x8  /* IMU_INT */
 		>;
 	};
 
+	pinctrl_micsel: micselgrp {
+		fsl,pins = <
+			MX8MQ_IOMUXC_SPDIF_EXT_CLK_GPIO5_IO5	0xc6  /* MIC_SEL */
+		>;
+	};
+
 	pinctrl_spkamp: spkamp {
 		fsl,pins = <
 			MX8MQ_IOMUXC_SPDIF_TX_GPIO5_IO3		0x81  /* MUTE */
Signature · 7 lines
2.30.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#6 lore raw

PATCH 6/6 arm64: dts: librem5-devkit: Move headphone detection to sound card

In reply to Guido Günther

This allows for automatic output source switching in userspace. Enable the pullup on the GPIO to actually make it trigger and mark it as active-high since detection is reversed otherwise.

---
 .../dts/freescale/imx8mq-librem5-devkit.dts   | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)
arch/arm64/boot/dts/freescale/imx8mq-librem5-devkit.dts +11 -10
index f818af592046..e3bfef98090a 100644
@@ -50,13 +50,6 @@ btn2 {
 			linux,code = <KEY_VOLUMEDOWN>;
 		};
 
-		hp-det {
-			label = "HP_DET";
-			gpios = <&gpio3 20 GPIO_ACTIVE_LOW>;
-			wakeup-source;
-			linux,code = <KEY_HP>;
-		};
-
 		wwan-wake {
 			label = "WWAN_WAKE";
 			gpios = <&gpio3 8 GPIO_ACTIVE_LOW>;
@@ -173,22 +166,25 @@ mic_mux: mic-mux {
 
 	sound {
 		compatible = "simple-audio-card";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_hpdet>;
 		simple-audio-card,aux-devs = <&speaker_amp>, <&mic_mux>;
 		simple-audio-card,name = "Librem 5 Devkit";
 		simple-audio-card,format = "i2s";
 		simple-audio-card,widgets =
 			"Microphone", "Builtin Microphone",
 			"Microphone", "Headset Microphone",
-			"Headphone", "Headphone Jack",
+			"Headphone", "Headphones",
 			"Speaker", "Builtin Speaker";
 		simple-audio-card,routing =
 			"MIC_IN", "Mic Mux OUT",
 			"Mic Mux IN1", "Headset Microphone",
 			"Mic Mux IN2", "Builtin Microphone",
 			"Mic Mux OUT", "Mic Bias",
-			"Headphone Jack", "HP_OUT",
+			"Headphones", "HP_OUT",
 			"Builtin Speaker", "Speaker Amp OUTR",
 			"Speaker Amp INR", "LINE_OUT";
+		simple-audio-card,hp-det-gpio = <&gpio3 20 GPIO_ACTIVE_HIGH>;
 
 		simple-audio-card,cpu {
 			sound-dai = <&sai2>;
@@ -630,7 +626,6 @@ pinctrl_gpio_keys: gpiokeygrp {
 		fsl,pins = <
 			MX8MQ_IOMUXC_SAI2_RXFS_GPIO4_IO21	0x16
 			MX8MQ_IOMUXC_SAI2_RXC_GPIO4_IO22	0x16
-			MX8MQ_IOMUXC_SAI5_RXC_GPIO3_IO20	0x180  /* HP_DET */
 			MX8MQ_IOMUXC_NAND_DATA02_GPIO3_IO8	0x80   /* nWoWWAN */
 		>;
 	};
@@ -641,6 +636,12 @@ MX8MQ_IOMUXC_SPDIF_RX_GPIO5_IO4		0xc6   /* nHAPTIC */
 		>;
 	};
 
+	pinctrl_hpdet: hpdetgrp {
+		fsl,pins = <
+			MX8MQ_IOMUXC_SAI5_RXC_GPIO3_IO20	0xC0   /* HP_DET */
+		>;
+	};
+
 	pinctrl_i2c1: i2c1grp {
 		fsl,pins = <
 			MX8MQ_IOMUXC_I2C1_SCL_I2C1_SCL		0x4000001f
Signature · 7 lines
2.30.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Applied
#7 lore raw
In reply to Guido Günther
Quoted 8 lines · Guido Günther

So far only headphone output worked. Thesse patches add support for the built in speaker and mic, allow a headset microphone to work and wire up jack detection so audio output can switch to headphones automatically. They also adjust the card name to match the board not the codec, similar what's done for the Librem 5.

Patches are against next-20210210 but also apply against Shawn's imx-dt64-5.12

Quoted 7 lines

Guido Günther (6):
arm64: dts: librem5-devkit: Use a less generic codec name
arm64: dts: librem5-devkit: Add speaker amplifier
arm64: dts: librem5-devkit: "Drop Line In Jack"
arm64: defconfig: Enable asoc simple mux
arm64: dts: librem5-devkit: Add mux for built-in vs headset mic
arm64: dts: librem5-devkit: Move headphone detection to sound card

Applied all, thanks.