⽤⼾态接口
⽤⼾态接口在/sys/class/thermal/⽬录下,具体内容和DTSI中thermal zone节点的配置对应。有的平台thermalzone节点下只有⼀个⼦节点,对应/sys/class/thermal/⽬录下也只有thermal_zone0⼦⽬录;有的平台有两个⼦节点,对应/sys/class/thermal/⽬录下就会有thermal_zone0和thermal_zone1⼦⽬录。通过⽤⼾态接口可以切换温控策略,查看当前温度等。
以RK3399为例⼦,/sys/class/thermal/thermal_zone0/⽬录下包含如下常⽤的信息:
temp /* 当前温度 */
available_policies /* ⽀持的温控策略 */
policy /* 当前使⽤的温控策略 */
sustainable_power /* 期望的最⾼温度下对应的power 值 */
integral_cutoff /* PID 算法中I的触发条件:当前温度-期望的最⾼温度
k_d /* PID 算法中计算D的时候⽤的参数 */
k_i /* PID 算法中计算I的时候⽤的参数 */
k_po /* PID 算法中计算P的时候⽤的参数 */
k_pu /* PID 算法中计算P的时候⽤的参数 */
mode /* enabled :⾃带定时获取温度,判断是否需要降频。disabled 关闭该功能 */
type /* 当前thermal zone 的类型 */
/* 不同的温度阀值,对应trips 节点的配置 */
trip_point_0_hyst
trip_point_0_temp
trip_point_0_type
trip_point_1_hyst
trip_point_1_temp
trip_point_1_type
trip_point_2_hyst
trip_point_2_temp
trip_point_2_type
/* 不同cooling devic 的状态,对应cooling-maps 节点的配置 */
cdev0 /* 代表⼀个cooling devic ,有的平台还有cdev1 、cdev2 等 */
cur_state /* 该cooling device 当前频率的档位 */
max_state /* 该cooling device 最多有⼏个档位 */
type /* 该cooling device 的类型 */
cdev0_weight /* 该cooling devic 在计算power 时扩⼤的倍数 */
常用设置
获取当前温度
直接查看⽤⼾态接口thermal_zone0或者thermal_zone1⽬录下的temp节点即可。
以RK3399为例,获取CPU温度,在串口中输⼊如下命令:
cat /sys /class /thermal /thermal_zone0 /temp
获取GPU温度,在串口中输⼊如下命令:
cat /sys /class /thermal /thermal_zone1 /temp
关闭温度控制功能
⽅法⼀:menuconfig中默认温控策略设置为user_space。
<*> Generic Thermal sysfs driver --->
--- Generic Thermal sysfs driver
APIs to parse thermal data out of device tree
Enable writable trip points
Default Thermal governor ( user_space ) ---> /* power_allocator 改为user_space */
⽅法⼆:开机后通过命令关温控。
⾸先,把温控策略切换到user_space,即把⽤⼾态接口下的policy节点改成user_space;或者把mode设置成
disabled状态;然后,解除频率限制,即将⽤⼾态接口下的所有cdev的cur_state设置为0。
以RK3399为例,策略切换到user_space:
echo user_space > /sys /class /thermal /thermal_zone0 /policy
或者把mode设置成disabled状态:
echo disabled > /sys /class /thermal /thermal_zone0 /mode
解除频率限制:
/* 具体有多少个cdev ,根据实际情况修改 */
echo 0 > /sys /class /thermal /thermal_zone0 /cdev0 /cur_state
echo 0 > /sys /class /thermal /thermal_zone0 /cdev1 /cur_state
echo 0 > /sys /class /thermal /thermal_zone0 /cdev2 /cur_state
⽤⼾态接口
⽤⼾态接口在/sys/class/thermal/⽬录下,具体内容和DTSI中thermal zone节点的配置对应。有的平台thermalzone节点下只有⼀个⼦节点,对应/sys/class/thermal/⽬录下也只有thermal_zone0⼦⽬录;有的平台有两个⼦节点,对应/sys/class/thermal/⽬录下就会有thermal_zone0和thermal_zone1⼦⽬录。通过⽤⼾态接口可以切换温控策略,查看当前温度等。
以RK3399为例⼦,/sys/class/thermal/thermal_zone0/⽬录下包含如下常⽤的信息:
temp /* 当前温度 */
available_policies /* ⽀持的温控策略 */
policy /* 当前使⽤的温控策略 */
sustainable_power /* 期望的最⾼温度下对应的power 值 */
integral_cutoff /* PID 算法中I的触发条件:当前温度-期望的最⾼温度
k_d /* PID 算法中计算D的时候⽤的参数 */
k_i /* PID 算法中计算I的时候⽤的参数 */
k_po /* PID 算法中计算P的时候⽤的参数 */
k_pu /* PID 算法中计算P的时候⽤的参数 */
mode /* enabled :⾃带定时获取温度,判断是否需要降频。disabled 关闭该功能 */
type /* 当前thermal zone 的类型 */
/* 不同的温度阀值,对应trips 节点的配置 */
trip_point_0_hyst
trip_point_0_temp
trip_point_0_type
trip_point_1_hyst
trip_point_1_temp
trip_point_1_type
trip_point_2_hyst
trip_point_2_temp
trip_point_2_type
/* 不同cooling devic 的状态,对应cooling-maps 节点的配置 */
cdev0 /* 代表⼀个cooling devic ,有的平台还有cdev1 、cdev2 等 */
cur_state /* 该cooling device 当前频率的档位 */
max_state /* 该cooling device 最多有⼏个档位 */
type /* 该cooling device 的类型 */
cdev0_weight /* 该cooling devic 在计算power 时扩⼤的倍数 */
常用设置
获取当前温度
直接查看⽤⼾态接口thermal_zone0或者thermal_zone1⽬录下的temp节点即可。
以RK3399为例,获取CPU温度,在串口中输⼊如下命令:
cat /sys /class /thermal /thermal_zone0 /temp
获取GPU温度,在串口中输⼊如下命令:
cat /sys /class /thermal /thermal_zone1 /temp
关闭温度控制功能
⽅法⼀:menuconfig中默认温控策略设置为user_space。
<*> Generic Thermal sysfs driver --->
--- Generic Thermal sysfs driver
APIs to parse thermal data out of device tree
Enable writable trip points
Default Thermal governor ( user_space ) ---> /* power_allocator 改为user_space */
⽅法⼆:开机后通过命令关温控。
⾸先,把温控策略切换到user_space,即把⽤⼾态接口下的policy节点改成user_space;或者把mode设置成
disabled状态;然后,解除频率限制,即将⽤⼾态接口下的所有cdev的cur_state设置为0。
以RK3399为例,策略切换到user_space:
echo user_space > /sys /class /thermal /thermal_zone0 /policy
或者把mode设置成disabled状态:
echo disabled > /sys /class /thermal /thermal_zone0 /mode
解除频率限制:
/* 具体有多少个cdev ,根据实际情况修改 */
echo 0 > /sys /class /thermal /thermal_zone0 /cdev0 /cur_state
echo 0 > /sys /class /thermal /thermal_zone0 /cdev1 /cur_state
echo 0 > /sys /class /thermal /thermal_zone0 /cdev2 /cur_state
举报