summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2020-12-28 11:42:29 -0700
committerCommit Bot <commit-bot@chromium.org>2020-12-29 16:53:12 +0000
commit96a7fefe36e701638616d69366eb9a5f093caa55 (patch)
treef4ac323a1fbea12f9d86c130b130d474ba81a144 /test
parentc33ab2439a46ea70b0647078bea940821a3a1b5c (diff)
downloadchrome-ec-96a7fefe36e701638616d69366eb9a5f093caa55.tar.gz
TCPMv2: Compliance Unit Test - cleanup common code
PROC.PD.E1 and PROC.PD.E3 used common code that was also peppered through out some of the tests. Make a common copy that they can all use. BUG=b:176249915 BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I82505fa8ac61db2ee941f2a236a22bdf3e69ae2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2604562 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Keith Short <keithshort@chromium.org> Commit-Queue: Keith Short <keithshort@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/usb_tcpmv2_compliance.h8
-rw-r--r--test/usb_tcpmv2_compliance_common.c225
-rw-r--r--test/usb_tcpmv2_td_pd_ll_e3.c97
-rw-r--r--test/usb_tcpmv2_td_pd_ll_e4.c97
-rw-r--r--test/usb_tcpmv2_td_pd_snk3_e12.c2
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e26.c2
6 files changed, 164 insertions, 267 deletions
diff --git a/test/usb_tcpmv2_compliance.h b/test/usb_tcpmv2_compliance.h
index 1426b9f825..99a614edf2 100644
--- a/test/usb_tcpmv2_compliance.h
+++ b/test/usb_tcpmv2_compliance.h
@@ -60,7 +60,13 @@ void partner_send_msg(enum pd_msg_type sop,
uint16_t ext,
uint32_t *payload);
-int proc_pd_e1(enum pd_data_role data_role);
+
+int handle_attach_expected_msgs(enum pd_data_role data_role);
+
+
+#define INITIAL_ATTACH true
+#define ALREADY_ATTACHED false
+int proc_pd_e1(enum pd_data_role data_role, bool initial_attach);
int proc_pd_e3(void);
int test_td_pd_ll_e3_dfp(void);
diff --git a/test/usb_tcpmv2_compliance_common.c b/test/usb_tcpmv2_compliance_common.c
index ea6babf921..11d68164d3 100644
--- a/test/usb_tcpmv2_compliance_common.c
+++ b/test/usb_tcpmv2_compliance_common.c
@@ -165,61 +165,92 @@ int tcpci_startup(void)
TEST_EQ(mock_tcpci_get_reg(TCPC_REG_COMMAND),
TCPC_REG_COMMAND_I2CIDLE, "%d");
+ /* TODO: this should be performed in TCPCI mock on startup but needs
+ * more TCPCI functionality added before that can happen. So until
+ * that time, if the FAULT register is set, send the alert here.
+ */
+ if (mock_tcpci_get_reg(TCPC_REG_FAULT_STATUS))
+ mock_set_alert(TCPC_REG_ALERT_FAULT);
+
return EC_SUCCESS;
}
/*****************************************************************************
* PROC.PD.E1. Bring-up procedure
*/
-int proc_pd_e1(enum pd_data_role data_role)
+int proc_pd_e1(enum pd_data_role data_role, bool initial_attach)
{
- /*
- * a) The test starts in a disconnected state.
- */
- mock_tcpci_set_reg(TCPC_REG_EXT_STATUS, TCPC_REG_EXT_STATUS_SAFE0V);
- mock_set_alert(TCPC_REG_ALERT_EXT_STATUS);
- task_wait_event(10 * SECOND);
- TEST_EQ(pd_get_data_role(I2C_PORT_HOST_TCPC),
- PD_ROLE_DISCONNECTED, "%d");
-
- switch (data_role) {
- case PD_ROLE_UFP:
+ if (initial_attach) {
/*
- * b) The tester applies Rp (PD3=1.5A, PD2=3A) and waits for
- * the UUT attachment.
+ * a) The test starts in a disconnected state.
*/
- mock_set_cc(MOCK_CC_DUT_IS_SNK,
- MOCK_CC_SNK_OPEN,
- (partner_get_pd_rev() == PD_REV30 ?
- MOCK_CC_SNK_RP_1_5 : MOCK_CC_SNK_RP_3_0));
- mock_set_alert(TCPC_REG_ALERT_CC_STATUS);
- task_wait_event(5 * MSEC);
-
- partner_set_data_role(PD_ROLE_DFP);
- partner_set_power_role(PD_ROLE_SOURCE);
-
- /*
- * c) If Ra is detected, the tester applies Vconn.
- */
-
- /*
- * d) The tester applies Vbus and waits 50 ms.
- */
- mock_tcpci_set_reg_bits(TCPC_REG_POWER_STATUS,
+ mock_tcpci_set_reg(TCPC_REG_EXT_STATUS,
+ TCPC_REG_EXT_STATUS_SAFE0V);
+ mock_set_alert(TCPC_REG_ALERT_EXT_STATUS);
+ task_wait_event(10 * SECOND);
+ TEST_EQ(pd_get_data_role(I2C_PORT_HOST_TCPC),
+ PD_ROLE_DISCONNECTED, "%d");
+
+ partner_set_data_role((data_role == PD_ROLE_UFP)
+ ? PD_ROLE_DFP
+ : PD_ROLE_UFP);
+
+ partner_set_power_role((data_role == PD_ROLE_UFP)
+ ? PD_ROLE_SOURCE
+ : PD_ROLE_SINK);
+
+ switch (partner_get_power_role()) {
+ case PD_ROLE_SOURCE:
+ /*
+ * b) The tester applies Rp (PD3=1.5A, PD2=3A) and
+ * waits for the UUT attachment.
+ */
+ mock_set_cc(MOCK_CC_DUT_IS_SNK,
+ MOCK_CC_SNK_OPEN,
+ (partner_get_pd_rev() == PD_REV30
+ ? MOCK_CC_SNK_RP_1_5
+ : MOCK_CC_SNK_RP_3_0));
+ mock_set_alert(TCPC_REG_ALERT_CC_STATUS);
+ task_wait_event(5 * MSEC);
+
+ /*
+ * c) If Ra is detected, the tester applies Vconn.
+ */
+
+ /*
+ * d) The tester applies Vbus and waits 50 ms.
+ */
+ mock_tcpci_set_reg_bits(TCPC_REG_POWER_STATUS,
TCPC_REG_POWER_STATUS_VBUS_PRES);
- mock_tcpci_clr_reg_bits(TCPC_REG_EXT_STATUS,
+ mock_tcpci_clr_reg_bits(TCPC_REG_EXT_STATUS,
TCPC_REG_EXT_STATUS_SAFE0V);
- mock_set_alert(TCPC_REG_ALERT_EXT_STATUS |
- TCPC_REG_ALERT_POWER_STATUS);
-
- task_wait_event(50 * MSEC);
+ mock_set_alert(TCPC_REG_ALERT_EXT_STATUS |
+ TCPC_REG_ALERT_POWER_STATUS);
+ task_wait_event(50 * MSEC);
+ break;
+
+ case PD_ROLE_SINK:
+ /*
+ * b) The tester applies Rd and waits for Vbus for
+ * tNoResponse max (5.5 s).
+ */
+ mock_set_cc(MOCK_CC_DUT_IS_SRC,
+ MOCK_CC_SRC_OPEN,
+ MOCK_CC_SRC_RD);
+ mock_set_alert(TCPC_REG_ALERT_CC_STATUS);
+ break;
+ }
+ }
+ switch (partner_get_power_role()) {
+ case PD_ROLE_SOURCE:
/*
* e) The tester transmits Source Capabilities until reception
* of GoodCrc for tNoResponse max (5.5s). The Source
* Capabilities includes Fixed 5V 3A PDO.
*/
+ task_wait_event(1 * MSEC);
partner_send_msg(PD_MSG_SOP, PD_DATA_SOURCE_CAP, 1, 0, &pdo);
/*
@@ -238,21 +269,11 @@ int proc_pd_e1(enum pd_data_role data_role)
task_wait_event(10 * MSEC);
partner_send_msg(PD_MSG_SOP, PD_CTRL_PS_RDY, 0, 0, NULL);
task_wait_event(1 * MSEC);
- break;
-
- case PD_ROLE_DFP:
- /*
- * b) The tester applies Rd and waits for Vbus for tNoResponse
- * max (5.5 s).
- */
- mock_set_cc(MOCK_CC_DUT_IS_SRC,
- MOCK_CC_SRC_OPEN,
- MOCK_CC_SRC_RD);
- mock_set_alert(TCPC_REG_ALERT_CC_STATUS);
- partner_set_data_role(PD_ROLE_UFP);
- partner_set_power_role(PD_ROLE_SINK);
+ TEST_EQ(tc_is_attached_snk(PORT0), true, "%d");
+ break;
+ case PD_ROLE_SINK:
/*
* c) The tester waits Source Capabilities for for tNoResponse
* max (5.5 s).
@@ -284,13 +305,14 @@ int proc_pd_e1(enum pd_data_role data_role)
TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_PS_RDY, 0),
EC_SUCCESS, "%d");
mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- break;
+ task_wait_event(1 * MSEC);
- case PD_ROLE_DISCONNECTED:
+ TEST_EQ(tc_is_attached_src(PORT0), true, "%d");
break;
}
- TEST_EQ(pd_get_data_role(I2C_PORT_HOST_TCPC), data_role, "%d");
+ TEST_EQ(pd_get_data_role(I2C_PORT_HOST_TCPC),
+ data_role, "%d");
return EC_SUCCESS;
}
@@ -300,37 +322,17 @@ int proc_pd_e1(enum pd_data_role data_role)
int proc_pd_e3(void)
{
/*
+ * Make sure we are idle. Reject everything that is pending
+ */
+ TEST_EQ(handle_attach_expected_msgs(PD_ROLE_DFP), EC_SUCCESS, "%d");
+
+ /*
* PROC.PD.E3. Wait to Start AMS for DFP(Source) UUT:
* a) The Tester keeps monitoring the Rp value and if the UUT doesn't
* set the value to SinkTXOK if it doesn't have anything to send in 1s,
* the test fails. During this period, the Tester replies any message
* sent from the UUT with a proper response.
*/
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP_PRIME, 0, PD_DATA_VENDOR_DEF),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP_PRIME, PD_CTRL_NOT_SUPPORTED, 0, 0, NULL);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0, PD_DATA_VENDOR_DEF),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_NOT_SUPPORTED, 0, 0, NULL);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_GET_SOURCE_CAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SOURCE_CAP, 1, 0, &pdo);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_GET_SINK_CAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SINK_CAP, 1, 0, &pdo);
-
- task_wait_event(1 * SECOND);
TEST_EQ(tc_is_attached_src(PORT0), true, "%d");
TEST_EQ(TCPC_REG_ROLE_CTRL_RP(mock_tcpci_get_reg(TCPC_REG_ROLE_CTRL)),
SINK_TX_OK, "%d");
@@ -338,3 +340,70 @@ int proc_pd_e3(void)
task_wait_event(10 * SECOND);
return EC_SUCCESS;
}
+
+/*****************************************************************************
+ * handle_attach_expected_msgs
+ *
+ * Depending on the data role, the DUT will send a sequence of messages on
+ * attach. Most of these can be rejected.
+ */
+int handle_attach_expected_msgs(enum pd_data_role data_role)
+{
+ if (data_role == PD_ROLE_DFP) {
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP_PRIME, 0,
+ PD_DATA_VENDOR_DEF),
+ EC_SUCCESS, "%d");
+ mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ task_wait_event(10 * MSEC);
+ partner_send_msg(PD_MSG_SOP_PRIME, PD_CTRL_NOT_SUPPORTED, 0, 0,
+ NULL);
+
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0,
+ PD_DATA_VENDOR_DEF),
+ EC_SUCCESS, "%d");
+ mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ task_wait_event(10 * MSEC);
+ partner_send_msg(PD_MSG_SOP, PD_CTRL_NOT_SUPPORTED, 0, 0, NULL);
+
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
+ PD_CTRL_GET_SOURCE_CAP, 0),
+ EC_SUCCESS, "%d");
+ mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ task_wait_event(10 * MSEC);
+ partner_send_msg(PD_MSG_SOP, PD_DATA_SOURCE_CAP, 1, 0, &pdo);
+
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
+ PD_CTRL_GET_SINK_CAP, 0),
+ EC_SUCCESS, "%d");
+ mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ task_wait_event(10 * MSEC);
+ partner_send_msg(PD_MSG_SOP, PD_DATA_SINK_CAP, 1, 0, &pdo);
+ } else if (data_role == PD_ROLE_UFP) {
+ int vcs;
+
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_DR_SWAP, 0),
+ EC_SUCCESS, "%d");
+ mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ task_wait_event(10 * MSEC);
+ partner_send_msg(PD_MSG_SOP, PD_CTRL_REJECT, 0, 0, NULL);
+
+ for (vcs = 0; vcs < 4; vcs++) {
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
+ PD_CTRL_VCONN_SWAP, 0),
+ EC_SUCCESS, "%d");
+ mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ task_wait_event(10 * MSEC);
+ partner_send_msg(PD_MSG_SOP, PD_CTRL_REJECT, 0, 0,
+ NULL);
+ }
+
+ TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
+ PD_CTRL_GET_SINK_CAP, 0),
+ EC_SUCCESS, "%d");
+ mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ task_wait_event(10 * MSEC);
+ partner_send_msg(PD_MSG_SOP, PD_DATA_SINK_CAP, 1, 0, &pdo);
+ }
+ task_wait_event(1 * SECOND);
+ return EC_SUCCESS;
+}
diff --git a/test/usb_tcpmv2_td_pd_ll_e3.c b/test/usb_tcpmv2_td_pd_ll_e3.c
index 155312bf0f..c2f1474acf 100644
--- a/test/usb_tcpmv2_td_pd_ll_e3.c
+++ b/test/usb_tcpmv2_td_pd_ll_e3.c
@@ -9,6 +9,7 @@
#include "test_util.h"
#include "timer.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
/*****************************************************************************
* TD.PD.LL.E3. Soft Reset Usage
@@ -28,69 +29,12 @@ static int td_pd_ll_e3(enum pd_data_role data_role)
/*
* a) Run PROC.PD.E1 Bring-up according to the UUT role.
*/
- TEST_EQ(proc_pd_e1(data_role), EC_SUCCESS, "%d");
+ TEST_EQ(proc_pd_e1(data_role, INITIAL_ATTACH), EC_SUCCESS, "%d");
/*
* Make sure we are idle. Reject everything that is pending
*/
- if (data_role == PD_ROLE_DFP) {
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP_PRIME, 0,
- PD_DATA_VENDOR_DEF),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP_PRIME, PD_CTRL_NOT_SUPPORTED, 0, 0,
- NULL);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0,
- PD_DATA_VENDOR_DEF),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_NOT_SUPPORTED, 0, 0, NULL);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- PD_CTRL_GET_SOURCE_CAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SOURCE_CAP, 1, 0, &pdo);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- PD_CTRL_GET_SINK_CAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SINK_CAP, 1, 0, &pdo);
- } else if (data_role == PD_ROLE_UFP) {
- int vcs;
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_DR_SWAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_REJECT, 0, 0, NULL);
-
- for (vcs = 0; vcs < 4; vcs++) {
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- PD_CTRL_VCONN_SWAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_REJECT, 0, 0,
- NULL);
- }
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- PD_CTRL_GET_SINK_CAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SINK_CAP, 1, 0, &pdo);
- }
-
- /* Should be idle now. */
- task_wait_event(10 * SECOND);
+ TEST_EQ(handle_attach_expected_msgs(data_role), EC_SUCCESS, "%d");
/*
* b) Send a Get_Sink_Cap message to the UUT, wait for a reply
@@ -124,41 +68,8 @@ static int td_pd_ll_e3(enum pd_data_role data_role)
* e) Continue the bring-up procedure and check that the link is
* successfully established.
*/
- if (partner_get_power_role() == PD_ROLE_SINK) {
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- 0,
- PD_DATA_SOURCE_CAP),
- EC_SUCCESS, "%d");
-
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
-
- partner_send_msg(PD_MSG_SOP, PD_DATA_REQUEST, 1, 0, &rdo);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_ACCEPT, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_PS_RDY, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(5 * MSEC);
-
- partner_send_msg(PD_MSG_SOP, PD_CTRL_ACCEPT, 0, 0, NULL);
- task_wait_event(1 * MSEC);
- } else {
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SOURCE_CAP, 1, 0, &pdo);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0, PD_DATA_REQUEST),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ TEST_EQ(proc_pd_e1(data_role, ALREADY_ATTACHED), EC_SUCCESS, "%d");
- partner_send_msg(PD_MSG_SOP, PD_CTRL_ACCEPT, 0, 0, NULL);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_PS_RDY, 0, 0, NULL);
- task_wait_event(1 * MSEC);
- }
return EC_SUCCESS;
}
int test_td_pd_ll_e3_dfp(void)
diff --git a/test/usb_tcpmv2_td_pd_ll_e4.c b/test/usb_tcpmv2_td_pd_ll_e4.c
index e79714ed9d..2ef421f14f 100644
--- a/test/usb_tcpmv2_td_pd_ll_e4.c
+++ b/test/usb_tcpmv2_td_pd_ll_e4.c
@@ -9,6 +9,7 @@
#include "test_util.h"
#include "timer.h"
#include "usb_tcpmv2_compliance.h"
+#include "usb_tc_sm.h"
/*****************************************************************************
* TD.PD.LL.E4. Hard Reset Usage
@@ -30,69 +31,12 @@ static int td_pd_ll_e4(enum pd_data_role data_role)
/*
* a) Run PROC.PD.E1 Bring-up according to the UUT role.
*/
- TEST_EQ(proc_pd_e1(data_role), EC_SUCCESS, "%d");
+ TEST_EQ(proc_pd_e1(data_role, INITIAL_ATTACH), EC_SUCCESS, "%d");
/*
* Make sure we are idle. Reject everything that is pending
*/
- if (data_role == PD_ROLE_DFP) {
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP_PRIME, 0,
- PD_DATA_VENDOR_DEF),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP_PRIME, PD_CTRL_NOT_SUPPORTED, 0, 0,
- NULL);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0,
- PD_DATA_VENDOR_DEF),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_NOT_SUPPORTED, 0, 0, NULL);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- PD_CTRL_GET_SOURCE_CAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SOURCE_CAP, 1, 0, &pdo);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- PD_CTRL_GET_SINK_CAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SINK_CAP, 1, 0, &pdo);
- } else if (data_role == PD_ROLE_UFP) {
- int vcs;
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_DR_SWAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_REJECT, 0, 0, NULL);
-
- for (vcs = 0; vcs < 4; vcs++) {
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- PD_CTRL_VCONN_SWAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_REJECT, 0, 0,
- NULL);
- }
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- PD_CTRL_GET_SINK_CAP, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SINK_CAP, 1, 0, &pdo);
- }
-
- /* Should be idle now. */
- task_wait_event(10 * SECOND);
+ TEST_EQ(handle_attach_expected_msgs(data_role), EC_SUCCESS, "%d");
/*
* b) Send a Get_Sink_Cap message to the UUT, wait for a reply
@@ -133,41 +77,8 @@ static int td_pd_ll_e4(enum pd_data_role data_role)
* e) Do the bring-up procedure for Link tests and check that the link
* is successfully established.
*/
- if (partner_get_power_role() == PD_ROLE_SINK) {
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP,
- 0,
- PD_DATA_SOURCE_CAP),
- EC_SUCCESS, "%d");
-
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(10 * MSEC);
-
- partner_send_msg(PD_MSG_SOP, PD_DATA_REQUEST, 1, 0, &rdo);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_ACCEPT, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, PD_CTRL_PS_RDY, 0),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
- task_wait_event(5 * MSEC);
-
- partner_send_msg(PD_MSG_SOP, PD_CTRL_ACCEPT, 0, 0, NULL);
- task_wait_event(1 * MSEC);
- } else {
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_DATA_SOURCE_CAP, 1, 0, &pdo);
-
- TEST_EQ(verify_tcpci_transmit(TCPC_TX_SOP, 0, PD_DATA_REQUEST),
- EC_SUCCESS, "%d");
- mock_set_alert(TCPC_REG_ALERT_TX_SUCCESS);
+ TEST_EQ(proc_pd_e1(data_role, ALREADY_ATTACHED), EC_SUCCESS, "%d");
- partner_send_msg(PD_MSG_SOP, PD_CTRL_ACCEPT, 0, 0, NULL);
- task_wait_event(10 * MSEC);
- partner_send_msg(PD_MSG_SOP, PD_CTRL_PS_RDY, 0, 0, NULL);
- task_wait_event(1 * MSEC);
- }
return EC_SUCCESS;
}
int test_td_pd_ll_e4_dfp(void)
diff --git a/test/usb_tcpmv2_td_pd_snk3_e12.c b/test/usb_tcpmv2_td_pd_snk3_e12.c
index 2de58f915e..99334860ab 100644
--- a/test/usb_tcpmv2_td_pd_snk3_e12.c
+++ b/test/usb_tcpmv2_td_pd_snk3_e12.c
@@ -25,7 +25,7 @@ int test_td_pd_snk3_e12(void)
* a) Run PROC.PD.E1 Bring-up according to the UUT role.
*/
TEST_EQ(tcpci_startup(), EC_SUCCESS, "%d");
- TEST_EQ(proc_pd_e1(PD_ROLE_UFP), EC_SUCCESS, "%d");
+ TEST_EQ(proc_pd_e1(PD_ROLE_UFP, INITIAL_ATTACH), EC_SUCCESS, "%d");
/*
* b) The Tester keeps the Rp value as SinkTXNG and sends a
diff --git a/test/usb_tcpmv2_td_pd_src3_e26.c b/test/usb_tcpmv2_td_pd_src3_e26.c
index cd54ce82a5..9d0a557c78 100644
--- a/test/usb_tcpmv2_td_pd_src3_e26.c
+++ b/test/usb_tcpmv2_td_pd_src3_e26.c
@@ -26,7 +26,7 @@ int test_td_pd_src3_e26(void)
* b) The Tester waits until it can start an AMS (Run PROC.PD.E3)...
*/
TEST_EQ(tcpci_startup(), EC_SUCCESS, "%d");
- TEST_EQ(proc_pd_e1(PD_ROLE_DFP), EC_SUCCESS, "%d");
+ TEST_EQ(proc_pd_e1(PD_ROLE_DFP, INITIAL_ATTACH), EC_SUCCESS, "%d");
TEST_EQ(proc_pd_e3(), EC_SUCCESS, "%d");
/*