Thermal
介绍 Thermal 的功能和使用方法。
模块介绍
Thermal 特指一套关于温控机制的驱动框架。Linux Thermal 框架是 Linux 系统下用于温度控制的一套架构,主要用于解决随着设备性能不断增强而引起的日益严重的发热问题。
功能介绍

- thermal_cooling_device:对应系 实施冷却措施的驱动,是温控的执行者。
- thermal core:Thermal的只要程序,负责驱动初始化,维护 thermal_zone,governor 和 cooling device 三者的关系,并通过 sysfs 和用户空间交互。
- thermal governor:温度控制算法,解决温控发生时 cooling device 应该选择哪个cooling state。
- thermal zone device:主要用来创建 thermal zone 结点和连接 thermal sensor。节点位于
/sys/class/thermal目录下,由 DTS 文件配置生成。 - thermal sensor:温度传感器,主要是给 thermal 提供温度数据。
源码结构介绍
CPU 调频平台驱动目录如下:
drivers/thermal/
├── cpufreq_cooling.c
├── cpufreq_cooling.o
├── cpuidle_cooling.c
├── devfreq_cooling.c
├── gov_bang_bang.c
├── gov_fair_share.c
├── gov_power_allocator.c
├── gov_step_wise.c
├── gov_user_space.c
├── k1x-thermal.c ---> 平台驱动
├── k1x-thermal.h
├── thermal_core.c
├── thermal_core.h
├── thermal_helpers.c
├── thermal_hwmon.c
├── thermal_hwmon.h
├── thermal_of.c
├── thermal_sysfs.c
关键特性
特性
- 支持 CPU 温度控制
- 支持 115°C 过温关机
测试方法
利用外部测温设备或运行高负载应用,制造温度变化的环境,检查 thermal 和 cpufreq 节点,确认 CPU 调温是否符合预期。
- 查看 thermal sensor 节点:
cat /sys/class/thermal/thermal_zone1/temp
- 查看 CPU 调频节点:
cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq
配置介绍
主要包括 驱动使能配置 和 DTS 配置
CONFIG 配置
THERMAL 配置如下:
CONFIG_K1X_THERMAL:
Enable this option if you want to have support for thermal management
controller present in Spacemit SoCs
Symbol: K1X_THERMAL [=y]
Type : tristate
Defined at drivers/thermal/Kconfig:450
Prompt: Spacemit K1X Thermal Support
Depends on: THERMAL [=y] && OF [=y] && SOC_SPACEMIT [=y]
Location:
-> Device Drivers
-> Thermal drivers (THERMAL [=y])
-> Spacemit K1X Thermal Support (K1X_THERMAL [=y])