Qualcomm thermal的介绍
随着智能设备的发展,很多产品越做越小,在一块很小的板子和结构内会附带很多功能,加上很多应用需要处理数据很大,必定造成设备很容易发热。且发热不仅会带来体验的不足还会带来大量的电量消耗。所以在移动消费产品,对热量的解决方案还是很重要的。今天我们就介绍下高通410C开发板上热量管理的机制,软件如何控制。
首先在软件架构上我们分为以下部分。
一:驱动部分
驱动代码位置:
共有部分:kernel/deriver/thermal_core.c
kernel/driver/user_space.c
platform部分:
mitigation部分:
kernel/driver/msm_thermal-dev.c
kernel/driver/msm_thermal.c
sensor部分:
qpnp-temp-alarm.c
msm8974-tsens.c
简要叙述驱动文件关键位置,基本理解驱动构架以及如何运作。
msm8974-tsens.c
1:sensor的注册,将thermal注册为class类:
2:thermal_zone_device_ops接口的填充,以给thermal_core的调用。
3:触发中断与通知上层。
thermal_core.c
1:thermal_zone_devices_register()提供相应sensor register接口,按先后顺序注册/sys/class/thermal/thermal_zoneN。
2:为上层提供trip_temp、type等接口,如:
root@msm8916_32:/ # cat /sys/class/thermal/thermal_zone5/trip_point_0_type
configurable_hi
root@msm8916_32:/ # cat /sys/class/thermal/thermal_zone5/trip_point_0_temp
85
这里trip_point_0_temp为high temp thresthold,那么trip_point_1_temp为low temp thresthold
3:调用sensor相关接口:
关于tpye name与thermal_zone的对应关系:
以8016为例:
type name
thermal_zone0 battery
thermal_zone1 tsens_tz_sensor0
thermal_zone2 tsens_tz_sensor1
thermal_zone3 tsens_tz_sensor2 pop_mem
thermal_zone4 tsens_tz_sensor4 cpu2-3
thermal_zone5 tsens_tz_sensor5 cpu0-1
thermal_zone6 pm8916_tz
thermal_zone7 bms
msm_thermal.c
mitigation分为轮训与中断,首先看下poll部分:
每隔指定的时间就会check温度,当超过范围会降频,关闭cpu,重设thsreshold等操作。
interrupt部分,默认启动的是中断方式,这里是interrupt的初始化。
再以hotplug细说interrupt的运行,这里会根据dts里面的参数先设置,后通过set_threshold调用之前sensor填充的接口,写入到寄存器里面,当达到温度后,触发中断后会通知上层,再温度非常高的话会运行起kernel mitigation,通过hotplug notify来做相应处理
二:上层thermal-engine部分:
thermal工作机制:首先上层设置trig point,包括恢复温度与临界温度,thermal engine主要有algo_monitor运作sensor monitor起辅助作用够成。algo_monitor依赖 sensor_monitor的运作,而sensor_monitor的运行依赖中断的触发。
1:首先初始化engine,