summaryrefslogtreecommitdiff
path: root/board/scarlet
diff options
context:
space:
mode:
authorPhilip Chen <philipchen@google.com>2018-03-29 20:23:20 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-03-31 01:56:32 -0700
commitf319a80975afe6f34286c9cbf115b815fa8c6416 (patch)
treecaf30de005ba8d32c7b109b82d423c6c7620b65b /board/scarlet
parent1a3851353892f7e26182e224a3a298e8f46dfa04 (diff)
downloadchrome-ec-f319a80975afe6f34286c9cbf115b815fa8c6416.tar.gz
scarlet: Enable charge termination only when battery is present
If we enable charge termination when booting w/o battery, charge termination would trigger and cut the power for max17055. BUG=b:72697658 BRANCH=scarlet TEST=Read rt946x reg 0x02, confirm charge termination is disabled when booting w/o battery, and enabled otherwise. Change-Id: I5780196ad993299ddfb37621bee5e941aa9b0d14 Signed-off-by: Philip Chen <philipchen@google.com> Reviewed-on: https://chromium-review.googlesource.com/989314 Commit-Ready: Philip Chen <philipchen@chromium.org> Tested-by: Philip Chen <philipchen@chromium.org> Reviewed-by: Philip Chen <philipchen@chromium.org>
Diffstat (limited to 'board/scarlet')
-rw-r--r--board/scarlet/battery.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/board/scarlet/battery.c b/board/scarlet/battery.c
index d84e8c1d6c..bc3ec6e84c 100644
--- a/board/scarlet/battery.c
+++ b/board/scarlet/battery.c
@@ -14,6 +14,7 @@
#include "ec_commands.h"
#include "extpower.h"
#include "gpio.h"
+#include "hooks.h"
#include "util.h"
/*
@@ -244,6 +245,19 @@ int charger_profile_override(struct charge_state_data *curr)
return 0;
}
+static void board_charge_termination(void)
+{
+ static uint8_t te;
+ /* Enable charge termination when we are sure battery is present. */
+ if (!te && battery_is_present() == BP_YES) {
+ if (!rt946x_enable_charge_termination(1))
+ te = 1;
+ }
+}
+DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE,
+ board_charge_termination,
+ HOOK_PRIO_DEFAULT);
+
/* Customs options controllable by host command. */
#define PARAM_FASTCHARGE (CS_PARAM_CUSTOM_PROFILE_MIN + 0)