From 30a9f90a098be3514beea0ed4238252c63d93c51 Mon Sep 17 00:00:00 2001 From: Diana Z Date: Wed, 11 Nov 2020 16:53:12 -0700 Subject: TCPMv2: Always probe sink caps This commit adds the ability to always probe the partner for sink capabilities, and re-names the state to reflect that sources may use it now too. This also fixes some issues in the state to get sink capabilities, including correcting the message detection and soft resetting with the SOP* of the unexpected message. This also updates the unit tests to expect a Get_Sink_Caps message as a part of typical startup. BRANCH=None BUG=b:168862110,b:160009733 TEST=on drawcia, observe sink caps are requested from source and sink partners Signed-off-by: Diana Z Change-Id: I5da3adc17ccec71f6cad9e8f152b9570ec99691d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2540389 Reviewed-by: Keith Short --- test/usb_pe_drp.c | 17 +++++++++++++++++ test/usb_tcpmv2_tcpci.c | 12 ++++++++++++ 2 files changed, 29 insertions(+) (limited to 'test') diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c index f780834612..f5ced4c7b1 100644 --- a/test/usb_pe_drp.c +++ b/test/usb_pe_drp.c @@ -102,6 +102,23 @@ test_static int test_send_caps_error(void) fake_prl_message_received(PORT0); task_wait_event(200 * MSEC); + /* + * Expect GET_SINK_CAP, reply with a simple Sink Cap since sink partners + * must support this message. + */ + TEST_EQ(fake_prl_get_last_sent_ctrl_msg(PORT0), + PD_CTRL_GET_SINK_CAP, "%d"); + fake_prl_message_sent(PORT0); + task_wait_event(10 * MSEC); + rx_emsg[PORT0].header = PD_HEADER(PD_DATA_SINK_CAP, PD_ROLE_SINK, + PD_ROLE_UFP, 2, + 1, PD_REV30, 0); + rx_emsg[PORT0].len = 4; + *(uint32_t *)rx_emsg[PORT0].buf = PDO_FIXED(5000, 500, + PDO_FIXED_COMM_CAP); + fake_prl_message_received(PORT0); + task_wait_event(200 * MSEC); + /* * Now connected. Send GET_SOURCE_CAP, to check how error sending * SOURCE_CAP is handled. diff --git a/test/usb_tcpmv2_tcpci.c b/test/usb_tcpmv2_tcpci.c index 960cb9ff0f..c032c472a2 100644 --- a/test/usb_tcpmv2_tcpci.c +++ b/test/usb_tcpmv2_tcpci.c @@ -244,6 +244,18 @@ __maybe_unused static int test_connect_as_pd3_source(void) rx_id++; mock_set_alert(TCPC_REG_ALERT_RX_STATUS); + 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); + mock_tcpci_receive(PD_MSG_SOP, + PD_HEADER(PD_DATA_SINK_CAP, PD_ROLE_SINK, + PD_ROLE_UFP, rx_id, + 1, PD_REV30, 0), + &pdo); + rx_id++; + mock_set_alert(TCPC_REG_ALERT_RX_STATUS); + 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)), -- cgit v1.2.1