2023-10-13 08:10:33

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 0/4] Add Fairphone 5 thermals (PMK7325, PM7250B, PM7325)

Configure the necessary components to register some thermal zones in
Linux for the different thermistors found on the Fairphone 5.

The names for the thermal zones and ADCs were taken from the downstream
kernel but double checked against hardware schematics.

Signed-off-by: Luca Weiss <[email protected]>
---
Luca Weiss (4):
iio: adc: Add PM7325 PMIC7 ADC bindings
arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7250B thermals
arm64: dts: qcom: qcm6490-fairphone-fp5: Add PMK7325 thermals
arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7325 thermals

arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 221 +++++++++++++++++++++
include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h | 69 +++++++
2 files changed, 290 insertions(+)
---
base-commit: 7c0d0c1272e82888aa01017818d00245d452b895
change-id: 20231013-fp5-thermals-2b318c859dd4

Best regards,
--
Luca Weiss <[email protected]>


2023-10-13 08:10:58

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 4/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7325 thermals

Configure the thermals for the QUIET_THERM, CAM_FLASH_THERM, MSM_THERM
and RFC_CAM_THERM thermistors connected to PM7325.

With this PMIC the software communication to the ADC is going through
PMK7325 (= PMK8350).

Signed-off-by: Luca Weiss <[email protected]>
---
arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 117 +++++++++++++++++++++
1 file changed, 117 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
index 2c01f799a6b2..d0b1e4e507ff 100644
--- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
+++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
@@ -9,6 +9,7 @@
#define PM7250B_SID 8
#define PM7250B_SID1 9

+#include <dt-bindings/iio/qcom,spmi-adc7-pm7325.h>
#include <dt-bindings/iio/qcom,spmi-adc7-pmk8350.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
@@ -137,6 +138,20 @@ afvdd_2p8: regulator-afvdd-2p8 {
};

thermal-zones {
+ camera-thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+ thermal-sensors = <&pmk8350_adc_tm 2>;
+
+ trips {
+ active-config0 {
+ temperature = <125000>;
+ hysteresis = <1000>;
+ type = "passive";
+ };
+ };
+ };
+
chg-skin-thermal {
polling-delay-passive = <0>;
polling-delay = <0>;
@@ -165,6 +180,48 @@ active-config0 {
};
};

+ quiet-thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+ thermal-sensors = <&pmk8350_adc_tm 1>;
+
+ trips {
+ active-config0 {
+ temperature = <125000>;
+ hysteresis = <1000>;
+ type = "passive";
+ };
+ };
+ };
+
+ rear-cam-thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+ thermal-sensors = <&pmk8350_adc_tm 4>;
+
+ trips {
+ active-config0 {
+ temperature = <125000>;
+ hysteresis = <1000>;
+ type = "passive";
+ };
+ };
+ };
+
+ sdm-skin-thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+ thermal-sensors = <&pmk8350_adc_tm 3>;
+
+ trips {
+ active-config0 {
+ temperature = <125000>;
+ hysteresis = <1000>;
+ type = "passive";
+ };
+ };
+ };
+
xo-thermal {
polling-delay-passive = <0>;
polling-delay = <0>;
@@ -538,6 +595,34 @@ xo-therm@0 {
qcom,ratiometric;
qcom,hw-settle-time-us = <200>;
};
+
+ quiet-therm@1 {
+ reg = <1>;
+ io-channels = <&pmk8350_vadc PM7325_ADC7_AMUX_THM1_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time-us = <200>;
+ };
+
+ cam-flash-therm@2 {
+ reg = <2>;
+ io-channels = <&pmk8350_vadc PM7325_ADC7_AMUX_THM2_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time-us = <200>;
+ };
+
+ sdm-skin-therm@3 {
+ reg = <3>;
+ io-channels = <&pmk8350_vadc PM7325_ADC7_AMUX_THM3_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time-us = <200>;
+ };
+
+ wide-rfc-therm@4 {
+ reg = <4>;
+ io-channels = <&pmk8350_vadc PM7325_ADC7_AMUX_THM4_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time-us = <200>;
+ };
};

&pmk8350_rtc {
@@ -554,6 +639,38 @@ channel@44 {
qcom,pre-scaling = <1 1>;
label = "pmk8350_xo_therm";
};
+
+ channel@144 {
+ reg = <PM7325_ADC7_AMUX_THM1_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time = <200>;
+ qcom,pre-scaling = <1 1>;
+ label = "pm7325_quiet_therm";
+ };
+
+ channel@145 {
+ reg = <PM7325_ADC7_AMUX_THM2_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time = <200>;
+ qcom,pre-scaling = <1 1>;
+ label = "pm7325_cam_flash_therm";
+ };
+
+ channel@146 {
+ reg = <PM7325_ADC7_AMUX_THM3_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time = <200>;
+ qcom,pre-scaling = <1 1>;
+ label = "pm7325_sdm_skin_therm";
+ };
+
+ channel@147 {
+ reg = <PM7325_ADC7_AMUX_THM4_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time = <200>;
+ qcom,pre-scaling = <1 1>;
+ label = "pm7325_wide_rfc_therm";
+ };
};

&pon_pwrkey {

--
2.42.0

2023-10-13 08:11:38

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 2/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7250B thermals

Configure the thermals for the CHARGER_SKIN_THERM and USB_CONN_THERM
thermistors connected to PM7250B.

Signed-off-by: Luca Weiss <[email protected]>
---
arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 66 ++++++++++++++++++++++
1 file changed, 66 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
index 2de0b8c26c35..7fe19b556e6a 100644
--- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
+++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
@@ -134,6 +134,36 @@ afvdd_2p8: regulator-afvdd-2p8 {
enable-active-high;
vin-supply = <&vreg_bob>;
};
+
+ thermal-zones {
+ chg-skin-thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+ thermal-sensors = <&pm7250b_adc_tm 0>;
+
+ trips {
+ active-config0 {
+ temperature = <125000>;
+ hysteresis = <1000>;
+ type = "passive";
+ };
+ };
+ };
+
+ conn-thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+ thermal-sensors = <&pm7250b_adc_tm 1>;
+
+ trips {
+ active-config0 {
+ temperature = <125000>;
+ hysteresis = <1000>;
+ type = "passive";
+ };
+ };
+ };
+ };
};

&apps_rsc {
@@ -425,6 +455,42 @@ &ipa {
status = "okay";
};

+&pm7250b_adc {
+ channel@4d {
+ reg = <ADC5_AMUX_THM1_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time = <200>;
+ qcom,pre-scaling = <1 1>;
+ label = "charger_skin_therm";
+ };
+
+ channel@4f {
+ reg = <ADC5_AMUX_THM3_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time = <200>;
+ qcom,pre-scaling = <1 1>;
+ label = "conn_therm";
+ };
+};
+
+&pm7250b_adc_tm {
+ status = "okay";
+
+ charger-skin-therm@0 {
+ reg = <0>;
+ io-channels = <&pm7250b_adc ADC5_AMUX_THM1_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time-us = <200>;
+ };
+
+ conn-therm@1 {
+ reg = <1>;
+ io-channels = <&pm7250b_adc ADC5_AMUX_THM3_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time-us = <200>;
+ };
+};
+
&pm7325_gpios {
volume_down_default: volume-down-default-state {
pins = "gpio6";

--
2.42.0

2023-10-13 08:12:15

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 1/4] iio: adc: Add PM7325 PMIC7 ADC bindings

Add the defines for the ADC channels found on the PM7325. The list is
taken from downstream msm-5.4 and adjusted for mainline.

Signed-off-by: Luca Weiss <[email protected]>
---
include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h | 69 +++++++++++++++++++++++++
1 file changed, 69 insertions(+)

diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h b/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h
new file mode 100644
index 000000000000..96908014e09e
--- /dev/null
+++ b/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h
@@ -0,0 +1,69 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (c) 2020 The Linux Foundation. All rights reserved.
+ */
+
+#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PM7325_H
+#define _DT_BINDINGS_QCOM_SPMI_VADC_PM7325_H
+
+#ifndef PM7325_SID
+#define PM7325_SID 1
+#endif
+
+#include <dt-bindings/iio/qcom,spmi-vadc.h>
+
+/* ADC channels for PM7325_ADC for PMIC7 */
+#define PM7325_ADC7_REF_GND (PM7325_SID << 8 | ADC7_REF_GND)
+#define PM7325_ADC7_1P25VREF (PM7325_SID << 8 | ADC7_1P25VREF)
+#define PM7325_ADC7_VREF_VADC (PM7325_SID << 8 | ADC7_VREF_VADC)
+#define PM7325_ADC7_DIE_TEMP (PM7325_SID << 8 | ADC7_DIE_TEMP)
+
+#define PM7325_ADC7_AMUX_THM1 (PM7325_SID << 8 | ADC7_AMUX_THM1)
+#define PM7325_ADC7_AMUX_THM2 (PM7325_SID << 8 | ADC7_AMUX_THM2)
+#define PM7325_ADC7_AMUX_THM3 (PM7325_SID << 8 | ADC7_AMUX_THM3)
+#define PM7325_ADC7_AMUX_THM4 (PM7325_SID << 8 | ADC7_AMUX_THM4)
+#define PM7325_ADC7_AMUX_THM5 (PM7325_SID << 8 | ADC7_AMUX_THM5)
+#define PM7325_ADC7_GPIO1 (PM7325_SID << 8 | ADC7_GPIO1)
+#define PM7325_ADC7_GPIO2 (PM7325_SID << 8 | ADC7_GPIO2)
+#define PM7325_ADC7_GPIO3 (PM7325_SID << 8 | ADC7_GPIO3)
+#define PM7325_ADC7_GPIO4 (PM7325_SID << 8 | ADC7_GPIO4)
+
+/* 30k pull-up1 */
+#define PM7325_ADC7_AMUX_THM1_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM1_30K_PU)
+#define PM7325_ADC7_AMUX_THM2_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM2_30K_PU)
+#define PM7325_ADC7_AMUX_THM3_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM3_30K_PU)
+#define PM7325_ADC7_AMUX_THM4_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM4_30K_PU)
+#define PM7325_ADC7_AMUX_THM5_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM5_30K_PU)
+#define PM7325_ADC7_GPIO1_30K_PU (PM7325_SID << 8 | ADC7_GPIO1_30K_PU)
+#define PM7325_ADC7_GPIO2_30K_PU (PM7325_SID << 8 | ADC7_GPIO2_30K_PU)
+#define PM7325_ADC7_GPIO3_30K_PU (PM7325_SID << 8 | ADC7_GPIO3_30K_PU)
+#define PM7325_ADC7_GPIO4_30K_PU (PM7325_SID << 8 | ADC7_GPIO4_30K_PU)
+
+/* 100k pull-up2 */
+#define PM7325_ADC7_AMUX_THM1_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM1_100K_PU)
+#define PM7325_ADC7_AMUX_THM2_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM2_100K_PU)
+#define PM7325_ADC7_AMUX_THM3_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM3_100K_PU)
+#define PM7325_ADC7_AMUX_THM4_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM4_100K_PU)
+#define PM7325_ADC7_AMUX_THM5_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM5_100K_PU)
+#define PM7325_ADC7_GPIO1_100K_PU (PM7325_SID << 8 | ADC7_GPIO1_100K_PU)
+#define PM7325_ADC7_GPIO2_100K_PU (PM7325_SID << 8 | ADC7_GPIO2_100K_PU)
+#define PM7325_ADC7_GPIO3_100K_PU (PM7325_SID << 8 | ADC7_GPIO3_100K_PU)
+#define PM7325_ADC7_GPIO4_100K_PU (PM7325_SID << 8 | ADC7_GPIO4_100K_PU)
+
+/* 400k pull-up3 */
+#define PM7325_ADC7_AMUX_THM1_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM1_400K_PU)
+#define PM7325_ADC7_AMUX_THM2_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM2_400K_PU)
+#define PM7325_ADC7_AMUX_THM3_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM3_400K_PU)
+#define PM7325_ADC7_AMUX_THM4_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM4_400K_PU)
+#define PM7325_ADC7_AMUX_THM5_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM5_400K_PU)
+#define PM7325_ADC7_GPIO1_400K_PU (PM7325_SID << 8 | ADC7_GPIO1_400K_PU)
+#define PM7325_ADC7_GPIO2_400K_PU (PM7325_SID << 8 | ADC7_GPIO2_400K_PU)
+#define PM7325_ADC7_GPIO3_400K_PU (PM7325_SID << 8 | ADC7_GPIO3_400K_PU)
+#define PM7325_ADC7_GPIO4_400K_PU (PM7325_SID << 8 | ADC7_GPIO4_400K_PU)
+
+/* 1/3 Divider */
+#define PM7325_ADC7_GPIO4_DIV3 (PM7325_SID << 8 | ADC7_GPIO4_DIV3)
+
+#define PM7325_ADC7_VPH_PWR (PM7325_SID << 8 | ADC7_VPH_PWR)
+
+#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PM7325_H */

--
2.42.0

2023-10-13 08:12:27

by Luca Weiss

[permalink] [raw]
Subject: [PATCH 3/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PMK7325 thermals

Configure the thermals for the XO_THERM line connected to PMK7325 (named
in software PMK8350).

Signed-off-by: Luca Weiss <[email protected]>
---
arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
index 7fe19b556e6a..2c01f799a6b2 100644
--- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
+++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
@@ -9,6 +9,7 @@
#define PM7250B_SID 8
#define PM7250B_SID1 9

+#include <dt-bindings/iio/qcom,spmi-adc7-pmk8350.h>
#include <dt-bindings/leds/common.h>
#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
#include <dt-bindings/regulator/qcom,rpmh-regulator.h>
@@ -163,6 +164,20 @@ active-config0 {
};
};
};
+
+ xo-thermal {
+ polling-delay-passive = <0>;
+ polling-delay = <0>;
+ thermal-sensors = <&pmk8350_adc_tm 0>;
+
+ trips {
+ active-config0 {
+ temperature = <125000>;
+ hysteresis = <1000>;
+ type = "passive";
+ };
+ };
+ };
};
};

@@ -514,10 +529,33 @@ led-0 {
};
};

+&pmk8350_adc_tm {
+ status = "okay";
+
+ xo-therm@0 {
+ reg = <0>;
+ io-channels = <&pmk8350_vadc PMK8350_ADC7_AMUX_THM1_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time-us = <200>;
+ };
+};
+
&pmk8350_rtc {
status = "okay";
};

+&pmk8350_vadc {
+ status = "okay";
+
+ channel@44 {
+ reg = <PMK8350_ADC7_AMUX_THM1_100K_PU>;
+ qcom,ratiometric;
+ qcom,hw-settle-time = <200>;
+ qcom,pre-scaling = <1 1>;
+ label = "pmk8350_xo_therm";
+ };
+};
+
&pon_pwrkey {
status = "okay";
};

--
2.42.0

2023-10-13 08:39:13

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 1/4] iio: adc: Add PM7325 PMIC7 ADC bindings

On 13/10/2023 10:09, Luca Weiss wrote:
> Add the defines for the ADC channels found on the PM7325. The list is
> taken from downstream msm-5.4 and adjusted for mainline.

Please use subject prefixes matching the subsystem. You can get them for
example with `git log --oneline -- DIRECTORY_OR_FILE` on the directory
your patch is touching.

>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h | 69 +++++++++++++++++++++++++
> 1 file changed, 69 insertions(+)
>
> diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h b/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h
> new file mode 100644
> index 000000000000..96908014e09e
> --- /dev/null
> +++ b/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h
> @@ -0,0 +1,69 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */

We expect the bindings to be dual licensed. What was the license of the
original work?

> +/*
> + * Copyright (c) 2020 The Linux Foundation. All rights reserved.
> + */



Best regards,
Krzysztof

2023-10-13 08:55:19

by Luca Weiss

[permalink] [raw]
Subject: Re: [PATCH 1/4] iio: adc: Add PM7325 PMIC7 ADC bindings

On Fri Oct 13, 2023 at 10:38 AM CEST, Krzysztof Kozlowski wrote:
> On 13/10/2023 10:09, Luca Weiss wrote:
> > Add the defines for the ADC channels found on the PM7325. The list is
> > taken from downstream msm-5.4 and adjusted for mainline.
>
> Please use subject prefixes matching the subsystem. You can get them for
> example with `git log --oneline -- DIRECTORY_OR_FILE` on the directory
> your patch is touching.

Seems very inconsistent (git log --oneline include/dt-bindings/iio/qcom,*)
but I guess this would fit better?

dt-bindings: iio: adc: Add PM7325 PMIC7 ADC bindings

Will update for v2.

>
> >
> > Signed-off-by: Luca Weiss <[email protected]>
> > ---
> > include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h | 69 +++++++++++++++++++++++++
> > 1 file changed, 69 insertions(+)
> >
> > diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h b/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h
> > new file mode 100644
> > index 000000000000..96908014e09e
> > --- /dev/null
> > +++ b/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h
> > @@ -0,0 +1,69 @@
> > +/* SPDX-License-Identifier: GPL-2.0-only */
>
> We expect the bindings to be dual licensed. What was the license of the
> original work?

Yes, just GPL-2.0-only:
https://git.codelinaro.org/clo/la/kernel/msm-5.4/-/blob/LA.UM.9.14.1.r1-08600-QCM6490.QSSI13.0/include/dt-bindings/iio/qcom%2Cspmi-adc7-pm7325.h

Unfortunately it's the same situation with all the other header files
like this one.

$ grep SPDX include/dt-bindings/iio/qcom,spmi-adc7-*
include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h:/* SPDX-License-Identifier: GPL-2.0-only */
include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h:/* SPDX-License-Identifier: GPL-2.0-only */
include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h:/* SPDX-License-Identifier: GPL-2.0-only */
include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h:/* SPDX-License-Identifier: GPL-2.0-only */
include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h:/* SPDX-License-Identifier: GPL-2.0-only */

If you know someone at Qualcomm to ask nicely to relicense those (plus
ones that will presumably be added later), that'd be appreciated.

Regards
Luca

>
> > +/*
> > + * Copyright (c) 2020 The Linux Foundation. All rights reserved.
> > + */
>
>
>
> Best regards,
> Krzysztof

2023-10-13 09:12:27

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 1/4] iio: adc: Add PM7325 PMIC7 ADC bindings

On 13/10/2023 10:54, Luca Weiss wrote:
>> We expect the bindings to be dual licensed. What was the license of the
>> original work?
>
> Yes, just GPL-2.0-only:
> https://git.codelinaro.org/clo/la/kernel/msm-5.4/-/blob/LA.UM.9.14.1.r1-08600-QCM6490.QSSI13.0/include/dt-bindings/iio/qcom%2Cspmi-adc7-pm7325.h
>
> Unfortunately it's the same situation with all the other header files
> like this one.
>
> $ grep SPDX include/dt-bindings/iio/qcom,spmi-adc7-*
> include/dt-bindings/iio/qcom,spmi-adc7-pm8350.h:/* SPDX-License-Identifier: GPL-2.0-only */
> include/dt-bindings/iio/qcom,spmi-adc7-pm8350b.h:/* SPDX-License-Identifier: GPL-2.0-only */
> include/dt-bindings/iio/qcom,spmi-adc7-pmk8350.h:/* SPDX-License-Identifier: GPL-2.0-only */
> include/dt-bindings/iio/qcom,spmi-adc7-pmr735a.h:/* SPDX-License-Identifier: GPL-2.0-only */
> include/dt-bindings/iio/qcom,spmi-adc7-pmr735b.h:/* SPDX-License-Identifier: GPL-2.0-only */
>
> If you know someone at Qualcomm to ask nicely to relicense those (plus
> ones that will presumably be added later), that'd be appreciated.

We could relicense Qualcomm stuff but this was transferred to Linux
Foundation. :/

Best regards,
Krzysztof

2023-10-13 23:11:51

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 2/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7250B thermals

On 13.10.2023 10:09, Luca Weiss wrote:
> Configure the thermals for the CHARGER_SKIN_THERM and USB_CONN_THERM
> thermistors connected to PM7250B.
>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 66 ++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> index 2de0b8c26c35..7fe19b556e6a 100644
> --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> @@ -134,6 +134,36 @@ afvdd_2p8: regulator-afvdd-2p8 {
> enable-active-high;
> vin-supply = <&vreg_bob>;
> };
> +
> + thermal-zones {
> + chg-skin-thermal {
skin

> + polling-delay-passive = <0>;
> + polling-delay = <0>;
> + thermal-sensors = <&pm7250b_adc_tm 0>;
> +
> + trips {
> + active-config0 {
> + temperature = <125000>;
125

hmm..

Konrad

2023-10-13 23:13:48

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 4/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7325 thermals

On 13.10.2023 10:09, Luca Weiss wrote:
> Configure the thermals for the QUIET_THERM, CAM_FLASH_THERM, MSM_THERM
> and RFC_CAM_THERM thermistors connected to PM7325.
>
> With this PMIC the software communication to the ADC is going through
> PMK7325 (= PMK8350).
>
> Signed-off-by: Luca Weiss <[email protected]>
> ---

> arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 117 +++++++++++++++++++++
> 1 file changed, 117 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> index 2c01f799a6b2..d0b1e4e507ff 100644
> --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> @@ -9,6 +9,7 @@
> #define PM7250B_SID 8
> #define PM7250B_SID1 9
>
> +#include <dt-bindings/iio/qcom,spmi-adc7-pm7325.h>
> #include <dt-bindings/iio/qcom,spmi-adc7-pmk8350.h>
> #include <dt-bindings/leds/common.h>
> #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
> @@ -137,6 +138,20 @@ afvdd_2p8: regulator-afvdd-2p8 {
> };
>
> thermal-zones {
> + camera-thermal {
> + polling-delay-passive = <0>;
> + polling-delay = <0>;
> + thermal-sensors = <&pmk8350_adc_tm 2>;
> +
> + trips {
> + active-config0 {
> + temperature = <125000>;
are

> + rear-cam-thermal {

> + temperature = <125000>;
you

> + sdm-skin-thermal {

> + temperature = <125000>;
sure

about these temps?

Konrad

2023-10-14 16:16:36

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 1/4] iio: adc: Add PM7325 PMIC7 ADC bindings

On Fri, 13 Oct 2023 10:09:53 +0200
Luca Weiss <[email protected]> wrote:

> Add the defines for the ADC channels found on the PM7325. The list is
> taken from downstream msm-5.4 and adjusted for mainline.
>
> Signed-off-by: Luca Weiss <[email protected]>

I assume this will go with the dts changes that use it.

Acked-by: Jonathan Cameron <[email protected]>

> ---
> include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h | 69 +++++++++++++++++++++++++
> 1 file changed, 69 insertions(+)
>
> diff --git a/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h b/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h
> new file mode 100644
> index 000000000000..96908014e09e
> --- /dev/null
> +++ b/include/dt-bindings/iio/qcom,spmi-adc7-pm7325.h
> @@ -0,0 +1,69 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Copyright (c) 2020 The Linux Foundation. All rights reserved.
> + */
> +
> +#ifndef _DT_BINDINGS_QCOM_SPMI_VADC_PM7325_H
> +#define _DT_BINDINGS_QCOM_SPMI_VADC_PM7325_H
> +
> +#ifndef PM7325_SID
> +#define PM7325_SID 1
> +#endif
> +
> +#include <dt-bindings/iio/qcom,spmi-vadc.h>
> +
> +/* ADC channels for PM7325_ADC for PMIC7 */
> +#define PM7325_ADC7_REF_GND (PM7325_SID << 8 | ADC7_REF_GND)
> +#define PM7325_ADC7_1P25VREF (PM7325_SID << 8 | ADC7_1P25VREF)
> +#define PM7325_ADC7_VREF_VADC (PM7325_SID << 8 | ADC7_VREF_VADC)
> +#define PM7325_ADC7_DIE_TEMP (PM7325_SID << 8 | ADC7_DIE_TEMP)
> +
> +#define PM7325_ADC7_AMUX_THM1 (PM7325_SID << 8 | ADC7_AMUX_THM1)
> +#define PM7325_ADC7_AMUX_THM2 (PM7325_SID << 8 | ADC7_AMUX_THM2)
> +#define PM7325_ADC7_AMUX_THM3 (PM7325_SID << 8 | ADC7_AMUX_THM3)
> +#define PM7325_ADC7_AMUX_THM4 (PM7325_SID << 8 | ADC7_AMUX_THM4)
> +#define PM7325_ADC7_AMUX_THM5 (PM7325_SID << 8 | ADC7_AMUX_THM5)
> +#define PM7325_ADC7_GPIO1 (PM7325_SID << 8 | ADC7_GPIO1)
> +#define PM7325_ADC7_GPIO2 (PM7325_SID << 8 | ADC7_GPIO2)
> +#define PM7325_ADC7_GPIO3 (PM7325_SID << 8 | ADC7_GPIO3)
> +#define PM7325_ADC7_GPIO4 (PM7325_SID << 8 | ADC7_GPIO4)
> +
> +/* 30k pull-up1 */
> +#define PM7325_ADC7_AMUX_THM1_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM1_30K_PU)
> +#define PM7325_ADC7_AMUX_THM2_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM2_30K_PU)
> +#define PM7325_ADC7_AMUX_THM3_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM3_30K_PU)
> +#define PM7325_ADC7_AMUX_THM4_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM4_30K_PU)
> +#define PM7325_ADC7_AMUX_THM5_30K_PU (PM7325_SID << 8 | ADC7_AMUX_THM5_30K_PU)
> +#define PM7325_ADC7_GPIO1_30K_PU (PM7325_SID << 8 | ADC7_GPIO1_30K_PU)
> +#define PM7325_ADC7_GPIO2_30K_PU (PM7325_SID << 8 | ADC7_GPIO2_30K_PU)
> +#define PM7325_ADC7_GPIO3_30K_PU (PM7325_SID << 8 | ADC7_GPIO3_30K_PU)
> +#define PM7325_ADC7_GPIO4_30K_PU (PM7325_SID << 8 | ADC7_GPIO4_30K_PU)
> +
> +/* 100k pull-up2 */
> +#define PM7325_ADC7_AMUX_THM1_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM1_100K_PU)
> +#define PM7325_ADC7_AMUX_THM2_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM2_100K_PU)
> +#define PM7325_ADC7_AMUX_THM3_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM3_100K_PU)
> +#define PM7325_ADC7_AMUX_THM4_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM4_100K_PU)
> +#define PM7325_ADC7_AMUX_THM5_100K_PU (PM7325_SID << 8 | ADC7_AMUX_THM5_100K_PU)
> +#define PM7325_ADC7_GPIO1_100K_PU (PM7325_SID << 8 | ADC7_GPIO1_100K_PU)
> +#define PM7325_ADC7_GPIO2_100K_PU (PM7325_SID << 8 | ADC7_GPIO2_100K_PU)
> +#define PM7325_ADC7_GPIO3_100K_PU (PM7325_SID << 8 | ADC7_GPIO3_100K_PU)
> +#define PM7325_ADC7_GPIO4_100K_PU (PM7325_SID << 8 | ADC7_GPIO4_100K_PU)
> +
> +/* 400k pull-up3 */
> +#define PM7325_ADC7_AMUX_THM1_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM1_400K_PU)
> +#define PM7325_ADC7_AMUX_THM2_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM2_400K_PU)
> +#define PM7325_ADC7_AMUX_THM3_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM3_400K_PU)
> +#define PM7325_ADC7_AMUX_THM4_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM4_400K_PU)
> +#define PM7325_ADC7_AMUX_THM5_400K_PU (PM7325_SID << 8 | ADC7_AMUX_THM5_400K_PU)
> +#define PM7325_ADC7_GPIO1_400K_PU (PM7325_SID << 8 | ADC7_GPIO1_400K_PU)
> +#define PM7325_ADC7_GPIO2_400K_PU (PM7325_SID << 8 | ADC7_GPIO2_400K_PU)
> +#define PM7325_ADC7_GPIO3_400K_PU (PM7325_SID << 8 | ADC7_GPIO3_400K_PU)
> +#define PM7325_ADC7_GPIO4_400K_PU (PM7325_SID << 8 | ADC7_GPIO4_400K_PU)
> +
> +/* 1/3 Divider */
> +#define PM7325_ADC7_GPIO4_DIV3 (PM7325_SID << 8 | ADC7_GPIO4_DIV3)
> +
> +#define PM7325_ADC7_VPH_PWR (PM7325_SID << 8 | ADC7_VPH_PWR)
> +
> +#endif /* _DT_BINDINGS_QCOM_SPMI_VADC_PM7325_H */
>

2023-10-14 18:12:45

by Luca Weiss

[permalink] [raw]
Subject: Re: [PATCH 4/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7325 thermals

On Samstag, 14. Oktober 2023 01:13:29 CEST Konrad Dybcio wrote:
> On 13.10.2023 10:09, Luca Weiss wrote:
> > Configure the thermals for the QUIET_THERM, CAM_FLASH_THERM, MSM_THERM
> > and RFC_CAM_THERM thermistors connected to PM7325.
> >
> > With this PMIC the software communication to the ADC is going through
> > PMK7325 (= PMK8350).
> >
> > Signed-off-by: Luca Weiss <[email protected]>
> > ---
> >
> > arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 117
> > +++++++++++++++++++++ 1 file changed, 117 insertions(+)
> >
> > diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> > b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts index
> > 2c01f799a6b2..d0b1e4e507ff 100644
> > --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> > +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> > @@ -9,6 +9,7 @@
> >
> > #define PM7250B_SID 8
> > #define PM7250B_SID1 9
> >
> > +#include <dt-bindings/iio/qcom,spmi-adc7-pm7325.h>
> >
> > #include <dt-bindings/iio/qcom,spmi-adc7-pmk8350.h>
> > #include <dt-bindings/leds/common.h>
> > #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
> >
> > @@ -137,6 +138,20 @@ afvdd_2p8: regulator-afvdd-2p8 {
> >
> > };
> >
> > thermal-zones {
> >
> > + camera-thermal {
> > + polling-delay-passive = <0>;
> > + polling-delay = <0>;
> > + thermal-sensors = <&pmk8350_adc_tm 2>;
> > +
> > + trips {
> > + active-config0 {
> > + temperature = <125000>;
>
> are
>
> > + rear-cam-thermal {
> >
> > + temperature = <125000>;
>
> you
>
> > + sdm-skin-thermal {
> >
> > + temperature = <125000>;
>
> sure
>
> about these temps?

(email from my other address, quicker right now)

Well yes and no.

Yes as in those are the temps specified in downstream dtb.
No as in I'm 99% sure there's user space with definitely lower threshold that
actually does something in response to the temps.

I didn't look too much into this but does the kernel even do something when it
hits one of these trip points? I assume when there's a cooling device thing
specified then it can actually tell the driver to do something, but without
(and most drivers don't support this?) I'm assuming the kernel can't do much
anyways?

So e.g. when the temperature for the flash led is reached I'm assuming
downstream (+Android) either dims the led or turns it off? But I'd have to dig
quite a bit into the thermal setup there to check what it's really doing.

But for now I think it's okay to put this current thermal config into dts and
we'll improve it later when 1. I understand more and 2. maybe some useful
drivers support the cooling bits?

Regards
Luca

>
> Konrad




2023-10-18 20:29:28

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 4/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7325 thermals



On 10/14/23 19:52, Luca Weiss wrote:
> On Samstag, 14. Oktober 2023 01:13:29 CEST Konrad Dybcio wrote:
>> On 13.10.2023 10:09, Luca Weiss wrote:
>>> Configure the thermals for the QUIET_THERM, CAM_FLASH_THERM, MSM_THERM
>>> and RFC_CAM_THERM thermistors connected to PM7325.
>>>
>>> With this PMIC the software communication to the ADC is going through
>>> PMK7325 (= PMK8350).
>>>
>>> Signed-off-by: Luca Weiss <[email protected]>
>>> ---
>>>
>>> arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 117
>>> +++++++++++++++++++++ 1 file changed, 117 insertions(+)
>>>
>>> diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
>>> b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts index
>>> 2c01f799a6b2..d0b1e4e507ff 100644
>>> --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
>>> +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
>>> @@ -9,6 +9,7 @@
>>>
>>> #define PM7250B_SID 8
>>> #define PM7250B_SID1 9
>>>
>>> +#include <dt-bindings/iio/qcom,spmi-adc7-pm7325.h>
>>>
>>> #include <dt-bindings/iio/qcom,spmi-adc7-pmk8350.h>
>>> #include <dt-bindings/leds/common.h>
>>> #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
>>>
>>> @@ -137,6 +138,20 @@ afvdd_2p8: regulator-afvdd-2p8 {
>>>
>>> };
>>>
>>> thermal-zones {
>>>
>>> + camera-thermal {
>>> + polling-delay-passive = <0>;
>>> + polling-delay = <0>;
>>> + thermal-sensors = <&pmk8350_adc_tm 2>;
>>> +
>>> + trips {
>>> + active-config0 {
>>> + temperature = <125000>;
>>
>> are
>>
>>> + rear-cam-thermal {
>>>
>>> + temperature = <125000>;
>>
>> you
>>
>>> + sdm-skin-thermal {
>>>
>>> + temperature = <125000>;
>>
>> sure
>>
>> about these temps?
>
> (email from my other address, quicker right now)
>
> Well yes and no.
>
> Yes as in those are the temps specified in downstream dtb.
> No as in I'm 99% sure there's user space with definitely lower threshold that
> actually does something in response to the temps.
>
> I didn't look too much into this but does the kernel even do something when it
> hits one of these trip points? I assume when there's a cooling device thing
> specified then it can actually tell the driver to do something, but without
> (and most drivers don't support this?) I'm assuming the kernel can't do much
> anyways?
>
> So e.g. when the temperature for the flash led is reached I'm assuming
> downstream (+Android) either dims the led or turns it off? But I'd have to dig
> quite a bit into the thermal setup there to check what it's really doing.
I think reaching "critical" shuts down the platform, unless something
registering the thermal zone explicitly overrides the behavior.

>
> But for now I think it's okay to put this current thermal config into dts and
> we'll improve it later when 1. I understand more and 2. maybe some useful
> drivers support the cooling bits?
Yeah it's better than nothing, but ultimately we should probably move
the values that userspace daemon operates on here in the dt..

Konrad

2023-10-18 20:31:52

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 2/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7250B thermals



On 10/13/23 10:09, Luca Weiss wrote:
> Configure the thermals for the CHARGER_SKIN_THERM and USB_CONN_THERM
> thermistors connected to PM7250B.
>
> Signed-off-by: Luca Weiss <[email protected]>
> ---
> arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 66 ++++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> index 2de0b8c26c35..7fe19b556e6a 100644
> --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> @@ -134,6 +134,36 @@ afvdd_2p8: regulator-afvdd-2p8 {
> enable-active-high;
> vin-supply = <&vreg_bob>;
> };
> +
> + thermal-zones {
> + chg-skin-thermal {
> + polling-delay-passive = <0>;
> + polling-delay = <0>;
> + thermal-sensors = <&pm7250b_adc_tm 0>;
> +
> + trips {
> + active-config0 {
> + temperature = <125000>;
I guess looking at skin-temp-thermal in x13s dts for starters
is a good idea.. we should probably then adjust it to something
more pocketable..

Konrad

2023-10-20 11:31:48

by Luca Weiss

[permalink] [raw]
Subject: Re: [PATCH 4/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7325 thermals

On Wed Oct 18, 2023 at 10:28 PM CEST, Konrad Dybcio wrote:
>
>
> On 10/14/23 19:52, Luca Weiss wrote:
> > On Samstag, 14. Oktober 2023 01:13:29 CEST Konrad Dybcio wrote:
> >> On 13.10.2023 10:09, Luca Weiss wrote:
> >>> Configure the thermals for the QUIET_THERM, CAM_FLASH_THERM, MSM_THERM
> >>> and RFC_CAM_THERM thermistors connected to PM7325.
> >>>
> >>> With this PMIC the software communication to the ADC is going through
> >>> PMK7325 (= PMK8350).
> >>>
> >>> Signed-off-by: Luca Weiss <[email protected]>
> >>> ---
> >>>
> >>> arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 117
> >>> +++++++++++++++++++++ 1 file changed, 117 insertions(+)
> >>>
> >>> diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> >>> b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts index
> >>> 2c01f799a6b2..d0b1e4e507ff 100644
> >>> --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> >>> +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
> >>> @@ -9,6 +9,7 @@
> >>>
> >>> #define PM7250B_SID 8
> >>> #define PM7250B_SID1 9
> >>>
> >>> +#include <dt-bindings/iio/qcom,spmi-adc7-pm7325.h>
> >>>
> >>> #include <dt-bindings/iio/qcom,spmi-adc7-pmk8350.h>
> >>> #include <dt-bindings/leds/common.h>
> >>> #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
> >>>
> >>> @@ -137,6 +138,20 @@ afvdd_2p8: regulator-afvdd-2p8 {
> >>>
> >>> };
> >>>
> >>> thermal-zones {
> >>>
> >>> + camera-thermal {
> >>> + polling-delay-passive = <0>;
> >>> + polling-delay = <0>;
> >>> + thermal-sensors = <&pmk8350_adc_tm 2>;
> >>> +
> >>> + trips {
> >>> + active-config0 {
> >>> + temperature = <125000>;
> >>
> >> are
> >>
> >>> + rear-cam-thermal {
> >>>
> >>> + temperature = <125000>;
> >>
> >> you
> >>
> >>> + sdm-skin-thermal {
> >>>
> >>> + temperature = <125000>;
> >>
> >> sure
> >>
> >> about these temps?
> >
> > (email from my other address, quicker right now)
> >
> > Well yes and no.
> >
> > Yes as in those are the temps specified in downstream dtb.
> > No as in I'm 99% sure there's user space with definitely lower threshold that
> > actually does something in response to the temps.
> >
> > I didn't look too much into this but does the kernel even do something when it
> > hits one of these trip points? I assume when there's a cooling device thing
> > specified then it can actually tell the driver to do something, but without
> > (and most drivers don't support this?) I'm assuming the kernel can't do much
> > anyways?
> >
> > So e.g. when the temperature for the flash led is reached I'm assuming
> > downstream (+Android) either dims the led or turns it off? But I'd have to dig
> > quite a bit into the thermal setup there to check what it's really doing.
> I think reaching "critical" shuts down the platform, unless something
> registering the thermal zone explicitly overrides the behavior.

Should probably be easy to test, especially the camera flash thermal
zone heats up *very* quickly when the flash is on, so should be trivial
to set the trip point down from 125degC to e.g. 45degC and see what
happens.

So I did this and... nothing happened.
I watched /sys/class/thermal/thermal_zone34/temp climb above 45degC and
nothing happened.

I guess trip type being "passive" and no cooling-device makes it not do
anything.

==> /sys/class/thermal/thermal_zone34/trip_point_0_hyst <==
1000
==> /sys/class/thermal/thermal_zone34/trip_point_0_temp <==
45000
==> /sys/class/thermal/thermal_zone34/trip_point_0_type <==
passive

From Documentation/devicetree/bindings/thermal/thermal-zones.yaml:

- active # enable active cooling e.g. fans
- passive # enable passive cooling e.g. throttling cpu
- hot # send notification to driver
- critical # send notification to driver, trigger shutdown

So unless we want to just shut down the system (with "critical"), I
don't think thermal can't really do anything else right now, since e.g.
leds-qcom-flash.c driver doesn't have any cooling support to lower the
brightness or turn off the LED.

So.. in essence not much we can do right now.

But seems we also cannot remove this (kinda useless) trip since we need
at least one trip point in the dts if I read the bindings yaml
correctly.

>
> >
> > But for now I think it's okay to put this current thermal config into dts and
> > we'll improve it later when 1. I understand more and 2. maybe some useful
> > drivers support the cooling bits?
> Yeah it's better than nothing, but ultimately we should probably move
> the values that userspace daemon operates on here in the dt..

For sure.. I spent a bit of time looking into the proprietary Qualcomm
thermal-daemon sources but didn't really see much interesting things
there for this platform, maybe some of this thermal handling is
somewhere else - or half of these thermal zones aren't even used with
Android.

So.. good to get the current patch upstream or not? :)

Regards
Luca

>
> Konrad

2023-10-21 16:23:05

by Konrad Dybcio

[permalink] [raw]
Subject: Re: [PATCH 4/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7325 thermals



On 10/20/23 13:31, Luca Weiss wrote:
> On Wed Oct 18, 2023 at 10:28 PM CEST, Konrad Dybcio wrote:
>>
>>
>> On 10/14/23 19:52, Luca Weiss wrote:
>>> On Samstag, 14. Oktober 2023 01:13:29 CEST Konrad Dybcio wrote:
>>>> On 13.10.2023 10:09, Luca Weiss wrote:
>>>>> Configure the thermals for the QUIET_THERM, CAM_FLASH_THERM, MSM_THERM
>>>>> and RFC_CAM_THERM thermistors connected to PM7325.
>>>>>
>>>>> With this PMIC the software communication to the ADC is going through
>>>>> PMK7325 (= PMK8350).
>>>>>
>>>>> Signed-off-by: Luca Weiss <[email protected]>
>>>>> ---
>>>>>
>>>>> arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 117
>>>>> +++++++++++++++++++++ 1 file changed, 117 insertions(+)
>>>>>
>>>>> diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
>>>>> b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts index
>>>>> 2c01f799a6b2..d0b1e4e507ff 100644
>>>>> --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
>>>>> +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts
>>>>> @@ -9,6 +9,7 @@
>>>>>
>>>>> #define PM7250B_SID 8
>>>>> #define PM7250B_SID1 9
>>>>>
>>>>> +#include <dt-bindings/iio/qcom,spmi-adc7-pm7325.h>
>>>>>
>>>>> #include <dt-bindings/iio/qcom,spmi-adc7-pmk8350.h>
>>>>> #include <dt-bindings/leds/common.h>
>>>>> #include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
>>>>>
>>>>> @@ -137,6 +138,20 @@ afvdd_2p8: regulator-afvdd-2p8 {
>>>>>
>>>>> };
>>>>>
>>>>> thermal-zones {
>>>>>
>>>>> + camera-thermal {
>>>>> + polling-delay-passive = <0>;
>>>>> + polling-delay = <0>;
>>>>> + thermal-sensors = <&pmk8350_adc_tm 2>;
>>>>> +
>>>>> + trips {
>>>>> + active-config0 {
>>>>> + temperature = <125000>;
>>>>
>>>> are
>>>>
>>>>> + rear-cam-thermal {
>>>>>
>>>>> + temperature = <125000>;
>>>>
>>>> you
>>>>
>>>>> + sdm-skin-thermal {
>>>>>
>>>>> + temperature = <125000>;
>>>>
>>>> sure
>>>>
>>>> about these temps?
>>>
>>> (email from my other address, quicker right now)
>>>
>>> Well yes and no.
>>>
>>> Yes as in those are the temps specified in downstream dtb.
>>> No as in I'm 99% sure there's user space with definitely lower threshold that
>>> actually does something in response to the temps.
>>>
>>> I didn't look too much into this but does the kernel even do something when it
>>> hits one of these trip points? I assume when there's a cooling device thing
>>> specified then it can actually tell the driver to do something, but without
>>> (and most drivers don't support this?) I'm assuming the kernel can't do much
>>> anyways?
>>>
>>> So e.g. when the temperature for the flash led is reached I'm assuming
>>> downstream (+Android) either dims the led or turns it off? But I'd have to dig
>>> quite a bit into the thermal setup there to check what it's really doing.
>> I think reaching "critical" shuts down the platform, unless something
>> registering the thermal zone explicitly overrides the behavior.
>
> Should probably be easy to test, especially the camera flash thermal
> zone heats up *very* quickly when the flash is on, so should be trivial
> to set the trip point down from 125degC to e.g. 45degC and see what
> happens.
>
> So I did this and... nothing happened.
> I watched /sys/class/thermal/thermal_zone34/temp climb above 45degC and
> nothing happened.
>
> I guess trip type being "passive" and no cooling-device makes it not do
> anything.
>
> ==> /sys/class/thermal/thermal_zone34/trip_point_0_hyst <==
> 1000
> ==> /sys/class/thermal/thermal_zone34/trip_point_0_temp <==
> 45000
> ==> /sys/class/thermal/thermal_zone34/trip_point_0_type <==
> passive
>
> From Documentation/devicetree/bindings/thermal/thermal-zones.yaml:
>
> - active # enable active cooling e.g. fans
> - passive # enable passive cooling e.g. throttling cpu
> - hot # send notification to driver
> - critical # send notification to driver, trigger shutdown
>
> So unless we want to just shut down the system (with "critical"), I
> don't think thermal can't really do anything else right now, since e.g.
> leds-qcom-flash.c driver doesn't have any cooling support to lower the
> brightness or turn off the LED.
>
> So.. in essence not much we can do right now.
Yeah.. crashing the phone because the LED is too hot is sorta
suboptimal! Though I mainly had the skin temp in mind..

>
> But seems we also cannot remove this (kinda useless) trip since we need
> at least one trip point in the dts if I read the bindings yaml
> correctly.
Right

>
>>
>>>
>>> But for now I think it's okay to put this current thermal config into dts and
>>> we'll improve it later when 1. I understand more and 2. maybe some useful
>>> drivers support the cooling bits?
>> Yeah it's better than nothing, but ultimately we should probably move
>> the values that userspace daemon operates on here in the dt..
>
> For sure.. I spent a bit of time looking into the proprietary Qualcomm
> thermal-daemon sources but didn't really see much interesting things
> there for this platform, maybe some of this thermal handling is
> somewhere else - or half of these thermal zones aren't even used with
> Android.
>
> So.. good to get the current patch upstream or not? :)
Yep, just having the ability to read out thing is always good ;)

Konrad

2023-12-03 04:53:16

by Bjorn Andersson

[permalink] [raw]
Subject: Re: [PATCH 0/4] Add Fairphone 5 thermals (PMK7325, PM7250B, PM7325)


On Fri, 13 Oct 2023 10:09:52 +0200, Luca Weiss wrote:
> Configure the necessary components to register some thermal zones in
> Linux for the different thermistors found on the Fairphone 5.
>
> The names for the thermal zones and ADCs were taken from the downstream
> kernel but double checked against hardware schematics.
>
>
> [...]

Applied, thanks!

[1/4] iio: adc: Add PM7325 PMIC7 ADC bindings
commit: 18c74d56fe6070c7c38058d7b43ccf2102abebcd
[2/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7250B thermals
commit: 4c343fe9b68adeca1aa3a851bd06e62ecdaed180
[3/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PMK7325 thermals
commit: 46a2f77e1eb81990d303a94ab62f1bf79d0c9926
[4/4] arm64: dts: qcom: qcm6490-fairphone-fp5: Add PM7325 thermals
commit: ae1122c375707a36c8fecebba745421a1e0ff93f

Best regards,
--
Bjorn Andersson <[email protected]>