summaryrefslogtreecommitdiff
path: root/zephyr/projects/nissa/pujjo/src/fan.c
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2022-07-19 15:42:17 +1000
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-20 02:38:03 +0000
commit0dea801e9a72f4eb7b34dded8aeca80bda584fd0 (patch)
tree25f81d8b37b780d3b3b64d4ee0626e2c96905a66 /zephyr/projects/nissa/pujjo/src/fan.c
parentfba0a2092ae80395754ebb2a310024ce2e2eaaf5 (diff)
downloadchrome-ec-0dea801e9a72f4eb7b34dded8aeca80bda584fd0.tar.gz
nissa: Rearrange projects into sub-directories
Rearrange the projects into separate sub-directories to improve clarity and separation. BUG=none TEST=zmake testall BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I14c3324760d195807f831bd72bdbc129fe76912b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3771363 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Diffstat (limited to 'zephyr/projects/nissa/pujjo/src/fan.c')
-rw-r--r--zephyr/projects/nissa/pujjo/src/fan.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/zephyr/projects/nissa/pujjo/src/fan.c b/zephyr/projects/nissa/pujjo/src/fan.c
new file mode 100644
index 0000000000..1884380de8
--- /dev/null
+++ b/zephyr/projects/nissa/pujjo/src/fan.c
@@ -0,0 +1,43 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+
+#include "nissa_common.h"
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/*
+ * Pujjo fan support
+ */
+static void fan_init(void)
+{
+ int ret;
+ uint32_t val;
+ /*
+ * Retrieve the fan config.
+ */
+ ret = cros_cbi_get_fw_config(FW_FAN, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN);
+ return;
+ }
+ if (val != FW_FAN_PRESENT) {
+ /* Disable the fan */
+ fan_set_count(0);
+ } else {
+ /* Configure the fan enable GPIO */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_fan_enable),
+ GPIO_OUTPUT);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST);