From f8e9a694f200f56ce7cb840184fa271b114ce32c Mon Sep 17 00:00:00 2001 From: Mary Ruthven Date: Fri, 3 Mar 2017 13:25:32 -0800 Subject: [PATCH] cr50: enable utmi wakeups We had disabled wakeups on the AP phy when we were running on gru, because the AP phy was not in use. We never changed that for reef, so UTMI wakeups were disabled even when the AP USB was supposed to be enabled. After Cr50 went to sleep any usb transactions would drop bits, because Cr50 wouldn't notice anything was happening until it woke up on one of the HOOK_TICK events. This change reenables UTMI wakeups on boards with AP usb. It writes 1 to USB_PCGCCTL_STOPCLK. This makes the controller disable the PHY clock whenever it detects a usb suspend. When it resumes out of suspend, this bit has no effect. BUG=b:35774906 BRANCH=cr50 TEST=Boot up reef. Wait until cr50 goes to sleep run 'usb_updater -f' and verify that it runs successfully. Make sure deep sleep still works Change-Id: I54bd866111b5c9b5738575f23757e0cbe4907ec4 Signed-off-by: Mary Ruthven Reviewed-on: https://chromium-review.googlesource.com/448988 Reviewed-by: Aseda Aboagye Reviewed-by: Vadim Bendebury --- board/cr50/rdd.c | 2 +- chip/g/idle.c | 2 +- chip/g/usb.c | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/board/cr50/rdd.c b/board/cr50/rdd.c index da93b1c401..993ccfc167 100644 --- a/board/cr50/rdd.c +++ b/board/cr50/rdd.c @@ -138,7 +138,7 @@ void rdd_detached(void) /* Done with case-closed debug mode */ gpio_set_level(GPIO_CCD_MODE_L, 1); - enable_usb_wakeup = 0; + enable_usb_wakeup = board_has_ap_usb(); ec_uart_enabled = 0; /* Disable CCD */ diff --git a/chip/g/idle.c b/chip/g/idle.c index cdc31ff810..3544948b5f 100644 --- a/chip/g/idle.c +++ b/chip/g/idle.c @@ -94,7 +94,7 @@ static void prepare_to_sleep(void) /* Wake on RBOX interrupts */ GREG32(RBOX, WAKEUP) = GC_RBOX_WAKEUP_ENABLE_MASK; - if (utmi_wakeup_is_enabled()) + if (utmi_wakeup_is_enabled() && idle_action != IDLE_DEEP_SLEEP) GR_PMU_EXITPD_MASK |= GC_PMU_EXITPD_MASK_UTMI_SUSPEND_N_MASK; diff --git a/chip/g/usb.c b/chip/g/usb.c index 901a959e92..1f9ee07ca1 100644 --- a/chip/g/usb.c +++ b/chip/g/usb.c @@ -1261,6 +1261,9 @@ void usb_init(void) GR_USB_DIEPMSK = 0; GR_USB_DOEPMSK = 0; + /* Disable the PHY clock whenever usb suspend is detected */ + GWRITE_FIELD(USB, PCGCCTL, STOPPCLK, 1); + /* Select the correct PHY */ usb_select_phy(which_phy);