All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Initial thermal management for Lichee Pi 4A board
@ 2025-08-16  9:32 ` Icenowy Zheng
  0 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-16  9:32 UTC (permalink / raw)
  To: Drew Fustini, Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel,
	Icenowy Zheng

The SoM+Dock design of Lichee Pi 4A is quite bad at dissipating heat, so
active cooling is quite important for it.

This patchset tries to do some initial active cooling for it, by
utilizing software PWM to drive the fan.

Ths 1st patch adds PVT temperature coefficients, as seen in the SoC
manual and BSP 6.6 kernel device trees.

The 2nd patch adds thermal zone information for the 2 thermal sensors in
the PVT block.

The 3rd patch adds soft PWM + PWM fan, and makes the fan an active
cooling device of the CPU thermal zone. 

Icenowy Zheng (3):
  riscv: dts: thead: th1520: add coefficients to the PVT node
  riscv: dts: thead: th1520: add initial thermal zones
  riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A

 .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
 arch/riscv/boot/dts/thead/th1520.dtsi         | 29 ++++++++++
 2 files changed, 82 insertions(+)

-- 
2.50.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 0/3] Initial thermal management for Lichee Pi 4A board
@ 2025-08-16  9:32 ` Icenowy Zheng
  0 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-16  9:32 UTC (permalink / raw)
  To: Drew Fustini, Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel,
	Icenowy Zheng

The SoM+Dock design of Lichee Pi 4A is quite bad at dissipating heat, so
active cooling is quite important for it.

This patchset tries to do some initial active cooling for it, by
utilizing software PWM to drive the fan.

Ths 1st patch adds PVT temperature coefficients, as seen in the SoC
manual and BSP 6.6 kernel device trees.

The 2nd patch adds thermal zone information for the 2 thermal sensors in
the PVT block.

The 3rd patch adds soft PWM + PWM fan, and makes the fan an active
cooling device of the CPU thermal zone. 

Icenowy Zheng (3):
  riscv: dts: thead: th1520: add coefficients to the PVT node
  riscv: dts: thead: th1520: add initial thermal zones
  riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A

 .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
 arch/riscv/boot/dts/thead/th1520.dtsi         | 29 ++++++++++
 2 files changed, 82 insertions(+)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node
  2025-08-16  9:32 ` Icenowy Zheng
@ 2025-08-16  9:32   ` Icenowy Zheng
  -1 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-16  9:32 UTC (permalink / raw)
  To: Drew Fustini, Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel,
	Icenowy Zheng

The manual of TH1520 contains a set of coefficients a little different
to the driver default ones.

Add them to the device tree node of PVT.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
---
 arch/riscv/boot/dts/thead/th1520.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index 03f1d73190499..e9c81bdabed8a 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -676,6 +676,10 @@ pvt: pvt@fffff4e000 {
 			reg-names = "common", "ts", "pd", "vm";
 			clocks = <&aonsys_clk>;
 			#thermal-sensor-cells = <1>;
+			moortec,ts-coeff-g = <42740>;
+			moortec,ts-coeff-h = <220500>;
+			moortec,ts-coeff-j = <(-160)>;
+			moortec,ts-coeff-cal5 = <4094>;
 		};
 
 		gpio@fffff52000 {
-- 
2.50.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node
@ 2025-08-16  9:32   ` Icenowy Zheng
  0 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-16  9:32 UTC (permalink / raw)
  To: Drew Fustini, Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel,
	Icenowy Zheng

The manual of TH1520 contains a set of coefficients a little different
to the driver default ones.

Add them to the device tree node of PVT.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
---
 arch/riscv/boot/dts/thead/th1520.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index 03f1d73190499..e9c81bdabed8a 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -676,6 +676,10 @@ pvt: pvt@fffff4e000 {
 			reg-names = "common", "ts", "pd", "vm";
 			clocks = <&aonsys_clk>;
 			#thermal-sensor-cells = <1>;
+			moortec,ts-coeff-g = <42740>;
+			moortec,ts-coeff-h = <220500>;
+			moortec,ts-coeff-j = <(-160)>;
+			moortec,ts-coeff-cal5 = <4094>;
 		};
 
 		gpio@fffff52000 {
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/3] riscv: dts: thead: th1520: add initial thermal zones
  2025-08-16  9:32 ` Icenowy Zheng
@ 2025-08-16  9:32   ` Icenowy Zheng
  -1 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-16  9:32 UTC (permalink / raw)
  To: Drew Fustini, Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel,
	Icenowy Zheng

As the PVT sensors's "T" means thermal, add thermal zones for the
thermal sensors.

Because of the current lack of DVFS, only a critical trip point is added
now.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
---
 arch/riscv/boot/dts/thead/th1520.dtsi | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index e9c81bdabed8a..a48eca5def606 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -701,4 +701,29 @@ gpio4: gpio-controller@0 {
 			};
 		};
 	};
+
+	thermal-zones {
+		cpu-thermal {
+			polling-delay-passive = <250>;
+			polling-delay = <15000>;
+
+			thermal-sensors = <&pvt 0>;
+
+			trips {
+				cpu_crit: crit-trip {
+					/* milliCelsius */
+					temperature = <110000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		ddrc-thermal {
+			polling-delay-passive = <250>;
+			polling-delay = <15000>;
+
+			thermal-sensors = <&pvt 1>;
+		};
+	};
 };
-- 
2.50.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 2/3] riscv: dts: thead: th1520: add initial thermal zones
@ 2025-08-16  9:32   ` Icenowy Zheng
  0 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-16  9:32 UTC (permalink / raw)
  To: Drew Fustini, Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel,
	Icenowy Zheng

As the PVT sensors's "T" means thermal, add thermal zones for the
thermal sensors.

Because of the current lack of DVFS, only a critical trip point is added
now.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
---
 arch/riscv/boot/dts/thead/th1520.dtsi | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index e9c81bdabed8a..a48eca5def606 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -701,4 +701,29 @@ gpio4: gpio-controller@0 {
 			};
 		};
 	};
+
+	thermal-zones {
+		cpu-thermal {
+			polling-delay-passive = <250>;
+			polling-delay = <15000>;
+
+			thermal-sensors = <&pvt 0>;
+
+			trips {
+				cpu_crit: crit-trip {
+					/* milliCelsius */
+					temperature = <110000>;
+					hysteresis = <2000>;
+					type = "critical";
+				};
+			};
+		};
+
+		ddrc-thermal {
+			polling-delay-passive = <250>;
+			polling-delay = <15000>;
+
+			thermal-sensors = <&pvt 1>;
+		};
+	};
 };
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
  2025-08-16  9:32 ` Icenowy Zheng
@ 2025-08-16  9:32   ` Icenowy Zheng
  -1 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-16  9:32 UTC (permalink / raw)
  To: Drew Fustini, Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel,
	Icenowy Zheng

Because of the SoM+Dock design of Lichee Pi 4A, heat dissipation does
not work well; fortunately it comes with a fan port with PWM driving
capability.

As the hardware PWM controller of Lichee Pi 4A isn't ready yet, drive it
with pwm-gpio driver (software PWM) now.

A long PWM period is used, because not only software PWM is used, but
also the fan port is a 2-pin one and fast PWM might confuse the BLDC
driver on fans.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
---
 .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
 arch/riscv/boot/dts/thead/th1520.dtsi         |  2 +-
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
index 4020c727f09e8..f696db01353c5 100644
--- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
+++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
@@ -4,6 +4,7 @@
  */
 
 #include "th1520-lichee-module-4a.dtsi"
+#include <dt-bindings/gpio/gpio.h>
 
 / {
 	model = "Sipeed Lichee Pi 4A";
@@ -28,6 +29,58 @@ aliases {
 	chosen {
 		stdout-path = "serial0:115200n8";
 	};
+
+	gpio_pwm: gpio-pwm {
+		#pwm-cells = <3>;
+		compatible = "pwm-gpio";
+		gpios = <&gpio3 3 GPIO_ACTIVE_HIGH>;
+	};
+
+	fan: pwm-fan {
+		compatible = "pwm-fan";
+		#cooling-cells = <2>;
+		pwms = <&gpio_pwm 0 100000000 0>;
+		cooling-levels = <0 66 196 255>;
+	};
+};
+
+&cpu_thermal_zone {
+	trips {
+		fan_trip0: fan-trip-0 {
+			temperature = <40000>;
+			hysteresis = <8000>;
+			type = "active";
+		};
+
+		fan_trip1: fan-trip-1 {
+			temperature = <50000>;
+			hysteresis = <8000>;
+			type = "active";
+		};
+
+		fan_trip2: fan-trip-2 {
+			temperature = <60000>;
+			hysteresis = <8000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map-active-0 {
+			cooling-device = <&fan 1 1>;
+			trip = <&fan_trip0>;
+		};
+
+		map-active-1 {
+			cooling-device = <&fan 2 2>;
+			trip = <&fan_trip1>;
+		};
+
+		map-active-2 {
+			cooling-device = <&fan 3 3>;
+			trip = <&fan_trip2>;
+		};
+	};
 };
 
 &padctrl0_apsys {
diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index a48eca5def606..5ac8044a05f1e 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -703,7 +703,7 @@ gpio4: gpio-controller@0 {
 	};
 
 	thermal-zones {
-		cpu-thermal {
+		cpu_thermal_zone: cpu-thermal {
 			polling-delay-passive = <250>;
 			polling-delay = <15000>;
 
-- 
2.50.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 21+ messages in thread

* [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
@ 2025-08-16  9:32   ` Icenowy Zheng
  0 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-16  9:32 UTC (permalink / raw)
  To: Drew Fustini, Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski,
	Conor Dooley
  Cc: Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel,
	Icenowy Zheng

Because of the SoM+Dock design of Lichee Pi 4A, heat dissipation does
not work well; fortunately it comes with a fan port with PWM driving
capability.

As the hardware PWM controller of Lichee Pi 4A isn't ready yet, drive it
with pwm-gpio driver (software PWM) now.

A long PWM period is used, because not only software PWM is used, but
also the fan port is a 2-pin one and fast PWM might confuse the BLDC
driver on fans.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
---
 .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
 arch/riscv/boot/dts/thead/th1520.dtsi         |  2 +-
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
index 4020c727f09e8..f696db01353c5 100644
--- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
+++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
@@ -4,6 +4,7 @@
  */
 
 #include "th1520-lichee-module-4a.dtsi"
+#include <dt-bindings/gpio/gpio.h>
 
 / {
 	model = "Sipeed Lichee Pi 4A";
@@ -28,6 +29,58 @@ aliases {
 	chosen {
 		stdout-path = "serial0:115200n8";
 	};
+
+	gpio_pwm: gpio-pwm {
+		#pwm-cells = <3>;
+		compatible = "pwm-gpio";
+		gpios = <&gpio3 3 GPIO_ACTIVE_HIGH>;
+	};
+
+	fan: pwm-fan {
+		compatible = "pwm-fan";
+		#cooling-cells = <2>;
+		pwms = <&gpio_pwm 0 100000000 0>;
+		cooling-levels = <0 66 196 255>;
+	};
+};
+
+&cpu_thermal_zone {
+	trips {
+		fan_trip0: fan-trip-0 {
+			temperature = <40000>;
+			hysteresis = <8000>;
+			type = "active";
+		};
+
+		fan_trip1: fan-trip-1 {
+			temperature = <50000>;
+			hysteresis = <8000>;
+			type = "active";
+		};
+
+		fan_trip2: fan-trip-2 {
+			temperature = <60000>;
+			hysteresis = <8000>;
+			type = "active";
+		};
+	};
+
+	cooling-maps {
+		map-active-0 {
+			cooling-device = <&fan 1 1>;
+			trip = <&fan_trip0>;
+		};
+
+		map-active-1 {
+			cooling-device = <&fan 2 2>;
+			trip = <&fan_trip1>;
+		};
+
+		map-active-2 {
+			cooling-device = <&fan 3 3>;
+			trip = <&fan_trip2>;
+		};
+	};
 };
 
 &padctrl0_apsys {
diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
index a48eca5def606..5ac8044a05f1e 100644
--- a/arch/riscv/boot/dts/thead/th1520.dtsi
+++ b/arch/riscv/boot/dts/thead/th1520.dtsi
@@ -703,7 +703,7 @@ gpio4: gpio-controller@0 {
 	};
 
 	thermal-zones {
-		cpu-thermal {
+		cpu_thermal_zone: cpu-thermal {
 			polling-delay-passive = <250>;
 			polling-delay = <15000>;
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
  2025-08-16  9:32   ` Icenowy Zheng
@ 2025-08-16 23:27     ` Drew Fustini
  -1 siblings, 0 replies; 21+ messages in thread
From: Drew Fustini @ 2025-08-16 23:27 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

On Sat, Aug 16, 2025 at 05:32:09PM +0800, Icenowy Zheng wrote:
> Because of the SoM+Dock design of Lichee Pi 4A, heat dissipation does
> not work well; fortunately it comes with a fan port with PWM driving
> capability.
> 
> As the hardware PWM controller of Lichee Pi 4A isn't ready yet, drive it
> with pwm-gpio driver (software PWM) now.
> 
> A long PWM period is used, because not only software PWM is used, but
> also the fan port is a 2-pin one and fast PWM might confuse the BLDC
> driver on fans.
> 
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
>  .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
>  arch/riscv/boot/dts/thead/th1520.dtsi         |  2 +-
>  2 files changed, 54 insertions(+), 1 deletion(-)

Is it possible to reconcile the work that Michal is doing with the
hardware PWM controller series [1] and this series?

The PWM controller does need Rust which works okay for me when using
llvm but that might not be the case for everyone. Maybe there is some
way to use the pwm controller if available and then failback to gpio if
not.

Thanks,
Drew 

[1] https://lore.kernel.org/linux-riscv/20250806-rust-next-pwm-working-fan-for-sending-v13-7-690b669295b6@samsung.com/

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
@ 2025-08-16 23:27     ` Drew Fustini
  0 siblings, 0 replies; 21+ messages in thread
From: Drew Fustini @ 2025-08-16 23:27 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

On Sat, Aug 16, 2025 at 05:32:09PM +0800, Icenowy Zheng wrote:
> Because of the SoM+Dock design of Lichee Pi 4A, heat dissipation does
> not work well; fortunately it comes with a fan port with PWM driving
> capability.
> 
> As the hardware PWM controller of Lichee Pi 4A isn't ready yet, drive it
> with pwm-gpio driver (software PWM) now.
> 
> A long PWM period is used, because not only software PWM is used, but
> also the fan port is a 2-pin one and fast PWM might confuse the BLDC
> driver on fans.
> 
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
>  .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
>  arch/riscv/boot/dts/thead/th1520.dtsi         |  2 +-
>  2 files changed, 54 insertions(+), 1 deletion(-)

Is it possible to reconcile the work that Michal is doing with the
hardware PWM controller series [1] and this series?

The PWM controller does need Rust which works okay for me when using
llvm but that might not be the case for everyone. Maybe there is some
way to use the pwm controller if available and then failback to gpio if
not.

Thanks,
Drew 

[1] https://lore.kernel.org/linux-riscv/20250806-rust-next-pwm-working-fan-for-sending-v13-7-690b669295b6@samsung.com/

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/3] Initial thermal management for Lichee Pi 4A board
  2025-08-16  9:32 ` Icenowy Zheng
@ 2025-08-16 23:40   ` Drew Fustini
  -1 siblings, 0 replies; 21+ messages in thread
From: Drew Fustini @ 2025-08-16 23:40 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

On Sat, Aug 16, 2025 at 05:32:06PM +0800, Icenowy Zheng wrote:
> The SoM+Dock design of Lichee Pi 4A is quite bad at dissipating heat, so
> active cooling is quite important for it.
> 
> This patchset tries to do some initial active cooling for it, by
> utilizing software PWM to drive the fan.
> 
> Ths 1st patch adds PVT temperature coefficients, as seen in the SoC
> manual and BSP 6.6 kernel device trees.
> 
> The 2nd patch adds thermal zone information for the 2 thermal sensors in
> the PVT block.
> 
> The 3rd patch adds soft PWM + PWM fan, and makes the fan an active
> cooling device of the CPU thermal zone. 
> 
> Icenowy Zheng (3):
>   riscv: dts: thead: th1520: add coefficients to the PVT node
>   riscv: dts: thead: th1520: add initial thermal zones
>   riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
> 
>  .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
>  arch/riscv/boot/dts/thead/th1520.dtsi         | 29 ++++++++++
>  2 files changed, 82 insertions(+)
> 
> -- 
> 2.50.1
> 

I just tested this on top of:
[PATCH v3 0/4] clk: thead: Changes to TH1520 clock driver for disp
[PATCH v2 0/2] clk: thead: th1520-ap: allow gate cascade and fix padctrl0

The fan is spinning when system boots at expected. That is nice that
GPIO can be used until the PWM controller driver is ready. hwmon0 shows
both temp inputs holding steady at 43.3 C and 44.4 C.

Thanks,
Drew


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 0/3] Initial thermal management for Lichee Pi 4A board
@ 2025-08-16 23:40   ` Drew Fustini
  0 siblings, 0 replies; 21+ messages in thread
From: Drew Fustini @ 2025-08-16 23:40 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

On Sat, Aug 16, 2025 at 05:32:06PM +0800, Icenowy Zheng wrote:
> The SoM+Dock design of Lichee Pi 4A is quite bad at dissipating heat, so
> active cooling is quite important for it.
> 
> This patchset tries to do some initial active cooling for it, by
> utilizing software PWM to drive the fan.
> 
> Ths 1st patch adds PVT temperature coefficients, as seen in the SoC
> manual and BSP 6.6 kernel device trees.
> 
> The 2nd patch adds thermal zone information for the 2 thermal sensors in
> the PVT block.
> 
> The 3rd patch adds soft PWM + PWM fan, and makes the fan an active
> cooling device of the CPU thermal zone. 
> 
> Icenowy Zheng (3):
>   riscv: dts: thead: th1520: add coefficients to the PVT node
>   riscv: dts: thead: th1520: add initial thermal zones
>   riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
> 
>  .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
>  arch/riscv/boot/dts/thead/th1520.dtsi         | 29 ++++++++++
>  2 files changed, 82 insertions(+)
> 
> -- 
> 2.50.1
> 

I just tested this on top of:
[PATCH v3 0/4] clk: thead: Changes to TH1520 clock driver for disp
[PATCH v2 0/2] clk: thead: th1520-ap: allow gate cascade and fix padctrl0

The fan is spinning when system boots at expected. That is nice that
GPIO can be used until the PWM controller driver is ready. hwmon0 shows
both temp inputs holding steady at 43.3 C and 44.4 C.

Thanks,
Drew


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node
@ 2025-08-17  0:12 kernel test robot
  0 siblings, 0 replies; 21+ messages in thread
From: kernel test robot @ 2025-08-17  0:12 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence static check first_new_problem: arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dtb: pvt@fffff4e000 (moortec,mr75203): moortec,ts-coeff-g: 42740 is not a multiple of 100"
:::::: Manual check reason: "dtcheck: binding changes may go via different trees"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250816093209.2600355-2-uwu@icenowy.me>
References: <20250816093209.2600355-2-uwu@icenowy.me>
TO: Icenowy Zheng <uwu@icenowy.me>
TO: Drew Fustini <fustini@kernel.org>
TO: Guo Ren <guoren@kernel.org>
TO: Fu Wei <wefu@redhat.com>
TO: Rob Herring <robh@kernel.org>
TO: Krzysztof Kozlowski <krzk@kernel.org>
TO: Conor Dooley <conor+dt@kernel.org>
CC: Han Gao <rabenda.cn@gmail.com>
CC: Yao Zi <ziyao@disroot.org>
CC: linux-riscv@lists.infradead.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: Icenowy Zheng <uwu@icenowy.me>

Hi Icenowy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on robh/for-next]
[also build test WARNING on linus/master v6.17-rc1 next-20250815]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Icenowy-Zheng/riscv-dts-thead-th1520-add-coefficients-to-the-PVT-node/20250816-173608
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20250816093209.2600355-2-uwu%40icenowy.me
patch subject: [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node
:::::: branch date: 15 hours ago
:::::: commit date: 15 hours ago
config: riscv-randconfig-052-20250817 (https://download.01.org/0day-ci/archive/20250817/202508170730.VFr1mLlG-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
dtschema version: 2025.6.2.dev4+g8f79ddd
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250817/202508170730.VFr1mLlG-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202508170730.VFr1mLlG-lkp@intel.com/

dtcheck warnings: (new ones prefixed by >>)
>> arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dtb: pvt@fffff4e000 (moortec,mr75203): moortec,ts-coeff-g: 42740 is not a multiple of 100
   	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
>> arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dtb: pvt@fffff4e000 (moortec,mr75203): moortec,ts-coeff-j: -160 is not a multiple of 100
   	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
--
>> arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dtb: pvt@fffff4e000 (moortec,mr75203): moortec,ts-coeff-g: 42740 is not a multiple of 100
   	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
>> arch/riscv/boot/dts/thead/th1520-beaglev-ahead.dtb: pvt@fffff4e000 (moortec,mr75203): moortec,ts-coeff-j: -160 is not a multiple of 100
   	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node
  2025-08-16  9:32   ` Icenowy Zheng
@ 2025-08-22 21:29     ` Drew Fustini
  -1 siblings, 0 replies; 21+ messages in thread
From: Drew Fustini @ 2025-08-22 21:29 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

On Sat, Aug 16, 2025 at 05:32:07PM +0800, Icenowy Zheng wrote:
> The manual of TH1520 contains a set of coefficients a little different
> to the driver default ones.
> 
> Add them to the device tree node of PVT.
> 
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
>  arch/riscv/boot/dts/thead/th1520.dtsi | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
> index 03f1d73190499..e9c81bdabed8a 100644
> --- a/arch/riscv/boot/dts/thead/th1520.dtsi
> +++ b/arch/riscv/boot/dts/thead/th1520.dtsi
> @@ -676,6 +676,10 @@ pvt: pvt@fffff4e000 {
>  			reg-names = "common", "ts", "pd", "vm";
>  			clocks = <&aonsys_clk>;
>  			#thermal-sensor-cells = <1>;
> +			moortec,ts-coeff-g = <42740>;
> +			moortec,ts-coeff-h = <220500>;
> +			moortec,ts-coeff-j = <(-160)>;
> +			moortec,ts-coeff-cal5 = <4094>;
>  		};
>  
>  		gpio@fffff52000 {
> -- 
> 2.50.1
> 

I think moortec,ts-coeff-XXX will need to be rounded to nearest multiple
of 100 as dtbs_check warns that:

pvt@fffff4e000: moortec,ts-coeff-g: 42740 is not a multiple of 100
	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
pvt@fffff4e000: moortec,ts-coeff-j: -160 is not a multiple of 100
	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
pvt@fffff4e000: moortec,ts-coeff-g: 42740 is not a multiple of 100
	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
pvt@fffff4e000: moortec,ts-coeff-j: -160 is not a multiple of 100
	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#

Thanks,
Drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node
@ 2025-08-22 21:29     ` Drew Fustini
  0 siblings, 0 replies; 21+ messages in thread
From: Drew Fustini @ 2025-08-22 21:29 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

On Sat, Aug 16, 2025 at 05:32:07PM +0800, Icenowy Zheng wrote:
> The manual of TH1520 contains a set of coefficients a little different
> to the driver default ones.
> 
> Add them to the device tree node of PVT.
> 
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
>  arch/riscv/boot/dts/thead/th1520.dtsi | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi b/arch/riscv/boot/dts/thead/th1520.dtsi
> index 03f1d73190499..e9c81bdabed8a 100644
> --- a/arch/riscv/boot/dts/thead/th1520.dtsi
> +++ b/arch/riscv/boot/dts/thead/th1520.dtsi
> @@ -676,6 +676,10 @@ pvt: pvt@fffff4e000 {
>  			reg-names = "common", "ts", "pd", "vm";
>  			clocks = <&aonsys_clk>;
>  			#thermal-sensor-cells = <1>;
> +			moortec,ts-coeff-g = <42740>;
> +			moortec,ts-coeff-h = <220500>;
> +			moortec,ts-coeff-j = <(-160)>;
> +			moortec,ts-coeff-cal5 = <4094>;
>  		};
>  
>  		gpio@fffff52000 {
> -- 
> 2.50.1
> 

I think moortec,ts-coeff-XXX will need to be rounded to nearest multiple
of 100 as dtbs_check warns that:

pvt@fffff4e000: moortec,ts-coeff-g: 42740 is not a multiple of 100
	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
pvt@fffff4e000: moortec,ts-coeff-j: -160 is not a multiple of 100
	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
pvt@fffff4e000: moortec,ts-coeff-g: 42740 is not a multiple of 100
	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
pvt@fffff4e000: moortec,ts-coeff-j: -160 is not a multiple of 100
	from schema $id: http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#

Thanks,
Drew

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
  2025-08-16  9:32   ` Icenowy Zheng
@ 2025-08-22 21:32     ` Drew Fustini
  -1 siblings, 0 replies; 21+ messages in thread
From: Drew Fustini @ 2025-08-22 21:32 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

On Sat, Aug 16, 2025 at 05:32:09PM +0800, Icenowy Zheng wrote:
> Because of the SoM+Dock design of Lichee Pi 4A, heat dissipation does
> not work well; fortunately it comes with a fan port with PWM driving
> capability.
> 
> As the hardware PWM controller of Lichee Pi 4A isn't ready yet, drive it
> with pwm-gpio driver (software PWM) now.
> 
> A long PWM period is used, because not only software PWM is used, but
> also the fan port is a 2-pin one and fast PWM might confuse the BLDC
> driver on fans.
> 
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
>  .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
>  arch/riscv/boot/dts/thead/th1520.dtsi         |  2 +-
>  2 files changed, 54 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> index 4020c727f09e8..f696db01353c5 100644
> --- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> +++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> @@ -4,6 +4,7 @@
>   */
>  
>  #include "th1520-lichee-module-4a.dtsi"
> +#include <dt-bindings/gpio/gpio.h>
>  
>  / {
>  	model = "Sipeed Lichee Pi 4A";
> @@ -28,6 +29,58 @@ aliases {
>  	chosen {
>  		stdout-path = "serial0:115200n8";
>  	};
> +
> +	gpio_pwm: gpio-pwm {
> +		#pwm-cells = <3>;
> +		compatible = "pwm-gpio";
> +		gpios = <&gpio3 3 GPIO_ACTIVE_HIGH>;
> +	};

I think the node name needs to be 'pwm' instead of 'gpio-pwm' as dtbs_check
warns that:

gpio-pwm: $nodename:0: 'gpio-pwm' does not match '^pwm(@.*|-([0-9]|[1-9][0-9]+))?$'
from schema $id: http://devicetree.org/schemas/pwm/pwm-gpio.yaml#

Thanks,
Drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
@ 2025-08-22 21:32     ` Drew Fustini
  0 siblings, 0 replies; 21+ messages in thread
From: Drew Fustini @ 2025-08-22 21:32 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

On Sat, Aug 16, 2025 at 05:32:09PM +0800, Icenowy Zheng wrote:
> Because of the SoM+Dock design of Lichee Pi 4A, heat dissipation does
> not work well; fortunately it comes with a fan port with PWM driving
> capability.
> 
> As the hardware PWM controller of Lichee Pi 4A isn't ready yet, drive it
> with pwm-gpio driver (software PWM) now.
> 
> A long PWM period is used, because not only software PWM is used, but
> also the fan port is a 2-pin one and fast PWM might confuse the BLDC
> driver on fans.
> 
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
>  .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53 +++++++++++++++++++
>  arch/riscv/boot/dts/thead/th1520.dtsi         |  2 +-
>  2 files changed, 54 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> index 4020c727f09e8..f696db01353c5 100644
> --- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> +++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> @@ -4,6 +4,7 @@
>   */
>  
>  #include "th1520-lichee-module-4a.dtsi"
> +#include <dt-bindings/gpio/gpio.h>
>  
>  / {
>  	model = "Sipeed Lichee Pi 4A";
> @@ -28,6 +29,58 @@ aliases {
>  	chosen {
>  		stdout-path = "serial0:115200n8";
>  	};
> +
> +	gpio_pwm: gpio-pwm {
> +		#pwm-cells = <3>;
> +		compatible = "pwm-gpio";
> +		gpios = <&gpio3 3 GPIO_ACTIVE_HIGH>;
> +	};

I think the node name needs to be 'pwm' instead of 'gpio-pwm' as dtbs_check
warns that:

gpio-pwm: $nodename:0: 'gpio-pwm' does not match '^pwm(@.*|-([0-9]|[1-9][0-9]+))?$'
from schema $id: http://devicetree.org/schemas/pwm/pwm-gpio.yaml#

Thanks,
Drew

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
  2025-08-22 21:32     ` Drew Fustini
@ 2025-08-23  5:45       ` Icenowy Zheng
  -1 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-23  5:45 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

在 2025-08-22星期五的 14:32 -0700,Drew Fustini写道:
> On Sat, Aug 16, 2025 at 05:32:09PM +0800, Icenowy Zheng wrote:
> > Because of the SoM+Dock design of Lichee Pi 4A, heat dissipation
> > does
> > not work well; fortunately it comes with a fan port with PWM
> > driving
> > capability.
> > 
> > As the hardware PWM controller of Lichee Pi 4A isn't ready yet,
> > drive it
> > with pwm-gpio driver (software PWM) now.
> > 
> > A long PWM period is used, because not only software PWM is used,
> > but
> > also the fan port is a 2-pin one and fast PWM might confuse the
> > BLDC
> > driver on fans.
> > 
> > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > ---
> >  .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53
> > +++++++++++++++++++
> >  arch/riscv/boot/dts/thead/th1520.dtsi         |  2 +-
> >  2 files changed, 54 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> > b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> > index 4020c727f09e8..f696db01353c5 100644
> > --- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> > +++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> > @@ -4,6 +4,7 @@
> >   */
> >  
> >  #include "th1520-lichee-module-4a.dtsi"
> > +#include <dt-bindings/gpio/gpio.h>
> >  
> >  / {
> >         model = "Sipeed Lichee Pi 4A";
> > @@ -28,6 +29,58 @@ aliases {
> >         chosen {
> >                 stdout-path = "serial0:115200n8";
> >         };
> > +
> > +       gpio_pwm: gpio-pwm {
> > +               #pwm-cells = <3>;
> > +               compatible = "pwm-gpio";
> > +               gpios = <&gpio3 3 GPIO_ACTIVE_HIGH>;
> > +       };
> 
> I think the node name needs to be 'pwm' instead of 'gpio-pwm' as
> dtbs_check
> warns that:

Sounds reasonable, although 'pwm' seems to be too generic.

But the recommended names below looks quite generic too... Is it just
some copy-pasta?

Well, maybe just take 'pwm' or 'pwm-0' now?

> 
> gpio-pwm: $nodename:0: 'gpio-pwm' does not match '^pwm(@.*|-([0-
> 9]|[1-9][0-9]+))?$'
> from schema $id: http://devicetree.org/schemas/pwm/pwm-gpio.yaml#
> 
> Thanks,
> Drew


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A
@ 2025-08-23  5:45       ` Icenowy Zheng
  0 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-23  5:45 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

在 2025-08-22星期五的 14:32 -0700,Drew Fustini写道:
> On Sat, Aug 16, 2025 at 05:32:09PM +0800, Icenowy Zheng wrote:
> > Because of the SoM+Dock design of Lichee Pi 4A, heat dissipation
> > does
> > not work well; fortunately it comes with a fan port with PWM
> > driving
> > capability.
> > 
> > As the hardware PWM controller of Lichee Pi 4A isn't ready yet,
> > drive it
> > with pwm-gpio driver (software PWM) now.
> > 
> > A long PWM period is used, because not only software PWM is used,
> > but
> > also the fan port is a 2-pin one and fast PWM might confuse the
> > BLDC
> > driver on fans.
> > 
> > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > ---
> >  .../boot/dts/thead/th1520-lichee-pi-4a.dts    | 53
> > +++++++++++++++++++
> >  arch/riscv/boot/dts/thead/th1520.dtsi         |  2 +-
> >  2 files changed, 54 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> > b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> > index 4020c727f09e8..f696db01353c5 100644
> > --- a/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> > +++ b/arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts
> > @@ -4,6 +4,7 @@
> >   */
> >  
> >  #include "th1520-lichee-module-4a.dtsi"
> > +#include <dt-bindings/gpio/gpio.h>
> >  
> >  / {
> >         model = "Sipeed Lichee Pi 4A";
> > @@ -28,6 +29,58 @@ aliases {
> >         chosen {
> >                 stdout-path = "serial0:115200n8";
> >         };
> > +
> > +       gpio_pwm: gpio-pwm {
> > +               #pwm-cells = <3>;
> > +               compatible = "pwm-gpio";
> > +               gpios = <&gpio3 3 GPIO_ACTIVE_HIGH>;
> > +       };
> 
> I think the node name needs to be 'pwm' instead of 'gpio-pwm' as
> dtbs_check
> warns that:

Sounds reasonable, although 'pwm' seems to be too generic.

But the recommended names below looks quite generic too... Is it just
some copy-pasta?

Well, maybe just take 'pwm' or 'pwm-0' now?

> 
> gpio-pwm: $nodename:0: 'gpio-pwm' does not match '^pwm(@.*|-([0-
> 9]|[1-9][0-9]+))?$'
> from schema $id: http://devicetree.org/schemas/pwm/pwm-gpio.yaml#
> 
> Thanks,
> Drew


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node
  2025-08-22 21:29     ` Drew Fustini
@ 2025-08-23 14:37       ` Icenowy Zheng
  -1 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-23 14:37 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

在 2025-08-22星期五的 14:29 -0700,Drew Fustini写道:
> On Sat, Aug 16, 2025 at 05:32:07PM +0800, Icenowy Zheng wrote:
> > The manual of TH1520 contains a set of coefficients a little
> > different
> > to the driver default ones.
> > 
> > Add them to the device tree node of PVT.
> > 
> > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > ---
> >  arch/riscv/boot/dts/thead/th1520.dtsi | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi
> > b/arch/riscv/boot/dts/thead/th1520.dtsi
> > index 03f1d73190499..e9c81bdabed8a 100644
> > --- a/arch/riscv/boot/dts/thead/th1520.dtsi
> > +++ b/arch/riscv/boot/dts/thead/th1520.dtsi
> > @@ -676,6 +676,10 @@ pvt: pvt@fffff4e000 {
> >                         reg-names = "common", "ts", "pd", "vm";
> >                         clocks = <&aonsys_clk>;
> >                         #thermal-sensor-cells = <1>;
> > +                       moortec,ts-coeff-g = <42740>;
> > +                       moortec,ts-coeff-h = <220500>;
> > +                       moortec,ts-coeff-j = <(-160)>;
> > +                       moortec,ts-coeff-cal5 = <4094>;
> >                 };
> >  
> >                 gpio@fffff52000 {
> > -- 
> > 2.50.1
> > 
> 
> I think moortec,ts-coeff-XXX will need to be rounded to nearest
> multiple
> of 100 as dtbs_check warns that:
> 
> pvt@fffff4e000: moortec,ts-coeff-g: 42740 is not a multiple of 100
>         from schema $id:
> http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
> pvt@fffff4e000: moortec,ts-coeff-j: -160 is not a multiple of 100
>         from schema $id:
> http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
> pvt@fffff4e000: moortec,ts-coeff-g: 42740 is not a multiple of 100
>         from schema $id:
> http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
> pvt@fffff4e000: moortec,ts-coeff-j: -160 is not a multiple of 100
>         from schema $id:
> http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#

Then it looks like the binding is to be blamed for not allowing fine
tweak.

> 
> Thanks,
> Drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node
@ 2025-08-23 14:37       ` Icenowy Zheng
  0 siblings, 0 replies; 21+ messages in thread
From: Icenowy Zheng @ 2025-08-23 14:37 UTC (permalink / raw)
  To: Drew Fustini
  Cc: Guo Ren, Fu Wei, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Han Gao, Yao Zi, linux-riscv, devicetree, linux-kernel

在 2025-08-22星期五的 14:29 -0700,Drew Fustini写道:
> On Sat, Aug 16, 2025 at 05:32:07PM +0800, Icenowy Zheng wrote:
> > The manual of TH1520 contains a set of coefficients a little
> > different
> > to the driver default ones.
> > 
> > Add them to the device tree node of PVT.
> > 
> > Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> > ---
> >  arch/riscv/boot/dts/thead/th1520.dtsi | 4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > diff --git a/arch/riscv/boot/dts/thead/th1520.dtsi
> > b/arch/riscv/boot/dts/thead/th1520.dtsi
> > index 03f1d73190499..e9c81bdabed8a 100644
> > --- a/arch/riscv/boot/dts/thead/th1520.dtsi
> > +++ b/arch/riscv/boot/dts/thead/th1520.dtsi
> > @@ -676,6 +676,10 @@ pvt: pvt@fffff4e000 {
> >                         reg-names = "common", "ts", "pd", "vm";
> >                         clocks = <&aonsys_clk>;
> >                         #thermal-sensor-cells = <1>;
> > +                       moortec,ts-coeff-g = <42740>;
> > +                       moortec,ts-coeff-h = <220500>;
> > +                       moortec,ts-coeff-j = <(-160)>;
> > +                       moortec,ts-coeff-cal5 = <4094>;
> >                 };
> >  
> >                 gpio@fffff52000 {
> > -- 
> > 2.50.1
> > 
> 
> I think moortec,ts-coeff-XXX will need to be rounded to nearest
> multiple
> of 100 as dtbs_check warns that:
> 
> pvt@fffff4e000: moortec,ts-coeff-g: 42740 is not a multiple of 100
>         from schema $id:
> http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
> pvt@fffff4e000: moortec,ts-coeff-j: -160 is not a multiple of 100
>         from schema $id:
> http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
> pvt@fffff4e000: moortec,ts-coeff-g: 42740 is not a multiple of 100
>         from schema $id:
> http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#
> pvt@fffff4e000: moortec,ts-coeff-j: -160 is not a multiple of 100
>         from schema $id:
> http://devicetree.org/schemas/hwmon/moortec,mr75203.yaml#

Then it looks like the binding is to be blamed for not allowing fine
tweak.

> 
> Thanks,
> Drew


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2025-08-23 14:45 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-16  9:32 [PATCH 0/3] Initial thermal management for Lichee Pi 4A board Icenowy Zheng
2025-08-16  9:32 ` Icenowy Zheng
2025-08-16  9:32 ` [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node Icenowy Zheng
2025-08-16  9:32   ` Icenowy Zheng
2025-08-22 21:29   ` Drew Fustini
2025-08-22 21:29     ` Drew Fustini
2025-08-23 14:37     ` Icenowy Zheng
2025-08-23 14:37       ` Icenowy Zheng
2025-08-16  9:32 ` [PATCH 2/3] riscv: dts: thead: th1520: add initial thermal zones Icenowy Zheng
2025-08-16  9:32   ` Icenowy Zheng
2025-08-16  9:32 ` [PATCH 3/3] riscv: dts: thead: th1520: add soft PWM fan for Lichee Pi 4A Icenowy Zheng
2025-08-16  9:32   ` Icenowy Zheng
2025-08-16 23:27   ` Drew Fustini
2025-08-16 23:27     ` Drew Fustini
2025-08-22 21:32   ` Drew Fustini
2025-08-22 21:32     ` Drew Fustini
2025-08-23  5:45     ` Icenowy Zheng
2025-08-23  5:45       ` Icenowy Zheng
2025-08-16 23:40 ` [PATCH 0/3] Initial thermal management for Lichee Pi 4A board Drew Fustini
2025-08-16 23:40   ` Drew Fustini
  -- strict thread matches above, loose matches on Subject: below --
2025-08-17  0:12 [PATCH 1/3] riscv: dts: thead: th1520: add coefficients to the PVT node kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.