diff options
author | Leila Lin <leilacy_lin@compal.corp-partner.google.com> | 2022-11-30 18:44:13 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-13 03:01:43 +0000 |
commit | 411fadab90778a57d0bd539e603cf20626122dfc (patch) | |
tree | a9e47e8ff5b6a4f0f01ec2df6223dc3db3bfd785 | |
parent | ee253e7e5ae01be179eee005cfd1732fd46a8d42 (diff) | |
download | chrome-ec-411fadab90778a57d0bd539e603cf20626122dfc.tar.gz |
winterhold: Dynamic switch thermal table
There are 3 modes: DESKTOP_LID_OPEN_MODEćDESKTOP_LID_CLOSE_MODE
and LAPTOP_MODE. The mode will base on the condition of lid and
body detection, when the hook notification is received, the mode
will change and different modes will have corresponding thermal
settings.
LOW_COVERAGE_REASON=no unit test for skyrim board yet: b/247151116
BRANCH=none
BUG=b:232946420
TEST=zmake build winterhold and confirm thermal config change when
mode change.
Change-Id: I5b4eaba2dbf3b4a833589e45588cf7f1001e22ea
Signed-off-by: Leila Lin <leilacy_lin@compal.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4066519
Commit-Queue: LeilaCY Lin <leilacy_lin@compal.corp-partner.google.com.test-google-a.com>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Reviewed-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
Tested-by: LeilaCY Lin <leilacy_lin@compal.corp-partner.google.com.test-google-a.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Tested-by: Elthan Huang <elthan_huang@compal.corp-partner.google.com>
-rw-r--r-- | zephyr/program/skyrim/winterhold/src/thermal.c | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/zephyr/program/skyrim/winterhold/src/thermal.c b/zephyr/program/skyrim/winterhold/src/thermal.c index 2c9432be09..9f4b8465f4 100644 --- a/zephyr/program/skyrim/winterhold/src/thermal.c +++ b/zephyr/program/skyrim/winterhold/src/thermal.c @@ -3,17 +3,105 @@ * found in the LICENSE file. */ +#include "body_detection.h" #include "hooks.h" #include "host_command.h" +#include "lid_switch.h" #include "temp_sensor/temp_sensor.h" +#include "thermal.h" #define CPRINTS(format, args...) cprints(CC_THERMAL, format, ##args) #define CPRINTF(format, args...) cprintf(CC_THERMAL, format, ##args) #define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_sensor_amb)) +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_DESKTOP_LID_OPEN \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_WARN] = C_TO_K(50), \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(110), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_WARN] = C_TO_K(45), \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(95), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(100), \ + }, \ + .temp_fan_off = C_TO_K(31), \ + .temp_fan_max = C_TO_K(38), \ + } +__maybe_unused static const struct ec_thermal_config thermal_desktop_lid_open = + THERMAL_DESKTOP_LID_OPEN; + +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_DESKTOP_LID_CLOSE \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_WARN] = C_TO_K(55), \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(110), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_WARN] = C_TO_K(50), \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(95), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(100), \ + }, \ + .temp_fan_off = C_TO_K(32), \ + .temp_fan_max = C_TO_K(39), \ + } +__maybe_unused static const struct ec_thermal_config thermal_desktop_lid_close = + THERMAL_DESKTOP_LID_CLOSE; + +/* + * TODO(b/202062363): Remove when clang is fixed. + */ +#define THERMAL_LAPTOP \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_WARN] = C_TO_K(45), \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(110), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_WARN] = C_TO_K(40), \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(95), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(100), \ + }, \ + .temp_fan_off = C_TO_K(30), \ + .temp_fan_max = C_TO_K(38), \ + } +__maybe_unused static const struct ec_thermal_config thermal_laptop = + THERMAL_LAPTOP; + static int last_amb_temp = -1; +/* Switch thermal table when mode change */ +static void thermal_table_switch(void) +{ + enum body_detect_states body_state = body_detect_get_state(); + + if (body_state == BODY_DETECTION_OFF_BODY) { + if (lid_is_open()) { + thermal_params[TEMP_AMB] = thermal_desktop_lid_open; + CPRINTS("Thermal: Desktop lid open mode"); + } else { + thermal_params[TEMP_AMB] = thermal_desktop_lid_close; + CPRINTS("Thermal: Desktop lid close mode"); + } + } else { + thermal_params[TEMP_AMB] = thermal_laptop; + CPRINTS("Thermal: Laptop mode"); + } +} +DECLARE_HOOK(HOOK_INIT, thermal_table_switch, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_LID_CHANGE, thermal_table_switch, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_BODY_DETECT_CHANGE, thermal_table_switch, HOOK_PRIO_DEFAULT); + /* Set SCI event to host for temperature change */ static void detect_temp_change(void) { |