Skip to contentSkip to conversation

Add support for audiocodec in Allwinner A64

PATCH Superseded Vasily Khoruzhick 2 participants 12 messages Nov 8, 2018 – Nov 17, 2018

Subsystems (2)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover Add support for audiocodec in Allwinner A64

This series enables sound on Pine64, SoPine boards and Pinebook.

v2: - Use simple-amplifier for speaker amp on Pinebook
- Rename sun50i-a64-i2s to sun50i-a64-codec-i2s to preserve compatible string for other 3 I2S modules in A64 in case if there's any incompatibility with H3
v3: - renamed sunxi-adda-pr-regmap to sun8i-adda-pr-regmap
- use ilog2() to calculate reg value for LRCK div instead of using a table
v4: - dts: don't use 'Mic' and 'Headset Mic' widgets from sun8i-codec,
define our board-level widgets instead.
v5: - collect all the tags
v6: - driver patches has been merged through ASoC tree
- rebase onto 4.20-rc1
- Drop 'Speaker' from routes on sopine and pine64, they don't have speaker.

Vasily Khoruzhick (3):
arm64: dts: allwinner: a64: add nodes necessary for analog sound
support
arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine
arm64: dts: allwinner: a64: enable sound on Pinebook

 .../boot/dts/allwinner/sun50i-a64-pine64.dts  | 28 +++++++++
 .../dts/allwinner/sun50i-a64-pinebook.dts     | 42 ++++++++++++++
 .../allwinner/sun50i-a64-sopine-baseboard.dts | 28 +++++++++
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 58 +++++++++++++++++++
 4 files changed, 156 insertions(+)
Signature · 1 line
2.19.1
#1 lore raw

PATCH v6 1/3 arm64: dts: allwinner: a64: add nodes necessary for analog sound support

Add nodes for i2s, digital and analog parts of audiocodec on A64

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +58 -0
index f3a66f888205..53796a3e6bf3 100644
@@ -173,6 +173,34 @@
 		compatible = "linux,spdif-dit";
 	};
 
+	sound: sound {
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "sun50i-a64-audio";
+		simple-audio-card,format = "i2s";
+		simple-audio-card,frame-master = <&cpudai>;
+		simple-audio-card,bitclock-master = <&cpudai>;
+		simple-audio-card,mclk-fs = <512>;
+		simple-audio-card,aux-devs = <&codec_analog>;
+		simple-audio-card,routing =
+				"Left DAC", "AIF1 Slot 0 Left",
+				"Right DAC", "AIF1 Slot 0 Right",
+				"AIF1 Slot 0 Left ADC", "Left ADC",
+				"AIF1 Slot 0 Right ADC", "Right ADC",
+				"Left ADC", "ADC",
+				"Right ADC", "ADC",
+				"MIC1", "Mic",
+				"MIC2", "Headset Mic";
+		status = "disabled";
+
+		cpudai: simple-audio-card,cpu {
+			sound-dai = <&dai>;
+		};
+
+		link_codec: simple-audio-card,codec {
+			sound-dai = <&codec>;
+		};
+	};
+
 	timer {
 		compatible = "arm,armv8-timer";
 		interrupts = <GIC_PPI 13
@@ -665,6 +693,30 @@
 			status = "disabled";
 		};
 
+		dai: dai@1c22c00 {
+			#sound-dai-cells = <0>;
+			compatible = "allwinner,sun50i-a64-codec-i2s";
+			reg = <0x01c22c00 0x200>;
+			interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;
+			clock-names = "apb", "mod";
+			resets = <&ccu RST_BUS_CODEC>;
+			reset-names = "rst";
+			dmas = <&dma 15>, <&dma 15>;
+			dma-names = "rx", "tx";
+			status = "disabled";
+		};
+
+		codec: codec at 1c22e00 {
+			#sound-dai-cells = <0>;
+			compatible = "allwinner,sun8i-a33-codec";
+			reg = <0x01c22e00 0x600>;
+			interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;
+			clock-names = "bus", "mod";
+			status = "disabled";
+		};
+
 		uart0: serial at 1c28000 {
 			compatible = "snps,dw-apb-uart";
 			reg = <0x01c28000 0x400>;
@@ -902,6 +954,12 @@
 			#reset-cells = <1>;
 		};
 
+		codec_analog: codec-analog at 1f015c0 {
+			compatible = "allwinner,sun50i-a64-codec-analog";
+			reg = <0x01f015c0 0x4>;
+			status = "disabled";
+		};
+
 		r_i2c: i2c at 1f02400 {
 			compatible = "allwinner,sun50i-a64-i2c",
 				     "allwinner,sun6i-a31-i2c";
Signature · 1 line
2.19.1
#2 lore raw

Re: [PATCH v6 1/3] arm64: dts: allwinner: a64: add nodes necessary for analog sound support

Quoted 21 lines · Vasily Khoruzhick

Add nodes for i2s, digital and analog parts of audiocodec on A64

---
 arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 58 +++++++++++++++++++
 1 file changed, 58 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +5 -0
index f3a66f888205..53796a3e6bf3 100644
@@ -173,6 +173,34 @@
                compatible = "linux,spdif-dit";
        };
 
+       sound: sound {
+               compatible = "simple-audio-card";
+               simple-audio-card,name = "sun50i-a64-audio";
+               simple-audio-card,format = "i2s";
+               simple-audio-card,frame-master = <&cpudai>;

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 190

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +10 -0
+               simple-audio-card,bitclock-master = <&cpudai>;
+               simple-audio-card,mclk-fs = <512>;
+               simple-audio-card,aux-devs = <&codec_analog>;
+               simple-audio-card,routing =
+                               "Left DAC", "AIF1 Slot 0 Left",
+                               "Right DAC", "AIF1 Slot 0 Right",
+                               "AIF1 Slot 0 Left ADC", "Left ADC",
+                               "AIF1 Slot 0 Right ADC", "Right ADC",
+                               "Left ADC", "ADC",
+                               "Right ADC", "ADC",

The ADC widget is an overall enable control for the digital part of the codec's ADC.
It is modeled as a supply widget in sun8i-codec. The routing should be internal to sun8i-codec. See the following for the DAC routing:

    https://elixir.bootlin.com/linux/v4.20-rc1/source/sound/soc/sunxi/sun8i-codec.c#L474

arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi line 192

Quoted 2 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +2 -0
+                               "MIC1", "Mic",
+                               "MIC2", "Headset Mic";

Drop the last two. These belong at the board level. And as previously mentioned, these two widgets from the sun8i-codec driver are bogus.

Quoted 61 lines
arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +41 -1
+               status = "disabled";
+
+               cpudai: simple-audio-card,cpu {
+                       sound-dai = <&dai>;
+               };
+
+               link_codec: simple-audio-card,codec {
+                       sound-dai = <&codec>;
+               };
+       };
+
        timer {
                compatible = "arm,armv8-timer";
                interrupts = <GIC_PPI 13
@@ -665,6 +693,30 @@
                        status = "disabled";
                };
 
+               dai: dai at 1c22c00 {
+                       #sound-dai-cells = <0>;
+                       compatible = "allwinner,sun50i-a64-codec-i2s";
+                       reg = <0x01c22c00 0x200>;
+                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;
+                       clock-names = "apb", "mod";
+                       resets = <&ccu RST_BUS_CODEC>;
+                       reset-names = "rst";
+                       dmas = <&dma 15>, <&dma 15>;
+                       dma-names = "rx", "tx";
+                       status = "disabled";
+               };
+
+               codec: codec at 1c22e00 {
+                       #sound-dai-cells = <0>;
+                       compatible = "allwinner,sun8i-a33-codec";
+                       reg = <0x01c22e00 0x600>;
+                       interrupts = <GIC_SPI 28 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;
+                       clock-names = "bus", "mod";
+                       status = "disabled";
+               };
+
                uart0: serial at 1c28000 {
                        compatible = "snps,dw-apb-uart";
                        reg = <0x01c28000 0x400>;
@@ -902,6 +954,12 @@
                        #reset-cells = <1>;
                };
 
+               codec_analog: codec-analog at 1f015c0 {
+                       compatible = "allwinner,sun50i-a64-codec-analog";
+                       reg = <0x01f015c0 0x4>;
+                       status = "disabled";
+               };
+
                r_i2c: i2c at 1f02400 {
                        compatible = "allwinner,sun50i-a64-i2c",
                                     "allwinner,sun6i-a31-i2c";
--

2.19.1

#3 lore raw

PATCH v6 2/3 arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine

In reply to Vasily Khoruzhick

This commit enables I2S, digital and analog parts of audiocodec on Pine64 and SoPine boards.

---
 .../boot/dts/allwinner/sun50i-a64-pine64.dts  | 28 +++++++++++++++++++
 .../allwinner/sun50i-a64-sopine-baseboard.dts | 28 +++++++++++++++++++
 2 files changed, 56 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +28 -0
index c077b6c1f458..ff352bdfbb93 100644
@@ -75,6 +75,18 @@
 	};
 };
 
+&codec {
+	status = "okay";
+};
+
+&codec_analog {
+	status = "okay";
+};
+
+&dai {
+	status = "okay";
+};
+
 &de {
 	status = "okay";
 };
@@ -264,6 +276,22 @@
 	status = "disabled";
 };
 
+&sound {
+	status = "okay";
+	simple-audio-card,widgets = "Microphone", "Microphone Jack",
+				    "Headphone", "Headphone Jack";
+	simple-audio-card,routing =
+			"Left DAC", "AIF1 Slot 0 Left",
+			"Right DAC", "AIF1 Slot 0 Right",
+			"Headphone Jack", "HP",
+			"AIF1 Slot 0 Left ADC", "Left ADC",
+			"AIF1 Slot 0 Right ADC", "Right ADC",
+			"Left ADC", "ADC",
+			"Right ADC", "ADC",
+			"Microphone Jack", "HBIAS",
+			"MIC2", "Microphone Jack";
+};
+
 /* On Exp and Euler connectors */
 &uart0 {
 	pinctrl-names = "default";
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +28 -0
index 53fcc9098df3..25d732df37c4 100644
@@ -80,6 +80,18 @@
 	};
 };
 
+&codec {
+	status = "okay";
+};
+
+&codec_analog {
+	status = "okay";
+};
+
+&dai {
+	status = "okay";
+};
+
 &de {
 	status = "okay";
 };
@@ -164,6 +176,22 @@
 	vcc-hdmi-supply = <&reg_dldo1>;
 };
 
+&sound {
+	status = "okay";
+	simple-audio-card,widgets = "Microphone", "Microphone Jack",
+				    "Headphone", "Headphone Jack";
+	simple-audio-card,routing =
+			"Left DAC", "AIF1 Slot 0 Left",
+			"Right DAC", "AIF1 Slot 0 Right",
+			"Headphone Jack", "HP",
+			"AIF1 Slot 0 Left ADC", "Left ADC",
+			"AIF1 Slot 0 Right ADC", "Right ADC",
+			"Left ADC", "ADC",
+			"Right ADC", "ADC",
+			"Microphone Jack", "HBIAS",
+			"MIC2", "Microphone Jack";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pb_pins>;
Signature · 1 line
2.19.1
#4 lore raw

Re: [PATCH v6 2/3] arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine

Quoted 39 lines · Vasily Khoruzhick

This commit enables I2S, digital and analog parts of audiocodec on Pine64 and SoPine boards.

---
 .../boot/dts/allwinner/sun50i-a64-pine64.dts  | 28 +++++++++++++++++++
 .../allwinner/sun50i-a64-sopine-baseboard.dts | 28 +++++++++++++++++++
 2 files changed, 56 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +14 -0
index c077b6c1f458..ff352bdfbb93 100644
@@ -75,6 +75,18 @@
        };
 };
 
+&codec {
+       status = "okay";
+};
+
+&codec_analog {
+       status = "okay";
+};
+
+&dai {
+       status = "okay";
+};
+
 &de {
        status = "okay";
 };
@@ -264,6 +276,22 @@
        status = "disabled";
 };
 
+&sound {
+       status = "okay";

arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts line 290

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +10 -0
+       simple-audio-card,widgets = "Microphone", "Microphone Jack",
+                                   "Headphone", "Headphone Jack";
+       simple-audio-card,routing =
+                       "Left DAC", "AIF1 Slot 0 Left",
+                       "Right DAC", "AIF1 Slot 0 Right",
+                       "Headphone Jack", "HP",
+                       "AIF1 Slot 0 Left ADC", "Left ADC",
+                       "AIF1 Slot 0 Right ADC", "Right ADC",
+                       "Left ADC", "ADC",
+                       "Right ADC", "ADC",

As mentioned the above two don't belong in the device tree.

arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts line 291

Quoted 1 line
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +1 -0
+                       "Microphone Jack", "HBIAS",

Schematics says this is NC or not connected by default. You may want to ask Pine64 about this?

Same comments for SoPine.

Quoted 55 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +3 -0
+                       "MIC2", "Microphone Jack";
+};
+
 /* On Exp and Euler connectors */
 &uart0 {
        pinctrl-names = "default";
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +28 -1
index 53fcc9098df3..25d732df37c4 100644
@@ -80,6 +80,18 @@
        };
 };
 
+&codec {
+       status = "okay";
+};
+
+&codec_analog {
+       status = "okay";
+};
+
+&dai {
+       status = "okay";
+};
+
 &de {
        status = "okay";
 };
@@ -164,6 +176,22 @@
        vcc-hdmi-supply = <&reg_dldo1>;
 };
 
+&sound {
+       status = "okay";
+       simple-audio-card,widgets = "Microphone", "Microphone Jack",
+                                   "Headphone", "Headphone Jack";
+       simple-audio-card,routing =
+                       "Left DAC", "AIF1 Slot 0 Left",
+                       "Right DAC", "AIF1 Slot 0 Right",
+                       "Headphone Jack", "HP",
+                       "AIF1 Slot 0 Left ADC", "Left ADC",
+                       "AIF1 Slot 0 Right ADC", "Right ADC",
+                       "Left ADC", "ADC",
+                       "Right ADC", "ADC",
+                       "Microphone Jack", "HBIAS",
+                       "MIC2", "Microphone Jack";
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_pb_pins>;
--

2.19.1

#5 lore raw

Re: [PATCH v6 2/3] arm64: dts: allwinner: a64: enable sound on Pine64 and SoPine

Quoted 54 lines · Chen-Yu Tsai
Quoted 39 lines · Vasily Khoruzhick

This commit enables I2S, digital and analog parts of audiocodec on Pine64 and SoPine boards.

---
 .../boot/dts/allwinner/sun50i-a64-pine64.dts  | 28 +++++++++++++++++++
 .../allwinner/sun50i-a64-sopine-baseboard.dts | 28 +++++++++++++++++++
 2 files changed, 56 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +14 -0
index c077b6c1f458..ff352bdfbb93 100644
@@ -75,6 +75,18 @@
        };
 };
 
+&codec {
+       status = "okay";
+};
+
+&codec_analog {
+       status = "okay";
+};
+
+&dai {
+       status = "okay";
+};
+
 &de {
        status = "okay";
 };
@@ -264,6 +276,22 @@
        status = "disabled";
 };
 
+&sound {
+       status = "okay";

arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts line 290

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +10 -0
+       simple-audio-card,widgets = "Microphone", "Microphone Jack",
+                                   "Headphone", "Headphone Jack";
+       simple-audio-card,routing =
+                       "Left DAC", "AIF1 Slot 0 Left",
+                       "Right DAC", "AIF1 Slot 0 Right",
+                       "Headphone Jack", "HP",
+                       "AIF1 Slot 0 Left ADC", "Left ADC",
+                       "AIF1 Slot 0 Right ADC", "Right ADC",
+                       "Left ADC", "ADC",
+                       "Right ADC", "ADC",

As mentioned the above two don't belong in the device tree.

Quoted 6 lines

arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts line 291

Quoted 1 line
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +1 -0
+                       "Microphone Jack", "HBIAS",

Schematics says this is NC or not connected by default. You may want to ask Pine64 about this?

Same comments for SoPine.

I'll just drop it. Not connected on schematics - we don't put it in dts.

Quoted 56 lines
Quoted 56 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pine64.dts +3 -0
+                       "MIC2", "Microphone Jack";
+};
+
 /* On Exp and Euler connectors */
 &uart0 {
        pinctrl-names = "default";
arch/arm64/boot/dts/allwinner/sun50i-a64-sopine-baseboard.dts +28 -1
index 53fcc9098df3..25d732df37c4 100644
@@ -80,6 +80,18 @@
        };
 };
 
+&codec {
+       status = "okay";
+};
+
+&codec_analog {
+       status = "okay";
+};
+
+&dai {
+       status = "okay";
+};
+
 &de {
        status = "okay";
 };
@@ -164,6 +176,22 @@
        vcc-hdmi-supply = <&reg_dldo1>;
 };
 
+&sound {
+       status = "okay";
+       simple-audio-card,widgets = "Microphone", "Microphone Jack",
+                                   "Headphone", "Headphone Jack";
+       simple-audio-card,routing =
+                       "Left DAC", "AIF1 Slot 0 Left",
+                       "Right DAC", "AIF1 Slot 0 Right",
+                       "Headphone Jack", "HP",
+                       "AIF1 Slot 0 Left ADC", "Left ADC",
+                       "AIF1 Slot 0 Right ADC", "Right ADC",
+                       "Left ADC", "ADC",
+                       "Right ADC", "ADC",
+                       "Microphone Jack", "HBIAS",
+                       "MIC2", "Microphone Jack";
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_pb_pins>;
--

2.19.1

#6 lore raw

PATCH v6 3/3 arm64: dts: allwinner: a64: enable sound on Pinebook

In reply to Vasily Khoruzhick

This commit enables I2S, digital and analog parts of audiocodec on Pinebook

---
 .../dts/allwinner/sun50i-a64-pinebook.dts     | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +42 -0
index 77fac84797e9..73f171f4ba9b 100644
@@ -64,6 +64,23 @@
 		compatible = "mmc-pwrseq-simple";
 		reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
 	};
+
+	speaker_amp: speaker_amp {
+		compatible = "simple-audio-amplifier";
+		enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */
+	};
+};
+
+&codec {
+	status = "okay";
+};
+
+&codec_analog {
+	status = "okay";
+};
+
+&dai {
+	status = "okay";
 };
 
 &ehci0 {
@@ -267,6 +284,31 @@
 	vcc-hdmi-supply = <&reg_dldo1>;
 };
 
+&sound {
+	status = "okay";
+	simple-audio-card,widgets = "Microphone", "Internal Microphone Left",
+				    "Microphone", "Internal Microphone Right",
+				    "Headphone", "Headphone Jack",
+				    "Speaker", "Internal Speaker";
+	simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>;
+	simple-audio-card,routing =
+			"Left DAC", "AIF1 Slot 0 Left",
+			"Right DAC", "AIF1 Slot 0 Right",
+			"INL", "LINEOUT",
+			"INR", "LINEOUT",
+			"Internal Speaker", "OUTL",
+			"Internal Speaker", "OUTR",
+			"Headphone Jack", "HP",
+			"AIF1 Slot 0 Left ADC", "Left ADC",
+			"AIF1 Slot 0 Right ADC", "Right ADC",
+			"Left ADC", "ADC",
+			"Right ADC", "ADC",
+			"Internal Microphone Left", "MBIAS",
+			"MIC1", "Internal Microphone Left",
+			"Internal Microphone Right", "HBIAS",
+			"MIC2", "Internal Microphone Right";
+};
+
 &uart0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&uart0_pb_pins>;
Signature · 1 line
2.19.1
#7 lore raw

Re: [PATCH v6 3/3] arm64: dts: allwinner: a64: enable sound on Pinebook

Quoted 14 lines · Vasily Khoruzhick

This commit enables I2S, digital and analog parts of audiocodec on Pinebook

---
 .../dts/allwinner/sun50i-a64-pinebook.dts     | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +0 -0
index 77fac84797e9..73f171f4ba9b 100644

arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts line 70

Quoted 7 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +4 -0
@@ -64,6 +64,23 @@
                compatible = "mmc-pwrseq-simple";
                reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
        };
+
+       speaker_amp: speaker_amp {
+               compatible = "simple-audio-amplifier";
+               enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */

You might want to add a sound-name-prefix property. See

Documentation/devicetree/bindings/sound/name-prefix.txt

Also this should have a reference to its power supply regulator.

Quoted 33 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +26 -0
+       };
+};
+
+&codec {
+       status = "okay";
+};
+
+&codec_analog {
+       status = "okay";
+};
+
+&dai {
+       status = "okay";
 };
 
 &ehci0 {
@@ -267,6 +284,31 @@
        vcc-hdmi-supply = <&reg_dldo1>;
 };
 
+&sound {
+       status = "okay";
+       simple-audio-card,widgets = "Microphone", "Internal Microphone Left",
+                                   "Microphone", "Internal Microphone Right",
+                                   "Headphone", "Headphone Jack",
+                                   "Speaker", "Internal Speaker";
+       simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>;
+       simple-audio-card,routing =
+                       "Left DAC", "AIF1 Slot 0 Left",
+                       "Right DAC", "AIF1 Slot 0 Right",
+                       "INL", "LINEOUT",
+                       "INR", "LINEOUT",
+                       "Internal Speaker", "OUTL",

arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts line 309

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +10 -0
+                       "Internal Speaker", "OUTR",
+                       "Headphone Jack", "HP",
+                       "AIF1 Slot 0 Left ADC", "Left ADC",
+                       "AIF1 Slot 0 Right ADC", "Right ADC",
+                       "Left ADC", "ADC",
+                       "Right ADC", "ADC",
+                       "Internal Microphone Left", "MBIAS",
+                       "MIC1", "Internal Microphone Left",
+                       "Internal Microphone Right", "HBIAS",
+                       "MIC2", "Internal Microphone Right";

The schematics is missing the actual jack, but this looks to be correct.

ChenYu

Quoted 8 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +2 -1
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_pb_pins>;
--

2.19.1

#8 lore raw

Re: [PATCH v6 3/3] arm64: dts: allwinner: a64: enable sound on Pinebook

Quoted 11 lines · Chen-Yu Tsai
Quoted 9 lines · Vasily Khoruzhick

This commit enables I2S, digital and analog parts of audiocodec on Pinebook

---
 .../dts/allwinner/sun50i-a64-pinebook.dts     | 42 +++++++++++++++++++
 1 file changed, 42 insertions(+)
Quoted 14 lines

arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts line 70

Quoted 12 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +4 -0
index 77fac84797e9..73f171f4ba9b 100644
@@ -64,6 +64,23 @@
                compatible = "mmc-pwrseq-simple";
                reset-gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
        };
+
+       speaker_amp: speaker_amp {
+               compatible = "simple-audio-amplifier";
+               enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */

You might want to add a sound-name-prefix property. See

No need, there's only speaker amplifier in Pinebook.

Quoted 4 lines

Documentation/devicetree/bindings/sound/name-prefix.txt

Also this should have a reference to its power supply regulator.

It's powered from V5P0_USB according to schematics, which comes out of 5V BOOST USB HOST MODE POWER - and it's not controlled by software. So there's nothing to reference.

Quoted 57 lines
Quoted 34 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +26 -0
+       };
+};
+
+&codec {
+       status = "okay";
+};
+
+&codec_analog {
+       status = "okay";
+};
+
+&dai {
+       status = "okay";
 };
 
 &ehci0 {
@@ -267,6 +284,31 @@
        vcc-hdmi-supply = <&reg_dldo1>;
 };
 
+&sound {
+       status = "okay";
+       simple-audio-card,widgets = "Microphone", "Internal Microphone Left",
+                                   "Microphone", "Internal Microphone Right",
+                                   "Headphone", "Headphone Jack",
+                                   "Speaker", "Internal Speaker";
+       simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>;
+       simple-audio-card,routing =
+                       "Left DAC", "AIF1 Slot 0 Left",
+                       "Right DAC", "AIF1 Slot 0 Right",
+                       "INL", "LINEOUT",
+                       "INR", "LINEOUT",
+                       "Internal Speaker", "OUTL",

arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts line 309

Quoted 10 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +10 -0
+                       "Internal Speaker", "OUTR",
+                       "Headphone Jack", "HP",
+                       "AIF1 Slot 0 Left ADC", "Left ADC",
+                       "AIF1 Slot 0 Right ADC", "Right ADC",
+                       "Left ADC", "ADC",
+                       "Right ADC", "ADC",
+                       "Internal Microphone Left", "MBIAS",
+                       "MIC1", "Internal Microphone Left",
+                       "Internal Microphone Right", "HBIAS",
+                       "MIC2", "Internal Microphone Right";

The schematics is missing the actual jack, but this looks to be correct.

ChenYu

Quoted 8 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +2 -1
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_pb_pins>;
--

2.19.1

#9 lore raw

Re: [PATCH v6 3/3] arm64: dts: allwinner: a64: enable sound on Pinebook

In reply to Chen-Yu Tsai
Quoted 10 lines · Chen-Yu Tsai

arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts line 70

Quoted 4 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +4 -0
+
+       speaker_amp: speaker_amp {
+               compatible = "simple-audio-amplifier";
+               enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */

You might want to add a sound-name-prefix property. See

Documentation/devicetree/bindings/sound/name-prefix.txt

Also this should have a reference to its power supply regulator.

You're right, it should reference its power supply which should be a fixed regulator controlled via GPIO from AXP803.

Unfortunately there's no AXP803 GPIO support yet and simple-audio-amplifier doesn't have regulator property.

I have no time (and interest) to work on it in near future, so if anyone wants to pick it up - feel free to do so.

Regards,
Vasily

#10 lore raw

Re: [PATCH v6 3/3] arm64: dts: allwinner: a64: enable sound on Pinebook

Quoted 13 lines · Vasily Khoruzhick
Quoted 10 lines · Chen-Yu Tsai

arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts line 70

Quoted 4 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +4 -0
+
+       speaker_amp: speaker_amp {
+               compatible = "simple-audio-amplifier";
+               enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */

You might want to add a sound-name-prefix property. See

Documentation/devicetree/bindings/sound/name-prefix.txt

Also this should have a reference to its power supply regulator.

Quoted 8 lines

You're right, it should reference its power supply which should be a fixed regulator controlled via GPIO from AXP803.

Unfortunately there's no AXP803 GPIO support yet and simple-audio-amplifier doesn't have regulator property.

I have no time (and interest) to work on it in near future, so if anyone wants to pick it up - feel free to do so.

Understood. I can try to pick it up when I have some extra time.

On the other hand, I tried this series on my Pine64 and (with the necessary device tree changes) on my Bananapi M64. While audio played (did not stall), no audio was actually coming out of the headphones I had plugged in. I made sure that all needed mixer controls were enabled, and the DAPM graph read all green from the DAI to the Headphone jack.

Any ideas?

Regards
ChenYu

#11 lore raw

Re: [PATCH v6 3/3] arm64: dts: allwinner: a64: enable sound on Pinebook

Quoted 26 lines · Chen-Yu Tsai
Quoted 13 lines · Vasily Khoruzhick
Quoted 10 lines · Chen-Yu Tsai

arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts line 70

Quoted 4 lines
arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts +4 -0
+
+       speaker_amp: speaker_amp {
+               compatible = "simple-audio-amplifier";
+               enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */

You might want to add a sound-name-prefix property. See

Documentation/devicetree/bindings/sound/name-prefix.txt

Also this should have a reference to its power supply regulator.

Quoted 8 lines

You're right, it should reference its power supply which should be a fixed regulator controlled via GPIO from AXP803.

Unfortunately there's no AXP803 GPIO support yet and simple-audio-amplifier doesn't have regulator property.

I have no time (and interest) to work on it in near future, so if anyone wants to pick it up - feel free to do so.

Understood. I can try to pick it up when I have some extra time.

Quoted 8 lines

On the other hand, I tried this series on my Pine64 and (with the necessary device tree changes) on my Bananapi M64. While audio played (did not stall), no audio was actually coming out of the headphones I had plugged in. I made sure that all needed mixer controls were enabled, and the DAPM graph read all green from the DAI to the Headphone jack.

Any ideas?

Please show output of amixer. My guess is that you don't have 'AIF1 DAC' enabled.

Quoted 3 lines

Regards
ChenYu