summaryrefslogtreecommitdiff
path: root/include/usb_api.h
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@google.com>2017-04-25 11:58:18 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-05-02 20:24:17 -0700
commit520bd3f6ad2098e6969dd353350e2e2281f28989 (patch)
tree3df6052d988c8024b2c31904c534d29f3e3e108e /include/usb_api.h
parentc388d3e27877c1e3b1b2f078cd320d604509087d (diff)
downloadchrome-ec-520bd3f6ad2098e6969dd353350e2e2281f28989.tar.gz
chip/stm32/usb: More reliable implementation of usb_wake
Current usb_wake was sleeping between setting and clearing RESUME bit, which is unprecise. Instead, we count ESOF interrupts in usb_interrupt to detect when to clear RESUME. It is also important that usb_wake does not block, as the calling task (e.g. keyboard scanning) must continue to service events while the USB device is resuming. BRANCH=none BUG=b:35587173 TEST=Connect hammer, force autosuspend using: DEVICE=$(dirname $(grep 5022 /sys/bus/usb/devices/*/idProduct)) echo 500 > $DEVICE/power/autosuspend_delay_ms echo auto > $DEVICE/power/control Wait a second, type something quickly, verify that no keys are lost. Change-Id: I53b46cce5a4adb0ee4c4a7e9f935c00f7f321636 Reviewed-on: https://chromium-review.googlesource.com/490129 Commit-Ready: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include/usb_api.h')
-rw-r--r--include/usb_api.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/usb_api.h b/include/usb_api.h
index a251b3f857..c6a949ab61 100644
--- a/include/usb_api.h
+++ b/include/usb_api.h
@@ -43,10 +43,16 @@ void usb_disconnect(void);
void usb_release(void);
/*
+ * Returns true if USB device is currently suspended.
+ * Requires CONFIG_USB_SUSPEND to be defined.
+ */
+int usb_is_suspended(void);
+
+/*
* Tell the host to wake up. Requires CONFIG_USB_REMOTE_WAKEUP to be defined,
* and a chip that implements the function.
*
- * This function sleeps, so it must not be used in interrupt context.
+ * Returns immediately, suspend status can be checked using usb_is_suspended.
*/
void usb_wake(void);