節(jié)點(diǎn)信息解釋
Thermal sysfs節(jié)點(diǎn)位置---/sys/class/thermal
每個(gè)thermal_zone下面代表一個(gè)sensor對(duì)應(yīng)的抽象,每個(gè)節(jié)點(diǎn)的基本含義如下
Thermal zone device sys I/F, created once it's registered:
/sys/class/thermal/thermal_zone[0-*]:
|---type: Type of the thermal zone
|---temp: Current temperature
|---mode: Working mode of the thermal zone
|---policy: Thermal governor used for this zone
|---available_policies: Available thermal governors for this zone
|---trip_point_[0-*]_temp: Trip point temperature
|---trip_point_[0-*]_type: Trip point type
|---trip_point_[0-*]_hyst: Hysteresis value for this trip point
|---emul_temp: Emulated temperature set node
|---sustainable_power: Sustainable dissipatable power
|---k_po: Proportional term during temperature overshoot
|---k_pu: Proportional term during temperature undershoot
|---k_i: PID's integral term in the power allocator gov
|---k_d: PID's derivative term in the power allocator
|---integral_cutoff: Offset above which errors are accumulated
|---slope: Slope constant applied as linear extrapolation
|---offset: Offset constant applied as linear extrapolation
補(bǔ)充:
passive :(被動(dòng))默認(rèn)是0,表示disabled,也可以設(shè)置以millidegrees為單位的溫度值,來使能被動(dòng)的trip point for this zone
policy : 一種當(dāng)前thermal zone的thermal governor, mtk用的只有backward_compatible(溫度大于等于設(shè)定,對(duì)應(yīng)的cooling device set_cur_state=1,溫度小于設(shè)定,對(duì)應(yīng)的cooling device set_cur_state=0), 高通的是多種的,有 low_limits_floor low_limits_cap user_space step_wise 等
mode : [enable/disable] enabled = enable Kernel Thermal management , disabled 表示應(yīng)用程序來調(diào)節(jié)thermal,內(nèi)核不管(mtk默認(rèn)使用私有的應(yīng)用層程序來管理)
Thermal cooling device sys I/F, created once it's registered:
/sys/class/thermal/cooling_device[0-*]:
|---type: Type of the cooling device(processor/fan/...)
|---max_state: Maximum cooling state of the cooling device
|---cur_state: Current cooling state of the cooling device
Kernel thermal governor --- step_wise 分析:
step_wise --- 根據(jù)溫度變化趨勢來確定,如果thermal_zone溫度是逐漸升高的,則對(duì)應(yīng)的cooling device會(huì)采取對(duì)應(yīng)的降溫措施,如果thermal_zone溫度是降低的,則會(huì)逐漸恢復(fù)性能限制。
對(duì)應(yīng)判斷的狀態(tài)枚舉參數(shù)如下
enum thermal_trend {
THERMAL_TREND_STABLE, /* temperature is stable */
THERMAL_TREND_RAISING, /* temperature is raising */
THERMAL_TREND_DROPPING, /* temperature is dropping */
THERMAL_TREND_RAISE_FULL, /* apply highest cooling action */
THERMAL_TREND_DROP_FULL, /* apply lowest cooling action */
};
throttle函數(shù)
static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
{
struct thermal_instance *instance;
thermal_zone_trip_update(tz, trip); //根據(jù)當(dāng)前溫度和上次溫度對(duì)比,得到溫度趨勢;然后根據(jù)溫度趨勢得出Cooling設(shè)備對(duì)應(yīng)的state。
if (tz->forced_passive)
thermal_zone_trip_update(tz, THERMAL_TRIPS_NONE);
mutex_lock(&tz->lock);
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
thermal_cdev_update(instance->cdev);//遍歷cdev->thermal_instances選擇最深的cooling狀態(tài)。然后調(diào)用cdev->ops->set_cur_state()中
mutex_unlock(&tz->lock);
return 0;
}