diff options
author | Ting Shen <phoenixshen@google.com> | 2020-10-14 18:29:17 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-19 09:30:24 +0000 |
commit | 3b22d002ef2cc59b32f6ce629d67831402de6600 (patch) | |
tree | c17c246ebbb88df110f20d4dcc611af7def20dea | |
parent | 854d5dc5b930ed56d56806d9acdc1b3df9e6a713 (diff) | |
download | chrome-ec-3b22d002ef2cc59b32f6ce629d67831402de6600.tar.gz |
Reland: asurada: set input voltage to 9V when S5 with full battery
(This relands CL:2470378 with an additional system unlocked check,
original message below)
The data in b:162467514#comment3 shows that 9V input has lowest
power consumption in S5.
This CL forces PD to select 9V when S5 with full battery.
BUG=b:162467514
TEST=Verify dut chooses 9V when in S5 and battery full, and
chooses 15V in other states.
TEST=pass firmware_PDVbusRequest.shutdown
BRANCH=none
Change-Id: I8de113ccd40fc76aee2e4e4026ef213ec542cf3a
Signed-off-by: Ting Shen <phoenixshen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2705453
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r-- | board/asurada/battery.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/board/asurada/battery.c b/board/asurada/battery.c index f8fc47034f..570d263c4a 100644 --- a/board/asurada/battery.c +++ b/board/asurada/battery.c @@ -5,7 +5,13 @@ #include "battery.h" #include "battery_fuel_gauge.h" +#include "battery_smart.h" +#include "charge_manager.h" +#include "chipset.h" #include "gpio.h" +#include "hooks.h" +#include "system.h" +#include "usb_pd.h" const struct board_batt_params board_battery_info[] = { [BATTERY_C235] = { @@ -39,3 +45,31 @@ const struct board_batt_params board_battery_info[] = { BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_C235; + +static void reduce_input_voltage_when_full(void) +{ + struct batt_params batt; + int max_pd_voltage_mv; + int active_chg_port; + + if (!system_is_locked()) + return; + + active_chg_port = charge_manager_get_active_charge_port(); + if (active_chg_port == CHARGE_PORT_NONE) + return; + + battery_get_params(&batt); + /* Lower our input voltage to 9V when battery is full. */ + if (!(batt.flags & BATT_FLAG_BAD_STATUS) && + (batt.status & STATUS_FULLY_CHARGED) && + chipset_in_state(CHIPSET_STATE_ANY_OFF)) + max_pd_voltage_mv = 9000; + else + max_pd_voltage_mv = PD_MAX_VOLTAGE_MV; + + if (pd_get_max_voltage() != max_pd_voltage_mv) + pd_set_external_voltage_limit(active_chg_port, + max_pd_voltage_mv); +} +DECLARE_HOOK(HOOK_SECOND, reduce_input_voltage_when_full, HOOK_PRIO_DEFAULT); |