summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2016-04-09 20:51:03 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-11 14:36:44 -0700
commitf3552a6863079a29a90268da55b2f2d2b789580a (patch)
treed1ff6ed1a73a600a64468c4d2a42867ede43fa02
parent7ec7e0d4a16e43f7210ac22a041e975fcc461da1 (diff)
downloadchrome-ec-f3552a6863079a29a90268da55b2f2d2b789580a.tar.gz
g: Add USB_STREAM_CONFIG_FULL macro to usb-stream.h
It's handy to use the usb-stream interfaces to avoid a lot of typing. But not all the endpoints are traditional serial ports. This just adds a new macro that lets us specify additional parameters. BUG=chrome-os-partner:50707 BRANCH=none TEST=make buildall; test on Cr50 Verified that all the previous endpoints still work as before. There are no endpoints that use the new macro yet. Change-Id: Ia37901cbe3adc4a4650ab91db3596efa15a110de Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/338086 Reviewed-by: Mary Ruthven <mruthven@chromium.org>
-rw-r--r--chip/g/usb-stream.h53
1 files changed, 41 insertions, 12 deletions
diff --git a/chip/g/usb-stream.h b/chip/g/usb-stream.h
index 761065d8b6..a79d530035 100644
--- a/chip/g/usb-stream.h
+++ b/chip/g/usb-stream.h
@@ -66,6 +66,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
@@ -87,14 +91,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) \
\
static struct g_usb_desc CONCAT2(NAME, _out_desc_); \
static struct g_usb_desc CONCAT2(NAME, _in_desc_); \
@@ -130,9 +137,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 \
@@ -174,7 +181,29 @@ extern struct producer_ops const usb_stream_producer_ops;
USB_DECLARE_EP(ENDPOINT, \
CONCAT2(NAME, _ep_tx), \
CONCAT2(NAME, _ep_rx), \
- CONCAT2(NAME, _ep_reset)); \
+ CONCAT2(NAME, _ep_reset));
+
+/* 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.
*/