Skip to content

Commit 648d89e

Browse files
Josh-Tsaiamstan
authored andcommitted
fwk: dogwood: adding the backup temperature sensor
In some cases the CPU temperature might not be updated. This change uses the onboard thermal sensors (QTH1 and UTH1) as a backup to the CPU sensor. The maxumum temperature sets to 65C and the minimum temperature sets to 50C. BRANCH=fwk-dogwood-27111 BUG=https://app.clickup.com/t/86et9h4tv TEST=heat the Qth1 sensor only to check the target duty uses the backup temperature sensor. [301.499900 Fan0 parameters:] [301.501400 Target Duty:34] [301.504100 Maximum Duty:100] [301.507100 Minimum Duty:25] [301.510100 Maximum Temperature:54] [301.513500 Minimum Temperature:35] [301.517000 Sensor Source:cpu@4c] [301.520400 Always on disabled] ec:~> temps mainboard_power@4d 325 K (= 52 C) 87% (311 K and 327 K) mainboard_memory@4d 303 K (= 30 C) 0% (313 K and 327 K) mainboard_ambient@4d 304 K (= 31 C) 0% (313 K and 327 K) cpu@4c 305 K (= 32 C) cpu-average 576 K (= 303 C) Signed-off-by: Josh-Tsai <josh_tsai@compal.com>
1 parent a4fbf36 commit 648d89e

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

  • zephyr/program/framework/dogwood/src

zephyr/program/framework/dogwood/src/thermal.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
#define FAN_CHASSIS_1 DT_NODELABEL(fan_front)
4141
#define FAN_CHASSIS_2 DT_NODELABEL(fan_rsv)
4242

43+
#define BACKUP_MAX_TEMP 65 /* Uint: Celsius */
44+
#define BACKUP_MIN_TEMP 50 /* Uint: Celsius */
45+
4346
/* Follow BIOS EC and SW ERS to define the fan off temperature (unit: C) */
4447
#define FAN_OFF_MIN_TEMP_HYSTERESIS 1
4548

@@ -117,13 +120,28 @@ static int thermal_process_sensor(int fan, enum temp_sensor_id id, int *temp)
117120
int duty;
118121
int duty_max = fan_param->max_duty;
119122
int duty_min = fan_param->min_duty;
120-
int temp_ratio;
123+
int temp_ratio, sensor_ratio;
124+
int backup_ratio = 0;
121125

122-
temp_ratio = thermal_fan_percent_with_hysteresis(fan_param->min_temperature,
126+
sensor_ratio = thermal_fan_percent_with_hysteresis(fan_param->min_temperature,
123127
fan_param->max_temperature,
124128
temp[id],
125129
fan_param->target_duty ? true : false);
126130

131+
/**
132+
* In some cases the CPU temperature might not be updated.
133+
* So we use the onboard thermal sensors (QTH1, UTH1) as a backup to the CPU sensor.
134+
*/
135+
if (id == TEMP_ID_CHIPSET || id == TEMP_ID_VIRTUAL) {
136+
backup_ratio = thermal_fan_percent_with_hysteresis(BACKUP_MIN_TEMP,
137+
BACKUP_MAX_TEMP,
138+
MAX(temp[TEMP_ID_DDR], temp[TEMP_ID_POWER]),
139+
fan_param->target_duty ? true : false);
140+
}
141+
142+
/* Select the biggest ratio to be the target duty */
143+
temp_ratio = MAX(sensor_ratio, backup_ratio);
144+
127145
/**
128146
* If the current temperature between minimum and maximum, we need to convert the
129147
* current ratio to fan duty

0 commit comments

Comments
 (0)