Skip to contentSkip to conversation

Add pwm-fan for Milk-V Pioneer

PATCH Applied Chen Wang 2 participants 4 messages Feb 12, 2025 – Feb 19, 2025

Subsystems (3)
lore
Share & tools
lore

Chen Wang

author
#0 lore raw

cover Add pwm-fan for Milk-V Pioneer

From: Chen Wang <[email protected]>

Milk-V Pioneer uses fan as cooling-device, and speed of the fan is controlled by the first channel of pwm controller of SG2042.

This patchset depends on another patchset for the SG2042 pwm controller, the driver part is now on pwm/for-next [pwm-for-next] and the dts part is now on sophgo/for-next [sophgo-for-next]. If you want to have a test, you need to apply the corresponding patchset.

Thanks,
Chen

---

Chen Wang (2):
riscv: sophgo: dts: add pwm-fan for Milk-V Pioneer
riscv: sophgo: dts: add cooling maps for Milk-V Pioneer

 .../boot/dts/sophgo/sg2042-milkv-pioneer.dts  | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)

base-commit: 2014c95afecee3e76ca4a56956a936e23283f05b
prerequisite-patch-id: c4b7f2697276f9278f13e3f2f54669eabed14157
prerequisite-patch-id: e6e1753842784bbc41eae5917470d4abfacd21a0
prerequisite-patch-id: 768254e961eb246d230258ff33922e4f2a36597e

Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 riscv: sophgo: dts: add pwm-fan for Milk-V Pioneer

From: Chen Wang <[email protected]>

Milk-V Pioneer uses fan as cooling-device, and speed of the fan is controlled by the first channel of pwm controller of SG2042.

---
 arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts | 7 +++++++
 1 file changed, 7 insertions(+)
arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +7 -0
index be596d01ff8d..74c997ed8283 100644
@@ -73,6 +73,13 @@ &uart0 {
 };
 
 / {
+	pwmfan: pwm-fan {
+		compatible = "pwm-fan";
+		cooling-levels = <103 128 179 230 255>;
+		pwms = <&pwm 0 40000 0>;
+		#cooling-cells = <2>;
+	};
+
 	thermal-zones {
 		soc-thermal {
 			polling-delay-passive = <1000>;
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH 2/2 riscv: sophgo: dts: add cooling maps for Milk-V Pioneer

In reply to Chen Wang

From: Chen Wang <[email protected]>

The normal operating temperature range of SG2042 is -20 degrees Celsius ~ 85 degrees Celsius.

Simultaneously monitor soc temperature and board temperature to improve redundancy and safety.

---
 .../boot/dts/sophgo/sg2042-milkv-pioneer.dts  | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +29 -0
index 74c997ed8283..34645a5f6038 100644
@@ -111,6 +111,28 @@ soc_hot: soc-hot {
 					type = "hot";
 				};
 			};
+
+			cooling-maps {
+				map0 {
+					trip = <&soc_active1>;
+					cooling-device = <&pwmfan 0 1>;
+				};
+
+				map1 {
+					trip = <&soc_active2>;
+					cooling-device = <&pwmfan 1 2>;
+				};
+
+				map2 {
+					trip = <&soc_active3>;
+					cooling-device = <&pwmfan 2 3>;
+				};
+
+				map3 {
+					trip = <&soc_hot>;
+					cooling-device = <&pwmfan 3 4>;
+				};
+			};
 		};
 
 		board-thermal {
@@ -125,6 +147,13 @@ board_active: board-active {
 					type = "active";
 				};
 			};
+
+			cooling-maps {
+				map4 {
+					trip = <&board_active>;
+					cooling-device = <&pwmfan 3 4>;
+				};
+			};
 		};
 	};
 };
Signature · 1 line
2.34.1
maintainer Applied
#3 lore raw
In reply to Chen Wang
Quoted 11 lines · Chen Wang

From: Chen Wang <[email protected]>

Milk-V Pioneer uses fan as cooling-device, and speed of the fan is controlled by the first channel of pwm controller of SG2042.

This patchset depends on another patchset for the SG2042 pwm controller, the driver part is now on pwm/for-next [pwm-for-next] and the dts part is now on sophgo/for-next [sophgo-for-next]. If you want to have a test, you need to apply the corresponding patchset.

[...]

Applied to for-next, thanks!

[1/2] riscv: sophgo: dts: add pwm-fan for Milk-V Pioneer

      https://github.com/sophgo/linux/commit/62cdf0a06dd5a650e4ca95b6f3a13daa48cf517a
[2/2] riscv: sophgo: dts: add cooling maps for Milk-V Pioneer
      https://github.com/sophgo/linux/commit/f047a9285f9f3fd5c0d5ae53af350b8b619e470a

Thanks,
Inochi