diff options
author | Randall Spangler <rspangler@chromium.org> | 2017-08-15 18:41:55 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-18 14:27:19 -0700 |
commit | 9ca5e791cc817b665b0a1bd20155c63649a31b99 (patch) | |
tree | 7274fabcaba06f4e2a002420e0562776a2a9ac08 /board | |
parent | d2108bbcaa19260582d2cf6f2b5a19dd6a553c39 (diff) | |
download | chrome-ec-9ca5e791cc817b665b0a1bd20155c63649a31b99.tar.gz |
cr50: Wake on AC detect edges
Currently, we only use the AC detect interrupt for battery cutoff
support on detachable devices, and we use the RDD detect interrupt for
waking Cr50 from deep sleep. However, Eve accidentally detects RDD
when the EC is off, so this is not a reliable signal - particularly if
Cr50 is explicitly driving EC reset.
Enable the AC detect interrupt all the time, and defer sleep for 5
seconds when it transitions. This will have a negligible effect on
overall power (since AC is not normally transitioning) and will allow
the RDD detect code to be simplified.
BUG=b:64799106
BRANCH=cr50
TEST=manually pull DIOR5 up and down; see AC interrupt debug output.
idle d, wait for sleep, then wiggle DIOR5 and see that cr50 wakes.
Change-Id: I7551f25e27a79573bf4527d8c38994634df621ec
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/619319
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board')
-rw-r--r-- | board/cr50/board.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c index ecf9eebfc7..c70fbd5268 100644 --- a/board/cr50/board.c +++ b/board/cr50/board.c @@ -288,7 +288,8 @@ enum { /* * ISR reacting to both falling and raising edges of the AC_PRESENT signal. - * Falling edge indicates pulling out of the charger cable and vice versa. + * Falling edge indicates AC no longer present (removal of the charger cable) + * and rising edge indicates AP present (insertion of charger cable). */ static void ac_power_state_changed(void) { @@ -298,7 +299,16 @@ static void ac_power_state_changed(void) req = GREG32(RBOX, INT_STATE) & (ac_pres_red | ac_pres_fed); GREG32(RBOX, INT_STATE) = req; - CPRINTS("%s: status 0x%x", __func__, req); + CPRINTS("AC: %c%c", + req & ac_pres_red ? 'R' : '-', + req & ac_pres_fed ? 'F' : '-'); + + /* Delay sleep so RDD state machines can stabilize */ + delay_sleep_by(5 * SECOND); + + /* The remaining code is only used for battery cutoff */ + if (!system_battery_cutoff_support_required()) + return; /* Raising edge gets priority, stop timeout timer and go. */ if (req & ac_pres_red) { @@ -324,7 +334,7 @@ DECLARE_IRQ(GC_IRQNUM_RBOX0_INTR_AC_PRESENT_RED_INT, ac_power_state_changed, 1); DECLARE_IRQ(GC_IRQNUM_RBOX0_INTR_AC_PRESENT_FED_INT, ac_power_state_changed, 1); /* Enable interrupts on plugging in and yanking out of the charger cable. */ -static void set_up_battery_cutoff_monitor(void) +static void init_ac_detect(void) { /* It is set in idle.c also. */ GWRITE_FIELD(RBOX, WAKEUP, ENABLE, 1); @@ -693,9 +703,12 @@ static void board_init(void) check_board_id_mismatch(); check_board_id_mismatch(); - /* Enable battery cutoff software support on detachable devices. */ - if (system_battery_cutoff_support_required()) - set_up_battery_cutoff_monitor(); + /* + * Start monitoring AC detect to wake Cr50 from deep sleep. This is + * needed to detect RDD cable changes in deep sleep. AC detect is also + * used for battery cutoff software support on detachable devices. + */ + init_ac_detect(); /* * The interrupt is enabled by default, but we only want it enabled when |