From 255f83ba5c16b0f79ad0c46c69b2e907012bde83 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Wed, 5 Feb 2025 15:01:34 +0800 Subject: [PATCH 1/4] riscv: sophgo: dts: add pwm controller for SG2042 SoC SG2042 has one PWM controller, which has 4 pwm output channels. Signed-off-by: Chen Wang Link: https://lore.kernel.org/r/f376e16c0ee0cdac51bb91421d78defc0601627a.1738737617.git.unicorn_wang@outlook.com Signed-off-by: Inochi Amaoto --- arch/riscv/boot/dts/sophgo/sg2042.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/riscv/boot/dts/sophgo/sg2042.dtsi b/arch/riscv/boot/dts/sophgo/sg2042.dtsi index e62ac51ac55a..4449c762d663 100644 --- a/arch/riscv/boot/dts/sophgo/sg2042.dtsi +++ b/arch/riscv/boot/dts/sophgo/sg2042.dtsi @@ -165,6 +165,15 @@ port2a: gpio-controller@0 { }; }; + pwm: pwm@703000c000 { + compatible = "sophgo,sg2042-pwm"; + reg = <0x70 0x3000c000 0x0 0x20>; + #pwm-cells = <3>; + clocks = <&clkgen GATE_CLK_APB_PWM>; + clock-names = "apb"; + resets = <&rstgen RST_PWM>; + }; + pllclk: clock-controller@70300100c0 { compatible = "sophgo,sg2042-pll"; reg = <0x70 0x300100c0 0x0 0x40>; From 8630ed6f2adc2dcc89ac601d27c3fe37a187dfec Mon Sep 17 00:00:00 2001 From: Inochi Amaoto Date: Wed, 12 Feb 2025 10:28:30 +0800 Subject: [PATCH 2/4] MAINTAINERS: update info for SOPHGO DEVICETREES and DRIVERS Add mail list and wiki info for SOPHGO entry. Also change Inochi's email as the old one can not be accessed. Reviewed-by: Alexander Sverdlin Reviewed-by: Chen Wang Link: https://lore.kernel.org/r/20250212022831.244143-1-inochiama@gmail.com Signed-off-by: Inochi Amaoto Signed-off-by: Chen Wang --- MAINTAINERS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 896a307fa065..6b79681877d2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -22097,7 +22097,9 @@ F: include/linux/sony-laptop.h SOPHGO DEVICETREES and DRIVERS M: Chen Wang -M: Inochi Amaoto +M: Inochi Amaoto +L: sophgo@lists.linux.dev +W: https://github.com/sophgo/linux/wiki T: git https://github.com/sophgo/linux.git S: Maintained N: sophgo From 62cdf0a06dd5a650e4ca95b6f3a13daa48cf517a Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Wed, 12 Feb 2025 17:42:02 +0800 Subject: [PATCH 3/4] riscv: sophgo: dts: add pwm-fan for Milk-V Pioneer Milk-V Pioneer uses fan as cooling-device, and speed of the fan is controlled by the first channel of pwm controller of SG2042. Signed-off-by: Chen Wang Link: https://lore.kernel.org/r/dd23362328f77dd91aa9354848bbb0abad0f554b.1739351437.git.unicorn_wang@outlook.com Signed-off-by: Inochi Amaoto --- arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts b/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts index be596d01ff8d..74c997ed8283 100644 --- a/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +++ b/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts @@ -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>; From f047a9285f9f3fd5c0d5ae53af350b8b619e470a Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Wed, 12 Feb 2025 17:42:23 +0800 Subject: [PATCH 4/4] riscv: sophgo: dts: add cooling maps for Milk-V Pioneer 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. Signed-off-by: Chen Wang Link: https://lore.kernel.org/r/5a36a2784d97ed7b1e06777cb0c3c14fe9185e99.1739351437.git.unicorn_wang@outlook.com Signed-off-by: Inochi Amaoto --- .../boot/dts/sophgo/sg2042-milkv-pioneer.dts | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts b/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts index 74c997ed8283..34645a5f6038 100644 --- a/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts +++ b/arch/riscv/boot/dts/sophgo/sg2042-milkv-pioneer.dts @@ -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>; + }; + }; }; }; };