2023-09-26 19:33:15

by Stephan Gerhold

[permalink] [raw]
Subject: [PATCH 07/13] arm64: dts: qcom: msm8916-alcatel-idol347: Add sound and modem

From: Vincent Knecht <[email protected]>

Enable sound and modem for the Alcatel Idol 3 (4.7"). The setup is
similar to most MSM8916 devices, i.e.:

- QDSP6 audio
- Microphones via digital/analog codec in MSM8916/PM8916
- WWAN Internet via BAM-DMUX

except:

- Stereo NXP TFA9890 codecs for speakers on Quaternary MI2S
- These are also used as earpieces at the top/bottom.
- Asahi Kasei AK4375 headphone codec on Secondary MI2S
-> Primary MI2S is not used for playback

Signed-off-by: Vincent Knecht <[email protected]>
[Stephan: minor cleanup, add consistent commit message]
Signed-off-by: Stephan Gerhold <[email protected]>
---
There are some trivial conflicts unless
https://lore.kernel.org/linux-arm-msm/[email protected]/
is applied first. But given that there are important fixups for the
dynamic reserved memory changes in that series it should preferably
get applied before this one anyway.
---
.../boot/dts/qcom/msm8916-alcatel-idol347.dts | 164 +++++++++++++++++++++
1 file changed, 164 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts b/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
index fade93c55299..ef5fc9289754 100644
--- a/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
+++ b/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
@@ -3,6 +3,8 @@
/dts-v1/;

#include "msm8916-pm8916.dtsi"
+#include "msm8916-modem-qdsp6.dtsi"
+
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>
#include <dt-bindings/leds/common.h>
@@ -22,6 +24,19 @@ chosen {
stdout-path = "serial0";
};

+ reserved-memory {
+ /delete-node/ reserved@86680000;
+ /delete-node/ rmtfs@86700000;
+
+ rmtfs: rmtfs@86680000 {
+ compatible = "qcom,rmtfs-mem";
+ reg = <0x0 0x86680000 0x0 0x160000>;
+ no-map;
+
+ qcom,client-id = <1>;
+ };
+ };
+
gpio-keys {
compatible = "gpio-keys";

@@ -50,6 +65,17 @@ led-0 {
};
};

+ reg_headphones_avdd: regulator-headphones-avdd {
+ compatible = "regulator-fixed";
+ regulator-name = "headphones_avdd";
+ regulator-min-microvolt = <1800000>;
+ regulator-max-microvolt = <1800000>;
+ gpio = <&tlmm 121 GPIO_ACTIVE_HIGH>;
+ enable-active-high;
+ pinctrl-0 = <&headphones_avdd_default>;
+ pinctrl-names = "default";
+ };
+
usb_id: usb-id {
compatible = "linux,extcon-usb-gpio";
id-gpios = <&tlmm 69 GPIO_ACTIVE_HIGH>;
@@ -58,6 +84,43 @@ usb_id: usb-id {
};
};

+&blsp_i2c3 {
+ status = "okay";
+
+ headphones: audio-codec@10 {
+ compatible = "asahi-kasei,ak4375";
+ reg = <0x10>;
+ avdd-supply = <&reg_headphones_avdd>;
+ tvdd-supply = <&pm8916_l6>;
+ pdn-gpios = <&tlmm 114 GPIO_ACTIVE_HIGH>;
+ pinctrl-0 = <&headphones_pdn_default>;
+ pinctrl-names = "default";
+ #sound-dai-cells = <0>;
+ };
+
+ speaker_codec_top: audio-codec@34 {
+ compatible = "nxp,tfa9897";
+ reg = <0x34>;
+ vddd-supply = <&pm8916_l6>;
+ rcv-gpios = <&tlmm 50 GPIO_ACTIVE_HIGH>;
+ pinctrl-0 = <&speaker_top_default>;
+ pinctrl-names = "default";
+ sound-name-prefix = "Speaker Top";
+ #sound-dai-cells = <0>;
+ };
+
+ speaker_codec_bottom: audio-codec@36 {
+ compatible = "nxp,tfa9897";
+ reg = <0x36>;
+ vddd-supply = <&pm8916_l6>;
+ rcv-gpios = <&tlmm 111 GPIO_ACTIVE_HIGH>;
+ pinctrl-0 = <&speaker_bottom_default>;
+ pinctrl-names = "default";
+ sound-name-prefix = "Speaker Bottom";
+ #sound-dai-cells = <0>;
+ };
+};
+
&blsp_i2c4 {
status = "okay";

@@ -153,6 +216,18 @@ &blsp_uart2 {
status = "okay";
};

+&mpss_mem {
+ reg = <0x0 0x86800000 0x0 0x5000000>;
+};
+
+&pm8916_codec {
+ qcom,micbias1-ext-cap;
+ qcom,micbias-lvl = <2800>;
+ qcom,mbhc-vthreshold-low = <75 100 120 180 500>;
+ qcom,mbhc-vthreshold-high = <75 100 120 180 500>;
+ qcom,hphl-jack-type-normally-open;
+};
+
&pm8916_resin {
status = "okay";
linux,code = <KEY_VOLUMEDOWN>;
@@ -169,6 +244,17 @@ &pm8916_vib {
status = "okay";
};

+&q6afedai {
+ dai@18 {
+ reg = <SECONDARY_MI2S_RX>;
+ qcom,sd-lines = <0>;
+ };
+ dai@22 {
+ reg = <QUATERNARY_MI2S_RX>;
+ qcom,sd-lines = <0>;
+ };
+};
+
&sdhc_1 {
status = "okay";
};
@@ -183,6 +269,47 @@ &sdhc_2 {
cd-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>;
};

+&sound {
+ status = "okay";
+
+ /* Add pin switches for speakers to allow disabling them individually */
+ model = "alcatel-idol3";
+ widgets =
+ "Speaker", "Speaker Top",
+ "Speaker", "Speaker Bottom";
+ pin-switches = "Speaker Top", "Speaker Bottom";
+ audio-routing =
+ "Speaker Top", "Speaker Top OUT",
+ "Speaker Bottom", "Speaker Bottom OUT",
+ "AMIC1", "MIC BIAS External1",
+ "AMIC2", "MIC BIAS Internal2",
+ "AMIC3", "MIC BIAS External1";
+
+ pinctrl-0 = <&cdc_pdm_default &pri_mi2s_default &pri_mi2s_ws_default &sec_mi2s_default>;
+ pinctrl-1 = <&cdc_pdm_sleep &pri_mi2s_sleep &pri_mi2s_ws_sleep &sec_mi2s_sleep>;
+ pinctrl-names = "default", "sleep";
+};
+
+&sound_dai_primary {
+ status = "disabled";
+};
+
+&sound_dai_quaternary {
+ status = "okay";
+
+ codec {
+ sound-dai = <&speaker_codec_top>, <&speaker_codec_bottom>;
+ };
+};
+
+&sound_dai_secondary {
+ status = "okay";
+
+ codec {
+ sound-dai = <&headphones>;
+ };
+};
+
&usb {
status = "okay";
extcon = <&usb_id>, <&usb_id>;
@@ -212,6 +339,15 @@ &wcnss_mem {
status = "okay";
};

+/* Only some of the pins are used */
+&pri_mi2s_default {
+ pins = "gpio113", "gpio115";
+};
+
+&pri_mi2s_sleep {
+ pins = "gpio113", "gpio115";
+};
+
&tlmm {
accel_int_default: accel-int-default-state {
pins = "gpio31";
@@ -245,6 +381,20 @@ gyro_int_default: gyro-int-default-state {
bias-disable;
};

+ headphones_avdd_default: headphones-avdd-default-state {
+ pins = "gpio121";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-disable;
+ };
+
+ headphones_pdn_default: headphones-pdn-default-state {
+ pins = "gpio114";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-disable;
+ };
+
/*
* The OEM wired an additional GPIO to be asserted so that
* the si-en,sn3190 LED IC works. Since this GPIO is not
@@ -291,6 +441,20 @@ sdc2_cd_default: sdc2-cd-default-state {
bias-disable;
};

+ speaker_bottom_default: speaker-bottom-default-state {
+ pins = "gpio111";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-disable;
+ };
+
+ speaker_top_default: speaker-top-default-state {
+ pins = "gpio50";
+ function = "gpio";
+ drive-strength = <2>;
+ bias-disable;
+ };
+
ts_int_reset_default: ts-int-reset-default-state {
pins = "gpio13", "gpio100";
function = "gpio";

--
2.42.0


2023-09-26 23:00:41

by Stephan Gerhold

[permalink] [raw]
Subject: Re: [PATCH 07/13] arm64: dts: qcom: msm8916-alcatel-idol347: Add sound and modem

On Tue, Sep 26, 2023 at 08:58:12PM +0200, Konrad Dybcio wrote:
> On 26.09.2023 18:51, Stephan Gerhold wrote:
> > From: Vincent Knecht <[email protected]>
> >
> > Enable sound and modem for the Alcatel Idol 3 (4.7"). The setup is
> > similar to most MSM8916 devices, i.e.:
> >
> > - QDSP6 audio
> > - Microphones via digital/analog codec in MSM8916/PM8916
> > - WWAN Internet via BAM-DMUX
> >
> > except:
> >
> > - Stereo NXP TFA9890 codecs for speakers on Quaternary MI2S
> > - These are also used as earpieces at the top/bottom.
> > - Asahi Kasei AK4375 headphone codec on Secondary MI2S
> > -> Primary MI2S is not used for playback
> >
> > Signed-off-by: Vincent Knecht <[email protected]>
> > [Stephan: minor cleanup, add consistent commit message]
> > Signed-off-by: Stephan Gerhold <[email protected]>
> > ---
> > There are some trivial conflicts unless
> > https://lore.kernel.org/linux-arm-msm/[email protected]/
> > is applied first. But given that there are important fixups for the
> > dynamic reserved memory changes in that series it should preferably
> > get applied before this one anyway.
> > ---
> > .../boot/dts/qcom/msm8916-alcatel-idol347.dts | 164 +++++++++++++++++++++
> > 1 file changed, 164 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts b/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
> > index fade93c55299..ef5fc9289754 100644
> > --- a/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
> > +++ b/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
> > @@ -3,6 +3,8 @@
> > /dts-v1/;
> >
> > #include "msm8916-pm8916.dtsi"
> > +#include "msm8916-modem-qdsp6.dtsi"
> > +
> > #include <dt-bindings/gpio/gpio.h>
> > #include <dt-bindings/input/input.h>
> > #include <dt-bindings/leds/common.h>
> > @@ -22,6 +24,19 @@ chosen {
> > stdout-path = "serial0";
> > };
> >
> > + reserved-memory {
> > + /delete-node/ reserved@86680000;
> > + /delete-node/ rmtfs@86700000;
> Deleting with a label reference is strongly preferred to avoid
> mistakes.
>

I would say the opposite applies here. The deletions are based on the
assumption that the nodes are at the address that are listed here. If
you would move rmtfs somewhere else the adjustments made here must be
re-evaulated.

/delete-node/ throws an error if the referenced name does not exist,
so it's exactly the indication we need if someone makes changes to the
original node in the SoC dtsi.

Note that this is different from property assignments, i.e.

/ {
reserved-memory {
rmtfs@86700000 {
status = "disabled";
};
};
};

instead of

&rmtfs {
status = "disabled";
};

because here there would not be an error if the node is renamed.

> [...]
>
> >
> > +&q6afedai {
> > + dai@18 {
> > + reg = <SECONDARY_MI2S_RX>;
> > + qcom,sd-lines = <0>;
> > + };
> > + dai@22 {
> Missing newline above
>

Thanks, will fix this!

>
> > +
> > +&sound_dai_primary {
> > + status = "disabled";
> > +};
> > +
> Hm, gives me an idea to sprinkle a bit more /omit-if-no-ref/ in
> patch 3..
>

(See reply in patch 3, /omit-if-no-ref/ sadly only works for phandle
references...)

Thanks,
Stephan

2023-09-27 09:56:55

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 07/13] arm64: dts: qcom: msm8916-alcatel-idol347: Add sound and modem

On 26.09.2023 18:51, Stephan Gerhold wrote:
> From: Vincent Knecht <[email protected]>
>
> Enable sound and modem for the Alcatel Idol 3 (4.7"). The setup is
> similar to most MSM8916 devices, i.e.:
>
> - QDSP6 audio
> - Microphones via digital/analog codec in MSM8916/PM8916
> - WWAN Internet via BAM-DMUX
>
> except:
>
> - Stereo NXP TFA9890 codecs for speakers on Quaternary MI2S
> - These are also used as earpieces at the top/bottom.
> - Asahi Kasei AK4375 headphone codec on Secondary MI2S
> -> Primary MI2S is not used for playback
>
> Signed-off-by: Vincent Knecht <[email protected]>
> [Stephan: minor cleanup, add consistent commit message]
> Signed-off-by: Stephan Gerhold <[email protected]>
> ---
> There are some trivial conflicts unless
> https://lore.kernel.org/linux-arm-msm/[email protected]/
> is applied first. But given that there are important fixups for the
> dynamic reserved memory changes in that series it should preferably
> get applied before this one anyway.
> ---
> .../boot/dts/qcom/msm8916-alcatel-idol347.dts | 164 +++++++++++++++++++++
> 1 file changed, 164 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts b/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
> index fade93c55299..ef5fc9289754 100644
> --- a/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
> +++ b/arch/arm64/boot/dts/qcom/msm8916-alcatel-idol347.dts
> @@ -3,6 +3,8 @@
> /dts-v1/;
>
> #include "msm8916-pm8916.dtsi"
> +#include "msm8916-modem-qdsp6.dtsi"
> +
> #include <dt-bindings/gpio/gpio.h>
> #include <dt-bindings/input/input.h>
> #include <dt-bindings/leds/common.h>
> @@ -22,6 +24,19 @@ chosen {
> stdout-path = "serial0";
> };
>
> + reserved-memory {
> + /delete-node/ reserved@86680000;
> + /delete-node/ rmtfs@86700000;
Deleting with a label reference is strongly preferred to avoid
mistakes.

[...]

>
> +&q6afedai {
> + dai@18 {
> + reg = <SECONDARY_MI2S_RX>;
> + qcom,sd-lines = <0>;
> + };
> + dai@22 {
Missing newline above

[...]

> +
> +&sound_dai_primary {
> + status = "disabled";
> +};
> +
Hm, gives me an idea to sprinkle a bit more /omit-if-no-ref/ in
patch 3..

Konrad