diff options
author | Anton Staaf <robotboy@chromium.org> | 2014-12-01 13:33:16 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-12-08 21:51:43 +0000 |
commit | 0967049df61384a4f25cdfe46ff1d4a38b1c787a (patch) | |
tree | 42a0bfc270e858d157545185b336120d69f8e7e5 | |
parent | 8bb26a29b04c39a81c4094de9d7fba5f85123f54 (diff) | |
download | chrome-ec-0967049df61384a4f25cdfe46ff1d4a38b1c787a.tar.gz |
USB: Add setup packet struct and parsing routine
This can be used by interface specific EP0 setup
packet callbacks. The USB-SPI bridge will use
this to handle enabling and disabling the bridge.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Change-Id: I3f3db65934707243f54bed9e093f376b6978d271
Reviewed-on: https://chromium-review.googlesource.com/232367
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
-rw-r--r-- | chip/stm32/usb.c | 9 | ||||
-rw-r--r-- | include/usb.h | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c index 64bff8bd40..82c1337a40 100644 --- a/chip/stm32/usb.c +++ b/chip/stm32/usb.c @@ -83,6 +83,15 @@ static int desc_left; /* pointer to descriptor data if any */ static const uint8_t *desc_ptr; +void usb_read_setup_packet(usb_uint *buffer, struct usb_setup_packet *packet) +{ + packet->bmRequestType = buffer[0] & 0xff; + packet->bRequest = buffer[0] >> 8; + packet->wValue = buffer[1]; + packet->wIndex = buffer[2]; + packet->wLength = buffer[3]; +} + /* Requests on the control endpoint (aka EP0) */ static void ep0_rx(void) { diff --git a/include/usb.h b/include/usb.h index 2b9db32811..0c96b19db1 100644 --- a/include/usb.h +++ b/include/usb.h @@ -194,6 +194,15 @@ struct usb_endpoint_descriptor { #define USB_BC12_CHARGE_VOLTAGE 5000 /* mV */ +/* Setup Packet */ +struct usb_setup_packet { + uint8_t bmRequestType; + uint8_t bRequest; + uint16_t wValue; + uint16_t wIndex; + uint16_t wLength; +}; + /* Helpers for descriptors */ #define WIDESTR(quote) WIDESTR2(quote) @@ -242,6 +251,9 @@ struct stm32_endpoint { extern struct stm32_endpoint btable_ep[]; +/* Read from USB RAM into a usb_setup_packet struct */ +void usb_read_setup_packet(usb_uint *buffer, struct usb_setup_packet *packet); + /* Copy data to the USB dedicated RAM and take care of the weird addressing */ static inline void memcpy_usbram(usb_uint *ebuf, const uint8_t *src, int size) { |