summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-11-20 12:43:46 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-21 22:55:39 +0000
commit613a2ec3e48dda8c119a71c6a5c5dc99f269c3a8 (patch)
treed341472862eff2d1a71bf9f6ceefdc58524d75db
parent7ac04ceac853508af1ac93b8829a7601c2a65f16 (diff)
downloadchrome-ec-613a2ec3e48dda8c119a71c6a5c5dc99f269c3a8.tar.gz
stm32: Do not wait for USB host if USB is disabled
For USB console, we wait for USB host to grab the data before writing the next chunk of characters. However, if the USB peripheral is disabled, the current implementation is confused as to whether the host has grabbed the previous chunk of data. Fix this by explicitly checking for USB peripheral enabled. BRANCH=ryu BUG=None TEST=Boot on Ryu and check console isn't slow. Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/231115 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> (cherry picked from commit b16bcb0eb08167c263aa8b53e23625e690331a7a) Change-Id: Ib5df1e8557b24c84d92e8b973ef51202b793db07 Reviewed-on: https://chromium-review.googlesource.com/231281 Tested-by: Vic Yang <victoryang@chromium.org> Commit-Queue: Vic Yang <victoryang@chromium.org> Reviewed-by: Vic Yang <victoryang@chromium.org>
-rw-r--r--chip/stm32/usb.c5
-rw-r--r--chip/stm32/usb_console.c3
-rw-r--r--include/usb_api.h3
3 files changed, 11 insertions, 0 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index a0a37524be..b4dfb31fb5 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -326,3 +326,8 @@ void usb_release(void)
/* disable USB device clock */
STM32_RCC_APB1ENR &= ~STM32_RCC_PB1_USB;
}
+
+int usb_is_enabled(void)
+{
+ return (STM32_RCC_APB1ENR & STM32_RCC_PB1_USB) ? 1 : 0;
+}
diff --git a/chip/stm32/usb_console.c b/chip/stm32/usb_console.c
index 6d81a5fa3c..665568a28a 100644
--- a/chip/stm32/usb_console.c
+++ b/chip/stm32/usb_console.c
@@ -146,6 +146,9 @@ static int usb_wait_console(void)
timestamp_t deadline = get_time();
int wait_time_us = 1;
+ if (!is_enabled || !usb_is_enabled())
+ return EC_SUCCESS;
+
deadline.val += USB_CONSOLE_TIMEOUT_US;
/*
diff --git a/include/usb_api.h b/include/usb_api.h
index dc0a0fd654..193c948fb6 100644
--- a/include/usb_api.h
+++ b/include/usb_api.h
@@ -21,6 +21,9 @@
*/
void usb_init(void);
+/* Check if USB peripheral is enabled. */
+int usb_is_enabled(void);
+
/*
* Enable the pullup on the DP line to signal that this device exists to the
* host and to start the enumeration process.