summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/usb_pd.h74
-rw-r--r--include/usb_pd_vdo.h95
2 files changed, 117 insertions, 52 deletions
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 49a14654ec..f781abae22 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -335,6 +335,26 @@ enum pd_discovery_state {
PD_DISC_FAIL, /* Cable did not respond, or Discover* NAK */
};
+/* Discover Identity ACK contents after headers */
+union disc_ident_ack {
+ struct {
+ struct id_header_vdo_rev20 idh;
+ struct cert_stat_vdo cert;
+ struct product_vdo product;
+ union product_type_vdo1 product_t1;
+ union product_type_vdo2 product_t2;
+ uint32_t product_t3;
+ };
+
+ uint32_t raw_value[PDO_MAX_OBJECTS - 1];
+};
+
+/* Discover Identity data - ACK plus discovery state */
+struct identity_data {
+ union disc_ident_ack response;
+ enum pd_discovery_state discovery;
+};
+
/* supported alternate modes */
enum pd_alternate_modes {
PD_AMODE_GOOGLE,
@@ -469,27 +489,6 @@ struct pd_discovery {
#define VDO_INDEX_PTYPE_DFP_VDO 6
#define VDO_I(name) VDO_INDEX_##name
-/*
- * SVDM Identity Header
- * --------------------
- * <31> :: data capable as a USB host
- * <30> :: data capable as a USB device
- * <29:27> :: product type
- * <26> :: modal operation supported (1b == yes)
- * <25:16> :: SBZ
- * <15:0> :: USB-IF assigned VID for this cable vendor
- */
-
-enum idh_ptype {
- IDH_PTYPE_UNDEF,
- IDH_PTYPE_HUB,
- IDH_PTYPE_PERIPH,
- IDH_PTYPE_PCABLE,
- IDH_PTYPE_ACABLE,
- IDH_PTYPE_AMA,
- IDH_PTYPE_VPD,
- IDH_PTYPE_COUNT,
-};
#define VDO_IDH(usbh, usbd, ptype, is_modal, vid) \
((usbh) << 31 | (usbd) << 30 | ((ptype) & 0x7) << 27 \
| (is_modal) << 26 | ((vid) & 0xffff))
@@ -498,21 +497,9 @@ enum idh_ptype {
#define PD_IDH_IS_MODAL(vdo) (((vdo) >> 26) & 0x1)
#define PD_IDH_VID(vdo) ((vdo) & 0xffff)
-/*
- * Cert Stat VDO
- * -------------
- * <31:20> : SBZ
- * <19:0> : USB-IF assigned TID for this cable
- */
#define VDO_CSTAT(tid) ((tid) & 0xfffff)
#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))
#define PD_PRODUCT_PID(vdo) (((vdo) >> 16) & 0xffff)
@@ -523,23 +510,6 @@ enum idh_ptype {
*/
#define INVALID_MSG_ID_COUNTER 0xff
-union cable_vdo {
- /* Passive cable VDO */
- union passive_cable_vdo_rev20 p_rev20;
- union passive_cable_vdo_rev30 p_rev30;
-
- /* Active cable VDO */
- union active_cable_vdo_rev20 a_rev20;
- union active_cable_vdo1_rev30 a_rev30;
-
- uint32_t raw_value;
-};
-
-union active_cable_vdo2 {
- union active_cable_vdo2_rev30 a2_rev30;
- uint32_t raw_value;
-};
-
/* Protocol revision */
enum pd_rev_type {
PD_REV10,
@@ -575,9 +545,9 @@ struct pd_cable {
/* Type of cable */
enum idh_ptype type;
/* Cable attributes */
- union cable_vdo attr;
+ union product_type_vdo1 attr;
/* For USB PD REV3, active cable has 2 VDOs */
- union active_cable_vdo2 attr2;
+ union product_type_vdo2 attr2;
/* Cable revision */
enum pd_rev_type rev;
diff --git a/include/usb_pd_vdo.h b/include/usb_pd_vdo.h
index d141d878f1..20861131c4 100644
--- a/include/usb_pd_vdo.h
+++ b/include/usb_pd_vdo.h
@@ -25,6 +25,28 @@
/*****************************************************************************/
/*
+ * Table 6-33 Cert Stat VDO (Note: same as Revision 2.0)
+ * -------------------------------------------------------------
+ * <31:0> : XID assigned by USB-IF
+ */
+struct cert_stat_vdo {
+ uint32_t xid;
+};
+
+/*****************************************************************************/
+/*
+ * Table 6-34 Product VDO (Note: same as Revision 2.0)
+ * -------------------------------------------------------------
+ * <31:16> : USB Product ID
+ * <15:0> : bcdDevice
+ */
+struct product_vdo {
+ uint16_t bcd_device;
+ uint16_t product_id;
+};
+
+/*****************************************************************************/
+/*
* Table 6-35 UFP VDO 1
* -------------------------------------------------------------
* <31:29> : UFP VDO version
@@ -434,6 +456,53 @@ enum vpd_cts_support {
/*****************************************************************************/
/*
+ * Table 6-23 ID Header VDO
+ *
+ * Note: PD 3.0 ID header (Table 6-29, PD Revision 3.0 Spec) makes use of
+ * reserved bits 25:21 for a connector type and product type (DFP). It is not
+ * advised to create a structure using these bits however, as the DFP product
+ * type crosses a byte boundary and causes problems with gcc's structure
+ * alignment.
+ * -------------------------------------------------------------
+ * <31> : USB Communications Capable as USB Host
+ * <30> : USB Communications Capable as a USB Device
+ * <29:27> : Product Type (UFP):
+ * 000b = Undefined
+ * 001b = PDUSB Hub
+ * 010b = PDUSB Peripheral
+ * 011b = PSD (PD 3.0)
+ * 101b = Alternate Mode Adapter (AMA)
+ * 110b = Vconn-Powered USB Device (VPD, PD 3.0)
+ * Product Type (Cable Plug):
+ * 000b = Undefined
+ * 011b = Passive Cable
+ * 100b = Active Cable
+ * <26> : Modal Operation Supported
+ * <25:16> : Reserved
+ * <15:0> : USB Vendor ID
+ */
+enum idh_ptype {
+ IDH_PTYPE_UNDEF,
+ IDH_PTYPE_HUB,
+ IDH_PTYPE_PERIPH,
+ IDH_PTYPE_PSD = 3,
+ IDH_PTYPE_PCABLE = 3,
+ IDH_PTYPE_ACABLE,
+ IDH_PTYPE_AMA,
+ IDH_PTYPE_VPD,
+};
+
+struct id_header_vdo_rev20 {
+ uint16_t usb_vendor_id;
+ uint16_t reserved0 : 10;
+ uint8_t modal_support : 1;
+ enum idh_ptype product_type : 3;
+ uint8_t usb_device : 1;
+ uint8_t usb_host : 1;
+};
+
+/*****************************************************************************/
+/*
* Table 6-28 Passive Cable VDO
* -------------------------------------------------------------
* <31:28> : HW Version
@@ -757,4 +826,30 @@ union enter_usb_data_obj {
uint32_t raw_value;
};
+/*
+ * ############################################################################
+ *
+ * Unions of VDOs which differ based on revision or type
+ *
+ * ############################################################################
+ */
+
+union product_type_vdo1 {
+ /* Passive cable VDO */
+ union passive_cable_vdo_rev20 p_rev20;
+ union passive_cable_vdo_rev30 p_rev30;
+
+ /* Active cable VDO */
+ union active_cable_vdo_rev20 a_rev20;
+ union active_cable_vdo1_rev30 a_rev30;
+
+ uint32_t raw_value;
+};
+
+union product_type_vdo2 {
+ union active_cable_vdo2_rev30 a2_rev30;
+
+ uint32_t raw_value;
+};
+
#endif /* __CROS_EC_USB_PD_VDO_H */