summaryrefslogtreecommitdiff
path: root/board/brya/fans.c
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2021-02-25 18:30:33 -0800
committerCommit Bot <commit-bot@chromium.org>2021-03-04 21:31:32 +0000
commit503826bfe1ae70ca020b35ca32848da85f25b1ef (patch)
treedcb18d8497cab8a1aa34145ae13a31f205581975 /board/brya/fans.c
parent92a4dfc5fcb5600a3299e390269939d733afdd6c (diff)
downloadchrome-ec-503826bfe1ae70ca020b35ca32848da85f25b1ef.tar.gz
brya: Use fixed fan speeds
This sets the fan speed based on SoC power state. If the AP is off, run the fan at 33%. If the AP is on, run the fan at 100%. Our sensors are not yet calibrated and we don't have confirmed thermal thresholds for the SoC, so just keep the fan running at full speed when the AP is running. BRANCH=none BUG=b:179975706,b:180681346,b:181271666 TEST=fan is slow before AP boots, then speeds up as soon as AP starts Change-Id: Id10e1510496d94bd3cc8ea70e4661c52d15fe9ed Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2722552 Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Sooraj Govindan <sooraj.govindan@intel.com>
Diffstat (limited to 'board/brya/fans.c')
-rw-r--r--board/brya/fans.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/board/brya/fans.c b/board/brya/fans.c
index 9a7b7f8199..1427499e79 100644
--- a/board/brya/fans.c
+++ b/board/brya/fans.c
@@ -6,9 +6,12 @@
/* Physical fans. These are logically separate from pwm_channels. */
#include "common.h"
-
-#include "fan.h"
+#include "console.h"
#include "fan_chip.h"
+#include "fan.h"
+#include "hooks.h"
+#include "pwm_chip.h"
+#include "pwm.h"
/* MFT channels. These are logically separate from pwm_channels. */
const struct mft_t mft_channels[] = {
@@ -45,3 +48,41 @@ const struct fan_t fans[FAN_CH_COUNT] = {
.rpm = &fan_rpm_0,
},
};
+
+#ifndef CONFIG_FANS
+
+/*
+ * TODO(b/181271666): use static fan speeds until fan and sensors are
+ * tuned. for now, use:
+ *
+ * AP off: 33%
+ * AP on: 100%
+ */
+
+static void fan_slow(void)
+{
+ const int duty_pct = 33;
+
+ ccprints("%s: speed %d%%", __func__, duty_pct);
+
+ pwm_enable(PWM_CH_FAN, 1);
+ pwm_set_duty(PWM_CH_FAN, duty_pct);
+}
+
+static void fan_max(void)
+{
+ const int duty_pct = 100;
+
+ ccprints("%s: speed %d%%", __func__, duty_pct);
+
+ pwm_enable(PWM_CH_FAN, 1);
+ pwm_set_duty(PWM_CH_FAN, duty_pct);
+}
+
+DECLARE_HOOK(HOOK_INIT, fan_slow, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, fan_slow, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, fan_slow, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_RESET, fan_max, HOOK_PRIO_FIRST);
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, fan_max, HOOK_PRIO_DEFAULT);
+
+#endif /* CONFIG_FANS */