From 74108a6ab365a110d70b4064ec2d99fa7ea9b73e Mon Sep 17 00:00:00 2001 From: Daisuke Nojiri Date: Thu, 23 Feb 2023 15:04:48 -0800 Subject: USB-PD: Make sink automatically enter EPR mode Currently, EPR mode is entered only by 'pd' console command. This CL makes sink ports enter EPR mode automatically. PE_FLAGS_EPR_EXPLICIT_EXIT is cleared when soft reset is sent, a source is disconnected, or EPR is entered again. BUG=b:257320026,b:274929940 BRANCH=None TEST=On Agah, plug AC, observe automatic entry to EPR. Then type 'pd 1 epr exit' and observe EPR mode is not re-entered. Then replug AC and observe the port enters EPR automatically. TEST=make run-usb_pd_console Signed-off-by: Daisuke Nojiri Change-Id: Ie2b94323ba404d44ee70756e1893c065c34911fd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4421425 Reviewed-by: Eric Yilun Lin --- test/usb_pd_console.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/usb_pd_console.c b/test/usb_pd_console.c index a835a643f8..119fe7131d 100644 --- a/test/usb_pd_console.c +++ b/test/usb_pd_console.c @@ -35,6 +35,7 @@ static bool pe_get_current_state_called; static bool pe_get_flags_called; static bool pe_is_explicit_contract_called; static bool pe_snk_in_epr_mode_called; +static bool pe_snk_epr_explicit_exit_called; static bool pd_get_dual_role_called; static bool board_get_usb_pd_port_count_called; static bool pd_srccaps_dump_called; @@ -86,6 +87,11 @@ bool pe_snk_in_epr_mode(int port) return true; } +void pe_snk_epr_explicit_exit(int port) +{ + pe_snk_epr_explicit_exit_called = true; +} + const char *pe_get_current_state(int port) { pe_get_current_state_called = true; @@ -726,18 +732,22 @@ static int test_command_pd_epr(void) request = 0; pd_get_power_role_called = false; pd_get_power_role_return = PD_ROLE_SINK; + pe_snk_epr_explicit_exit_called = false; TEST_ASSERT(command_pd(argc, argv) == EC_SUCCESS); TEST_ASSERT(pd_get_power_role_called); TEST_ASSERT(request == DPM_REQUEST_EPR_MODE_ENTRY); + TEST_ASSERT(!pe_snk_epr_explicit_exit_called); /* Return SUCCESS with request==DPM_REQUEST_EPR_MODE_EXIT. */ argv[3] = "exit"; request = 0; pd_get_power_role_called = false; pd_get_power_role_return = PD_ROLE_SINK; + pe_snk_epr_explicit_exit_called = false; TEST_ASSERT(command_pd(argc, argv) == EC_SUCCESS); TEST_ASSERT(pd_get_power_role_called); TEST_ASSERT(request == DPM_REQUEST_EPR_MODE_EXIT); + TEST_ASSERT(pe_snk_epr_explicit_exit_called); /* Return EC_ERROR_PARAM3 for invalid sub-command. */ argv[3] = "start"; -- cgit v1.2.1