diff options
-rw-r--r-- | common/temp_sensor.c | 11 | ||||
-rw-r--r-- | common/thermal.c | 8 | ||||
-rw-r--r-- | include/thermal.h | 3 |
3 files changed, 17 insertions, 5 deletions
diff --git a/common/temp_sensor.c b/common/temp_sensor.c index 9be87d9ece..4f1a8d7701 100644 --- a/common/temp_sensor.c +++ b/common/temp_sensor.c @@ -11,6 +11,7 @@ #include "host_command.h" #include "task.h" #include "temp_sensor.h" +#include "thermal.h" #include "timer.h" #include "util.h" @@ -109,7 +110,15 @@ static int command_temps(int argc, char **argv) switch (rv) { case EC_SUCCESS: - ccprintf("%d K = %d C\n", t, K_TO_C(t)); + ccprintf("%d K = %d C", t, K_TO_C(t)); + if (thermal_params[i].temp_fan_off && + thermal_params[i].temp_fan_max) + ccprintf(" %d%%", + thermal_fan_percent( + thermal_params[i].temp_fan_off, + thermal_params[i].temp_fan_max, + t)); + ccprintf("\n"); break; case EC_ERROR_NOT_POWERED: ccprintf("Not powered\n"); diff --git a/common/thermal.c b/common/thermal.c index 742430e6bb..066331275f 100644 --- a/common/thermal.c +++ b/common/thermal.c @@ -121,7 +121,7 @@ test_mockable_static void smi_sensor_failure_warning(void) host_set_single_event(EC_HOST_EVENT_THERMAL); } -static int fan_percent(int low, int high, int cur) +int thermal_fan_percent(int low, int high, int cur) { if (cur < low) return 0; @@ -181,9 +181,9 @@ static void thermal_control(void) /* figure out the max fan needed, too */ if (thermal_params[i].temp_fan_off && thermal_params[i].temp_fan_max) { - f = fan_percent(thermal_params[i].temp_fan_off, - thermal_params[i].temp_fan_max, - t); + f = thermal_fan_percent(thermal_params[i].temp_fan_off, + thermal_params[i].temp_fan_max, + t); if (f > fmax) fmax = f; } diff --git a/include/thermal.h b/include/thermal.h index d3729591a0..77b513aacc 100644 --- a/include/thermal.h +++ b/include/thermal.h @@ -16,4 +16,7 @@ */ extern struct ec_thermal_config thermal_params[]; +/* Helper function to compute percent cooling */ +int thermal_fan_percent(int low, int high, int cur); + #endif /* __CROS_EC_THERMAL_H */ |