Skip to contentSkip to conversation

msm8916-huawei-g7: Add sound and clarify installation

PATCH New Stephan Gerhold 1 participant 3 messages Apr 10, 2022

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

cover msm8916-huawei-g7: Add sound and clarify installation

This patch set adds the sound card to the msm8916-huawei-g7 device tree and clarifies the suggested installation instructions. Speakers, headphones and the microphones are all functional, although the audio jack detection is a bit unreliable sometimes (not a big problem though).

Stephan Gerhold (2):
arm64: dts: qcom: msm8916-huawei-g7: Clarify installation instructions
arm64: dts: qcom: msm8916-huawei-g7: Add sound card

 .../arm64/boot/dts/qcom/msm8916-huawei-g7.dts | 59 ++++++++++++++++---
 1 file changed, 50 insertions(+), 9 deletions(-)
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 arm64: dts: qcom: msm8916-huawei-g7: Clarify installation instructions

The comment with installation instructions in the huawei-g7 device tree is a bit misleading and does not describe the recommended installation steps very well. The bootloader is actually not patched; to avoid all trouble with the vendor bootloader it is easier to bypass it completely by jumping to a custom bootloader (e.g. based on the open-source LK released by Qualcomm).

To avoid confusion, simplify the comment to state only the problem and then refer to the wiki article which contains detailed suggested installation instructions. This will also make it easier to keep it up to date with new developments in the future.

Fixes 55056b229189 ("arm64: dts: qcom: msm8916: Add device tree for Huawei Ascend G7")
---
 arch/arm64/boot/dts/qcom/msm8916-huawei-g7.dts | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
arch/arm64/boot/dts/qcom/msm8916-huawei-g7.dts +4 -9
index 42d93d3fba36..8ad9eb436a0c 100644
@@ -11,15 +11,10 @@
 
 /*
  * Note: The original firmware from Huawei can only boot 32-bit kernels.
- * To boot arm64 kernels it is necessary to flash 64-bit TZ/HYP firmware
- * with EDL, e.g. taken from the DragonBoard 410c. This works because Huawei
- * forgot to set up (firmware) secure boot for some reason.
- *
- * Also note that Huawei no longer provides bootloader unlock codes.
- * This can be bypassed by patching the bootloader from a custom HYP firmware,
- * making it think the bootloader is unlocked.
- *
- * See: https://wiki.postmarketos.org/wiki/Huawei_Ascend_G7_(huawei-g7)
+ * To boot this device tree using arm64 it is necessary to flash 64-bit TZ/HYP
+ * firmware (e.g. taken from the DragonBoard 410c).
+ * See https://wiki.postmarketos.org/wiki/Huawei_Ascend_G7_(huawei-g7)
+ * for suggested installation instructions.
  */
 
 / {
Signature · 1 line
2.35.1
#2 lore raw

PATCH 2/2 arm64: dts: qcom: msm8916-huawei-g7: Add sound card

In reply to Stephan Gerhold

The huawei-g7 uses the msm8916-wcd-digital/analog audio codecs similar to apq8016-sbc, so we can mostly copy paste it from there to make audio work correctly. The main difference is the hphl-jack-type-normally-open property, which is needed to avoid inverted audio jack detection.

Note that at least on my device the jack detection is not fully
reliable: sometimes headphones are detected as headsets (with microphone). However, this is not a big problem for typical usage.

---
 .../arm64/boot/dts/qcom/msm8916-huawei-g7.dts | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
arch/arm64/boot/dts/qcom/msm8916-huawei-g7.dts +46 -0
index 8ad9eb436a0c..00488afb413d 100644
@@ -8,6 +8,7 @@
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/leds/common.h>
+#include <dt-bindings/sound/apq8016-lpass.h>
 
 /*
  * Note: The original firmware from Huawei can only boot 32-bit kernels.
@@ -211,6 +212,10 @@ &blsp1_uart2 {
 	status = "okay";
 };
 
+&lpass {
+	status = "okay";
+};
+
 &pm8916_resin {
 	status = "okay";
 	linux,code = <KEY_VOLUMEDOWN>;
@@ -255,6 +260,40 @@ &sdhc_2 {
 	cd-gpios = <&msmgpio 56 GPIO_ACTIVE_LOW>;
 };
 
+&sound {
+	status = "okay";
+
+	model = "msm8916";
+	audio-routing =
+		"AMIC1", "MIC BIAS External1",
+		"AMIC2", "MIC BIAS External2",
+		"AMIC3", "MIC BIAS External1";
+
+	pinctrl-names = "default", "sleep";
+	pinctrl-0 = <&cdc_pdm_lines_act>;
+	pinctrl-1 = <&cdc_pdm_lines_sus>;
+
+	primary-dai-link {
+		link-name = "WCD";
+		cpu {
+			sound-dai = <&lpass MI2S_PRIMARY>;
+		};
+		codec {
+			sound-dai = <&lpass_codec 0>, <&wcd_codec 0>;
+		};
+	};
+
+	tertiary-dai-link {
+		link-name = "WCD-Capture";
+		cpu {
+			sound-dai = <&lpass MI2S_TERTIARY>;
+		};
+		codec {
+			sound-dai = <&lpass_codec 1>, <&wcd_codec 1>;
+		};
+	};
+};
+
 &usb {
 	status = "okay";
 	extcon = <&usb_id>, <&usb_id>;
@@ -264,6 +303,13 @@ &usb_hs_phy {
 	extcon = <&usb_id>;
 };
 
+&wcd_codec {
+	qcom,micbias-lvl = <2800>;
+	qcom,mbhc-vthreshold-low = <75 150 237 450 500>;
+	qcom,mbhc-vthreshold-high = <75 150 237 450 500>;
+	qcom,hphl-jack-type-normally-open;
+};
+
 &smd_rpm_regulators {
 	vdd_l1_l2_l3-supply = <&pm8916_s3>;
 	vdd_l4_l5_l6-supply = <&pm8916_s4>;
Signature · 1 line
2.35.1