summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2021-01-19 08:45:21 -0700
committerCommit Bot <commit-bot@chromium.org>2021-02-01 19:27:06 +0000
commit4344a16290c13b0ddbab4656774a86058ea7ee48 (patch)
tree2a6da11d23350ee321bfdf48c2e178ad584cc7b9
parenta1f362d31471bd5cd3cde71617445587a46267ce (diff)
downloadchrome-ec-4344a16290c13b0ddbab4656774a86058ea7ee48.tar.gz
volteer: stub in fan for Zephyr
Enable the PWM channel used for the cooling fan. This change forces the fan speed to 50% to provide active cooling until temperature sensors and a Zephyr fan API are available. BUG=b:174851463 BRANCH=none TEST=make buildall, zmake testall TEST=Load zephyr on Volteer, verify fan turns on when the AP is powered. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: Iaad82e4c83ccfcda3d4cc33be6fcd550930c4caa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2637995 Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/projects/volteer/CMakeLists.txt5
-rw-r--r--zephyr/projects/volteer/boards/arm/volteer/volteer.dts10
-rw-r--r--zephyr/projects/volteer/include/gpio_map.h3
-rw-r--r--zephyr/projects/volteer/include/pwm_map.h2
-rw-r--r--zephyr/projects/volteer/src/fan.c30
5 files changed, 50 insertions, 0 deletions
diff --git a/zephyr/projects/volteer/CMakeLists.txt b/zephyr/projects/volteer/CMakeLists.txt
index 21a941ac0b..47c3d1def9 100644
--- a/zephyr/projects/volteer/CMakeLists.txt
+++ b/zephyr/projects/volteer/CMakeLists.txt
@@ -54,3 +54,8 @@ zephyr_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
"${PLATFORM_EC_BOARD}/led.c")
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USBC
"${PLATFORM_EC_BOARD}/usbc_config.c")
+
+# TODO: b/177854276, b/174851465
+# Fan stub requires on PWM support. Remove once full fan support
+# is available.
+zephyr_sources_ifdef(CONFIG_PLATFORM_EC_PWM "src/fan.c")
diff --git a/zephyr/projects/volteer/boards/arm/volteer/volteer.dts b/zephyr/projects/volteer/boards/arm/volteer/volteer.dts
index 24b3610d95..c02bb8ff2f 100644
--- a/zephyr/projects/volteer/boards/arm/volteer/volteer.dts
+++ b/zephyr/projects/volteer/boards/arm/volteer/volteer.dts
@@ -85,6 +85,11 @@
label = "KBLIGHT";
frequency = <2400>;
};
+ fan {
+ pwms = <&pwm5 0 0>;
+ label = "FAN";
+ frequency = <25000>;
+ };
};
named-gpios {
@@ -518,6 +523,11 @@
status = "okay";
};
+/* Fan control */
+&pwm5 {
+ status = "okay";
+};
+
/* Side selection LED */
&pwm7 {
status = "okay";
diff --git a/zephyr/projects/volteer/include/gpio_map.h b/zephyr/projects/volteer/include/gpio_map.h
index 77b8f10e3b..cc0afe5040 100644
--- a/zephyr/projects/volteer/include/gpio_map.h
+++ b/zephyr/projects/volteer/include/gpio_map.h
@@ -69,6 +69,9 @@
#define GPIO_USB_C1_RT_RST_ODL \
NAMED_GPIO_NODELABEL(usb_c1_bb_retimer, reset_gpios)
+/* Fan control */
+#define GPIO_EN_PP5000_FAN NAMED_GPIO(en_pp5000_fan)
+
/* Don't have a load switch for retimer */
/* TODO(b/176559881): How to do unimplemented GPIOs? */
#define GPIO_USB_C1_LS_EN \
diff --git a/zephyr/projects/volteer/include/pwm_map.h b/zephyr/projects/volteer/include/pwm_map.h
index c15b820a86..2616bad589 100644
--- a/zephyr/projects/volteer/include/pwm_map.h
+++ b/zephyr/projects/volteer/include/pwm_map.h
@@ -23,4 +23,6 @@
#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
+#define PWM_CH_FAN NAMED_PWM(fan)
+
#endif /* __ZEPHYR_CHROME_PWM_MAP_H */
diff --git a/zephyr/projects/volteer/src/fan.c b/zephyr/projects/volteer/src/fan.c
new file mode 100644
index 0000000000..5e683f1f2b
--- /dev/null
+++ b/zephyr/projects/volteer/src/fan.c
@@ -0,0 +1,30 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Temporary fan stub for Zephyr running on Volteer.
+ * TODO: b/177854276, b/174851465
+ * Remove once temperature sensor and a Zephyr fan API are available.
+ */
+
+#include "common.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "pwm.h"
+
+static void board_fan_chipset_startup(void)
+{
+ gpio_set_level(GPIO_EN_PP5000_FAN, 1);
+ pwm_enable(PWM_CH_FAN, 1);
+ pwm_set_duty(PWM_CH_FAN, 50);
+}
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_fan_chipset_startup,
+ HOOK_PRIO_DEFAULT);
+
+static void board_fan_chipset_shutdown(void)
+{
+ gpio_set_level(GPIO_EN_PP5000_FAN, 0);
+ pwm_enable(PWM_CH_FAN, 0);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_fan_chipset_shutdown,
+ HOOK_PRIO_DEFAULT);