stm32: add generic stream interface for stm32

usb-stream is used by USB updater as well as uart
forwarding. Add parameter for custom USB class define.

BUG=chromium:571476
TEST=builds
BRANCH=none

Change-Id: Id6294709de0c5408b10ed366b261be1bc7da7767
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/361832
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
This commit is contained in:
Nick Sanders
2016-07-19 15:21:49 -07:00
committed by chrome-bot
parent 4fe82acac2
commit 8162f744e0

View File

@@ -87,6 +87,10 @@ extern struct producer_ops const usb_stream_producer_ops;
* INTERFACE is the index of the USB interface to associate with this
* stream.
*
* INTERFACE_CLASS, INTERFACE_SUBCLASS, INTERFACE_PROTOCOL are the
* .bInterfaceClass, .bInterfaceSubClass, and .bInterfaceProtocol fields
* respectively in the USB interface descriptor.
*
* INTERFACE_NAME is the index of the USB string descriptor (iInterface).
*
* ENDPOINT is the index of the USB bulk endpoint used for receiving and
@@ -108,14 +112,17 @@ extern struct producer_ops const usb_stream_producer_ops;
* BUILD_ASSERT(RX_QUEUE.unit_bytes == 1);
* BUILD_ASSERT(TX_QUEUE.unit_bytes == 1);
*/
#define USB_STREAM_CONFIG(NAME, \
INTERFACE, \
INTERFACE_NAME, \
ENDPOINT, \
RX_SIZE, \
TX_SIZE, \
RX_QUEUE, \
TX_QUEUE) \
#define USB_STREAM_CONFIG_FULL(NAME, \
INTERFACE, \
INTERFACE_CLASS, \
INTERFACE_SUBCLASS, \
INTERFACE_PROTOCOL, \
INTERFACE_NAME, \
ENDPOINT, \
RX_SIZE, \
TX_SIZE, \
RX_QUEUE, \
TX_QUEUE) \
\
BUILD_ASSERT(RX_SIZE <= USB_MAX_PACKET_SIZE); \
BUILD_ASSERT(TX_SIZE <= USB_MAX_PACKET_SIZE); \
@@ -155,9 +162,9 @@ extern struct producer_ops const usb_stream_producer_ops;
.bInterfaceNumber = INTERFACE, \
.bAlternateSetting = 0, \
.bNumEndpoints = 2, \
.bInterfaceClass = USB_CLASS_VENDOR_SPEC, \
.bInterfaceSubClass = USB_SUBCLASS_GOOGLE_SERIAL, \
.bInterfaceProtocol = USB_PROTOCOL_GOOGLE_SERIAL, \
.bInterfaceClass = INTERFACE_CLASS, \
.bInterfaceSubClass = INTERFACE_SUBCLASS, \
.bInterfaceProtocol = INTERFACE_PROTOCOL, \
.iInterface = INTERFACE_NAME, \
}; \
const struct usb_endpoint_descriptor \
@@ -197,6 +204,27 @@ extern struct producer_ops const usb_stream_producer_ops;
static void CONCAT2(NAME, _deferred_)(void) \
{ usb_stream_deferred(&NAME); }
/* This is a short version for declaring Google serial endpoints */
#define USB_STREAM_CONFIG(NAME, \
INTERFACE, \
INTERFACE_NAME, \
ENDPOINT, \
RX_SIZE, \
TX_SIZE, \
RX_QUEUE, \
TX_QUEUE) \
USB_STREAM_CONFIG_FULL(NAME, \
INTERFACE, \
USB_CLASS_VENDOR_SPEC, \
USB_SUBCLASS_GOOGLE_SERIAL, \
USB_PROTOCOL_GOOGLE_SERIAL, \
INTERFACE_NAME, \
ENDPOINT, \
RX_SIZE, \
TX_SIZE, \
RX_QUEUE, \
TX_QUEUE)
/*
* Handle USB and Queue request in a deferred callback.
*/