diff options
author | Jett Rink <jettrink@chromium.org> | 2019-01-11 07:22:24 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-01-17 20:20:48 -0800 |
commit | a1bb29e2dfc756e3a9d01956dabf9bfa9030299d (patch) | |
tree | cc169c580d83d8ff6d55d171f367e11517e6f68e | |
parent | 948c320a35f3f5a1942bd33a93a3f4233ef19008 (diff) | |
download | chrome-ec-a1bb29e2dfc756e3a9d01956dabf9bfa9030299d.tar.gz |
apel: lower input voltage to 5V when battery full
For ERP compliance, we want to ensure that we are using the least amount
of power when the device is in S5 and plugged into AC power.
BRANCH=octopus
BUG=b:113830171
TEST=passes ERP
Change-Id: I91f44de96bdab86edabc5031cb92eaa70b9a39b3
Signed-off-by: Jett Rink <jettrink@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1406852
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Karthikeyan Ramasubramanian <kramasub@chromium.org>
-rw-r--r-- | board/ampton/battery.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/board/ampton/battery.c b/board/ampton/battery.c index adb88f1f1b..9289792d46 100644 --- a/board/ampton/battery.c +++ b/board/ampton/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 ampton/apel battery types. Note that the fields @@ -90,3 +93,26 @@ 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_C214; + +/* 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); |