diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2018-07-16 12:22:54 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-07-17 21:53:37 -0700 |
commit | a8d34b791540534d6e45aac719cee0e72ce79824 (patch) | |
tree | ea3962e89a34a392d1d1e16a063e055955fbc174 /common/fan.c | |
parent | 9b7ce9c9dbdb5eb858757dc61a55bb98749019b0 (diff) | |
download | chrome-ec-a8d34b791540534d6e45aac719cee0e72ce79824.tar.gz |
fan: Enable fan control on AP startup not on shutdown/suspend
There is no need to cool CPU in S3 or S5. We currently don't have fans
for a charging system (i.e. a battery or a charger chip).
Battery management systems control charge current based on its own
temperature readings. Thus, we do not need to keep fans running in S3/S5.
Even with a fan for a charging system, it's questionable to run a fan in
S3/S5. Under a heated condition, spinning a fan would create more heat
as a fan draws current from a battery and the ambient air is hot.
With this patch, EC disables fan control when entering S3/S5 (though fan
control would be already disabled if DPTF is used). It also makes EC
enables fan control when AP starts (for BIOS and OS if DPTF isn't used).
Signee-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=none
BRANCH=none
TEST=Verify fan spins in S0 and stops in S3/S5. Fan is controled by EC
in BIOS and by DPTF in OS after warm and cold reboot.
Run make run-fan.
Change-Id: Idb4610303e65f7fd4d6b24a0dfe511cd629bf6a7
Reviewed-on: https://chromium-review.googlesource.com/1138822
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'common/fan.c')
-rw-r--r-- | common/fan.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/common/fan.c b/common/fan.c index 29c7d508a9..46233da715 100644 --- a/common/fan.c +++ b/common/fan.c @@ -83,7 +83,7 @@ static void set_enabled(int fan, int enable) gpio_set_level(fans[fan].conf->enable_gpio, enable); } -static void set_thermal_control_enabled(int fan, int enable) +test_export_static void set_thermal_control_enabled(int fan, int enable) { thermal_control_enabled[fan] = enable; @@ -454,9 +454,6 @@ static void pwm_fan_init(void) CONFIG_FAN_INIT_SPEED)); } - for (fan = 0; fan < CONFIG_FANS; fan++) - set_thermal_control_enabled(fan, 1); - /* Initialize memory-mapped data */ mapped = (uint16_t *)host_get_memmap(EC_MEMMAP_FAN); for (i = 0; i < EC_FAN_SPEED_ENTRIES; i++) @@ -522,21 +519,40 @@ static void pwm_fan_resume(void) } DECLARE_HOOK(HOOK_CHIPSET_RESUME, pwm_fan_resume, HOOK_PRIO_DEFAULT); -static void pwm_fan_S3_S5(void) +static void pwm_fan_startup(void) +{ + int fan; + /* Turn on fan control when the processor boots up (for BIOS screens) */ + for (fan = 0; fan < CONFIG_FANS; fan++) + set_thermal_control_enabled(fan, 1); +} +/* We need to cover cold boot and warm boot. */ +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, pwm_fan_startup, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_RESET, pwm_fan_startup, HOOK_PRIO_FIRST); + +static void pwm_fan_s3_s5(void) { int fan; /* TODO(crosbug.com/p/23530): Still treating all fans as one. */ for (fan = 0; fan < CONFIG_FANS; fan++) { - /* Take back fan control when the processor shuts down */ - set_thermal_control_enabled(fan, 1); - /* For now don't do anything with it. We'll have to turn it on - * again if we need active cooling during heavy battery - * charging or something. + /* + * There is no need to cool CPU in S3 or S5. We currently don't + * have fans for battery or charger chip. Battery systems will + * control charge current based on its own temperature readings. + * Thus, we do not need to keep fans running in S3 or S5. + * + * Even with a fan on charging system, it's questionable to run + * a fan in S3/S5. Under an extreme heat condition, spinning a + * fan would create more heat as it draws current from a + * battery and heat would come from ambient air instead of CPU. + * + * Thermal control may be already disabled if DPTF is used. */ + set_thermal_control_enabled(fan, 0); fan_set_rpm_target(FAN_CH(fan), 0); set_enabled(fan, 0); /* crosbug.com/p/8097 */ } } -DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, pwm_fan_S3_S5, HOOK_PRIO_DEFAULT); -DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, pwm_fan_S3_S5, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, pwm_fan_s3_s5, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, pwm_fan_s3_s5, HOOK_PRIO_DEFAULT); |