summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2018-07-16 12:22:54 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2018-11-20 19:01:07 +0000
commita46aa68b290160b712cefc8d24cec3b5e1156976 (patch)
tree3fb553a5a46b7d8932911f5cbccd6a939c848cf2
parente54a1a2d6be3d462e71314b8977d7861bcc02706 (diff)
downloadchrome-ec-a46aa68b290160b712cefc8d24cec3b5e1156976.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> Reviewed-on: https://chromium-review.googlesource.com/c/1344571 Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r--common/fan.c40
-rw-r--r--test/fan.c4
2 files changed, 32 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);
diff --git a/test/fan.c b/test/fan.c
index 6082de1553..c5e4c32fd8 100644
--- a/test/fan.c
+++ b/test/fan.c
@@ -22,6 +22,8 @@
/*****************************************************************************/
/* Tests */
+void set_thermal_control_enabled(int fan, int enable);
+
static int test_fan(void)
{
/* "actual" fan speed from board/host/fan.c */
@@ -32,6 +34,8 @@ static int test_fan(void)
/* With nothing else to do, fans default to full-on */
TEST_ASSERT(fan_get_rpm_actual(0) == FAN_RPM(0)->rpm_max);
+ set_thermal_control_enabled(0, 1);
+
/*
* fan_set_percent_needed() is normally called once a second by the
* thermal task, but we're not using a thermal test in this test so