diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2017-08-10 14:36:30 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-08-16 04:03:24 -0700 |
commit | 9e33d6ce3c6c0a8de24dd6afa71f2adc255a156b (patch) | |
tree | 081b226e96525148b389e76681e41b502edd5eb4 /chip/stm32/usb.c | |
parent | a1abf686c3174c6b18d20e8fc250cc4d5a045d97 (diff) | |
download | chrome-ec-9e33d6ce3c6c0a8de24dd6afa71f2adc255a156b.tar.gz |
chip/stm32/usb: Replace reset handler by generic event handler
Some USB interface handlers need to know when USB has been
successfully resumed after a wake event. For example, this is
useful so that HID keyboard can send the events at the right time.
BRANCH=none
BUG=b:35775048
TEST=Using USB HID keyboard patches to queue keys in a FIFO:
After USB autosuspends, press a single key and hold it. Without
this patch the endpoint data only gets reloaded on the _next_
event.
TEST=On hammer, I2C passthrough still works.
Change-Id: I9b52b9de16767c8a66c702a5ae70369334a3d590
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/569547
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/stm32/usb.c')
-rw-r--r-- | chip/stm32/usb.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c index fc6cda9ab5..26890cadff 100644 --- a/chip/stm32/usb.c +++ b/chip/stm32/usb.c @@ -292,8 +292,11 @@ error: STM32_TOGGLE_EP(0, EP_TX_MASK, EP_TX_VALID, 0); } -static void ep0_reset(void) +static void ep0_event(enum usb_ep_event evt) { + if (evt != USB_EVENT_RESET) + return; + STM32_USB_EP(0) = (1 << 9) /* control EP */ | (2 << 4) /* TX NAK */ | (3 << 12) /* RX VALID */; @@ -303,14 +306,14 @@ static void ep0_reset(void) btable_ep[0].rx_count = 0x8000 | ((USB_MAX_PACKET_SIZE/32-1) << 10); btable_ep[0].tx_count = 0; } -USB_DECLARE_EP(0, ep0_tx, ep0_rx, ep0_reset); +USB_DECLARE_EP(0, ep0_tx, ep0_rx, ep0_event); static void usb_reset(void) { int ep; for (ep = 0; ep < USB_EP_COUNT; ep++) - usb_ep_reset[ep](); + usb_ep_event[ep](USB_EVENT_RESET); /* * set the default address : 0 @@ -455,6 +458,8 @@ static void usb_interrupt_handle_wake(uint16_t status) /* Either: state is ready, or we timed out. */ if (good || state == 3 || esof_count <= -USB_RESUME_TIMEOUT_MS) { + int ep; + STM32_USB_CNTR &= ~(STM32_USB_CNTR_ESOFM | STM32_USB_CNTR_SOFM); usb_wake_done = 1; if (!good) { @@ -465,6 +470,9 @@ static void usb_interrupt_handle_wake(uint16_t status) } CPRINTF("RSMOK%d %d\n", -esof_count, state); + + for (ep = 1; ep < USB_EP_COUNT; ep++) + usb_ep_event[ep](USB_EVENT_DEVICE_RESUME); } } #endif /* CONFIG_USB_SUSPEND && CONFIG_USB_REMOTE_WAKEUP */ |