Skip to content

Commit 2881db6

Browse files
kiram9JohnAZoidberg
authored andcommitted
fwk: hx30 fix thermal sensor index
This fixes an issue in 56f3bf7fc5a487b289c052a97c8f608b0c6f3fe6 Where the CPU temperature index was calculated incorrectly, causing the wrong thermal sensor to be read. f75303_get_val_mk uses the sensor index. However other lookups such as thermal_params use the enum temp_sensor_id. These are not 100% aligned, causing the wrong sensor to be used for CPU temps. Signed-off-by: Kieran Levin <ktl@frame.work>
1 parent c706510 commit 2881db6

1 file changed

Lines changed: 20 additions & 36 deletions

File tree

baseboard/fwk/thermal.c

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,6 @@ bool log_thermal;
4343
/* battery-temp */
4444
#define TEMP_BATTERY TEMP_SENSOR_BATTERY
4545

46-
/* TODO: Rename to SOC */
47-
/* soc-temp */
48-
#define TEMP_APU TEMP_SENSOR_PECI
49-
50-
/* ddr-f75303 */
51-
#define TEMP_DDR TEMP_SENSOR_DDR
52-
#define TEMP_DDR_F TEMP_SENSOR_DDR
53-
54-
/* cpu-f75303 */
55-
#define TEMP_CPU TEMP_SENSOR_CPU
56-
#define TEMP_CPU_F TEMP_SENSOR_CPU
57-
58-
/* local-f75397 */
59-
#define TEMP_LOCAL TEMP_SENSOR_LOCAL
60-
#define TEMP_LOCAL_F TEMP_SENSOR_LOCAL
61-
6246

6347
int fan_percent_to_rpm(int fan_index, int temp_ratio)
6448
{
@@ -77,7 +61,6 @@ int fan_percent_to_rpm(int fan_index, int temp_ratio)
7761
void board_override_fan_control(int fan, int *temp)
7862
{
7963
int actual_rpm, new_rpm;
80-
int apu_temp_mk = 0;
8164

8265
int apu_pct = 0;
8366
int pct = 0;
@@ -106,28 +89,29 @@ void board_override_fan_control(int fan, int *temp)
10689
if (chipset_in_state(CHIPSET_STATE_ON)) {
10790

10891
if (fan == 0)
109-
thermal_filter_update(&apu_filtered, temp[TEMP_APU]);
110-
111-
/*f75303_get_val_mk(TEMP_CPU_F, &apu_temp_mk); */
92+
thermal_filter_update(&apu_filtered, temp[TEMP_SENSOR_PECI]);
11293

11394
apu_filtered_temp = thermal_filter_get(&apu_filtered);
11495

115-
f75303_get_val_mk(TEMP_CPU_F, &temps_mk[1]);
116-
if (thermal_params[TEMP_CPU].temp_fan_off &&
117-
thermal_params[TEMP_CPU].temp_fan_max) {
118-
apu_pct = thermal_fan_percent(thermal_params[TEMP_CPU].temp_fan_off * 1000,
119-
thermal_params[TEMP_CPU].temp_fan_max * 1000,
96+
/* Note this gets the index based on the thermal sensor index */
97+
f75303_get_val_mk(temp_sensors[TEMP_SENSOR_CPU].idx , &temps_mk[1]);
98+
if (thermal_params[TEMP_SENSOR_CPU].temp_fan_off &&
99+
thermal_params[TEMP_SENSOR_CPU].temp_fan_max) {
100+
apu_pct = thermal_fan_percent(thermal_params[TEMP_SENSOR_CPU].temp_fan_off * 1000,
101+
thermal_params[TEMP_SENSOR_CPU].temp_fan_max * 1000,
120102
temps_mk[1]);
121103
}
122104

123-
if (thermal_params[TEMP_APU].temp_fan_off &&
124-
thermal_params[TEMP_APU].temp_fan_max) {
105+
if (thermal_params[TEMP_SENSOR_PECI].temp_fan_off &&
106+
thermal_params[TEMP_SENSOR_PECI].temp_fan_max) {
125107
apu_filtered_pct = thermal_fan_percent(
126-
thermal_params[TEMP_APU].temp_fan_off * 1000,
127-
thermal_params[TEMP_APU].temp_fan_max * 1000,
108+
thermal_params[TEMP_SENSOR_PECI].temp_fan_off * 1000,
109+
thermal_params[TEMP_SENSOR_PECI].temp_fan_max * 1000,
128110
C_TO_K(apu_filtered_temp)*1000);
129111
}
130-
pct = MAX(apu_pct, apu_filtered_pct);
112+
pct = apu_filtered_pct;
113+
114+
//pct = MAX(apu_pct, apu_filtered_pct);
131115
new_rpm = fan_percent_to_rpm(fan, pct);
132116
actual_rpm = fan_get_rpm_actual(FAN_CH(fan));
133117

@@ -144,8 +128,8 @@ void board_override_fan_control(int fan, int *temp)
144128
/* add temperature histeresis so the fan does not turn off
145129
* unless the system has cooled 0.5C below the fan turn on temperature
146130
*/
147-
if (thermal_params[TEMP_APU].temp_fan_off &&
148-
apu_temp_mk > (thermal_params[TEMP_APU].temp_fan_off
131+
if (thermal_params[TEMP_SENSOR_CPU].temp_fan_off &&
132+
temps_mk[1] > (thermal_params[TEMP_SENSOR_CPU].temp_fan_off
149133
* 1000 - 500)) {
150134
deadline.val = get_time().val + FAN_STOP_DELAY_S;
151135
}
@@ -156,9 +140,9 @@ void board_override_fan_control(int fan, int *temp)
156140
}
157141

158142
if (log_thermal && fan == 0) {
159-
f75303_get_val_mk(TEMP_DDR_F, &temps_mk[0]);
160-
f75303_get_val_mk(TEMP_CPU_F, &temps_mk[1]);
161-
f75397_get_val_mk(TEMP_LOCAL_F, &temps_mk[2]);
143+
f75303_get_val_mk(temp_sensors[TEMP_SENSOR_DDR].idx, &temps_mk[0]);
144+
f75303_get_val_mk(temp_sensors[TEMP_SENSOR_CPU].idx, &temps_mk[1]);
145+
f75397_get_val_mk(temp_sensors[TEMP_SENSOR_LOCAL].idx, &temps_mk[2]);
162146
CPRINTS(
163147
"\tThrm\t%d\t%d\t%d\t"
164148
"\t%d\t%d\t"
@@ -168,7 +152,7 @@ void board_override_fan_control(int fan, int *temp)
168152
MILLI_KELVIN_TO_CELSIUS(temps_mk[0]),
169153
MILLI_KELVIN_TO_CELSIUS(temps_mk[1]),
170154
MILLI_KELVIN_TO_CELSIUS(temps_mk[2]),
171-
temp[TEMP_BATTERY], temp[TEMP_APU],
155+
temp[TEMP_SENSOR_BATTERY], temp[TEMP_SENSOR_PECI],
172156
thermal_filter_get(&apu_filtered),
173157
pct, apu_pct, apu_filtered_pct,
174158
new_rpm, actual_rpm);

0 commit comments

Comments
 (0)