summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Broch <tbroch@chromium.org>2014-10-10 23:05:50 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-15 00:09:56 +0000
commitfca5deab2f7070b757ec0386ad9fe3661cbb0079 (patch)
tree6f4e0bd8901ddc857fd6bc7a2fdecfbc5db33a36
parentce6cb6effaab1f050a39ccf2ef8ce5b3745f32c7 (diff)
downloadchrome-ec-fca5deab2f7070b757ec0386ad9fe3661cbb0079.tar.gz
dingdong: Add USB Billboard class device.
BRANCH=none BUG=chrome-os-partner:31193 TEST=manual Plug dingdong into samus and see: # lsusb -d 18d1:5011 -v Bus 001 Device 013: ID 18d1:5011 Google Inc. Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.01 bDeviceClass 17 bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 64 idVendor 0x18d1 Google Inc. idProduct 0x5011 bcdDevice 2.00 iManufacturer 1 Google Inc. iProduct 2 Dingdong iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 10 bNumInterfaces 0 bConfigurationValue 1 iConfiguration 3 dingdong_v1.1.2338-562101b 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: Icfc2e7eab9c88d6c8a05a33782213717e64ddcf0 Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/223003 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/dingdong/board.c70
-rw-r--r--board/dingdong/board.h27
2 files changed, 97 insertions, 0 deletions
diff --git a/board/dingdong/board.c b/board/dingdong/board.c
index 70720171a1..bf5333cc08 100644
--- a/board/dingdong/board.c
+++ b/board/dingdong/board.c
@@ -9,6 +9,9 @@
#include "common.h"
#include "gpio.h"
#include "registers.h"
+#include "usb.h"
+#include "usb_bb.h"
+#include "usb_pd.h"
#include "util.h"
#include "gpio_list.h"
@@ -28,3 +31,70 @@ const struct adc_t adc_channels[] = {
[ADC_CH_CC1_PD] = {"USB_C_CC1_PD", 3300, 4096, 0, STM32_AIN(1)},
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+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("Dingdong"),
+ [USB_STR_VERSION] = NULL /* filled at runtime */,
+ [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 = USB_SID_DISPLAYPORT,
+ .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),
+};
diff --git a/board/dingdong/board.h b/board/dingdong/board.h
index a703b95d17..c814b6f48d 100644
--- a/board/dingdong/board.h
+++ b/board/dingdong/board.h
@@ -19,6 +19,8 @@
#define CONFIG_ADC
#define CONFIG_BOARD_PRE_INIT
#define CONFIG_HW_CRC
+#define CONFIG_USB
+#define CONFIG_USB_BOS
#define CONFIG_USB_POWER_DELIVERY
#define CONFIG_USB_PD_ALT_MODE
#define CONFIG_USB_PD_DUAL_ROLE
@@ -30,6 +32,9 @@
#undef CONFIG_LID_SWITCH
#undef CONFIG_TASK_PROFILING
+/* USB configuration */
+#define CONFIG_USB_PID 0x5011
+
/*
* Allow dangerous commands all the time, since we don't have a write protect
* switch.
@@ -50,6 +55,28 @@ enum adc_channel {
/* Number of ADC channels */
ADC_CH_COUNT
};
+
+/* USB string indexes */
+enum usb_strings {
+ USB_STR_DESC = 0,
+ USB_STR_VENDOR,
+ USB_STR_PRODUCT,
+ USB_STR_VERSION,
+ USB_STR_BB_URL,
+
+ USB_STR_COUNT
+};
+
#endif /* !__ASSEMBLER__ */
+/* USB Device class */
+#define USB_DEV_CLASS USB_CLASS_BILLBOARD
+
+/* USB interface indexes (use define rather than enum to expand them) */
+#define USB_IFACE_COUNT 0
+
+/* USB endpoint indexes (use define rather than enum to expand them) */
+#define USB_EP_CONTROL 0
+#define USB_EP_COUNT 1
+
#endif /* __BOARD_H */