arm64: dts: qcom: msm8916-samsung-a2015: Add sound and modem
authorStephan Gerhold <stephan@gerhold.net>
Tue, 3 Oct 2023 13:18:23 +0000 (15:18 +0200)
committerBjorn Andersson <andersson@kernel.org>
Sat, 21 Oct 2023 20:06:57 +0000 (13:06 -0700)
Enable sound and modem for the Samsung A2015 based devices (A3, A5, E5,
E7, Grand Max). The setup is similar to most MSM8916 devices, i.e.:

 - QDSP6 audio
 - Earpiece/headphones/microphones via digital/analog codec in
   MSM8916/PM8916
 - WWAN Internet via BAM-DMUX

except:

 - NXP TFA9895 codec for speaker on Quaternary MI2S
 - Samsung-specific audio jack detection (not supported yet)

[Lin: Add e2015 and grandmax]

Co-developed-by: "Lin, Meng-Bo" <linmengbo0689@protonmail.com>
Signed-off-by: "Lin, Meng-Bo" <linmengbo0689@protonmail.com>
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Link: https://lore.kernel.org/r/20231003-msm8916-modem-v2-5-61b684be55c0@gerhold.net
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
arch/arm64/boot/dts/qcom/msm8916-samsung-a2015-common.dtsi
arch/arm64/boot/dts/qcom/msm8916-samsung-e2015-common.dtsi
arch/arm64/boot/dts/qcom/msm8916-samsung-grandmax.dts

index 0b29132b74e1da1cec11efb9cd2e90df168790c9..2937495940ea02abf7d7d537160df8be171f9dd2 100644 (file)
@@ -1,10 +1,13 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
 #include "msm8916-pm8916.dtsi"
+#include "msm8916-modem-qdsp6.dtsi"
+
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
+#include <dt-bindings/sound/apq8016-lpass.h>
 
 / {
        aliases {
        };
 };
 
+&blsp_i2c1 {
+       status = "okay";
+
+       speaker_codec: audio-codec@34 {
+               compatible = "nxp,tfa9895";
+               reg = <0x34>;
+               vddd-supply = <&pm8916_l5>;
+               sound-name-prefix = "Speaker";
+               #sound-dai-cells = <0>;
+       };
+};
+
 &blsp_i2c2 {
        status = "okay";
 
        status = "okay";
 };
 
+/*
+ * For some reason the speaker amplifier is connected to the second SD line
+ * (MI2S_2_D1) instead of the first (MI2S_2_D0). This must be configured in the
+ * device tree, otherwise audio will seemingly play fine on the wrong SD line
+ * but the speaker stays silent.
+ *
+ * When routing audio via QDSP6 (the default) the &lpass node is reserved and
+ * the definitions from &q6afedai are used. When the modem is disabled audio can
+ * be alternatively routed directly to the LPASS hardware with reduced latency.
+ * The definitions for &lpass are here for completeness to simplify changing the
+ * setup with minor changes to the DT (either manually or with DT overlays).
+ */
+&lpass {
+       dai-link@3 {
+               reg = <MI2S_QUATERNARY>;
+               qcom,playback-sd-lines = <1>;
+       };
+};
+
 &mdss {
        status = "okay";
 };
        pinctrl-1 = <&mdss_sleep>;
 };
 
+&mpss_mem {
+       reg = <0x0 0x86800000 0x0 0x5400000>;
+};
+
 &pm8916_resin {
        status = "okay";
        linux,code = <KEY_VOLUMEDOWN>;
        };
 };
 
+&q6afedai {
+       dai@22 {
+               reg = <QUATERNARY_MI2S_RX>;
+               qcom,sd-lines = <1>;
+       };
+};
+
 &sdhc_1 {
        status = "okay";
 };
        cd-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;
 };
 
+&sound {
+       model = "samsung-a2015";
+       audio-routing =
+               "AMIC1", "MIC BIAS External1",
+               "AMIC2", "MIC BIAS Internal2",
+               "AMIC3", "MIC BIAS External1";
+
+       pinctrl-0 = <&cdc_pdm_default &sec_mi2s_default>;
+       pinctrl-1 = <&cdc_pdm_sleep &sec_mi2s_sleep>;
+       pinctrl-names = "default", "sleep";
+
+       sound_link_backend2: backend2-dai-link {
+               link-name = "Quaternary MI2S";
+
+               cpu {
+                       sound-dai = <&q6afedai QUATERNARY_MI2S_RX>;
+               };
+               platform {
+                       sound-dai = <&q6routing>;
+               };
+               codec {
+                       sound-dai = <&speaker_codec>;
+               };
+       };
+};
+
 &usb {
        status = "okay";
        extcon = <&muic>, <&muic>;
index 0824ab041d805d80ead62addaedbfc6ff5802eef..3c49dac92d2d4ad88074ec547264acb0398bcd29 100644 (file)
        };
 };
 
+&mpss_mem {
+       reg = <0x0 0x86800000 0x0 0x5a00000>;
+};
+
 &reg_motor_vdd {
        regulator-min-microvolt = <3300000>;
        regulator-max-microvolt = <3300000>;
index 3f145dde4059f86992a40002496a7bc7ec59bb4b..5882b3a593b8c9cf850690ece85f7a0802b32e16 100644 (file)
        status = "disabled";
 };
 
+&sound {
+       model = "samsung-gmax"; /* No secondary microphone */
+};
+
 &tlmm {
        gpio_leds_default: gpio-led-default-state {
                pins = "gpio60";