diff options
author | Peter Chi <peter_chi@wistron.corp-partner.google.com> | 2022-05-16 09:32:25 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-06-30 00:33:59 +0000 |
commit | a11e8ae9dcdd295122e36105f5a4ab14abb2348d (patch) | |
tree | 241b1917c812594c8acb5cfffc00d1260aebd3e7 /board/crota | |
parent | bd8cdbe80c41895a39591a3cb79d5a7f7f9d19fb (diff) | |
download | chrome-ec-a11e8ae9dcdd295122e36105f5a4ab14abb2348d.tar.gz |
crota: add custom fan control
BUG=b:232656160
BRANCH=none
TEST=make -j BOARD=crota
Signed-off-by: Peter Chi <peter_chi@wistron.corp-partner.google.com>
Change-Id: I1dbafced042678af75f714121d421ff0f263dba7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3650086
Reviewed-by: Boris Mittelberg <bmbm@google.com>
Diffstat (limited to 'board/crota')
-rw-r--r-- | board/crota/board.h | 16 | ||||
-rw-r--r-- | board/crota/fans.c | 83 | ||||
-rw-r--r-- | board/crota/sensors.c | 133 |
3 files changed, 110 insertions, 122 deletions
diff --git a/board/crota/board.h b/board/crota/board.h index 3b0bea06dc..e972cf3425 100644 --- a/board/crota/board.h +++ b/board/crota/board.h @@ -188,6 +188,10 @@ #define CONFIG_LED_ONOFF_STATES #define CONFIG_LED_ONOFF_STATES_BAT_LOW 10 +/* Fan features */ +#define CONFIG_CUSTOM_FAN_CONTROL +#define CONFIG_FAN_DYNAMIC + /* Charger defines */ #define CONFIG_CHARGER_BQ25720 #define CONFIG_CHARGER_BQ25720_VSYS_TH2_CUSTOM @@ -204,18 +208,18 @@ #include "usbc_config.h" enum adc_channel { - ADC_TEMP_SENSOR_1_DDR_SOC, - ADC_TEMP_SENSOR_2_AMBIENT, + ADC_TEMP_SENSOR_1_SOC, + ADC_TEMP_SENSOR_2_DDR, ADC_TEMP_SENSOR_3_CHARGER, - ADC_TEMP_SENSOR_4_WWAN, + ADC_TEMP_SENSOR_4_AMBIENT, ADC_CH_COUNT }; enum temp_sensor_id { - TEMP_SENSOR_1_DDR_SOC, - TEMP_SENSOR_2_AMBIENT, + TEMP_SENSOR_1_SOC, + TEMP_SENSOR_2_DDR, TEMP_SENSOR_3_CHARGER, - TEMP_SENSOR_4_WWAN, + TEMP_SENSOR_4_AMBIENT, TEMP_SENSOR_COUNT }; diff --git a/board/crota/fans.c b/board/crota/fans.c index 443ccf13d3..e09519385f 100644 --- a/board/crota/fans.c +++ b/board/crota/fans.c @@ -12,6 +12,8 @@ #include "fan.h" #include "hooks.h" #include "pwm.h" +#include "thermal.h" +#include "util.h" /* MFT channels. These are logically separate from pwm_channels. */ const struct mft_t mft_channels[] = { @@ -30,20 +32,19 @@ static const struct fan_conf fan_conf_0 = { .enable_gpio = GPIO_EN_PP5000_FAN, }; -/* - * TOOD(b/181271666): thermistor placement and calibration - * - * Prototype fan spins at about 4200 RPM at 100% PWM, this - * is specific to board ID 2 and might also apears in later - * boards as well. - */ static const struct fan_rpm fan_rpm_0 = { - .rpm_min = 2200, - .rpm_start = 2200, - .rpm_max = 4200, + .rpm_min = 3500, + .rpm_start = 3500, + .rpm_max = 4300, }; -const struct fan_t fans[FAN_CH_COUNT] = { +static const struct fan_rpm fan_rpm_1 = { + .rpm_min = 4300, + .rpm_start = 4300, + .rpm_max = 4700, +}; + +struct fan_t fans[FAN_CH_COUNT] = { [FAN_CH_0] = { .conf = &fan_conf_0, .rpm = &fan_rpm_0, @@ -87,3 +88,63 @@ DECLARE_HOOK(HOOK_CHIPSET_RESET, fan_max, HOOK_PRIO_FIRST); DECLARE_HOOK(HOOK_CHIPSET_RESUME, fan_max, HOOK_PRIO_DEFAULT); #endif /* CONFIG_FANS */ + +static void fan_set_percent(int fan, int pct, bool fan_triggered) +{ + int new_rpm; + + if (fan_triggered) + fans[fan].rpm = &fan_rpm_1; + else + fans[fan].rpm = &fan_rpm_0; + + new_rpm = fan_percent_to_rpm(fan, pct); + + fan_set_rpm_target(FAN_CH(fan), new_rpm); +} + +void board_override_fan_control(int fan, int *tmp) +{ + /* + * Crota's fan speed is control by three sensors. + * + * Sensor SOC control high loading's speed. + * Sensor ambient control low loading's speed. + * Sensor charger control the speed when system's temperature + * is too high. + * + * When sensor charger is not triggered, the fan is control + * and choose the smaller speed between SOC and ambient. + * + * When sensor charger is triggered, the fan speed is only + * control by sensor charger, avoid heat damage to system. + */ + + int pct; + int sensor_soc; + int sensor_ambient; + int sensor_charger; + bool fan_triggered; + + sensor_soc = thermal_fan_percent(thermal_params[0].temp_fan_off, + thermal_params[0].temp_fan_max, + C_TO_K(tmp[0])); + sensor_ambient = thermal_fan_percent(thermal_params[3].temp_fan_off, + thermal_params[3].temp_fan_max, + C_TO_K(tmp[3])); + sensor_charger = thermal_fan_percent(thermal_params[2].temp_fan_off, + thermal_params[2].temp_fan_max, + C_TO_K(tmp[2])); + + if (sensor_charger){ + fan_triggered = true; + pct = sensor_charger; + } + else{ + fan_triggered = false; + pct = MIN(sensor_soc, sensor_ambient); + } + + /* transfer percent to rpm */ + fan_set_percent(fan, pct, fan_triggered); +} diff --git a/board/crota/sensors.c b/board/crota/sensors.c index baa82f7b56..05eae65783 100644 --- a/board/crota/sensors.c +++ b/board/crota/sensors.c @@ -9,7 +9,6 @@ #include "adc.h" #include "driver/accel_lis2dw12.h" #include "driver/accelgyro_lsm6dso.h" -#include "driver/als_tcs3400_public.h" #include "gpio.h" #include "hooks.h" #include "motion_sense.h" @@ -19,15 +18,15 @@ /* ADC configuration */ const struct adc_t adc_channels[] = { - [ADC_TEMP_SENSOR_1_DDR_SOC] = { - .name = "TEMP_DDR_SOC", + [ADC_TEMP_SENSOR_1_SOC] = { + .name = "TEMP_SOC", .input_ch = NPCX_ADC_CH0, .factor_mul = ADC_MAX_VOLT, .factor_div = ADC_READ_MAX + 1, .shift = 0, }, - [ADC_TEMP_SENSOR_2_AMBIENT] = { - .name = "TEMP_AMBIENT", + [ADC_TEMP_SENSOR_2_DDR] = { + .name = "TEMP_DDR", .input_ch = NPCX_ADC_CH1, .factor_mul = ADC_MAX_VOLT, .factor_div = ADC_READ_MAX + 1, @@ -40,8 +39,8 @@ const struct adc_t adc_channels[] = { .factor_div = ADC_READ_MAX + 1, .shift = 0, }, - [ADC_TEMP_SENSOR_4_WWAN] = { - .name = "TEMP_WWAN", + [ADC_TEMP_SENSOR_4_AMBIENT] = { + .name = "TEMP_AMBIENT", .input_ch = NPCX_ADC_CH7, .factor_mul = ADC_MAX_VOLT, .factor_div = ADC_READ_MAX + 1, @@ -156,17 +155,17 @@ DECLARE_HOOK(HOOK_INIT, baseboard_sensors_init, HOOK_PRIO_INIT_I2C + 1); /* Temperature sensor configuration */ const struct temp_sensor_t temp_sensors[] = { - [TEMP_SENSOR_1_DDR_SOC] = { - .name = "DDR and SOC", + [TEMP_SENSOR_1_SOC] = { + .name = "SOC", .type = TEMP_SENSOR_TYPE_BOARD, .read = get_temp_3v3_30k9_47k_4050b, - .idx = ADC_TEMP_SENSOR_1_DDR_SOC, + .idx = ADC_TEMP_SENSOR_1_SOC, }, - [TEMP_SENSOR_2_AMBIENT] = { - .name = "Ambient", + [TEMP_SENSOR_2_DDR] = { + .name = "DDR", .type = TEMP_SENSOR_TYPE_BOARD, .read = get_temp_3v3_30k9_47k_4050b, - .idx = ADC_TEMP_SENSOR_2_AMBIENT, + .idx = ADC_TEMP_SENSOR_2_DDR, }, [TEMP_SENSOR_3_CHARGER] = { .name = "Charger", @@ -174,124 +173,48 @@ const struct temp_sensor_t temp_sensors[] = { .read = get_temp_3v3_30k9_47k_4050b, .idx = ADC_TEMP_SENSOR_3_CHARGER, }, - [TEMP_SENSOR_4_WWAN] = { - .name = "WWAN", + [TEMP_SENSOR_4_AMBIENT] = { + .name = "Ambient", .type = TEMP_SENSOR_TYPE_BOARD, .read = get_temp_3v3_30k9_47k_4050b, - .idx = ADC_TEMP_SENSOR_4_WWAN, + .idx = ADC_TEMP_SENSOR_4_AMBIENT, }, }; BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT); -/* - * TODO(b/180681346): update for Alder Lake/brya - * - * Alder Lake specifies 100 C as maximum TDP temperature. THRMTRIP# occurs at - * 130 C. However, sensor is located next to DDR, so we need to use the lower - * DDR temperature limit (85 C) - */ -/* - * TODO(b/202062363): Remove when clang is fixed. - */ #define THERMAL_CPU \ { \ .temp_host = { \ - [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \ - [EC_TEMP_THRESH_HALT] = C_TO_K(90), \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(77), \ + [EC_TEMP_THRESH_HALT] = C_TO_K(80), \ }, \ .temp_host_release = { \ - [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \ + [EC_TEMP_THRESH_HIGH] = C_TO_K(77), \ }, \ - .temp_fan_off = C_TO_K(35), \ - .temp_fan_max = C_TO_K(60), \ + .temp_fan_off = C_TO_K(39), \ + .temp_fan_max = C_TO_K(52), \ } __maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU; -/* - * TODO(b/180681346): update for Alder Lake/brya - * - * Inductor limits - used for both charger and PP3300 regulator - * - * Need to use the lower of the charger IC, PP3300 regulator, and the inductors - * - * Charger max recommended temperature 100C, max absolute temperature 125C - * PP3300 regulator: operating range -40 C to 145 C - * - * Inductors: limit of 125c - * PCB: limit is 80c - */ -/* - * TODO(b/202062363): Remove when clang is fixed. - */ -#define THERMAL_AMBIENT \ - { \ - .temp_host = { \ - [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \ - [EC_TEMP_THRESH_HALT] = C_TO_K(90), \ - }, \ - .temp_host_release = { \ - [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \ - }, \ - .temp_fan_off = C_TO_K(35), \ - .temp_fan_max = C_TO_K(60), \ - } -__maybe_unused static const struct ec_thermal_config thermal_ambient = - THERMAL_AMBIENT; - -/* - * Inductor limits - used for both charger and PP3300 regulator - * - * Need to use the lower of the charger IC, PP3300 regulator, and the inductors - * - * Charger max recommended temperature 125C, max absolute temperature 150C - * PP3300 regulator: operating range -40 C to 125 C - * - * Inductors: limit of 125c - * PCB: limit is 80c - */ -/* - * TODO(b/202062363): Remove when clang is fixed. - */ #define THERMAL_CHARGER \ { \ - .temp_host = { \ - [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \ - [EC_TEMP_THRESH_HALT] = C_TO_K(120), \ - }, \ - .temp_host_release = { \ - [EC_TEMP_THRESH_HIGH] = C_TO_K(90), \ - }, \ - .temp_fan_off = C_TO_K(35), \ + .temp_fan_off = C_TO_K(59), \ .temp_fan_max = C_TO_K(65), \ } __maybe_unused static const struct ec_thermal_config thermal_charger = THERMAL_CHARGER; -/* - * TODO(b/180681346): update for brya WWAN module - */ -/* - * TODO(b/202062363): Remove when clang is fixed. - */ -#define THERMAL_WWAN \ +#define THERMAL_AMBIENT \ { \ - .temp_host = { \ - [EC_TEMP_THRESH_HIGH] = C_TO_K(130), \ - [EC_TEMP_THRESH_HALT] = C_TO_K(130), \ - }, \ - .temp_host_release = { \ - [EC_TEMP_THRESH_HIGH] = C_TO_K(100), \ - }, \ - .temp_fan_off = C_TO_K(35), \ - .temp_fan_max = C_TO_K(60), \ + .temp_fan_off = C_TO_K(26), \ + .temp_fan_max = C_TO_K(31), \ } -__maybe_unused static const struct ec_thermal_config thermal_wwan = - THERMAL_WWAN; +__maybe_unused static const struct ec_thermal_config thermal_ambient = + THERMAL_AMBIENT; struct ec_thermal_config thermal_params[] = { - [TEMP_SENSOR_1_DDR_SOC] = THERMAL_CPU, - [TEMP_SENSOR_2_AMBIENT] = THERMAL_AMBIENT, + [TEMP_SENSOR_1_SOC] = THERMAL_CPU, [TEMP_SENSOR_3_CHARGER] = THERMAL_CHARGER, - [TEMP_SENSOR_4_WWAN] = THERMAL_WWAN, + [TEMP_SENSOR_4_AMBIENT] = THERMAL_AMBIENT, }; BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT); |