summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2023-02-09 16:12:12 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-02-13 22:08:44 +0000
commit13b898fbf00ed8aced0d9758c323a3cd58a8c6a0 (patch)
treefd574df365cfc6eac1dee177ffb546e4f3c956de /test
parent6a0c42bf25c153f53f6377f1c0b776286771bf2e (diff)
downloadchrome-ec-13b898fbf00ed8aced0d9758c323a3cd58a8c6a0.tar.gz
TCPMv2: Remove PE_FLAGS_VDM_SETUP_DONE
Remove a PE flag that is redundant with the discovery state. Update the discovery state where appropriate to keep it internally consistent. BUG=b:189353401 TEST=voxel: Attach TBT4 hub; verify discovery sequence BRANCH=none Change-Id: I8ea870271ee95eb1dd4633370f7e39ca789f1328 Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4237156 Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/usb_pe_drp_old.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/test/usb_pe_drp_old.c b/test/usb_pe_drp_old.c
index 4ea07c1ec9..c352760d1d 100644
--- a/test/usb_pe_drp_old.c
+++ b/test/usb_pe_drp_old.c
@@ -83,11 +83,40 @@ void pd_set_error_recovery(int port)
{
}
+/* Skip discovery (and the corresponding DRS and VCS sequences) by default. A
+ * test may enable this to allow those sequences to run.
+ */
+static bool discovery_enabled;
+
+__override bool port_discovery_dr_swap_policy(int port, enum pd_data_role dr,
+ bool dr_swap_flag)
+{
+ if (!discovery_enabled)
+ return false;
+
+ if (dr_swap_flag && dr == PD_ROLE_UFP)
+ return true;
+
+ return false;
+}
+
+__override bool port_discovery_vconn_swap_policy(int port, bool vconn_swap_flag)
+{
+ if (!discovery_enabled)
+ return false;
+
+ if (IS_ENABLED(CONFIG_USBC_VCONN) && vconn_swap_flag &&
+ !tc_is_vconn_src(port) && tc_check_vconn_swap(port))
+ return true;
+
+ return false;
+}
+
test_static void setup_source(void)
{
/* Start PE. */
task_wait_event(10 * MSEC);
- pe_set_flag(PORT0, PE_FLAGS_VDM_SETUP_DONE);
+ pd_disable_discovery(PORT0);
pe_set_flag(PORT0, PE_FLAGS_EXPLICIT_CONTRACT);
/* As long as we're hacking our way to ready, clear any DPM requests */
pe_clr_dpm_requests(PORT0);
@@ -103,7 +132,7 @@ test_static void setup_sink(void)
task_wait_event(10 * MSEC);
pd_comm_enable(PORT0, 1);
task_wait_event(10 * MSEC);
- pe_set_flag(PORT0, PE_FLAGS_VDM_SETUP_DONE);
+ pd_disable_discovery(PORT0);
pe_set_flag(PORT0, PE_FLAGS_EXPLICIT_CONTRACT);
/* As long as we're hacking our way to ready, clear any DPM requests */
pe_clr_dpm_requests(PORT0);
@@ -131,7 +160,7 @@ static int test_pe_frs(void)
* background tasks (ex. discovery) aren't running.
*/
tc_prs_src_snk_assert_rd(PORT0);
- pe_set_flag(PORT0, PE_FLAGS_VDM_SETUP_DONE);
+ pd_disable_discovery(PORT0);
pe_set_flag(PORT0, PE_FLAGS_EXPLICIT_CONTRACT);
pe_clr_dpm_requests(PORT0);
set_state_pe(PORT0, PE_SNK_READY);
@@ -332,6 +361,8 @@ test_static int test_prl_is_busy(enum pd_power_role pr)
{
int ready_state;
+ discovery_enabled = true;
+
if (pr == PD_ROLE_SOURCE)
ready_state = PE_SRC_READY;
else
@@ -363,6 +394,8 @@ test_static int test_prl_is_busy(enum pd_power_role pr)
*/
TEST_ASSERT(get_state_pe(PORT0) != ready_state);
+ discovery_enabled = false;
+
return EC_SUCCESS;
}