Skip to contentSkip to conversation

Add D1/T113s thermal sensor controller support

PATCH Applied Maksim Kiselev 5 participants 10 messages Dec 17, 2023 – Sep 9, 2024

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

v6 cover Add D1/T113s thermal sensor controller support

This series adds support for Allwinner D1/T113s thermal sensor controller. THIS controller is similar to the one on H6, but with only one sensor and uses a different scale and offset values.

v6:
- Rebased onto 6.7.0-rc5

v5:
- Dropeed 'thermal-zones' node from sunxi-d1s-t113.dtsi

v4:
- Dropeed DT bindings example

v3:
- Fixed SoB tag again

v2:
- Fixed SoB tag
- Moved binding patch before driver changes

v1:
- Initial version

Maxim Kiselev (3):
dt-bindings: thermal: sun8i: Add binding for D1/T113s THS controller
thermal: sun8i: Add D1/T113s THS controller support
riscv: dts: allwinner: d1: Add thermal sensor

 .../thermal/allwinner,sun8i-a83t-ths.yaml       |  7 ++++++-
 .../boot/dts/allwinner/sunxi-d1s-t113.dtsi      | 17 +++++++++++++++++
 drivers/thermal/sun8i_thermal.c                 | 13 +++++++++++++
 3 files changed, 36 insertions(+), 1 deletion(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH v6 1/3 dt-bindings: thermal: sun8i: Add binding for D1/T113s THS controller

From: Maxim Kiselev <[email protected]>

Add a binding for D1/T113s thermal sensor controller.

---
 .../bindings/thermal/allwinner,sun8i-a83t-ths.yaml         | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml +6 -1
index fbd4212285e2..9b2272a9ec15 100644
@@ -16,6 +16,7 @@ properties:
       - allwinner,sun8i-a83t-ths
       - allwinner,sun8i-h3-ths
       - allwinner,sun8i-r40-ths
+      - allwinner,sun20i-d1-ths
       - allwinner,sun50i-a64-ths
       - allwinner,sun50i-a100-ths
       - allwinner,sun50i-h5-ths
@@ -61,6 +62,7 @@ allOf:
         compatible:
           contains:
             enum:
+              - allwinner,sun20i-d1-ths
               - allwinner,sun50i-a100-ths
               - allwinner,sun50i-h6-ths
 
@@ -84,7 +86,9 @@ allOf:
       properties:
         compatible:
           contains:
-            const: allwinner,sun8i-h3-ths
+            enum:
+              - allwinner,sun8i-h3-ths
+              - allwinner,sun20i-d1-ths
 
     then:
       properties:
@@ -103,6 +107,7 @@ allOf:
             enum:
               - allwinner,sun8i-h3-ths
               - allwinner,sun8i-r40-ths
+              - allwinner,sun20i-d1-ths
               - allwinner,sun50i-a64-ths
               - allwinner,sun50i-a100-ths
               - allwinner,sun50i-h5-ths
Signature · 1 line
2.40.1
#2 lore raw

PATCH v6 2/3 thermal: sun8i: Add D1/T113s THS controller support

In reply to Maksim Kiselev

From: Maxim Kiselev <[email protected]>

This patch adds a thermal sensor controller support for the D1/T113s, which is similar to the one on H6, but with only one sensor and different scale and offset values.

---
 drivers/thermal/sun8i_thermal.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/thermal/sun8i_thermal.c +13 -0
index f989b55a8aa8..6a8e386dbc8d 100644
@@ -606,6 +606,18 @@ static const struct ths_thermal_chip sun50i_h6_ths = {
 	.calc_temp = sun8i_ths_calc_temp,
 };
 
+static const struct ths_thermal_chip sun20i_d1_ths = {
+	.sensor_num = 1,
+	.has_bus_clk_reset = true,
+	.offset = 188552,
+	.scale = 673,
+	.temp_data_base = SUN50I_H6_THS_TEMP_DATA,
+	.calibrate = sun50i_h6_ths_calibrate,
+	.init = sun50i_h6_thermal_init,
+	.irq_ack = sun50i_h6_irq_ack,
+	.calc_temp = sun8i_ths_calc_temp,
+};
+
 static const struct of_device_id of_ths_match[] = {
 	{ .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths },
 	{ .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths },
@@ -614,6 +626,7 @@ static const struct of_device_id of_ths_match[] = {
 	{ .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths },
 	{ .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths },
 	{ .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths },
+	{ .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, of_ths_match);
Signature · 1 line
2.40.1
#5 lore raw

PATCH v6 3/3 riscv: dts: allwinner: d1: Add thermal sensor

In reply to Maksim Kiselev

From: Maxim Kiselev <[email protected]>

This patch adds a thermal sensor controller node for the D1/T113s. Also it adds a THS calibration data cell to efuse node.

---
 .../boot/dts/allwinner/sunxi-d1s-t113.dtsi      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +17 -0
index 5a9d7f5a75b4..6f5427d9cfbf 100644
@@ -166,6 +166,19 @@ gpadc: adc@2009000 {
 			#io-channel-cells = <1>;
 		};
 
+		ths: thermal-sensor@2009400 {
+			compatible = "allwinner,sun20i-d1-ths";
+			reg = <0x02009400 0x400>;
+			interrupts = <SOC_PERIPHERAL_IRQ(58) IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_THS>;
+			clock-names = "bus";
+			resets = <&ccu RST_BUS_THS>;
+			nvmem-cells = <&ths_calibration>;
+			nvmem-cell-names = "calibration";
+			status = "disabled";
+			#thermal-sensor-cells = <0>;
+		};
+
 		dmic: dmic@2031000 {
 			compatible = "allwinner,sun20i-d1-dmic",
 				     "allwinner,sun50i-h6-dmic";
@@ -415,6 +428,10 @@ sid: efuse@3006000 {
 			reg = <0x3006000 0x1000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+
+			ths_calibration: thermal-sensor-calibration@14 {
+				reg = <0x14 0x4>;
+			};
 		};
 
 		crypto: crypto@3040000 {
Signature · 1 line
2.40.1
Reviewed-by on v6 2/3
#3 lore raw

Re: [PATCH v6 2/3] thermal: sun8i: Add D1/T113s THS controller support

In reply to Maksim Kiselev

On Mon, 18 Dec 2023 00:06:23 +0300
Maksim Kiselev <[email protected]> wrote:

Hi Maksim,

Quoted 5 lines

From: Maxim Kiselev <[email protected]>

This patch adds a thermal sensor controller support for the D1/T113s, which is similar to the one on H6, but with only one sensor and different scale and offset values.

That looks alright to me, the offset and scale values match the converted values in the manual, and the rest looks indeed the same as used on the H6.

Quoted 1 line

Thanks,
Andre

Quoted 35 lines
---
 drivers/thermal/sun8i_thermal.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/thermal/sun8i_thermal.c +13 -0
index f989b55a8aa8..6a8e386dbc8d 100644
@@ -606,6 +606,18 @@ static const struct ths_thermal_chip sun50i_h6_ths = {
 	.calc_temp = sun8i_ths_calc_temp,
 };
 
+static const struct ths_thermal_chip sun20i_d1_ths = {
+	.sensor_num = 1,
+	.has_bus_clk_reset = true,
+	.offset = 188552,
+	.scale = 673,
+	.temp_data_base = SUN50I_H6_THS_TEMP_DATA,
+	.calibrate = sun50i_h6_ths_calibrate,
+	.init = sun50i_h6_thermal_init,
+	.irq_ack = sun50i_h6_irq_ack,
+	.calc_temp = sun8i_ths_calc_temp,
+};
+
 static const struct of_device_id of_ths_match[] = {
 	{ .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths },
 	{ .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths },
@@ -614,6 +626,7 @@ static const struct of_device_id of_ths_match[] = {
 	{ .compatible = "allwinner,sun50i-a100-ths", .data = &sun50i_a100_ths },
 	{ .compatible = "allwinner,sun50i-h5-ths", .data = &sun50i_h5_ths },
 	{ .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths },
+	{ .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, of_ths_match);
Reviewed-by on v6 3/3
#6 lore raw

Re: [PATCH v6 3/3] riscv: dts: allwinner: d1: Add thermal sensor

In reply to Maksim Kiselev

On Mon, 18 Dec 2023 00:06:24 +0300
Maksim Kiselev <[email protected]> wrote:

Hi,

Quoted 18 lines

From: Maxim Kiselev <[email protected]>

This patch adds a thermal sensor controller node for the D1/T113s. Also it adds a THS calibration data cell to efuse node.

---
 .../boot/dts/allwinner/sunxi-d1s-t113.dtsi      | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +0 -0
index 5a9d7f5a75b4..6f5427d9cfbf 100644
@@ -166,6 +166,19 @@ gpadc: adc@2009000 {
 			#io-channel-cells = <1>;
 		};
 

arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi gpadc: adc@2009000 { · line 178

Quoted 10 lines
arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +10 -0
+		ths: thermal-sensor@2009400 {
+			compatible = "allwinner,sun20i-d1-ths";
+			reg = <0x02009400 0x400>;
+			interrupts = <SOC_PERIPHERAL_IRQ(58) IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&ccu CLK_BUS_THS>;
+			clock-names = "bus";
+			resets = <&ccu RST_BUS_THS>;
+			nvmem-cells = <&ths_calibration>;
+			nvmem-cell-names = "calibration";
+			status = "disabled";

Any reason this is disabled? We typically don't disable those internal devices in the SoC .dtsi, the THS is one example (check the instances in other SoCs' .dtsi files).

The rest looks alright, compared to the manual, so with this line removed:

Cheers,
Andre

Quoted 17 lines
arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi +7 -0
+			#thermal-sensor-cells = <0>;
+		};
+
 		dmic: dmic@2031000 {
 			compatible = "allwinner,sun20i-d1-dmic",
 				     "allwinner,sun50i-h6-dmic";
@@ -415,6 +428,10 @@ sid: efuse@3006000 {
 			reg = <0x3006000 0x1000>;
 			#address-cells = <1>;
 			#size-cells = <1>;
+
+			ths_calibration: thermal-sensor-calibration@14 {
+				reg = <0x14 0x4>;
+			};
 		};
 
 		crypto: crypto@3040000 {
maintainer Acked-by on v6 2/3
#4 lore raw

Re: [PATCH v6 2/3] thermal: sun8i: Add D1/T113s THS controller support

In reply to Maksim Kiselev

Dne nedelja, 17. december 2023 ob 22:06:23 CET je Maksim Kiselev napisal(a):

Quoted 7 lines

From: Maxim Kiselev <[email protected]>

This patch adds a thermal sensor controller support for the D1/T113s, which is similar to the one on H6, but with only one sensor and different scale and offset values.

Best regards,
Jernej

#9 lore raw
In reply to Maksim Kiselev
Quoted 6 lines · Maksim Kiselev

This series adds support for Allwinner D1/T113s thermal sensor controller. THIS controller is similar to the one on H6, but with only one sensor and uses a different scale and offset values.

v6:
- Rebased onto 6.7.0-rc5

Applied, patch 1 & 2

Thanks

Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#7 lore raw

Re: [PATCH v6 3/3] riscv: dts: allwinner: d1: Add thermal sensor

In reply to Maksim Kiselev

Hi Maksim,

Apologies if I have failed to find a v7 of this patch in my searching, but I'm seeing that patch #3 here was never applied, so Linux still does not enable the thermal sensor in these chips. I just thought I'd give you a heads-up in case you weren't aware. :)

Thanks for all your hard work,
Sam

#8 lore raw

Re: [PATCH v6 3/3] riscv: dts: allwinner: d1: Add thermal sensor

On Mon, 9 Sep 2024 10:16:56 -0700
Sam Edwards <[email protected]> wrote:

Hi,

Quoted 6 lines

Hi Maksim,

Apologies if I have failed to find a v7 of this patch in my searching, but I'm seeing that patch #3 here was never applied, so Linux still does not enable the thermal sensor in these chips. I just thought I'd give you a heads-up in case you weren't aware. :)

There is an unaddressed comment on this patch: to remove the "disabled" status line. Sam, feel free to fix this and send the patch again, unless Maksim beats you to it.

Cheers,
Andre

Quoted 4 lines

Thanks for all your hard work,
Sam