summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Broch <tbroch@chromium.org>2014-10-28 18:04:01 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-10-31 06:29:34 +0000
commitce9ae08b6889e7d7032ba66821e4c73dae20fb78 (patch)
treef4d37db7152bab2ba549a0805e237bdb5a97f2cf
parentaac88442d7bbc76ec5116fdb3019af09cc522938 (diff)
downloadchrome-ec-ce9ae08b6889e7d7032ba66821e4c73dae20fb78.tar.gz
pd: dingdong/hoho: Include product VDO in discovery identity.
Per table 6-24 of USB PD spec an alternate mode adapter (AMA) should include both product & AMA VDOs. BRANCH=samus BUG=chrome-os-partner:31192,chrome-os-partner:31193 TEST=manual, Connect hoho/dingdong to fpie/samus and see product VDO proceed the AMA VDO in DFP_U console output: Product VDO -----------------------------v |------| SVDM/5 [1] ff008041 340018d1 00000000 50100001 1100000b Note, hoho's PID == 0x5010 And dingdong (0x5011) SVDM/5 [1] ff008041 340018d1 00000000 50110001 1100000b Also see bcdDevice field in descriptor match above data. $ lsusb -v -d 18d1: | egrep -i "idproduct|bcddev" idProduct 0x5011 bcdDevice 0.01 Change-Id: I4d898816a45c68c7ff75a54fd348fc11be408ae0 Signed-off-by: Todd Broch <tbroch@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/226125 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--board/dingdong/board.h1
-rw-r--r--board/dingdong/usb_pd_policy.c12
-rw-r--r--board/hoho/board.h1
-rw-r--r--board/hoho/usb_pd_policy.c12
-rw-r--r--chip/stm32/usb.c6
-rw-r--r--include/config.h3
-rw-r--r--include/usb_pd.h22
7 files changed, 42 insertions, 15 deletions
diff --git a/board/dingdong/board.h b/board/dingdong/board.h
index 814df199bc..de68de93e8 100644
--- a/board/dingdong/board.h
+++ b/board/dingdong/board.h
@@ -35,6 +35,7 @@
/* USB configuration */
#define CONFIG_USB_PID 0x5011
+#define CONFIG_USB_BCD_DEV 0x0001 /* v 0.01 */
/*
* Allow dangerous commands all the time, since we don't have a write protect
diff --git a/board/dingdong/usb_pd_policy.c b/board/dingdong/usb_pd_policy.c
index 5894427ca8..d531f7428b 100644
--- a/board/dingdong/usb_pd_policy.c
+++ b/board/dingdong/usb_pd_policy.c
@@ -14,6 +14,7 @@
#include "timer.h"
#include "util.h"
#include "usb.h"
+#include "usb_bb.h"
#include "usb_pd.h"
#include "version.h"
@@ -105,6 +106,8 @@ const uint32_t vdo_idh = VDO_IDH(0, /* data caps as USB host */
1, /* supports alt modes */
USB_VID_GOOGLE);
+const uint32_t vdo_product = VDO_PRODUCT(CONFIG_USB_PID, CONFIG_USB_BCD_DEV);
+
const uint32_t vdo_ama = VDO_AMA(CONFIG_USB_PD_IDENTITY_HW_VERS,
CONFIG_USB_PD_IDENTITY_SW_VERS,
0, 0, 0, 0, /* SS[TR][12] */
@@ -118,8 +121,9 @@ static int svdm_response_identity(int port, uint32_t *payload)
payload[VDO_I(IDH)] = vdo_idh;
/* TODO(tbroch): Do we plan to obtain TID (test ID) for hoho */
payload[VDO_I(CSTAT)] = VDO_CSTAT(0);
+ payload[VDO_I(PRODUCT)] = vdo_product;
payload[VDO_I(AMA)] = vdo_ama;
- return 4;
+ return VDO_I(AMA) + 1;
}
static int svdm_response_svids(int port, uint32_t *payload)
@@ -128,9 +132,9 @@ static int svdm_response_svids(int port, uint32_t *payload)
return 2;
}
-/* Will only ever be a single mode for this UFP_D device as it has no USB
- * support (2.0 or 3.0) making it only PIN_E configureable nor does it have any
- * source functionality.
+/*
+ * Will only ever be a single mode for this UFP_D device as it has no real USB
+ * support making it only PIN_E configureable
*/
#define MODE_CNT 1
#define OPOS 1
diff --git a/board/hoho/board.h b/board/hoho/board.h
index d98ba5b135..41c7dc40a7 100644
--- a/board/hoho/board.h
+++ b/board/hoho/board.h
@@ -46,6 +46,7 @@
/* USB configuration */
#define CONFIG_USB_PID 0x5010
+#define CONFIG_USB_BCD_DEV 0x0001 /* v 0.01 */
/*
* Allow dangerous commands all the time, since we don't have a write protect
diff --git a/board/hoho/usb_pd_policy.c b/board/hoho/usb_pd_policy.c
index 3da52023c3..6a01d0ec00 100644
--- a/board/hoho/usb_pd_policy.c
+++ b/board/hoho/usb_pd_policy.c
@@ -13,6 +13,7 @@
#include "task.h"
#include "timer.h"
#include "usb.h"
+#include "usb_bb.h"
#include "usb_pd.h"
#include "util.h"
#include "version.h"
@@ -105,6 +106,8 @@ const uint32_t vdo_idh = VDO_IDH(0, /* data caps as USB host */
1, /* supports alt modes */
USB_VID_GOOGLE);
+const uint32_t vdo_product = VDO_PRODUCT(CONFIG_USB_PID, CONFIG_USB_BCD_DEV);
+
const uint32_t vdo_ama = VDO_AMA(CONFIG_USB_PD_IDENTITY_HW_VERS,
CONFIG_USB_PD_IDENTITY_SW_VERS,
0, 0, 0, 0, /* SS[TR][12] */
@@ -118,8 +121,9 @@ static int svdm_response_identity(int port, uint32_t *payload)
payload[VDO_I(IDH)] = vdo_idh;
/* TODO(tbroch): Do we plan to obtain TID (test ID) for hoho */
payload[VDO_I(CSTAT)] = VDO_CSTAT(0);
+ payload[VDO_I(PRODUCT)] = vdo_product;
payload[VDO_I(AMA)] = vdo_ama;
- return 4;
+ return VDO_I(AMA) + 1;
}
static int svdm_response_svids(int port, uint32_t *payload)
@@ -128,9 +132,9 @@ static int svdm_response_svids(int port, uint32_t *payload)
return 2;
}
-/* Will only ever be a single mode for this UFP_D device as it has no USB
- * support (2.0 or 3.0) making it only PIN_E configureable nor does it have any
- * source functionality.
+/*
+ * Will only ever be a single mode for this UFP_D device as it has no real USB
+ * support making it only PIN_C configureable
*/
#define MODE_CNT 1
#define OPOS 1
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index 409cb4f69d..8cb01a002b 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -30,6 +30,10 @@
#define USB_DEV_CLASS USB_CLASS_PER_INTERFACE
#endif
+#ifndef CONFIG_USB_BCD_DEV
+#define CONFIG_USB_BCD_DEV 0x0100 /* 1.00 */
+#endif
+
/* USB Standard Device Descriptor */
static const struct usb_device_descriptor dev_desc = {
.bLength = USB_DT_DEVICE_SIZE,
@@ -41,7 +45,7 @@ static const struct usb_device_descriptor dev_desc = {
.bMaxPacketSize0 = USB_MAX_PACKET_SIZE,
.idVendor = USB_VID_GOOGLE,
.idProduct = CONFIG_USB_PID,
- .bcdDevice = 0x0200, /* 2.00 */
+ .bcdDevice = CONFIG_USB_BCD_DEV,
.iManufacturer = USB_STR_VENDOR,
.iProduct = USB_STR_PRODUCT,
.iSerialNumber = 0,
diff --git a/include/config.h b/include/config.h
index dd0815e22c..c7ebc9a1a8 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1111,6 +1111,9 @@
/* USB Binary device Object Store support */
#undef CONFIG_USB_BOS
+/* USB Device version of product */
+#undef CONFIG_USB_BCD_DEV
+
/*****************************************************************************/
/* USB interfaces config */
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 072f070359..1eede4fd89 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -247,14 +247,16 @@ struct pd_policy {
* [0] :: SVDM header
* [1] :: Identitiy header
* [2] :: Cert Stat VDO
- * [3] :: (Product | Cable | AMA) VDO
+ * [3] :: (Product | Cable) VDO
+ * [4] :: AMA VDO
*
*/
-#define VDO_INDEX_HDR 0
-#define VDO_INDEX_IDH 1
-#define VDO_INDEX_CSTAT 2
-#define VDO_INDEX_CABLE 3
-#define VDO_INDEX_AMA 3
+#define VDO_INDEX_HDR 0
+#define VDO_INDEX_IDH 1
+#define VDO_INDEX_CSTAT 2
+#define VDO_INDEX_CABLE 3
+#define VDO_INDEX_PRODUCT 3
+#define VDO_INDEX_AMA 4
#define VDO_I(name) VDO_INDEX_##name
/*
@@ -291,6 +293,14 @@ struct pd_policy {
#define PD_CSTAT_TID(vdo) ((vdo) & 0xfffff)
/*
+ * Product VDO
+ * -----------
+ * <31:16> : USB Product ID
+ * <15:0> : USB bcdDevice
+ */
+#define VDO_PRODUCT(pid, bcd) (((pid) & 0xffff) << 16 | ((bcd) & 0xffff))
+
+/*
* Cable VDO
* ---------
* <31:28> :: Cable HW version