summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2020-07-15 11:03:25 -0600
committerCommit Bot <commit-bot@chromium.org>2020-07-29 03:33:52 +0000
commit545e72a8540f14416c3d91bf1b5483882a10519e (patch)
treeac91cc9b5159ad208aa931eea46677acc3c53da0 /include
parenta3a577297d83798dd7a74771cfbc621d9228b838 (diff)
downloadchrome-ec-545e72a8540f14416c3d91bf1b5483882a10519e.tar.gz
TCPMv2: Optionally build extended message support
If CONFIG_USB_PD_EXTENDED_MESSAGES is defined, support sending and receiving extended messages. If it is not, remove the chunking state machines from the PRL and modify the PE to respond with Not Supported as appropriate. BUG=b:160374787,b:158572770 TEST=Attach various devices; observe PD traffic TEST=make run-usb_prl_noextended; make run-usb_pe_drp_noextended BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I862020155927b5613d599274708e60678c49c43c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2304263 Commit-Queue: Jett Rink <jettrink@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'include')
-rw-r--r--include/config.h14
-rw-r--r--include/usb_pd.h89
-rw-r--r--include/usb_prl_sm.h5
3 files changed, 64 insertions, 44 deletions
diff --git a/include/config.h b/include/config.h
index c94be56206..78fd4b71cf 100644
--- a/include/config.h
+++ b/include/config.h
@@ -3885,6 +3885,14 @@
*/
#undef CONFIG_USB_PD_REV30
+/*
+ * Support USB PD 3.0 Extended Messages. This will only take effect if
+ * CONFIG_USB_PD_REV30 is also enabled. Note that Chromebooks disabling this
+ * config item are non-compliant with PD 3.0, because they have batteries but do
+ * not support Get_Battery_Cap or Get_Battery_Status.
+ */
+#define CONFIG_USB_PD_EXTENDED_MESSAGES
+
/* Major and Minor ChromeOS specific PD device Hardware IDs. */
#undef CONFIG_USB_PD_HW_DEV_ID_BOARD_MAJOR
#undef CONFIG_USB_PD_HW_DEV_ID_BOARD_MINOR
@@ -4726,7 +4734,11 @@
#define CONFIG_USB_PD_FRS
#endif
-
+/******************************************************************************/
+/* Disable extended message support if PD 3.0 support is disabled. */
+#ifndef CONFIG_USB_PD_REV30
+#undef CONFIG_USB_PD_EXTENDED_MESSAGES
+#endif
/******************************************************************************/
/*
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 5d09b7ab6c..e34220da0b 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -188,50 +188,51 @@ enum pd_rx_errors {
#define SVID_DISCOVERY_MAX 16
/* Timers */
-#define PD_T_SINK_TX (18*MSEC) /* between 16ms and 20 */
-#define PD_T_CHUNK_SENDER_RSP (24*MSEC) /* between 24ms and 30ms */
-#define PD_T_CHUNK_SENDER_REQ (24*MSEC) /* between 24ms and 30ms */
-#define PD_T_HARD_RESET_COMPLETE (5*MSEC) /* between 4ms and 5ms*/
-#define PD_T_HARD_RESET_RETRY (1*MSEC) /* 1ms */
-#define PD_T_SEND_SOURCE_CAP (100*MSEC) /* between 100ms and 200ms */
-#define PD_T_SINK_WAIT_CAP (600*MSEC) /* between 310ms and 620ms */
-#define PD_T_SINK_TRANSITION (35*MSEC) /* between 20ms and 35ms */
-#define PD_T_SOURCE_ACTIVITY (45*MSEC) /* between 40ms and 50ms */
-#define PD_T_SENDER_RESPONSE (30*MSEC) /* between 24ms and 30ms */
-#define PD_T_PS_TRANSITION (500*MSEC) /* between 450ms and 550ms */
-#define PD_T_PS_SOURCE_ON (480*MSEC) /* between 390ms and 480ms */
-#define PD_T_PS_SOURCE_OFF (920*MSEC) /* between 750ms and 920ms */
-#define PD_T_PS_HARD_RESET (25*MSEC) /* between 25ms and 35ms */
-#define PD_T_ERROR_RECOVERY (240*MSEC) /* min 240ms if sourcing VConn */
-#define PD_T_CC_DEBOUNCE (100*MSEC) /* between 100ms and 200ms */
+#define PD_T_SINK_TX (18*MSEC) /* between 16ms and 20 */
+#define PD_T_CHUNKING_NOT_SUPPORTED (45*MSEC) /* between 40ms and 50ms */
+#define PD_T_CHUNK_SENDER_RSP (24*MSEC) /* between 24ms and 30ms */
+#define PD_T_CHUNK_SENDER_REQ (24*MSEC) /* between 24ms and 30ms */
+#define PD_T_HARD_RESET_COMPLETE (5*MSEC) /* between 4ms and 5ms*/
+#define PD_T_HARD_RESET_RETRY (1*MSEC) /* 1ms */
+#define PD_T_SEND_SOURCE_CAP (100*MSEC) /* between 100ms and 200ms */
+#define PD_T_SINK_WAIT_CAP (600*MSEC) /* between 310ms and 620ms */
+#define PD_T_SINK_TRANSITION (35*MSEC) /* between 20ms and 35ms */
+#define PD_T_SOURCE_ACTIVITY (45*MSEC) /* between 40ms and 50ms */
+#define PD_T_SENDER_RESPONSE (30*MSEC) /* between 24ms and 30ms */
+#define PD_T_PS_TRANSITION (500*MSEC) /* between 450ms and 550ms */
+#define PD_T_PS_SOURCE_ON (480*MSEC) /* between 390ms and 480ms */
+#define PD_T_PS_SOURCE_OFF (920*MSEC) /* between 750ms and 920ms */
+#define PD_T_PS_HARD_RESET (25*MSEC) /* between 25ms and 35ms */
+#define PD_T_ERROR_RECOVERY (240*MSEC) /* min 240ms if sourcing VConn */
+#define PD_T_CC_DEBOUNCE (100*MSEC) /* between 100ms and 200ms */
/* DRP_SNK + DRP_SRC must be between 50ms and 100ms with 30%-70% duty cycle */
-#define PD_T_DRP_SNK (40*MSEC) /* toggle time for sink DRP */
-#define PD_T_DRP_SRC (30*MSEC) /* toggle time for source DRP */
-#define PD_T_DEBOUNCE (15*MSEC) /* between 10ms and 20ms */
-#define PD_T_TRY_CC_DEBOUNCE (15*MSEC) /* between 10ms and 20ms */
-#define PD_T_SINK_ADJ (55*MSEC) /* between PD_T_DEBOUNCE and 60ms */
-#define PD_T_SRC_RECOVER (760*MSEC) /* between 660ms and 1000ms */
-#define PD_T_SRC_RECOVER_MAX (1000*MSEC) /* 1000ms */
-#define PD_T_SRC_TURN_ON (275*MSEC) /* 275ms */
-#define PD_T_SAFE_0V (650*MSEC) /* 650ms */
-#define PD_T_NO_RESPONSE (5500*MSEC) /* between 4.5s and 5.5s */
-#define PD_T_BIST_TRANSMIT (50*MSEC) /* 50ms (used for task_wait arg) */
-#define PD_T_BIST_RECEIVE (60*MSEC) /* 60ms (max time to process bist) */
-#define PD_T_BIST_CONT_MODE (60*MSEC) /* 30ms to 60ms */
-#define PD_T_VCONN_SOURCE_ON (100*MSEC) /* 100ms */
-#define PD_T_DRP_TRY (125*MSEC) /* btween 75 and 150ms(monitor Vbus) */
-#define PD_T_TRY_TIMEOUT (550*MSEC) /* between 550ms and 1100ms */
-#define PD_T_TRY_WAIT (600*MSEC) /* Max time for TryWait.SNK state */
-#define PD_T_SINK_REQUEST (100*MSEC) /* Wait 100ms before next request */
-#define PD_T_PD_DEBOUNCE (15*MSEC) /* between 10ms and 20ms */
-#define PD_T_CHUNK_SENDER_RESPONSE (25*MSEC) /* 25ms */
-#define PD_T_CHUNK_SENDER_REQUEST (25*MSEC) /* 25ms */
-#define PD_T_SWAP_SOURCE_START (25*MSEC) /* Min of 20ms */
-#define PD_T_RP_VALUE_CHANGE (20*MSEC) /* 20ms */
-#define PD_T_SRC_DISCONNECT (15*MSEC) /* 15ms */
-#define PD_T_VCONN_STABLE (50*MSEC) /* 50ms */
-#define PD_T_DISCOVER_IDENTITY (45*MSEC) /* between 40ms and 50ms */
-#define PD_T_SYSJUMP (1000*MSEC) /* 1s */
+#define PD_T_DRP_SNK (40*MSEC) /* toggle time for sink DRP */
+#define PD_T_DRP_SRC (30*MSEC) /* toggle time for source DRP */
+#define PD_T_DEBOUNCE (15*MSEC) /* between 10ms and 20ms */
+#define PD_T_TRY_CC_DEBOUNCE (15*MSEC) /* between 10ms and 20ms */
+#define PD_T_SINK_ADJ (55*MSEC) /* between tPDDebounce and 60ms */
+#define PD_T_SRC_RECOVER (760*MSEC) /* between 660ms and 1000ms */
+#define PD_T_SRC_RECOVER_MAX (1000*MSEC) /* 1000ms */
+#define PD_T_SRC_TURN_ON (275*MSEC) /* 275ms */
+#define PD_T_SAFE_0V (650*MSEC) /* 650ms */
+#define PD_T_NO_RESPONSE (5500*MSEC) /* between 4.5s and 5.5s */
+#define PD_T_BIST_TRANSMIT (50*MSEC) /* 50ms (for task_wait arg) */
+#define PD_T_BIST_RECEIVE (60*MSEC) /* 60ms (time to process bist) */
+#define PD_T_BIST_CONT_MODE (60*MSEC) /* 30ms to 60ms */
+#define PD_T_VCONN_SOURCE_ON (100*MSEC) /* 100ms */
+#define PD_T_DRP_TRY (125*MSEC) /* between 75ms and 150ms */
+#define PD_T_TRY_TIMEOUT (550*MSEC) /* between 550ms and 1100ms */
+#define PD_T_TRY_WAIT (600*MSEC) /* Wait time for TryWait.SNK */
+#define PD_T_SINK_REQUEST (100*MSEC) /* 100ms before next request */
+#define PD_T_PD_DEBOUNCE (15*MSEC) /* between 10ms and 20ms */
+#define PD_T_CHUNK_SENDER_RESPONSE (25*MSEC) /* 25ms */
+#define PD_T_CHUNK_SENDER_REQUEST (25*MSEC) /* 25ms */
+#define PD_T_SWAP_SOURCE_START (25*MSEC) /* Min of 20ms */
+#define PD_T_RP_VALUE_CHANGE (20*MSEC) /* 20ms */
+#define PD_T_SRC_DISCONNECT (15*MSEC) /* 15ms */
+#define PD_T_VCONN_STABLE (50*MSEC) /* 50ms */
+#define PD_T_DISCOVER_IDENTITY (45*MSEC) /* between 40ms and 50ms */
+#define PD_T_SYSJUMP (1000*MSEC) /* 1s */
/* number of edges and time window to detect CC line is not idle */
#define PD_RX_TRANSITION_COUNT 3
@@ -1231,6 +1232,8 @@ enum pd_msg_type {
/* Used to get extended header from the first 32-bit word of the message */
#define GET_EXT_HEADER(msg) (msg & 0xffff)
+#define PD_MAX_EXTENDED_MESSAGE_CHUNK_LEN 26
+
/* K-codes for special symbols */
#define PD_SYNC1 0x18
#define PD_SYNC2 0x11
diff --git a/include/usb_prl_sm.h b/include/usb_prl_sm.h
index 6b35bd67e8..3575d9443b 100644
--- a/include/usb_prl_sm.h
+++ b/include/usb_prl_sm.h
@@ -124,6 +124,11 @@ void prl_execute_hard_reset(int port);
* Fake to track the last sent control message
*/
enum pd_ctrl_msg_type fake_prl_get_last_sent_ctrl_msg(int port);
+
+/**
+ * Fake to set the last sent control message to an invalid value.
+ */
+void fake_prl_clear_last_sent_ctrl_msg(int port);
#endif
#endif /* __CROS_EC_USB_PRL_H */