summaryrefslogtreecommitdiff
path: root/board/hoho/board.c
diff options
context:
space:
mode:
authorTodd Broch <tbroch@chromium.org>2014-10-03 18:12:33 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-11 02:22:36 +0000
commit03cbbb2be714a104f74005774991049e257be996 (patch)
tree8e9d6e66aa8af4b034e15d1383621bd66119c933 /board/hoho/board.c
parent8a6c72022f1a43fe8288eed2e1a5b94400ca4b1f (diff)
downloadchrome-ec-03cbbb2be714a104f74005774991049e257be996.tar.gz
hoho: Add USB Billboard class device.
BRANCH=none BUG=chrome-os-partner:31192 TEST=manual Plug hoho into samus and see: # lsusb -d 18d1:5010 -v Bus 001 Device 007: ID 18d1:5010 Google Inc. Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.01 bDeviceClass 17 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x18d1 Google Inc. idProduct 0x5010 bcdDevice 2.00 iManufacturer 1 Google Inc. iProduct 2 Hoho iSerial 3 v0.001 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 10 bNumInterfaces 0 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 (Bus Powered) MaxPower 500mA Binary Object Store Descriptor: bLength 5 bDescriptorType 15 wTotalLength 73 bNumDeviceCaps 2 FIXME: alloc bigger buffer for device capability descriptors Device Status: 0x0000 (Bus Powered) Change-Id: I1431829f926eaf86477b49591e9b0adf2b4cb3a6 Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/221571 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'board/hoho/board.c')
-rw-r--r--board/hoho/board.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/board/hoho/board.c b/board/hoho/board.c
index 35bd123bc5..598768ee6d 100644
--- a/board/hoho/board.c
+++ b/board/hoho/board.c
@@ -13,6 +13,9 @@
#include "i2c.h"
#include "registers.h"
#include "task.h"
+#include "usb.h"
+#include "usb_bb.h"
+#include "usb_pd.h"
#include "util.h"
#include "gpio_list.h"
@@ -78,3 +81,71 @@ const struct i2c_port_t i2c_ports[] = {
{"master", I2C_PORT_MASTER, 400, GPIO_MCDP_I2C_SCL, GPIO_MCDP_I2C_SDA},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+
+const void * const usb_strings[] = {
+ [USB_STR_DESC] = usb_string_desc,
+ [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."),
+ [USB_STR_PRODUCT] = USB_STRING_DESC("Hoho"),
+ [USB_STR_VERSION] = USB_STRING_DESC("v0.001"),
+ [USB_STR_BB_URL] = USB_STRING_DESC(USB_GOOGLE_TYPEC_URL),
+};
+BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT);
+
+/**
+ * USB configuration
+ * Any type-C device with alternate mode capabilities must have the following
+ * set of descriptors.
+ *
+ * 1. Standard Device
+ * 2. BOS
+ * 2a. Container ID
+ * 2b. Billboard Caps
+ */
+struct my_bos {
+ struct usb_bos_hdr_descriptor bos;
+ struct usb_contid_caps_descriptor contid_caps;
+ struct usb_bb_caps_base_descriptor bb_caps;
+ struct usb_bb_caps_svid_descriptor bb_caps_svids[1];
+};
+
+static struct my_bos bos_desc = {
+ .bos = {
+ .bLength = USB_DT_BOS_SIZE,
+ .bDescriptorType = USB_DT_BOS,
+ .wTotalLength = (USB_DT_BOS_SIZE + USB_DT_CONTID_SIZE +
+ USB_BB_CAPS_BASE_SIZE +
+ USB_BB_CAPS_SVID_SIZE * 1),
+ .bNumDeviceCaps = 2, /* contid + bb_caps */
+ },
+ .contid_caps = {
+ .bLength = USB_DT_CONTID_SIZE,
+ .bDescriptorType = USB_DT_DEVICE_CAPABILITY,
+ .bDevCapabilityType = USB_DC_DTYPE_CONTID,
+ .bReserved = 0,
+ .ContainerID = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ },
+ .bb_caps = {
+ .bLength = (USB_BB_CAPS_BASE_SIZE + USB_BB_CAPS_SVID_SIZE * 1),
+ .bDescriptorType = USB_DT_DEVICE_CAPABILITY,
+ .bDevCapabilityType = USB_DC_DTYPE_BILLBOARD,
+ .iAdditionalInfoURL = USB_STR_BB_URL,
+ .bNumberOfAlternateModes = 1,
+ .bPreferredAlternateMode = 1,
+ .VconnPower = 0,
+ .bmConfigured = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ .bReserved = 0,
+ },
+ .bb_caps_svids = {
+ {
+ .wSVID = 0xff01, /* TODO(tbroch) def'd in other CL remove hardcode */
+ .bAlternateMode = 1,
+ .iAlternateModeString = USB_STR_BB_URL, /* TODO(crosbug.com/p/32687) */
+ },
+ },
+};
+
+const struct bos_context bos_ctx = {
+ .descp = (void *)&bos_desc,
+ .size = sizeof(struct my_bos),
+};