summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2018-08-08 18:20:35 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-08-22 04:07:41 -0700
commit0feb2fc0d0a4f2aec948ac045c2d6d99f9c77a80 (patch)
tree48ab5a5c098ef6b22a27a4d8a6f994f265490f2d
parentf70528e53dfbdc1f33508d157b05c608934a660f (diff)
downloadchrome-ec-0feb2fc0d0a4f2aec948ac045c2d6d99f9c77a80.tar.gz
DragonEgg: Enable/disable battery learn mode based on AC
This CL is a software workaround for an issue with the bq25710 charger. There is an issue with the converter control loop not being biased correctly when it starts switching. This leads to a reverse current (from battery to charger). To avoid this issue, the switching converter is turned off when AC is not present, then only enalbed 200 msec after AC presence is detected. BUG=b:112372451 BRANCH=none TEST=Veried that reverse buck/boost not present with this CL and that charger still functions as expected. Change-Id: I4d3a975e3c0e24cdf7f13fdab69da32ccd70a428 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1168597 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org>
-rw-r--r--board/dragonegg/board.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/board/dragonegg/board.c b/board/dragonegg/board.c
index 162f596b38..e1ba7f4336 100644
--- a/board/dragonegg/board.c
+++ b/board/dragonegg/board.c
@@ -6,6 +6,7 @@
/* DragonEgg board-specific configuration */
#include "common.h"
+#include "charger.h"
#include "console.h"
#include "driver/ppc/sn5s330.h"
#include "extpower.h"
@@ -57,3 +58,45 @@ void board_overcurrent_event(int port)
cprints(CC_USBPD, "p%d: overcurrent!", port);
}
}
+
+static void board_disable_learn_mode(void)
+{
+ /* Disable learn mode after checking to make sure AC is still present */
+ if (extpower_is_present())
+ charger_discharge_on_ac(0);
+}
+DECLARE_DEFERRED(board_disable_learn_mode);
+
+static void board_extpower(void)
+{
+ /*
+ * For the bq25710 charger, we need the switching converter to remain
+ * disabled until ~130 msec from when VBUS present to allow the
+ * converter to be biased properly. Otherwise, there will be a reverse
+ * buck/boost until the converter is biased. The recommendation is to
+ * exit learn mode 200 msec after external charger is connected.
+ *
+ * TODO(b/112372451): When there are updated versions of the bq25710,
+ * this set of changes can be removed.
+ */
+ if (extpower_is_present()) {
+ hook_call_deferred(&board_disable_learn_mode_data, 200 * MSEC);
+ } else {
+ /* Enable charger learn mode */
+ charger_discharge_on_ac(1);
+ /* Cancel any pending call to disable learn mode */
+ hook_call_deferred(&board_disable_learn_mode_data, -1);
+ }
+}
+DECLARE_HOOK(HOOK_AC_CHANGE, board_extpower, HOOK_PRIO_DEFAULT);
+
+/* Initialize board. */
+static void board_init(void)
+{
+ /*
+ * On EC reboot, need to always set battery learn mode to the correct
+ * state based on presence of AC.
+ */
+ board_extpower();
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);