summaryrefslogtreecommitdiff
path: root/include/fan.h
diff options
context:
space:
mode:
authorDawid Niedzwiecki <dn@semihalf.com>2021-03-02 14:46:32 +0100
committerCommit Bot <commit-bot@chromium.org>2021-03-08 17:31:52 +0000
commitcfbbbb93b44799c61f5591b9658d650136ab5ac4 (patch)
tree40c0a2598c3c8b46f3fb187812d399e5fa3fc2a6 /include/fan.h
parent1a7ba0f3822829ad69d860ee41bb4ae756c4756d (diff)
downloadchrome-ec-cfbbbb93b44799c61f5591b9658d650136ab5ac4.tar.gz
zephyr: add shim fan
Add fan support to Zephyr. The fan is controlled with PWM and the fan speed is measured with the tachometer. Fan properties are defied in the dts file. The struct fan_t fans[] array and enum fan_channel are generated automatically according to named-fans node in the device tree. The implementation is based on the npxc driver, but it is platform-independent. It assumes that there are PWM channel to control the fan and the tachometer sensor to measure RPM (in RPM mode). If it is not the case in the future, the shim may be split per chip. Enable fan related console commands - fanduty, fanset, faninfo, fanauto and host commands - EC_CMD_PWM_GET_FAN_TARGET_RPM, EC_CMD_PWM_SET_FAN_TARGET_RPM, EC_CMD_PWM_SET_FAN_DUTY, EC_CMD_THERMAL_AUTO_FAN_CTRL. BUG=b:174851463 BRANCH=none TEST=build Zephyr TEST=Run "fanset"/"fanduty" commands and check with "faninfo" if the fan follows the command. Then run "fanauto" and verify that the fan controls the temperature correctly. Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com> Change-Id: I52255848e271fb5b204cd1eb8a797e2fbc81130d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2729375 Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'include/fan.h')
-rw-r--r--include/fan.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/fan.h b/include/fan.h
index fd49649547..bd92b97254 100644
--- a/include/fan.h
+++ b/include/fan.h
@@ -8,6 +8,23 @@
#ifndef __CROS_EC_FAN_H
#define __CROS_EC_FAN_H
+#ifdef CONFIG_ZEPHYR
+#ifdef CONFIG_PLATFORM_EC_FAN
+
+#include <devicetree.h>
+#define NODE_ID_AND_COMMA(node_id) node_id,
+enum fan_channel {
+#if DT_NODE_EXISTS(DT_INST(0, named_fans))
+ DT_FOREACH_CHILD(DT_INST(0, named_fans), NODE_ID_AND_COMMA)
+#endif /* named_fans */
+ FAN_CH_COUNT
+};
+
+#define CONFIG_FANS FAN_CH_COUNT
+
+#endif /* CONFIG_PLATFORM_EC_FAN */
+#endif /* CONFIG_ZEPHYR */
+
struct fan_conf {
unsigned int flags;
/* Hardware channel number (the meaning is chip-specific) */