rk3568 is compatible with temperature-controlled fans

rk3568 is compatible with temperature-controlled fans

The temperature-controlled fan usually monitors the temperature of the CPU by a temperature sensor on the motherboard, and controls the speed of the fan according to a preset temperature threshold. When the CPU temperature exceeds the preset threshold, the fan will automatically speed up to reduce the CPU temperature. The ARM motherboard does not have a BIOS, but the fan speed and temperature threshold can be manually adjusted in the kernel to meet the needs of users. It is recommended that users regularly clean the CPU heatsink and fan to maintain a good heat dissipation effect.

Author: Charcoal Grilled Maodan , click on the blogger to learn more.


提示:开发过程使用新增 xxx.dtsi,小差异修改迁移到 xxx.dts。不仅让设备树更简洁、清晰,也减少适配过程的重复工作量。 在SDK更新时会自动合入相关修改,减少代码合并的工作量,也避免遗漏SDK重要的更新。


1. Check the schematic diagram and adapt the fan

The fan uses a PWM-9 channel with a frequency of 10kHz and positive polarity control PWM.

1.1 Kernel configuration

CONFIG_SENSORS_PWM_FAN=y

1.2 Kernel device tree configuration

/ {
    
    
	pwm_fan: pwm-fan {
    
    
		compatible = "pwm-fan";
		#cooling-cells = <2>;
		pwms = <&pwm9 0 100000 0>;
		cooling-levels = <
			0 25 50 75 100 125
			150 175 200 225 255>;
		rockchip,temp-trips = <
			47500   1
			50000   2
			52500   3
			55000   4
			57500   5
			60000   6
			62500   7
			65000   9
			67500   9
			70000   10
		>;
	};
};

&pwm9 {
    
    
        pinctrl-0 = <&pwm9m0_pins>;
        status = "okay";
};

pwms = <&pwm9 0 100000 0>; It is the application handle for PWM application.

  • pwms: PWM signal configuration, the format is <channel>, <index>, <period>, <polarity>.
  • channel: The handle of the PWM channel, that is, the number of the PWM controller, here is <&pwm9>, indicating that the PWM controller 9 is used.
  • index (per-chip index of the PWM to request): Indicates the internal number of the pwm, usually 0, because there is only one for each chip of the Rockchip PWM.
  • period: The period of the PWM signal, in nanoseconds, here is 100000, which means that the period is 100 microseconds, and the frequency is 10KHz (1GHz / 100000).
  • polarity: The polarity of the PWM signal, 0 means active low; 1 means active high, which is often referred to as negative polarity.

cooling-levels = <0 25 50 75 100 125 150 175 200 225 255>;

  • <0~255>: Assign gear to control the duty cycle of pwm value, 10 gears, the range is 0-255.
    By setting the duty cycle of pwm and then adjusting the speed gear, the number and size of gears can be defined as required.

rockchip,temp-tripsIt is the gear level of the fan speed triggered by the cpu temperature
- <47500 1> is the fan speed level triggered by the CPU temperature, and the wind speed is 1 gear at 47.5 degrees Celsius.
The heat dissipation effect needs to be adjusted according to the actual situation, for example, 70 degrees corresponds to gear 10.

1.3 Kernel loading and verification

After the kernel driver is loaded normally, the relevant driver nodes can be identified.

  1. Drive full file node
cd /sys/class/thermal/cooling_device0

ls
cur_state  max_state  power  subsystem  type  uevent

cat max_state
10
  1. Manually adjust the fan level
# 设定风扇档位为 9
echo 9 > cur_state

# 查看当前等级
cat cur_state 
9

Tips

  1. The pwm application failure is mostly multiplexed, which can be found through the GPIO multiplexing relationship.
  2. When registering the temperature-controlled fan driver, the fan control pwm needs to be enabled at the same time.

epilogue

It is worthwhile for the blogger to explain in detail, welcome to subscribe to the blogger – Charcoal Grilled Maodan .

Guess you like

Origin blog.csdn.net/weixin_35723192/article/details/130877706