From 06bc6b6ae01fd5e2e9cdc570581b5795cc7cd019 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Sat, 22 Feb 2020 23:40:29 +0100
Subject: ARM: dts: sun8i-a83t-tbs-a711: Add sound support via AC100 codec

...

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 .../dts/allwinner/sun8i-a83t-tbs-a711.dts     | 85 +++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/arch/arm/boot/dts/allwinner/sun8i-a83t-tbs-a711.dts b/arch/arm/boot/dts/allwinner/sun8i-a83t-tbs-a711.dts
index f7d8e5425233..925891a1d6d9 100644
--- a/arch/arm/boot/dts/allwinner/sun8i-a83t-tbs-a711.dts
+++ b/arch/arm/boot/dts/allwinner/sun8i-a83t-tbs-a711.dts
@@ -145,6 +145,74 @@ modem {
 		reset-gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
 		wakeup-gpios = <&r_pio 0 11 GPIO_ACTIVE_HIGH>; /* PL11 */
 	};
+
+	bt_sco_codec: bt-sco-codec {
+		#sound-dai-cells = <1>;
+		compatible = "linux,bt-sco";
+		sound-name-prefix = "Bluetooth";
+	};
+
+	speaker_amp: audio-amplifier {
+		compatible = "simple-audio-amplifier";
+		enable-gpios = <&pio 6 13 GPIO_ACTIVE_HIGH>; /* PG13 */
+		sound-name-prefix = "Speaker Amp";
+	};
+
+	sound: sound {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "simple-audio-card";
+		simple-audio-card,name = "ac100-audio";
+		simple-audio-card,aux-devs = <&ac100_codec_analog>, <&speaker_amp>;
+		simple-audio-card,widgets = "Microphone", "Headset Microphone",
+					    "Microphone", "Internal Microphone",
+					    "Headphone", "Headphone Jack",
+					    "Speaker", "Internal Speaker";
+		simple-audio-card,routing =
+				"Headphone Jack", "HP",
+				"Internal Speaker", "Speaker Amp OUTL",
+				"Speaker Amp INL", "SPKOUTL",
+				"Left DAC", "DACL",
+				"Right DAC", "DACR",
+				"ADCL", "Left ADC",
+				"ADCR", "Right ADC",
+				"Internal Microphone", "MBIAS",
+				"MIC1", "Internal Microphone",
+				"Headset Microphone", "HBIAS",
+				"MIC2", "Headset Microphone";
+
+		simple-audio-card,dai-link@0 {
+			format = "i2s";
+			frame-master = <&link0_cpu>;
+			bitclock-master = <&link0_cpu>;
+			mclk-fs = <512>;
+
+			link0_cpu: cpu {
+				sound-dai = <&i2s0>;
+			};
+
+			link0_codec: codec {
+				sound-dai = <&ac100_codec 0>;
+			};
+		};
+
+		simple-audio-card,dai-link@2 {
+			format = "dsp_a";
+			frame-master = <&link2_codec>;
+			bitclock-master = <&link2_codec>;
+			bitclock-inversion;
+
+			link2_cpu: cpu {
+				sound-dai = <&bt_sco_codec 0>;
+			};
+
+			link2_codec: codec {
+				sound-dai = <&ac100_codec 2>;
+				dai-tdm-slot-num = <2>;
+				dai-tdm-slot-width = <16>;
+			};
+		};
+	};
 };
 
 &cpu0 {
@@ -213,6 +281,12 @@ npc100: nfc@28 {
 	};
 };
 
+&i2s0 {
+	status = "okay";
+	pinctrl-names = "default";
+	pinctrl-0 = <&i2s0_pins>;
+};
+
 &mmc0 {
 	vmmc-supply = <&reg_dcdc1>;
 	pinctrl-names = "default";
@@ -293,12 +367,23 @@ ac100: codec@e89 {
 		compatible = "x-powers,ac100";
 		reg = <0xe89>;
 
+		ac100_codec_analog: codec-analog {
+			compatible = "x-powers,ac100-codec-analog";
+			cpvdd-supply = <&reg_aldo2>;
+		};
+
 		ac100_codec: codec {
+			#sound-dai-cells = <1>;
 			compatible = "x-powers,ac100-codec";
 			interrupt-parent = <&r_pio>;
 			interrupts = <0 12 IRQ_TYPE_LEVEL_LOW>; /* PL12 */
 			#clock-cells = <0>;
 			clock-output-names = "4M_adda";
+
+			LDOIN-supply = <&reg_aldo2>;
+			AVCC-supply = <&reg_aldo3>;
+			VDDIO1-supply = <&reg_dcdc1>;
+			VDDIO2-supply = <&reg_dldo1>;
 		};
 
 		ac100_rtc: rtc {
-- 
2.35.3

