diff options
author | Mary Ruthven <mruthven@google.com> | 2018-07-24 16:59:57 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-07-25 16:35:07 -0700 |
commit | 5d09bd535504253593e05938cbddb092f7eb277a (patch) | |
tree | cbf29d43d751455be0c450a5f1351a3737d9a02a | |
parent | 88b8e085862c8ebc68ac62e08f49d0b6e41f13f9 (diff) | |
download | chrome-ec-5d09bd535504253593e05938cbddb092f7eb277a.tar.gz |
cr50: wait for RBOX_WAKEUP_INTR to be cleared
Wait for the interrupt status register to be cleared before clearing the
RBOX_WAKEUP_CLEAR bit.
BUG=b:111801707
BRANCH=cr50
TEST=shutdown the AP. Make sure cr50 doesn't wake up immediately after
entering deep sleep. Make sure RBOX wakeups still work.
Change-Id: I8f02e387f212a5071d9bad0bf977ab09fd053756
Signed-off-by: Mary Ruthven <mruthven@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1149320
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | board/cr50/board.c | 14 | ||||
-rw-r--r-- | chip/g/idle.c | 5 |
2 files changed, 14 insertions, 5 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c index f485506ab7..158b94b731 100644 --- a/board/cr50/board.c +++ b/board/cr50/board.c @@ -319,11 +319,25 @@ enum { static void ac_power_state_changed(void) { uint32_t req; + int i = 0; /* Get current status and clear it. */ req = GREG32(RBOX, INT_STATE) & (ac_pres_red | ac_pres_fed); GREG32(RBOX, INT_STATE) = req; + /* Clear the wakeup interrupt */ + GREG32(RBOX, WAKEUP) = GC_RBOX_WAKEUP_CLEAR_MASK; + /* + * Wait until the interrupt status register is cleared, since RBOX runs + * off of RTC instead of the core clock. Wait a max of 50 iterations. + * Experimentally, 15 iterations is usually sufficient. We don't want to + * wait here forever. + */ + while (GREAD(RBOX, WAKEUP_INTR) && i < 50) + i++; + /* Reenable rbox wakeup */ + GREG32(RBOX, WAKEUP) = GC_RBOX_WAKEUP_ENABLE_MASK; + CPRINTS("AC: %c%c", req & ac_pres_red ? 'R' : '-', req & ac_pres_fed ? 'F' : '-'); diff --git a/chip/g/idle.c b/chip/g/idle.c index dd745ec766..e0f82cb0ef 100644 --- a/chip/g/idle.c +++ b/chip/g/idle.c @@ -97,11 +97,6 @@ static void prepare_to_sleep(void) GC_PMU_EXITPD_MASK_TIMELS0_PD_EXIT_TIMER0_MASK | GC_PMU_EXITPD_MASK_TIMELS0_PD_EXIT_TIMER1_MASK; - /* Clear the RBOX wakeup signal and status bits */ - GREG32(RBOX, WAKEUP) = GC_RBOX_WAKEUP_CLEAR_MASK; - /* Wake on RBOX interrupts */ - GREG32(RBOX, WAKEUP) = GC_RBOX_WAKEUP_ENABLE_MASK; - if (utmi_wakeup_is_enabled() && idle_action != IDLE_DEEP_SLEEP) GR_PMU_EXITPD_MASK |= GC_PMU_EXITPD_MASK_UTMI_SUSPEND_N_MASK; |