usb: Groundwork for USB BOS & Billboard class descriptors. [chromiumos/platform/ec : firmware-samus-6300.B]

190 views
Skip to first unread message

chrome-internal-fetch (Gerrit)

unread,
Oct 11, 2014, 1:51:17 PM10/11/14
to Duncan Laurie, Todd Broch
chrome-internal-fetch has submitted this change and it was merged.

Change subject: usb: Groundwork for USB BOS & Billboard class descriptors.
......................................................................


usb: Groundwork for USB BOS & Billboard class descriptors.

The BOS (Binary Device Object Store) descriptor was added to the USB
specification (3.0) to allow a richer set of device capability
specific descriptors.

The Billboard class is meant to expose (read-only) the status of USB
devices capable of alternate mode functions. It's required to use the
BOS descriptor type and at a high level looks like:

- BOS Device Descriptor (5bytes)
- Container ID Device Capability Descriptor (20bytes)
- Billboard Device Capability Descriptor (44byte + 4 * numSVIDs)

This CL adds:
1. Ability for Get Descriptor on BOS descriptors. Note hidden behind
CONFIG_USB_BOS as these descriptors change USB device requirements
to:
- bcdUSB >= 0201
- no interface descriptors

2. structures for all BOS, Container & Billboard descriptor elements
complete w/ CamelCase.

BRANCH=none
BUG=chrome-os-partner:32652
TEST=compiles with CONFIG_USB & CONFIG_USB_BOS enabled.

Signed-off-by: Todd Broch <tbr...@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/221570
(cherry picked from commit 44e4f7cfe7953198091cfd5e39bf339a770138dc)
Signed-off-by: Duncan Laurie <dla...@chromium.org>

Change-Id: I1b24bc728f2ebba7d91840801d2ebe576e240e7c
Reviewed-on: https://chromium-review.googlesource.com/223020
Tested-by: Duncan Laurie <dla...@chromium.org>
Commit-Queue: Duncan Laurie <dla...@chromium.org>
Reviewed-by: Duncan Laurie <dla...@chromium.org>
---
M chip/stm32/usb.c
M include/config.h
M include/usb.h
A include/usb_bb.h
4 files changed, 124 insertions(+), 3 deletions(-)

Approvals:
Duncan Laurie: Looks good to me, approved; Ready; Verified



diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index 6ff0070..d4ad8e4 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -19,12 +19,23 @@
/* Console output macro */
#define CPRINTF(format, args...) cprintf(CC_USB, format, ## args)

+#ifdef CONFIG_USB_BOS
+/* v2.01 (vs 2.00) BOS Descriptor provided */
+#define USB_DEV_BCDUSB 0x0201
+#else
+#define USB_DEV_BCDUSB 0x0200
+#endif
+
+#ifndef USB_DEV_CLASS
+#define USB_DEV_CLASS USB_CLASS_PER_INTERFACE
+#endif
+
/* USB Standard Device Descriptor */
static const struct usb_device_descriptor dev_desc = {
.bLength = USB_DT_DEVICE_SIZE,
.bDescriptorType = USB_DT_DEVICE,
- .bcdUSB = 0x0200, /* v2.00 */
- .bDeviceClass = USB_CLASS_PER_INTERFACE,
+ .bcdUSB = USB_DEV_BCDUSB,
+ .bDeviceClass = USB_DEV_CLASS,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = USB_MAX_PACKET_SIZE,
@@ -100,6 +111,12 @@
desc = __usb_desc;
len = USB_DESC_SIZE;
break;
+#ifdef CONFIG_USB_BOS
+ case USB_DT_BOS: /* Setup : Get BOS descriptor */
+ desc = bos_ctx.descp;
+ len = bos_ctx.size;
+ break;
+#endif
case USB_DT_STRING: /* Setup : Get string descriptor */
if (idx >= USB_STR_COUNT)
/* The string does not exist : STALL */
diff --git a/include/config.h b/include/config.h
index 3183e3b..2cc2b0f 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1041,6 +1041,12 @@
/* Support for USB type-c superspeed mux */
#undef CONFIG_USBC_SS_MUX

+/* Support for USB type-c vconn. Not needed for captive cables. */
+#undef CONFIG_USBC_VCONN
+
+/* USB Binary device Object Store support */
+#undef CONFIG_USB_BOS
+

/*****************************************************************************/
/* USB interfaces config */

diff --git a/include/usb.h b/include/usb.h
index d43450d..3d63efa 100644
--- a/include/usb.h
+++ b/include/usb.h
@@ -24,6 +24,8 @@
#define USB_DT_OTHER_SPEED_CONFIG 0x07
#define USB_DT_INTERFACE_POWER 0x08
#define USB_DT_DEBUG 0x0a
+#define USB_DT_BOS 0x0f
+#define USB_DT_DEVICE_CAPABILITY 0x10

/* USB Device Descriptor */
struct usb_device_descriptor {
@@ -43,6 +45,46 @@
uint8_t bNumConfigurations;
} __packed;
#define USB_DT_DEVICE_SIZE 18
+
+/* BOS Descriptor ( USB3.1 rev1 Section 9.6.2 ) */
+struct bos_context {
+ void *descp;
+ int size;
+};
+
+struct usb_bos_hdr_descriptor {
+ uint8_t bLength;
+ uint8_t bDescriptorType; /* USB_DT_BOS */
+ uint16_t wTotalLength; /* Total length of of hdr + all dev caps */
+ uint8_t bNumDeviceCaps; /* Container ID Descriptor + others */
+} __packed;
+#define USB_DT_BOS_SIZE 5
+
+/* Container ID Descriptor */
+struct usb_contid_caps_descriptor {
+ uint8_t bLength;
+ uint8_t bDescriptorType; /* USB_DT_DEVICE_CAPABILITY */
+ uint8_t bDevCapabilityType; /* USB_DC_DTYPE_xxx */
+ uint8_t bReserved; /* SBZ */
+ uint8_t ContainerID[16]; /* UUID */
+} __packed;
+#define USB_DT_CONTID_SIZE 20
+
+/* Device Cap Type Codes ( offset 2 of Device Capability Descriptor */
+#define USB_DC_DTYPE_WIRELESS 0x01
+#define USB_DC_DTYPE_USB20EXT 0x02
+#define USB_DC_DTYPE_USBSS 0x03
+#define USB_DC_DTYPE_CONTID 0x04
+#define USB_DC_DTYPE_PLATFORM 0x05
+#define USB_DC_DTYPE_PD 0x06
+#define USB_DC_DTYPE_BATTINFO 0x07
+#define USB_DC_DTYPE_CONSUMER 0x08
+#define USB_DC_DTYPE_PRODUCER 0x09
+#define USB_DC_DTYPE_USBSSP 0x0a
+#define USB_DC_DTYPE_PCSTIME 0x0b
+#define USB_DC_DTYPE_WUSBEXT 0x0c
+#define USB_DC_DTYPE_BILLBOARD 0x0d
+/* RESERVED 0x00, 0xOe - 0xff */

/* Configuration Descriptor */
struct usb_config_descriptor {
@@ -103,6 +145,7 @@
#define USB_CLASS_CSCID 0x0b
#define USB_CLASS_CONTENT_SEC 0x0d
#define USB_CLASS_VIDEO 0x0e
+#define USB_CLASS_BILLBOARD 0x11
#define USB_CLASS_WIRELESS_CONTROLLER 0xe0
#define USB_CLASS_MISC 0xef
#define USB_CLASS_APP_SPEC 0xfe
@@ -211,9 +254,10 @@
(((uint32_t)(x) - (uint32_t)__usb_ram_start) \
/ (sizeof(usb_uint)/sizeof(uint16_t)))

-/* String descriptors are defined in the board code */
+/* These descriptors defined in board code */
extern const void * const usb_strings[];
extern const uint8_t usb_string_desc[];
+extern struct bos_context bos_ctx;

/* Helpers for endpoint declaration */

diff --git a/include/usb_bb.h b/include/usb_bb.h
new file mode 100644
index 0000000..56864a6
--- /dev/null
+++ b/include/usb_bb.h
@@ -0,0 +1,54 @@
+/* Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * USB billboard definitions.
+ */
+
+#ifndef USB_BB_H
+#define USB_BB_H
+
+/* per Billboard Device Class Spec Revision 1.0 */
+
+/* device descriptor fields */
+#define USB_BB_BCDUSB_MIN 0x0201 /* v2.01 minimum */
+#define USB_BB_SUBCLASS 0x00
+#define USB_BB_PROTOCOL 0x00
+#define USB_BB_EP0_PACKET_SIZE 8
+#define USB_BB_CAP_DESC_TYPE 0x0d
+
+
+#define USB_BB_CAPS_SVID_SIZE 4
+struct usb_bb_caps_svid_descriptor {
+ uint16_t wSVID;
+ uint8_t bAlternateMode;
+ uint8_t iAlternateModeString;
+} __packed;
+
+#define USB_BB_CAPS_BASE_SIZE 44
+struct usb_bb_caps_base_descriptor {
+ uint8_t bLength;
+ uint8_t bDescriptorType;
+ uint8_t bDevCapabilityType;
+ uint8_t iAdditionalInfoURL;
+ uint8_t bNumberOfAlternateModes;
+ uint8_t bPreferredAlternateMode;
+ uint16_t VconnPower;
+ uint8_t bmConfigured[32]; /* 2b per SVID w/ 128 SVIDs allowed. */
+ uint32_t bReserved; /* SBZ */
+} __packed;
+
+
+#define USB_BB_VCONN_PWRON(x) (x << 15)
+#define USB_BB_VCONN_PWR_1W 0
+#define USB_BB_VCONN_PWR_1p5W 1
+#define USB_BB_VCONN_PWR_2W 2
+#define USB_BB_VCONN_PWR_3W 3
+#define USB_BB_VCONN_PWR_4W 4
+#define USB_BB_VCONN_PWR_5W 5
+#define USB_BB_VCONN_PWR_6W 6
+/* Note, 7W (111b) is reserved */
+
+
+#endif /* USB_BB_H */
+

--
To view, visit https://chromium-review.googlesource.com/223020
To unsubscribe, visit https://chromium-review.googlesource.com/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1b24bc728f2ebba7d91840801d2ebe576e240e7c
Gerrit-PatchSet: 2
Gerrit-Project: chromiumos/platform/ec
Gerrit-Branch: firmware-samus-6300.B
Gerrit-Owner: Duncan Laurie <dla...@chromium.org>
Gerrit-Reviewer: Duncan Laurie <dla...@chromium.org>
Gerrit-Reviewer: chrome-internal-fetch <chrome-int...@google.com>
Reply all
Reply to author
Forward
0 new messages