summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2016-09-13 10:48:26 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-23 12:21:34 -0700
commit3831cef72810b3b4a3f64acb64ec8711198ccdfc (patch)
tree84b7b0ac0881b7a85443cef21dea787b8f3461ad
parent773c5db6d4253b651789dd11a2267b92fc9aaf83 (diff)
downloadchrome-ec-3831cef72810b3b4a3f64acb64ec8711198ccdfc.tar.gz
kevin: gru: Reset charger before initializing it.
The reset line to the charger IC isn't hooked up to the cold_reset circuitry. This commit makes the EC reset the charger at init time. BUG=chrome-os-partner:57524 BRANCH=gru TEST=Enable power save mode. Toggle cold reset. Verify that power save mode is still enabled. Flash kevin with this patch. Verify that power save mode is disabled. TEST=Enable power save mode, reboot, verify power save mode is disabled. TEST=Enter G3. Enter hibernate. Insert zinger and verify that EC wakes up. Repeat 20 times. TEST=Verify system powers successfully with no battery, and wakes successfully from battery cut-off. Change-Id: Ib1362aefc71056e7c2b212a4fbdd6f979c57e20f Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/384320 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--board/kevin/board.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/board/kevin/board.c b/board/kevin/board.c
index 53fc52c36f..4b71b5df76 100644
--- a/board/kevin/board.c
+++ b/board/kevin/board.c
@@ -321,6 +321,32 @@ DECLARE_HOOK(HOOK_CHIPSET_SUSPEND,
board_spi_disable,
MOTION_SENSE_HOOK_PRIO + 1);
+/*
+ * Reset our charger IC on power-on. This will briefly cut extpower to the
+ * system, so skip the reset if our battery can't provide sufficient charge
+ * to briefly power the system.
+ */
+static void board_reset_charger(void)
+{
+ int bat_pct = 0;
+
+ if (!system_jumped_to_this_image() &&
+ battery_is_present() == BP_YES &&
+ battery_get_disconnect_state() != BATTERY_DISCONNECTED) {
+ if (battery_state_of_charge_abs(&bat_pct) ||
+ bat_pct < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
+ return;
+ /* Reset the charger before we initialize it. */
+ gpio_set_level(GPIO_CHARGER_RESET_L, 0);
+ /* Reset detection is 100 us minimum. */
+ usleep(100);
+ gpio_set_level(GPIO_CHARGER_RESET_L, 1);
+ /* Allow time for the charger to reinitialize. */
+ usleep(120);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, board_reset_charger, HOOK_PRIO_INIT_EXTPOWER - 1);
+
static void board_init(void)
{
/* Enable TCPC alert interrupts */