summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2022-08-30 16:51:26 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-14 00:47:56 +0000
commit25af2e9e8fa969b80dd3135c3a28b554bc05f5f7 (patch)
tree01c2f7998625f6af2aaa905c97cf7e239744dd1c
parenta76b443b75004565b59a2515c46920479f3b312f (diff)
downloadchrome-ec-25af2e9e8fa969b80dd3135c3a28b554bc05f5f7.tar.gz
TCPMv1: Remove cable discovery support
TCPMv1 cable discovery support has not been used for some time. Remove it to facilitate refactoring TBT and USB4 code. LOW_COVERAGE_REASON=TCPMv1 is known to be buggy but is deprecated; its behavior is hard to describe but should not be changed. BUG=b:244218024 TEST=make BOARD=careena; DP monitor behavior same as ToT BRANCH=none Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Change-Id: I6500f56418a860c343e8159f33151e765512067c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3887962 Reviewed-by: Diana Z <dzigterman@chromium.org> Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
-rw-r--r--common/usb_pd_policy.c74
-rw-r--r--common/usb_pd_protocol.c89
2 files changed, 10 insertions, 153 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index d39aaf4172..c63cde6301 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -102,58 +102,6 @@ uint8_t pd_get_src_cap_cnt(int port)
return pd_src_cap_cnt[port];
}
-static struct pd_cable cable[CONFIG_USB_PD_PORT_MAX_COUNT];
-
-enum pd_rev_type get_usb_pd_cable_revision(int port)
-{
- return cable[port].rev;
-}
-
-bool consume_sop_prime_repeat_msg(int port, uint8_t msg_id)
-{
- if (cable[port].last_sop_p_msg_id != msg_id) {
- cable[port].last_sop_p_msg_id = msg_id;
- return false;
- }
- CPRINTF("C%d SOP Prime repeat msg_id %d\n", port, msg_id);
- return true;
-}
-
-bool consume_sop_prime_prime_repeat_msg(int port, uint8_t msg_id)
-{
- if (cable[port].last_sop_p_p_msg_id != msg_id) {
- cable[port].last_sop_p_p_msg_id = msg_id;
- return false;
- }
- CPRINTF("C%d SOP Prime Prime repeat msg_id %d\n", port, msg_id);
- return true;
-}
-
-__maybe_unused static uint8_t is_sop_prime_ready(int port)
-{
- /*
- * Ref: USB PD 3.0 sec 2.5.4: When an Explicit Contract is in place the
- * VCONN Source (either the DFP or the UFP) can communicate with the
- * Cable Plug(s) using SOP’/SOP’’ Packets
- *
- * Ref: USB PD 2.0 sec 2.4.4: When an Explicit Contract is in place the
- * DFP (either the Source or the Sink) can communicate with the
- * Cable Plug(s) using SOP’/SOP” Packets.
- * Sec 3.6.11 : Before communicating with a Cable Plug a Port Should
- * ensure that it is the Vconn Source
- */
- return (pd_get_vconn_state(port) &&
- (IS_ENABLED(CONFIG_USB_PD_REV30) ||
- (pd_get_data_role(port) == PD_ROLE_DFP)));
-}
-
-void reset_pd_cable(int port)
-{
- memset(&cable[port], 0, sizeof(cable[port]));
- cable[port].last_sop_p_msg_id = INVALID_MSG_ID_COUNTER;
- cable[port].last_sop_p_p_msg_id = INVALID_MSG_ID_COUNTER;
-}
-
#ifdef CONFIG_USB_PD_ALT_MODE
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
@@ -235,15 +183,6 @@ static int process_am_discover_ident_sop(int port, int cnt, uint32_t head,
return dfp_discover_svids(payload);
}
-static int process_am_discover_ident_sop_prime(int port, int cnt, uint32_t head,
- uint32_t *payload)
-{
- dfp_consume_identity(port, TCPCI_MSG_SOP_PRIME, cnt, payload);
- cable[port].rev = PD_HEADER_REV(head);
-
- return dfp_discover_svids(payload);
-}
-
static int process_am_discover_svids(int port, int cnt, uint32_t *payload,
enum tcpci_msg_type sop,
enum tcpci_msg_type *rtype)
@@ -341,15 +280,9 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload,
switch (cmd) {
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
case CMD_DISCOVER_IDENT:
- /* Received a SOP' Discover Ident msg */
- if (sop == TCPCI_MSG_SOP_PRIME) {
- rsize = process_am_discover_ident_sop_prime(
- port, cnt, head, payload);
- /* Received a SOP Discover Ident Message */
- } else {
- rsize = process_am_discover_ident_sop(
- port, cnt, head, payload, rtype);
- }
+ /* Received a SOP Discover Ident Message */
+ rsize = process_am_discover_ident_sop(port, cnt, head,
+ payload, rtype);
break;
case CMD_DISCOVER_SVID:
rsize = process_am_discover_svids(port, cnt, payload,
@@ -453,7 +386,6 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload,
rsize = 0;
}
} else if (cmd_type == CMDT_RSP_NAK) {
- /* Passive cable Nacked for Discover SVID */
rsize = 0;
#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
} else {
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 780cd6ce34..80d3b400da 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -367,9 +367,6 @@ int pd_get_rev(int port, enum tcpci_msg_type type)
/* TCPMv1 Only stores PD revision for SOP and SOP' types */
ASSERT(type < NUM_SOP_STAR_TYPES - 1);
- if (type == TCPCI_MSG_SOP_PRIME)
- return get_usb_pd_cable_revision(port);
-
return pd[port].rev;
#else
return PD_REV20;
@@ -379,9 +376,6 @@ int pd_get_rev(int port, enum tcpci_msg_type type)
int pd_get_vdo_ver(int port, enum tcpci_msg_type type)
{
#ifdef CONFIG_USB_PD_REV30
- if (type == TCPCI_MSG_SOP_PRIME)
- return vdo_ver[get_usb_pd_cable_revision(port)];
-
return vdo_ver[pd[port].rev];
#else
return VDM_VER10;
@@ -691,24 +685,15 @@ static bool consume_sop_repeat_message(int port, uint8_t msg_id)
* @param port USB PD TCPC port number
* @param msg_header Message Header containing the RX message ID
* @return True if the received message is a duplicate one, False otherwise.
- *
- * From USB PD version 1.3 section 6.7.1, the port which communicates
- * using SOP* Packets Shall maintain copies of the last MessageID for
- * each type of SOP* it uses.
*/
static bool consume_repeat_message(int port, uint32_t msg_header)
{
uint8_t msg_id = PD_HEADER_ID(msg_header);
- enum tcpci_msg_type sop = PD_HEADER_GET_SOP(msg_header);
/* If repeat message ignore, except softreset control request. */
if (PD_HEADER_TYPE(msg_header) == PD_CTRL_SOFT_RESET &&
PD_HEADER_CNT(msg_header) == 0) {
return false;
- } else if (sop == TCPCI_MSG_SOP_PRIME) {
- return consume_sop_prime_repeat_msg(port, msg_id);
- } else if (sop == TCPCI_MSG_SOP_PRIME_PRIME) {
- return consume_sop_prime_prime_repeat_msg(port, msg_id);
} else {
return consume_sop_repeat_message(port, msg_id);
}
@@ -806,7 +791,6 @@ static inline void set_state(int port, enum pd_states next_state)
if (last_state != PD_STATE_SNK_DISCONNECTED_DEBOUNCE &&
last_state != PD_STATE_SRC_DISCONNECTED_DEBOUNCE) {
pd[port].flags &= ~PD_FLAGS_RESET_ON_DISCONNECT_MASK;
- reset_pd_cable(port);
}
/* Clear the input current limit */
@@ -2141,7 +2125,6 @@ static void pd_vdm_send_state_machine(int port)
{
int res;
uint16_t header;
- enum tcpci_msg_type msg_type = pd[port].xmit_type;
switch (pd[port].vdm_state) {
case VDM_STATE_READY:
@@ -2158,63 +2141,13 @@ static void pd_vdm_send_state_machine(int port)
if (pdo_busy(port))
break;
- /*
- * To communicate with the cable plug, an explicit contract
- * should be established, VCONN should be enabled and data role
- * that can communicate with the cable plug should be in place.
- * For USB3.0, UFP/DFP can communicate whereas in case of
- * USB2.0 only DFP can talk to the cable plug.
- *
- * For communication between USB2.0 UFP and cable plug,
- * data role swap takes place during source and sink
- * negotiation and in case of failure, a soft reset is issued.
- */
- if ((msg_type == TCPCI_MSG_SOP_PRIME) ||
- (msg_type == TCPCI_MSG_SOP_PRIME_PRIME)) {
- /* Prepare SOP'/SOP'' header and send VDM */
- header = PD_HEADER(PD_DATA_VENDOR_DEF,
- PD_PLUG_FROM_DFP_UFP, 0,
- pd[port].msg_id,
- (int)pd[port].vdo_count,
- pd_get_rev(port, TCPCI_MSG_SOP), 0);
- res = pd_transmit(port, msg_type, header,
- pd[port].vdo_data, AMS_START);
- /*
- * In the case of SOP', if there is no response from
- * the cable, it's a non-emark cable and therefore the
- * pd flow should continue irrespective of cable
- * response, sending discover_identity so the pd flow
- * remains intact.
- *
- * In the case of SOP'', if there is no response from
- * the cable, exit Thunderbolt-Compatible mode
- * discovery, reset the mux state since, the mux will
- * be set to a safe state before entering
- * Thunderbolt-Compatible mode and enter the default
- * mode.
- */
- if (res < 0) {
- header = PD_HEADER(
- PD_DATA_VENDOR_DEF, pd[port].power_role,
- pd[port].data_role, pd[port].msg_id,
- (int)pd[port].vdo_count,
- pd_get_rev(port, TCPCI_MSG_SOP), 0);
- pd[port].vdo_data[0] =
- VDO(USB_SID_PD, 1, CMD_DISCOVER_SVID);
- res = pd_transmit(port, TCPCI_MSG_SOP, header,
- pd[port].vdo_data, AMS_START);
- reset_pd_cable(port);
- }
- } else {
- /* Prepare SOP header and send VDM */
- header = PD_HEADER(PD_DATA_VENDOR_DEF,
- pd[port].power_role,
- pd[port].data_role, pd[port].msg_id,
- (int)pd[port].vdo_count,
- pd_get_rev(port, TCPCI_MSG_SOP), 0);
- res = pd_transmit(port, TCPCI_MSG_SOP, header,
- pd[port].vdo_data, AMS_START);
- }
+ /* Prepare SOP header and send VDM */
+ header = PD_HEADER(PD_DATA_VENDOR_DEF, pd[port].power_role,
+ pd[port].data_role, pd[port].msg_id,
+ (int)pd[port].vdo_count,
+ pd_get_rev(port, TCPCI_MSG_SOP), 0);
+ res = pd_transmit(port, TCPCI_MSG_SOP, header,
+ pd[port].vdo_data, AMS_START);
if (res < 0) {
pd[port].vdm_state = VDM_STATE_ERR_SEND;
@@ -3378,8 +3311,6 @@ void pd_task(void *u)
set_state(port, PD_STATE_SRC_STARTUP);
break;
case PD_STATE_SRC_STARTUP:
- /* Reset cable attributes and flags */
- reset_pd_cable(port);
/* Wait for power source to enable */
if (pd[port].last_state != pd[port].task_state) {
pd[port].flags |= PD_FLAGS_CHECK_IDENTITY;
@@ -3954,9 +3885,6 @@ void pd_task(void *u)
pd[port].flags |= PD_FLAGS_CHECK_PR_ROLE |
PD_FLAGS_CHECK_DR_ROLE |
PD_FLAGS_CHECK_IDENTITY;
- /* Reset cable attributes and flags */
- reset_pd_cable(port);
-
if (new_cc_state == PD_CC_DFP_DEBUG_ACC)
pd[port].flags |=
PD_FLAGS_TS_DTS_PARTNER;
@@ -4783,8 +4711,6 @@ static void pd_chipset_startup(void)
for (i = 0; i < board_get_usb_pd_port_count(); i++) {
pd_set_dual_role_no_wakeup(i, PD_DRP_TOGGLE_OFF);
pd[i].flags |= PD_FLAGS_CHECK_IDENTITY;
- /* Reset cable attributes and flags */
- reset_pd_cable(i);
task_set_event(PD_PORT_TO_TASK_ID(i),
PD_EVENT_POWER_STATE_CHANGE |
PD_EVENT_UPDATE_DUAL_ROLE);
@@ -5310,5 +5236,4 @@ DECLARE_HOST_COMMAND(EC_CMD_USB_PD_FW_UPDATE, hc_remote_flash, EC_VER_MASK(0));
#endif /* CONFIG_HOSTCMD_FLASHPD */
#endif /* HAS_TASK_HOSTCMD */
-
#endif /* CONFIG_COMMON_RUNTIME */