]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
riscv: dts: thead: Add PWM fan and thermal control
authorMichal Wilczynski <m.wilczynski@samsung.com>
Thu, 16 Oct 2025 13:38:07 +0000 (15:38 +0200)
committerDrew Fustini <fustini@kernel.org>
Tue, 28 Oct 2025 09:38:44 +0000 (09:38 +0000)
Add Device Tree nodes to enable a PWM controlled fan and it's associated
thermal management for the Lichee Pi 4A board.

This enables temperature-controlled active cooling for the Lichee Pi 4A
board based on SoC temperature.

Reviewed-by: Drew Fustini <fustini@kernel.org>
Tested-by: Drew Fustini <fustini@kernel.org>
Reviewed-by: Elle Rhumsaa <elle@weathered-steel.dev>
Signed-off-by: Michal Wilczynski <m.wilczynski@samsung.com>
Signed-off-by: Drew Fustini <fustini@kernel.org>
arch/riscv/boot/dts/thead/th1520-lichee-pi-4a.dts

index 4020c727f09e8e2286fdc7fecd79dbd8eba69556..c58c2085ca92a3234f1350500cedae4157f0c35f 100644 (file)
        chosen {
                stdout-path = "serial0:115200n8";
        };
+
+       thermal-zones {
+               cpu-thermal {
+                       polling-delay = <1000>;
+                       polling-delay-passive = <1000>;
+                       thermal-sensors = <&pvt 0>;
+
+                       trips {
+                               fan_config0: fan-trip0 {
+                                       temperature = <39000>;
+                                       hysteresis = <5000>;
+                                       type = "active";
+                               };
+
+                               fan_config1: fan-trip1 {
+                                       temperature = <50000>;
+                                       hysteresis = <5000>;
+                                       type = "active";
+                               };
+
+                               fan_config2: fan-trip2 {
+                                       temperature = <60000>;
+                                       hysteresis = <5000>;
+                                       type = "active";
+                               };
+                       };
+
+                       cooling-maps {
+                               map-active-0 {
+                                       cooling-device = <&fan 1 1>;
+                                       trip = <&fan_config0>;
+                               };
+
+                               map-active-1 {
+                                       cooling-device = <&fan 2 2>;
+                                       trip = <&fan_config1>;
+                               };
+
+                               map-active-2 {
+                                       cooling-device = <&fan 3 3>;
+                                       trip = <&fan_config2>;
+                               };
+                       };
+               };
+       };
+
+       fan: pwm-fan {
+               pinctrl-names = "default";
+               pinctrl-0 = <&fan_pins>;
+               compatible = "pwm-fan";
+               #cooling-cells = <2>;
+               pwms = <&pwm 1 10000000 0>;
+               cooling-levels = <0 66 196 255>;
+       };
+
 };
 
 &padctrl0_apsys {
+       fan_pins: fan-0 {
+               pwm1-pins {
+                       pins = "GPIO3_3"; /* PWM1 */
+                       function = "pwm";
+                       bias-disable;
+                       drive-strength = <25>;
+                       input-disable;
+                       input-schmitt-disable;
+                       slew-rate = <0>;
+               };
+       };
+
        uart0_pins: uart0-0 {
                tx-pins {
                        pins = "UART0_TXD";