Skip to contentSkip to conversation

Thermal monitor on PM660

PATCH In review Richard Acayan 4 participants 16 messages Feb 10 – Apr 15

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

cover Thermal monitor on PM660

This series adds the ADC thermal monitor on PM660. It also fixes the scaling between voltage and temperature for the HC variant.

Richard Acayan (3):
dt-bindings: mfd: qcom,spmi-pmic: Allow PMIC4 thermal monitor on pm660
thermal: qcom-spmi-adc-tm5: Correct the voltage-code scaling for HC
arm64: dts: qcom: pm660: add thermal monitor

 .../devicetree/bindings/mfd/qcom,spmi-pmic.yaml        |  1 +
 arch/arm64/boot/dts/qcom/pm660.dtsi                    | 10 ++++++++++
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c               |  2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/3 dt-bindings: mfd: qcom,spmi-pmic: Allow PMIC4 thermal monitor on pm660

While newer PMICs are compatible with PMIC5 drivers, the PM8998 and PM660 are both PMIC4. The PM8998 is allowed to use the PMIC4 thermal monitor. Allow it for PM660 as well.

---
 Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml +1 -0
index 65c80e3b4500..d2fce7f669b2 100644
@@ -221,6 +221,7 @@ allOf:
         compatible:
           contains:
             enum:
+              - qcom,pm660
               - qcom,pm8998
     then:
       patternProperties:
Signature · 1 line
2.53.0
#4 lore raw

PATCH 2/3 thermal: qcom-spmi-adc-tm5: Correct the voltage-code scaling for HC

In reply to Richard Acayan

When support was added for the HC variant, the full_scale_code_volt value was copied from the tm5 variant. From the downstream kernel, the scaling value is 0x70e4 on PMI632 (tm5 variant), but it is 0x4000 on PM660 and PM8998 (HC variant). Correct the ADC code to voltage scaling factor for the HC variant.

Fixes f6c83676c6097 ("thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant")
---
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/qcom/qcom-spmi-adc-tm5.c +1 -1
index d7f2e6ca92c2..6ccd02fe0e4c 100644
@@ -909,7 +909,7 @@ static const struct adc_tm5_data adc_tm5_data_pmic = {
 };
 
 static const struct adc_tm5_data adc_tm_hc_data_pmic = {
-	.full_scale_code_volt = 0x70e4,
+	.full_scale_code_volt = 0x4000,
 	.decimation = (unsigned int []) { 256, 512, 1024 },
 	.hw_settle = (unsigned int []) { 0, 100, 200, 300, 400, 500, 600, 700,
 					 1000, 2000, 4000, 6000, 8000, 10000 },
Signature · 1 line
2.53.0
#7 lore raw

PATCH 3/3 arm64: dts: qcom: pm660: add thermal monitor

In reply to Richard Acayan

The thermal monitor is used to monitor arbitrary ADC-based thermal sensors. It is suitable for use in thermal zones. Add support for it in PM660.

---
 arch/arm64/boot/dts/qcom/pm660.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/qcom/pm660.dtsi +10 -0
index 156b2ddff0dc..7cedf6980b34 100644
@@ -197,6 +197,16 @@ channel@85 {
 			};
 		};
 
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";
+		};
+
 		pm660_rradc: adc@4500 {
 			compatible = "qcom,pm660-rradc";
 			reg = <0x4500>;
Signature · 1 line
2.53.0
Reviewed-by on v1 2/3
#5 lore raw

Re: [PATCH 2/3] thermal: qcom-spmi-adc-tm5: Correct the voltage-code scaling for HC

In reply to Richard Acayan
Quoted 9 lines · Richard Acayan

When support was added for the HC variant, the full_scale_code_volt value was copied from the tm5 variant. From the downstream kernel, the scaling value is 0x70e4 on PMI632 (tm5 variant), but it is 0x4000 on PM660 and PM8998 (HC variant). Correct the ADC code to voltage scaling factor for the HC variant.

Fixes f6c83676c6097 ("thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant")

---

nice catch!

Konrad

#8 lore raw

Re: [PATCH 3/3] arm64: dts: qcom: pm660: add thermal monitor

In reply to Richard Acayan
Quoted 15 lines · Richard Acayan

The thermal monitor is used to monitor arbitrary ADC-based thermal sensors. It is suitable for use in thermal zones. Add support for it in PM660.

---
 arch/arm64/boot/dts/qcom/pm660.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/qcom/pm660.dtsi +0 -0
index 156b2ddff0dc..7cedf6980b34 100644
@@ -197,6 +197,16 @@ channel@85 {
 			};

arch/arm64/boot/dts/qcom/pm660.dtsi channel@85 { · line 207

Quoted 10 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +8 -0
 		};
 
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";

Can we enable it by default?

Konrad

#9 lore raw

Re: [PATCH 3/3] arm64: dts: qcom: pm660: add thermal monitor

Quoted 1 line · Konrad Dybcio

On 2/10/26 3:18 AM, Richard Acayan wrote:

(snip)

Quoted 10 lines

arch/arm64/boot/dts/qcom/pm660.dtsi channel@85 { · line 207

Quoted 8 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +8 -0
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";

Can we enable it by default?

No, the thermal monitor fails to probe if it doesn't have any channels:

	[   17.728926] qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: error -EINVAL: get dt data failed
	[   17.728945] qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: probe with driver qcom-spmi-adc-tm5 failed with error -22

Triggered by https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/thermal/qcom/qcom-spmi-adc-tm5.c?h=next-20260209#n945

Reviewed-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] thermal: qcom-spmi-adc-tm5: Correct the voltage-code scaling for HC

In reply to Richard Acayan
Quoted 11 lines · Richard Acayan

When support was added for the HC variant, the full_scale_code_volt value was copied from the tm5 variant. From the downstream kernel, the scaling value is 0x70e4 on PMI632 (tm5 variant), but it is 0x4000 on PM660 and PM8998 (HC variant). Correct the ADC code to voltage scaling factor for the HC variant.

Fixes f6c83676c6097 ("thermal/drivers/qcom/spmi-adc-tm5: Add support for HC variant")
---
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line
Signature · 2 lines
With best wishes
Dmitry
Reviewed-by on v1 1/3
#3 lore raw

Re: [PATCH 1/3] dt-bindings: mfd: qcom,spmi-pmic: Allow PMIC4 thermal monitor on pm660

In reply to Richard Acayan
Quoted 8 lines · Richard Acayan

While newer PMICs are compatible with PMIC5 drivers, the PM8998 and PM660 are both PMIC4. The PM8998 is allowed to use the PMIC4 thermal monitor. Allow it for PM660 as well.

---
 Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.yaml | 1 +
 1 file changed, 1 insertion(+)

Best regards,
Krzysztof

#10 lore raw

Re: [PATCH 3/3] arm64: dts: qcom: pm660: add thermal monitor

In reply to Richard Acayan
Quoted 14 lines · Richard Acayan
Quoted 1 line · Konrad Dybcio

On 2/10/26 3:18 AM, Richard Acayan wrote:

(snip)

Quoted 10 lines

arch/arm64/boot/dts/qcom/pm660.dtsi channel@85 { · line 207

Quoted 8 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +8 -0
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";

Can we enable it by default?

Quoted 6 lines

No, the thermal monitor fails to probe if it doesn't have any channels:

	[   17.728926] qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: error -EINVAL: get dt data failed
	[   17.728945] qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: probe with driver qcom-spmi-adc-tm5 failed with error -22

Triggered by https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/thermal/qcom/qcom-spmi-adc-tm5.c?h=next-20260209#n945

You can define the following ones in the common dt:

REF_GND
1.25VREF
VREF_VADC
VPH_PWR
VCOIN
DIE_TEMP
ANA_IN

as they're (almost or) always going to be present

Konrad

#11 lore raw

Re: [PATCH 3/3] arm64: dts: qcom: pm660: add thermal monitor

Quoted 17 lines · Konrad Dybcio
Quoted 16 lines · Richard Acayan
Quoted 1 line · Konrad Dybcio

On 2/10/26 3:18 AM, Richard Acayan wrote:

(snip)

Quoted 10 lines

arch/arm64/boot/dts/qcom/pm660.dtsi channel@85 { · line 207

Quoted 8 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +8 -0
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";

Can we enable it by default?

No, the thermal monitor fails to probe if it doesn't have any channels:

Quoted 8 lines
Quoted 4 lines
	[   17.728926] qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: error -EINVAL: get dt data failed
	[   17.728945] qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: probe with driver qcom-spmi-adc-tm5 failed with error -22

Triggered by https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/thermal/qcom/qcom-spmi-adc-tm5.c?h=next-20260209#n945

You can define the following ones in the common dt:

REF_GND

Is there any (likely passive, if any) cooling device that should be activated when this goes above or below a certain reading?

Quoted 5 lines

1.25VREF
VREF_VADC
VPH_PWR
VCOIN
DIE_TEMP

Maybe this temperature can be included, but I don't see any other PMIC devicetree that has this channel ready-to-go.

Quoted 1 line

ANA_IN

#12 lore raw

Re: [PATCH 3/3] arm64: dts: qcom: pm660: add thermal monitor

Quoted 21 lines · Richard Acayan
Quoted 20 lines · Konrad Dybcio
Quoted 19 lines · Richard Acayan
Quoted 1 line · Konrad Dybcio

On 2/10/26 3:18 AM, Richard Acayan wrote:

(snip)

Quoted 10 lines

arch/arm64/boot/dts/qcom/pm660.dtsi channel@85 { · line 207

Quoted 8 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +8 -0
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";

Can we enable it by default?

No, the thermal monitor fails to probe if it doesn't have any channels:

	[   17.728926] qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: error -EINVAL: get dt data failed
	[   17.728945] qcom-spmi-adc-tm5 c440000.spmi:pmic@0:adc-tm@3400: probe with driver qcom-spmi-adc-tm5 failed with error -22
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Triggered by https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/thermal/qcom/qcom-spmi-adc-tm5.c?h=next-20260209#n945

You can define the following ones in the common dt:

REF_GND

Is there any (likely passive, if any) cooling device that should be activated when this goes above or below a certain reading?

I don't think so

Quoted 9 lines
Quoted 6 lines

1.25VREF
VREF_VADC
VPH_PWR
VCOIN
DIE_TEMP

Maybe this temperature can be included, but I don't see any other PMIC devicetree that has this channel ready-to-go.

This channel is internally connected and handled by temp_alarm, I think describing it via the ADC just lets one peek into the raw values

Konrad

Quoted 2 lines
Quoted 2 lines

ANA_IN

#13 lore raw

Re: [PATCH 3/3] arm64: dts: qcom: pm660: add thermal monitor

In reply to Konrad Dybcio
Quoted 18 lines · Konrad Dybcio
Quoted 17 lines · Richard Acayan

The thermal monitor is used to monitor arbitrary ADC-based thermal sensors. It is suitable for use in thermal zones. Add support for it in PM660.

---
 arch/arm64/boot/dts/qcom/pm660.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/qcom/pm660.dtsi +0 -0
index 156b2ddff0dc..7cedf6980b34 100644
@@ -197,6 +197,16 @@ channel@85 {
 			};
 		};
 
Quoted 10 lines

arch/arm64/boot/dts/qcom/pm660.dtsi channel@85 { · line 207

Quoted 8 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +8 -0
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";

Can we enable it by default?

This is for the ADC thermal monitor, and not the ADC itself. I don't see the need to allocate channels just so this can be enabled by default, since the thermal monitor's purpose is mostly to send interrupts when the ADC values go above or below a certain threshold.

#14 lore raw

Re: [PATCH 3/3] arm64: dts: qcom: pm660: add thermal monitor

Quoted 30 lines · Richard Acayan
Quoted 18 lines · Konrad Dybcio
Quoted 17 lines · Richard Acayan

The thermal monitor is used to monitor arbitrary ADC-based thermal sensors. It is suitable for use in thermal zones. Add support for it in PM660.

---
 arch/arm64/boot/dts/qcom/pm660.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/qcom/pm660.dtsi +0 -0
index 156b2ddff0dc..7cedf6980b34 100644
@@ -197,6 +197,16 @@ channel@85 {
 			};
 		};
 
Quoted 10 lines

arch/arm64/boot/dts/qcom/pm660.dtsi channel@85 { · line 207

Quoted 8 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +8 -0
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";

Can we enable it by default?

Quoted 4 lines

This is for the ADC thermal monitor, and not the ADC itself. I don't see the need to allocate channels just so this can be enabled by default, since the thermal monitor's purpose is mostly to send interrupts when the ADC values go above or below a certain threshold.

Sorry, this fell through the cracks

I see your argument, but at the same time, there are channels that are always present (e.g. VPH_PWR) and any way to reduce the boilerplate is welcome

Konrad

#15 lore raw

Re: [PATCH 3/3] arm64: dts: qcom: pm660: add thermal monitor

Quoted 36 lines · Konrad Dybcio
Quoted 30 lines · Richard Acayan
Quoted 18 lines · Konrad Dybcio
Quoted 17 lines · Richard Acayan

The thermal monitor is used to monitor arbitrary ADC-based thermal sensors. It is suitable for use in thermal zones. Add support for it in PM660.

---
 arch/arm64/boot/dts/qcom/pm660.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm64/boot/dts/qcom/pm660.dtsi +0 -0
index 156b2ddff0dc..7cedf6980b34 100644
@@ -197,6 +197,16 @@ channel@85 {
 			};
 		};
 
Quoted 10 lines

arch/arm64/boot/dts/qcom/pm660.dtsi channel@85 { · line 207

Quoted 8 lines
arch/arm64/boot/dts/qcom/pm660.dtsi +8 -0
+		pm660_adc_tm: adc-tm@3400 {
+			compatible = "qcom,spmi-adc-tm-hc";
+			reg = <0x3400>;
+			interrupts = <0x0 0x34 0x0 IRQ_TYPE_EDGE_RISING>;
+			#thermal-sensor-cells = <1>;
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "disabled";

Can we enable it by default?

Quoted 4 lines

This is for the ADC thermal monitor, and not the ADC itself. I don't see the need to allocate channels just so this can be enabled by default, since the thermal monitor's purpose is mostly to send interrupts when the ADC values go above or below a certain threshold.

Quoted 5 lines

Sorry, this fell through the cracks

I see your argument, but at the same time, there are channels that are always present (e.g. VPH_PWR) and any way to reduce the boilerplate is welcome

If you saw my first sentence in the reply, why are we talking about VPH_PWR? I don't understand if you're asking for the thermal monitor to handle a voltage sensor here.