diff options
author | Moises Garcia <moisesgarcia@google.com> | 2022-07-12 17:47:35 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-20 21:25:03 +0000 |
commit | edddbb2066ea245f6b9c88b4090a98252a0b1ee5 (patch) | |
tree | 8015a7ac7176fcba7fd1942637d030cce86f04e4 | |
parent | ed64e30940355ebbc089b4f0b1cf0162a430e97a (diff) | |
download | chrome-ec-edddbb2066ea245f6b9c88b4090a98252a0b1ee5.tar.gz |
zephyr: Set fan count from fw_config fan flag
Currently, when there is no fan, EC reports fan stalled.
Read FW_CONFIG fan absent/present flag an set fan_count accordingly.
BRANCH=NONE
BUG=b:234765697
TEST=Tried the 4 different combinations in SKUA2
BOARD_VERSION >=3 && FW_CONFIG[10]=1 -> Fan is on
BOARD_VERSION >=3 && FW_CONFIG[10]=0 -> Fan is off
BOARD_VERSION <3 && FW_CONFIG[10]=1 -> Fan is on
BOARD_VERSION <3 && FW_CONFIG[10]=0 -> Fan is on
Change-Id: If4681c9f97c2a4a4c6b200bd1acccd89111f7abf
Signed-off-by: Moises Garcia <moisesgarcia@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3756743
Commit-Queue: Jonathon Murphy <jpmurphy@google.com>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Tested-by: Jonathon Murphy <jpmurphy@google.com>
Reviewed-by: Jonathon Murphy <jpmurphy@google.com>
-rw-r--r-- | zephyr/projects/skyrim/CMakeLists.txt | 2 | ||||
-rw-r--r-- | zephyr/projects/skyrim/fan.c | 46 | ||||
-rw-r--r-- | zephyr/projects/skyrim/skyrim.dts | 25 |
3 files changed, 73 insertions, 0 deletions
diff --git a/zephyr/projects/skyrim/CMakeLists.txt b/zephyr/projects/skyrim/CMakeLists.txt index b1573a81ab..79a1c72c94 100644 --- a/zephyr/projects/skyrim/CMakeLists.txt +++ b/zephyr/projects/skyrim/CMakeLists.txt @@ -21,3 +21,5 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_AMD_STT "stt.c") + +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "fan.c") diff --git a/zephyr/projects/skyrim/fan.c b/zephyr/projects/skyrim/fan.c new file mode 100644 index 0000000000..71896420da --- /dev/null +++ b/zephyr/projects/skyrim/fan.c @@ -0,0 +1,46 @@ +/* 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_board_info.h" +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Skyrim fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + uint32_t board_version; + /* + * 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; + } + + ret = cbi_get_board_version(&board_version); + if (ret != EC_SUCCESS) { + LOG_ERR("Error retrieving CBI board version"); + return; + } + + if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { + /* Disable the fan */ + fan_set_count(0); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/projects/skyrim/skyrim.dts b/zephyr/projects/skyrim/skyrim.dts index 51aebe8d1d..494b33b4eb 100644 --- a/zephyr/projects/skyrim/skyrim.dts +++ b/zephyr/projects/skyrim/skyrim.dts @@ -187,6 +187,31 @@ default; }; }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; }; /* Rotation matrices for motion sensors. */ |