Skip to content

Commit f36e738

Browse files
thatoddmailboxwens
authored andcommitted
riscv: dts: allwinner: d1: Add CPU thermal sensor and zone
The sun20i THS (built in CPU thermal sensor) is supported in code, but was never added to the device tree. So, add it to the device tree, along with a thermal zone for the CPU. Signed-off-by: Alex Studer <alex@studer.dev> Changes since v1: - Move include before defines in sun20i-d1s.dtsi - Fix register size for thermal-sensor@2009400 - Move thermal-sensor@2009400 in SoC to match register address sorting - Add thermal-zone for sun8i-t113s.dtsi and fix missing cooling-cells Link: https://lore.kernel.org/r/20250218020629.1476126-1-alex@studer.dev Signed-off-by: Lukas Schmid <lukas.schmid@netcube.li> Link: https://patch.msgid.link/20260113182951.1059690-1-lukas.schmid@netcube.li Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
1 parent db5e926 commit f36e738

3 files changed

Lines changed: 80 additions & 0 deletions

File tree

arch/arm/boot/dts/allwinner/sun8i-t113s.dtsi

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define SOC_PERIPHERAL_IRQ(nr) GIC_SPI nr
55

66
#include <dt-bindings/interrupt-controller/arm-gic.h>
7+
#include <dt-bindings/thermal/thermal.h>
78
#include <riscv/allwinner/sunxi-d1s-t113.dtsi>
89
#include <riscv/allwinner/sunxi-d1-t113.dtsi>
910

@@ -20,6 +21,7 @@
2021
reg = <0>;
2122
clocks = <&ccu CLK_CPUX>;
2223
clock-names = "cpu";
24+
#cooling-cells = <2>;
2325
};
2426

2527
cpu1: cpu@1 {
@@ -28,6 +30,7 @@
2830
reg = <1>;
2931
clocks = <&ccu CLK_CPUX>;
3032
clock-names = "cpu";
33+
#cooling-cells = <2>;
3134
};
3235
};
3336

@@ -56,4 +59,34 @@
5659
<GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
5760
interrupt-affinity = <&cpu0>, <&cpu1>;
5861
};
62+
63+
thermal-zones {
64+
cpu-thermal {
65+
polling-delay-passive = <0>;
66+
polling-delay = <0>;
67+
thermal-sensors = <&ths>;
68+
69+
cooling-maps {
70+
map0 {
71+
trip = <&cpu_alert>;
72+
cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>,
73+
<&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
74+
};
75+
};
76+
77+
trips {
78+
cpu_alert: cpu-alert {
79+
temperature = <85000>;
80+
hysteresis = <2000>;
81+
type = "passive";
82+
};
83+
84+
cpu-crit {
85+
temperature = <100000>;
86+
hysteresis = <0>;
87+
type = "critical";
88+
};
89+
};
90+
};
91+
};
5992
};

arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
22
// Copyright (C) 2021-2022 Samuel Holland <samuel@sholland.org>
33

4+
#include <dt-bindings/thermal/thermal.h>
5+
46
#define SOC_PERIPHERAL_IRQ(nr) (nr + 16)
57

68
#include "sunxi-d1s-t113.dtsi"
@@ -115,4 +117,33 @@
115117
<0x00000000 0x0000000e 0xffffffff 0xffffffff 0x00010000>,
116118
<0x00000000 0x0000000f 0xffffffff 0xffffffff 0x00020000>;
117119
};
120+
121+
thermal-zones {
122+
cpu-thermal {
123+
polling-delay-passive = <0>;
124+
polling-delay = <0>;
125+
thermal-sensors = <&ths>;
126+
127+
cooling-maps {
128+
map0 {
129+
trip = <&cpu_alert>;
130+
cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
131+
};
132+
};
133+
134+
trips {
135+
cpu_alert: cpu-alert {
136+
temperature = <85000>;
137+
hysteresis = <2000>;
138+
type = "passive";
139+
};
140+
141+
cpu-crit {
142+
temperature = <100000>;
143+
hysteresis = <0>;
144+
type = "critical";
145+
};
146+
};
147+
};
148+
};
118149
};

arch/riscv/boot/dts/allwinner/sunxi-d1s-t113.dtsi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,18 @@
229229
#io-channel-cells = <1>;
230230
};
231231

232+
ths: thermal-sensor@2009400 {
233+
compatible = "allwinner,sun20i-d1-ths";
234+
reg = <0x2009400 0x400>;
235+
interrupts = <SOC_PERIPHERAL_IRQ(58) IRQ_TYPE_LEVEL_HIGH>;
236+
clocks = <&ccu CLK_BUS_THS>;
237+
clock-names = "bus";
238+
resets = <&ccu RST_BUS_THS>;
239+
nvmem-cells = <&ths_calibration>;
240+
nvmem-cell-names = "calibration";
241+
#thermal-sensor-cells = <0>;
242+
};
243+
232244
dmic: dmic@2031000 {
233245
compatible = "allwinner,sun20i-d1-dmic",
234246
"allwinner,sun50i-h6-dmic";
@@ -489,6 +501,10 @@
489501
reg = <0x3006000 0x1000>;
490502
#address-cells = <1>;
491503
#size-cells = <1>;
504+
505+
ths_calibration: thermal-sensor-calibration@14 {
506+
reg = <0x14 0x8>;
507+
};
492508
};
493509

494510
crypto: crypto@3040000 {

0 commit comments

Comments
 (0)