diff options
-rw-r--r-- | zephyr/program/corsola/voltorb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | zephyr/program/corsola/voltorb/project.conf | 3 | ||||
-rw-r--r-- | zephyr/program/corsola/voltorb/src/board.c | 41 |
3 files changed, 45 insertions, 0 deletions
diff --git a/zephyr/program/corsola/voltorb/CMakeLists.txt b/zephyr/program/corsola/voltorb/CMakeLists.txt index bcd3e753c1..82fa262bda 100644 --- a/zephyr/program/corsola/voltorb/CMakeLists.txt +++ b/zephyr/program/corsola/voltorb/CMakeLists.txt @@ -9,3 +9,4 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "../src/npcx_usb_pd_policy.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "../src/npcx_usbc.c" "./src/usbc.c") +zephyr_library_sources("src/board.c") diff --git a/zephyr/program/corsola/voltorb/project.conf b/zephyr/program/corsola/voltorb/project.conf index 5343c7f524..53e619098a 100644 --- a/zephyr/program/corsola/voltorb/project.conf +++ b/zephyr/program/corsola/voltorb/project.conf @@ -38,3 +38,6 @@ CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 # AC_OK debounce time CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800 + +# Battery config +CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=15000 diff --git a/zephyr/program/corsola/voltorb/src/board.c b/zephyr/program/corsola/voltorb/src/board.c new file mode 100644 index 0000000000..d1d7f0350e --- /dev/null +++ b/zephyr/program/corsola/voltorb/src/board.c @@ -0,0 +1,41 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charge_state.h" +#include "common.h" +#include "dps.h" +#include "math_util.h" + +#include <zephyr/logging/log.h> + +#include <dt-bindings/battery.h> + +LOG_MODULE_REGISTER(board_init, LOG_LEVEL_ERR); + +bool voltorb_is_more_efficient(int curr_mv, int prev_mv, int batt_mv, + int batt_mw, int input_mw) +{ + int batt_state; + + battery_status(&batt_state); + + /* Choose 15V PDO or higher when battery is full. */ + if ((batt_state & SB_STATUS_FULLY_CHARGED) && (curr_mv >= 15000) && + (prev_mv < 15000 || curr_mv <= prev_mv)) { + return true; + } else { + return ABS(curr_mv - batt_mv) < ABS(prev_mv - batt_mv); + } +} + +__override struct dps_config_t dps_config = { + .k_less_pwr = 93, + .k_more_pwr = 96, + .k_sample = 1, + .k_window = 3, + .t_stable = 10 * SECOND, + .t_check = 5 * SECOND, + .is_more_efficient = &voltorb_is_more_efficient, +}; |