summaryrefslogtreecommitdiff
path: root/board/dratini
diff options
context:
space:
mode:
authorDevin Lu <devin.lu@quantatw.com>2020-03-16 13:18:57 +0800
committerCommit Bot <commit-bot@chromium.org>2020-03-25 20:28:53 +0000
commitb70f61a519e67ef4f19d6f3dd0b9c9862b02eef1 (patch)
treefb2821532051e344a05f63796d5e0dfaa1dc8da7 /board/dratini
parent11b0f59e33b4683225232c1ee809e78a89cd782c (diff)
downloadchrome-ec-b70f61a519e67ef4f19d6f3dd0b9c9862b02eef1.tar.gz
dratini: Reduce input voltage to 5V when battery full
Apply CL:1401018 for dratini. 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:149890873 BRANCH=firmware-hatch-12672.B TEST=battery 90%: chgsup shows 15V or 20V, when battery full: chgsup shows 5V, power on AP: chgsup shows 15V or 20V Change-Id: Ifa013d8f696f69aeba587fa45c72413a42445728 Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2104813 Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Diffstat (limited to 'board/dratini')
-rw-r--r--board/dratini/battery.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/board/dratini/battery.c b/board/dratini/battery.c
index ee5db0f30c..dafd0c9425 100644
--- a/board/dratini/battery.c
+++ b/board/dratini/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 Dratini/Dragonair battery types. Note that the fields
@@ -93,3 +96,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_SIMPLO_COS;
+
+/* 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_MAX_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);