高通865,内核版本4.19
drivers/thermal/of-thermal.c
thermal_of_populate_trip //解析trip具体参数 tz->ntrips
thermal_of_build_thermal_zone // 解析每个zone 用于生成/sys/devices/virtual/thermal/thermal_zone*各个虚拟设备和节点,返回结构体__thermal_zone
of_parse_thermal_zones调用thermal_of_build_thermal_zone解析设备树
核心函数:
void thermal_zone_device_update(struct thermal_zone_device *tz,
enum thermal_notify_event event)
{
int count;
if (atomic_read(&in_suspend) && (!tz->ops->is_wakeable ||
!(tz->ops->is_wakeable(tz))))
return;
if (!tz->ops->get_temp)
return;
trace_thermal_device_update(tz, event);
update_temperature(tz);
thermal_zone_set_trips(tz);
tz->notify_event = event;
for (count = 0; count < tz->trips; count++)
handle_thermal_trip(tz, count);
}
thermal_zone_set_trips 计算low 和 high,并调用
// Set a temperature window. When this window is left the driver
// must inform the thermal core via thermal_zone_device_update.
ret = tz->ops->set_trips(tz, low, high); 这个函数会设置到硬件寄存器里,bcl对应下面三个设置函数
qcom/bcl_pmic5.c:507: vbat->ops.set_trips = bcl_set_vbat;
qcom/bcl_pmic5.c:542: ibat->ops.set_trips = bcl_set_ibat;
qcom/bcl_pmic5.c:576: lbat->ops.set_trips = bcl_set_lbat;