From 2cf576727cd3f9434c1a9921d69ca2eb04273f3c Mon Sep 17 00:00:00 2001
From: Samuel Holland <samuel@sholland.org>
Date: Wed, 5 Feb 2020 23:14:27 -0600
Subject: arm64: dts: sun50i-a64-pinephone: Add support for modem audio

The PinePhone has a Quectel EG25-G modem (a variant of the EC25) with
its PCM interface connected to AIF2. Add the DAI link so call audio can
be routed in hardware.

The modem supports two fixed sample rates, and one fixed word size, with
a variable BCLK frequency. Use the minimum supported BCLK frequency,
which corresponds to a slot width of 32 bits.

Signed-off-by: Samuel Holland <samuel@sholland.org>
---
 .../dts/allwinner/sun50i-a64-pinephone.dtsi   | 25 ++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
index 4f471e80dcd8..76e55a0e415a 100644
--- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi
@@ -188,6 +188,12 @@ chosen {
 		stdout-path = "serial0:115200n8";
 	};
 
+	ec25_codec: ec25-codec {
+		#sound-dai-cells = <1>;
+		compatible = "quectel,ec25";
+		sound-name-prefix = "Modem";
+	};
+
 	i2c_csi: i2c-csi {
 		compatible = "i2c-gpio";
 		sda-gpios = <&pio 4 13 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>; /* PE13 */
@@ -316,7 +322,7 @@ vibrator {
 
 &codec {
 	pinctrl-names = "default";
-	pinctrl-0 = <&aif3_pins>;
+	pinctrl-0 = <&aif2_pins>, <&aif3_pins>;
 	status = "okay";
 };
 
@@ -799,6 +805,23 @@ &sound {
 			"Headset Microphone", "HBIAS",
 			"MIC2", "Headset Microphone";
 
+	simple-audio-card,dai-link@1 {
+		format = "dsp_a";
+		frame-master = <&link1_codec>;
+		bitclock-master = <&link1_codec>;
+		bitclock-inversion;
+
+		link1_cpu: cpu {
+			sound-dai = <&ec25_codec 0>;
+		};
+
+		link1_codec: codec {
+			sound-dai = <&codec 1>;
+			dai-tdm-slot-num = <1>;
+			dai-tdm-slot-width = <32>;
+		};
+	};
+
 	simple-audio-card,dai-link@2 {
 		format = "dsp_a";
 		frame-master = <&link2_codec>;
-- 
2.35.3

