summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2020-06-29 13:14:43 -0600
committerCommit Bot <commit-bot@chromium.org>2020-07-10 22:21:58 +0000
commit23ea3fbd4a6e52b8a54f4278bbed8975af34cca7 (patch)
tree84b8b0ee67f7fdbb9d9ad44695ed7659439c7c06 /test
parent0f713b36be38449cddea2196d1a135d7bdcfb82a (diff)
downloadchrome-ec-23ea3fbd4a6e52b8a54f4278bbed8975af34cca7.tar.gz
tcpmv2: perform partner reset on startup, remove BBRAM
- Reset the port partner by applying CC Open on both CC lines - Reuse the existing error recovery state to apply CC values - Extend error recovery timer to 240 msec to account for us being able to source Vconn - Since we always reset on startup, we don't need to store previous contracts in BBRAM. BRANCH=none BUG=b:159495742,b:158802939 TEST=see that we apply CC Open upon reset TEST=see that we do not get a fault on Trembyle went setting CC open TEST=apple 3-1 dongle with display port and power on Puff will come back with power and display after a `reboot` EC command (which will trigger the ErrorRecovery brownout path) Signed-off-by: Jett Rink <jettrink@chromium.org> Change-Id: Iaac09d62e4a31557492cebb354d3a34371c1e9bb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2271002 Reviewed-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/usb_typec_drp_acc_trysrc.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/usb_typec_drp_acc_trysrc.c b/test/usb_typec_drp_acc_trysrc.c
index fbaa8018aa..9c47bedbf0 100644
--- a/test/usb_typec_drp_acc_trysrc.c
+++ b/test/usb_typec_drp_acc_trysrc.c
@@ -7,6 +7,7 @@
#include "charge_manager.h"
#include "mock/tcpc_mock.h"
#include "mock/usb_mux_mock.h"
+#include "system.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -600,6 +601,65 @@ __maybe_unused static int test_try_src_partner_does_not_switch_no_vbus(void)
return EC_SUCCESS;
}
+/* Record the cc voltages */
+static enum tcpc_cc_pull cc_pull[16];
+static int cc_pull_count;
+static int record_cc_pull(int port, int pull)
+{
+ if (cc_pull_count < ARRAY_SIZE(cc_pull))
+ cc_pull[cc_pull_count++] = pull;
+
+ return EC_SUCCESS;
+};
+
+__maybe_unused static int test_cc_open_on_normal_reset(void)
+{
+ uint32_t flags = system_get_reset_flags();
+
+ cc_pull_count = 0;
+ mock_tcpc.callbacks.set_cc = &record_cc_pull;
+
+ system_clear_reset_flags(EC_RESET_FLAG_POWER_ON);
+
+ task_set_event(TASK_ID_PD_C0, TASK_EVENT_RESET_DONE, 0);
+ task_wait_event(SECOND * 10);
+
+ /* Ensure that the first CC set call was to open (error recovery). */
+ TEST_GT(cc_pull_count, 0, "%d");
+ TEST_EQ(cc_pull[0], TYPEC_CC_OPEN, "%d");
+
+ /* Ensure that the second CC set call was to Rd (sink) */
+ TEST_GT(cc_pull_count, 1, "%d");
+ TEST_EQ(cc_pull[1], TYPEC_CC_RD, "%d");
+
+ /* Reset system flags after test */
+ system_set_reset_flags(flags);
+
+ return EC_SUCCESS;
+}
+
+__maybe_unused static int test_cc_rd_on_por_reset(void)
+{
+ uint32_t flags = system_get_reset_flags();
+
+ cc_pull_count = 0;
+ mock_tcpc.callbacks.set_cc = &record_cc_pull;
+
+ system_set_reset_flags(EC_RESET_FLAG_POWER_ON);
+
+ task_set_event(TASK_ID_PD_C0, TASK_EVENT_RESET_DONE, 0);
+ task_wait_event(SECOND * 10);
+
+ /* Ensure that the first CC set call was to Rd (sink) */
+ TEST_GT(cc_pull_count, 0, "%d");
+ TEST_EQ(cc_pull[0], TYPEC_CC_RD, "%d");
+
+ /* Reset system flags after test */
+ system_clear_reset_flags(~flags);
+
+ return EC_SUCCESS;
+}
+
/* TODO(b/153071799): test as SNK monitor for Vbus disconnect (not CC line) */
/* TODO(b/153071799): test as SRC monitor for CC line state change */
@@ -646,6 +706,9 @@ void run_test(int argc, char **argv)
RUN_TEST(test_try_src_partner_does_not_switch_vbus);
RUN_TEST(test_try_src_partner_does_not_switch_no_vbus);
+ RUN_TEST(test_cc_open_on_normal_reset);
+ RUN_TEST(test_cc_rd_on_por_reset);
+
/* Do basic state machine sanity checks last. */
RUN_TEST(test_tc_no_parent_cycles);
RUN_TEST(test_tc_no_empty_state);