diff options
author | Peter Chi <peter_chi@wistron.corp-partner.google.com> | 2022-09-13 14:56:18 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-09-27 04:03:26 +0000 |
commit | 9dbc099037a8fd626f1e00ac3dcbe69e55cb6758 (patch) | |
tree | 1d6aeefac56dfb6e582c367f94f05e51820e3503 | |
parent | 817f468ae22bef0558ea87a50c582c65db35176b (diff) | |
download | chrome-ec-9dbc099037a8fd626f1e00ac3dcbe69e55cb6758.tar.gz |
crota: change fan table and add tablet fan control
Add different fan speed on clamshell and tablet mode,
also verified by Thermal team(thermal policy table V17)
BUG=b:248457426, b:246214508
BRANCH=none
TEST=make -j BOARD=crota
Signed-off-by: Peter Chi <peter_chi@wistron.corp-partner.google.com>
Change-Id: I4d34da9663fe392992fa5436e543c259c8a7b27a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3893691
Commit-Queue: caveh jalali <caveh@chromium.org>
Reviewed-by: caveh jalali <caveh@chromium.org>
-rw-r--r-- | board/crota/board.h | 17 | ||||
-rw-r--r-- | board/crota/fans.c | 135 | ||||
-rw-r--r-- | board/crota/sensors.c | 46 |
3 files changed, 128 insertions, 70 deletions
diff --git a/board/crota/board.h b/board/crota/board.h index 6c406584d8..70b7efac1b 100644 --- a/board/crota/board.h +++ b/board/crota/board.h @@ -261,8 +261,8 @@ enum pwm_channel { enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT }; enum fan_rpm_table { - RPM_TABLE_CPU0, - RPM_TABLE_CPU1, + RPM_TABLE_CPU, + RPM_TABLE_CPU_TABLET, RPM_TABLE_DDR, RPM_TABLE_CHARGER, RPM_TABLE_AMBIENT, @@ -271,6 +271,19 @@ enum fan_rpm_table { enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT }; +struct thermal_policy_config { + uint8_t fan_off_slop1; + uint8_t fan_max_slop1; + uint8_t fan_off_slop2; + uint8_t fan_max_slop2; + uint8_t fan_slop_threshold; + uint8_t ddr_fan_turn_on; + uint8_t ddr_fan_turn_off; + uint8_t rpm_table_cpu; +}; + +enum thermal_cfg_table { LAPTOP_MODE, TABLET_MODE, THERMAL_CFG_TABLE_COUNT }; + void motion_interrupt(enum gpio_signal signal); #endif /* !__ASSEMBLER__ */ diff --git a/board/crota/fans.c b/board/crota/fans.c index 17e19dc863..d38b82e44f 100644 --- a/board/crota/fans.c +++ b/board/crota/fans.c @@ -12,15 +12,11 @@ #include "fan.h" #include "hooks.h" #include "pwm.h" +#include "tablet_mode.h" #include "timer.h" #include "thermal.h" #include "util.h" -#define SENSOR_SOC_FAN_OFF 30 -#define SENSOR_SOC_FAN_MID 47 -#define SENSOR_SOC_FAN_MAX 53 -#define SENSOR_DDR_FAN_TURN_OFF 37 -#define SENSOR_DDR_FAN_TURN_ON 38 #define RECORD_TIME (2 * MINUTE) /* MFT channels. These are logically separate from pwm_channels. */ @@ -41,15 +37,15 @@ static const struct fan_conf fan_conf_0 = { }; static const struct fan_rpm rpm_table[FAN_RPM_TABLE_COUNT] = { - [RPM_TABLE_CPU0] = { - .rpm_min = 2200, - .rpm_start = 2200, - .rpm_max = 3700, + [RPM_TABLE_CPU] = { + .rpm_min = 0, + .rpm_start = 0, + .rpm_max = 4000, }, - [RPM_TABLE_CPU1] = { - .rpm_min = 3700, - .rpm_start = 3700, + [RPM_TABLE_CPU_TABLET] = { + .rpm_min = 0, + .rpm_start = 0, .rpm_max = 4000, }, @@ -75,7 +71,32 @@ static const struct fan_rpm rpm_table[FAN_RPM_TABLE_COUNT] = { struct fan_t fans[FAN_CH_COUNT] = { [FAN_CH_0] = { .conf = &fan_conf_0, - .rpm = &rpm_table[RPM_TABLE_CPU0], + .rpm = &rpm_table[RPM_TABLE_CPU], + }, +}; + +static const struct thermal_policy_config + thermal_cfg[THERMAL_CFG_TABLE_COUNT] = { + [LAPTOP_MODE] = { + .fan_off_slop1 = 24, + .fan_max_slop1 = 51, + .fan_off_slop2 = 29, + .fan_max_slop2 = 48, + .fan_slop_threshold = 45, + .ddr_fan_turn_off = 38, + .ddr_fan_turn_on = 44, + .rpm_table_cpu = RPM_TABLE_CPU, + }, + + [TABLET_MODE] = { + .fan_off_slop1 = 25, + .fan_max_slop1 = 52, + .fan_off_slop2 = 30, + .fan_max_slop2 = 49, + .fan_slop_threshold = 45, + .ddr_fan_turn_off = 38, + .ddr_fan_turn_on = 44, + .rpm_table_cpu = RPM_TABLE_CPU_TABLET, }, }; @@ -116,68 +137,68 @@ void board_override_fan_control(int fan, int *tmp) * Sensor SOC has two slopes for fan speed. * Sensor DDR also become a fan on/off switch. */ + const struct thermal_policy_config *t; static int pct; - int sensor_soc; - int sensor_ddr; - int sensor_charger; - int sensor_ambient; + int i; + int fan_pct[TEMP_SENSOR_COUNT]; + int fan_off; + int fan_max; + + /* Decide is tablet mode or laptop mode. */ + if (tablet_get_mode()) + t = &thermal_cfg[TABLET_MODE]; + else + t = &thermal_cfg[LAPTOP_MODE]; /* Decide sensor SOC temperature using which slope. */ - if (tmp[TEMP_SENSOR_1_SOC] > SENSOR_SOC_FAN_MID) { - thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off = - C_TO_K(SENSOR_SOC_FAN_MID); - thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max = - C_TO_K(SENSOR_SOC_FAN_MAX); + if (tmp[TEMP_SENSOR_1_SOC] <= t->fan_slop_threshold) { + fan_off = t->fan_off_slop1; + fan_max = t->fan_max_slop1; } else { - thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off = - C_TO_K(SENSOR_SOC_FAN_OFF); - thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max = - C_TO_K(SENSOR_SOC_FAN_MID); + fan_off = t->fan_off_slop2; + fan_max = t->fan_max_slop2; } + thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off = C_TO_K(fan_off); + thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max = C_TO_K(fan_max); - sensor_soc = thermal_fan_percent( - thermal_params[TEMP_SENSOR_1_SOC].temp_fan_off, - thermal_params[TEMP_SENSOR_1_SOC].temp_fan_max, - C_TO_K(tmp[TEMP_SENSOR_1_SOC])); - sensor_ddr = thermal_fan_percent( - thermal_params[TEMP_SENSOR_2_DDR].temp_fan_off, - thermal_params[TEMP_SENSOR_2_DDR].temp_fan_max, - C_TO_K(tmp[TEMP_SENSOR_2_DDR])); - sensor_charger = thermal_fan_percent( - thermal_params[TEMP_SENSOR_3_CHARGER].temp_fan_off, - thermal_params[TEMP_SENSOR_3_CHARGER].temp_fan_max, - C_TO_K(tmp[TEMP_SENSOR_3_CHARGER])); - sensor_ambient = thermal_fan_percent( - thermal_params[TEMP_SENSOR_4_AMBIENT].temp_fan_off, - thermal_params[TEMP_SENSOR_4_AMBIENT].temp_fan_max, - C_TO_K(tmp[TEMP_SENSOR_4_AMBIENT])); + for (i = 0; i < TEMP_SENSOR_COUNT; i++) { + fan_pct[i] = thermal_fan_percent(thermal_params[i].temp_fan_off, + thermal_params[i].temp_fan_max, + C_TO_K(tmp[i])); + } /* - * Sensor DDR turn on when temperature > 38, - * turn off when temperature < 37 + * In Balance mode: + * Sensor DDR turn on when temperature > 44, + * turn off when temperature < 38 + * + * In Tablet mode: + * Sensor DDR turn on when temperature > 44, + * turn off when temperature < 38 + * + * When temperature from high dropping to 38 ~ 44, + * if pct is not 0, keep sensor trigger and choose table. */ - if ((tmp[TEMP_SENSOR_2_DDR]) < SENSOR_DDR_FAN_TURN_OFF) { + if (((tmp[TEMP_SENSOR_2_DDR]) <= t->ddr_fan_turn_on && pct == 0) || + ((tmp[TEMP_SENSOR_2_DDR]) < t->ddr_fan_turn_off)) pct = 0; - } else if ((tmp[TEMP_SENSOR_2_DDR]) > SENSOR_DDR_FAN_TURN_ON) { + else { /* * Decide which sensor was triggered and choose table. * Priority: charger > soc > ddr > ambient */ - if (sensor_charger) { + if (fan_pct[TEMP_SENSOR_3_CHARGER]) { fans[fan].rpm = &rpm_table[RPM_TABLE_CHARGER]; - pct = sensor_charger; - } else if (sensor_soc) { - if (tmp[TEMP_SENSOR_1_SOC] > SENSOR_SOC_FAN_MID) - fans[fan].rpm = &rpm_table[RPM_TABLE_CPU1]; - else - fans[fan].rpm = &rpm_table[RPM_TABLE_CPU0]; - pct = sensor_soc; - } else if (sensor_ddr) { + pct = fan_pct[TEMP_SENSOR_3_CHARGER]; + } else if (fan_pct[TEMP_SENSOR_1_SOC]) { + fans[fan].rpm = &rpm_table[t->rpm_table_cpu]; + pct = fan_pct[TEMP_SENSOR_1_SOC]; + } else if (fan_pct[TEMP_SENSOR_2_DDR]) { fans[fan].rpm = &rpm_table[RPM_TABLE_DDR]; - pct = sensor_ddr; + pct = fan_pct[TEMP_SENSOR_2_DDR]; } else { fans[fan].rpm = &rpm_table[RPM_TABLE_AMBIENT]; - pct = sensor_ambient; + pct = fan_pct[TEMP_SENSOR_4_AMBIENT]; } } diff --git a/board/crota/sensors.c b/board/crota/sensors.c index bbd2686512..79d2492060 100644 --- a/board/crota/sensors.c +++ b/board/crota/sensors.c @@ -260,27 +260,51 @@ BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); .temp_host_release = { \ [EC_TEMP_THRESH_HIGH] = C_TO_K(77), \ }, \ - .temp_fan_off = C_TO_K(30), \ - .temp_fan_max = C_TO_K(47), \ + .temp_fan_off = C_TO_K(24), \ + .temp_fan_max = C_TO_K(51), \ } __maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU; -#define THERMAL_DDR \ - { \ - .temp_fan_off = C_TO_K(56), .temp_fan_max = C_TO_K(59), \ +#define THERMAL_DDR \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(75), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(78), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(75), \ + }, \ + .temp_fan_off = C_TO_K(56), \ + .temp_fan_max = C_TO_K(59), \ } __maybe_unused static const struct ec_thermal_config thermal_ddr = THERMAL_DDR; -#define THERMAL_CHARGER \ - { \ - .temp_fan_off = C_TO_K(67), .temp_fan_max = C_TO_K(70), \ +#define THERMAL_CHARGER \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(86), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(89), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(86), \ + }, \ + .temp_fan_off = C_TO_K(67), \ + .temp_fan_max = C_TO_K(70), \ } __maybe_unused static const struct ec_thermal_config thermal_charger = THERMAL_CHARGER; -#define THERMAL_AMBIENT \ - { \ - .temp_fan_off = C_TO_K(38), .temp_fan_max = C_TO_K(45), \ +#define THERMAL_AMBIENT \ + { \ + .temp_host = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(57), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(60), \ + }, \ + .temp_host_release = { \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(57), \ + }, \ + .temp_fan_off = C_TO_K(38), \ + .temp_fan_max = C_TO_K(45), \ } __maybe_unused static const struct ec_thermal_config thermal_ambient = THERMAL_AMBIENT; |