diff options
author | Edward Hill <ecgh@chromium.org> | 2019-01-08 11:21:12 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2019-01-29 15:47:53 +0000 |
commit | b2cc4c961bf34f3ae15c320029c384e1bdbc4511 (patch) | |
tree | cd51facc580aac5413e799bb52cfc125f0dcd299 /board | |
parent | 97acbbcdd598ef1de4b93a3a520b2a2d18205df8 (diff) | |
download | chrome-ec-b2cc4c961bf34f3ae15c320029c384e1bdbc4511.tar.gz |
liara: Reduce input voltage to 5V when battery full
To reduce power consumption, reduce USB-C PD input voltage to 5V
when the battery is full and the system is off (S5/G3).
BUG=b:121383620
BRANCH=grunt
TEST=battery 90%: chgsup shows 15V or 20V,
when battery full: chgsup shows 5V,
power on AP: chgsup shows 15V or 20V
Change-Id: I377bc02ca5ec352619b05ef619c7a9e184f547cb
Signed-off-by: Edward Hill <ecgh@chromium.org>
Previous-Reviewed-on: https://chromium-review.googlesource.com/1401018
(cherry picked from commit 0800a84aff4ba8275b62b6aa09de2f946546f1ff)
Reviewed-on: https://chromium-review.googlesource.com/c/1443271
Diffstat (limited to 'board')
-rw-r--r-- | board/liara/battery.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/board/liara/battery.c b/board/liara/battery.c index f3066949e6..b88b446473 100644 --- a/board/liara/battery.c +++ b/board/liara/battery.c @@ -6,8 +6,11 @@ */ #include "battery_fuel_gauge.h" +#include "charge_state.h" +#include "chipset.h" #include "common.h" -#include "util.h" +#include "hooks.h" +#include "usb_pd.h" /* * Battery info for all Liara battery types. Note that the fields @@ -162,3 +165,27 @@ 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_PANASONIC; + +/* Lower our input voltage to 5V in S5/G3 when battery is full. */ +static void reduce_input_voltage_when_full(void) +{ + int max_pd_voltage_mv; + int port; + + if (charge_get_percent() == 100 && + chipset_in_or_transitioning_to_state(CHIPSET_STATE_ANY_OFF)) + max_pd_voltage_mv = 5000; + else + max_pd_voltage_mv = PD_MAX_VOLTAGE_MV; + + if (pd_get_max_voltage() != max_pd_voltage_mv) { + for (port = 0; port < CONFIG_USB_PD_PORT_COUNT; port++) + pd_set_external_voltage_limit(port, max_pd_voltage_mv); + } +} +DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE, reduce_input_voltage_when_full, + HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_STARTUP, reduce_input_voltage_when_full, + HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, reduce_input_voltage_when_full, + HOOK_PRIO_DEFAULT); |