From 003ec08f8c67845ae8481d3fb4124555213b04c4 Mon Sep 17 00:00:00 2001 From: Abe Levkoy Date: Fri, 27 Aug 2021 15:21:39 -0600 Subject: TCPM: Rename enum tcpm_sop_type and its constants As a followup to CL:3104290, give the TCPCI TRANSMIT and RX_BUF_FRAME_TYPE types more consistent names. Most of them can be used for receiving, not just transmitting. Fix lint errors thus revealed. BUG=b:155476419 TEST=make buildall BRANCH=none Signed-off-by: Abe Levkoy Change-Id: I399ec479eacc18622fc4d3f55f8bdabf4560fcff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3125995 Reviewed-by: Keith Short --- common/mock/tcpc_mock.c | 2 +- common/mock/tcpci_i2c_mock.c | 12 +- common/mock/usb_pd_dpm_mock.c | 4 +- common/mock/usb_pe_sm_mock.c | 4 +- common/mock/usb_prl_mock.c | 32 ++--- common/mock/usb_tc_sm_mock.c | 2 +- common/usb_common.c | 4 +- common/usb_pd_alt_mode_dfp.c | 132 ++++++++--------- common/usb_pd_console_cmd.c | 18 +-- common/usb_pd_host_cmd.c | 18 +-- common/usb_pd_policy.c | 82 +++++------ common/usb_pd_protocol.c | 106 +++++++------- common/usb_pd_tcpc.c | 18 +-- common/usbc/dp_alt_mode.c | 26 ++-- common/usbc/tbt_alt_mode.c | 77 +++++----- common/usbc/usb_mode.c | 36 ++--- common/usbc/usb_pd_dp_ufp.c | 2 +- common/usbc/usb_pd_dpm.c | 23 +-- common/usbc/usb_pd_host.c | 14 +- common/usbc/usb_pe_ctvpd_sm.c | 6 +- common/usbc/usb_pe_drp_sm.c | 256 +++++++++++++++++---------------- common/usbc/usb_prl_sm.c | 36 ++--- common/usbc/usb_tc_drp_acc_trysrc_sm.c | 14 +- 23 files changed, 466 insertions(+), 458 deletions(-) (limited to 'common') diff --git a/common/mock/tcpc_mock.c b/common/mock/tcpc_mock.c index b12267401f..7097837268 100644 --- a/common/mock/tcpc_mock.c +++ b/common/mock/tcpc_mock.c @@ -141,7 +141,7 @@ static int mock_get_message_raw(int port, uint32_t *payload, int *head) return EC_SUCCESS; } -static int mock_transmit(int port, enum tcpm_sop_type type, +static int mock_transmit(int port, enum tcpci_msg_type type, uint16_t header, const uint32_t *data) { return EC_SUCCESS; diff --git a/common/mock/tcpci_i2c_mock.c b/common/mock/tcpci_i2c_mock.c index 2df24586af..8ec7556fca 100644 --- a/common/mock/tcpci_i2c_mock.c +++ b/common/mock/tcpci_i2c_mock.c @@ -181,7 +181,7 @@ static bool debug_accessory_indicator_supported(void) return true; } -static int verify_transmit(enum tcpm_sop_type want_tx_type, +static int verify_transmit(enum tcpci_msg_type want_tx_type, int want_tx_retry, enum pd_ctrl_msg_type want_ctrl_msg, enum pd_data_msg_type want_data_msg, @@ -230,7 +230,7 @@ static int verify_transmit(enum tcpm_sop_type want_tx_type, return EC_ERROR_UNKNOWN; } -int verify_tcpci_transmit(enum tcpm_sop_type tx_type, +int verify_tcpci_transmit(enum tcpci_msg_type tx_type, enum pd_ctrl_msg_type ctrl_msg, enum pd_data_msg_type data_msg) { @@ -239,7 +239,7 @@ int verify_tcpci_transmit(enum tcpm_sop_type tx_type, VERIFY_TIMEOUT); } -int verify_tcpci_tx_timeout(enum tcpm_sop_type tx_type, +int verify_tcpci_tx_timeout(enum tcpci_msg_type tx_type, enum pd_ctrl_msg_type ctrl_msg, enum pd_data_msg_type data_msg, int timeout) @@ -249,7 +249,7 @@ int verify_tcpci_tx_timeout(enum tcpm_sop_type tx_type, timeout); } -int verify_tcpci_tx_retry_count(enum tcpm_sop_type tx_type, +int verify_tcpci_tx_retry_count(enum tcpci_msg_type tx_type, enum pd_ctrl_msg_type ctrl_msg, enum pd_data_msg_type data_msg, int retry_count) @@ -259,7 +259,7 @@ int verify_tcpci_tx_retry_count(enum tcpm_sop_type tx_type, VERIFY_TIMEOUT); } -int verify_tcpci_tx_with_data(enum tcpm_sop_type tx_type, +int verify_tcpci_tx_with_data(enum tcpci_msg_type tx_type, enum pd_data_msg_type data_msg, uint8_t *data, int data_bytes, @@ -362,7 +362,7 @@ int verify_tcpci_possible_tx(struct possible_tx possible[], return EC_ERROR_TIMEOUT; } -void mock_tcpci_receive(enum tcpm_sop_type sop, uint16_t header, +void mock_tcpci_receive(enum tcpci_msg_type sop, uint16_t header, uint32_t *payload) { int i; diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c index 9bec8358dd..8b6fbaa30e 100644 --- a/common/mock/usb_pd_dpm_mock.c +++ b/common/mock/usb_pd_dpm_mock.c @@ -31,12 +31,12 @@ void dpm_init(int port) dpm[port].mode_exit_request = false; } -void dpm_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, +void dpm_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count, uint32_t *vdm) { } -void dpm_vdm_naked(int port, enum tcpm_sop_type type, uint16_t svid, +void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid, uint8_t vdm_cmd) { } diff --git a/common/mock/usb_pe_sm_mock.c b/common/mock/usb_pe_sm_mock.c index a237102a74..8d1a25324b 100644 --- a/common/mock/usb_pe_sm_mock.c +++ b/common/mock/usb_pe_sm_mock.c @@ -46,7 +46,7 @@ void mock_pe_port_reset(void) } } -void pe_report_error(int port, enum pe_error e, enum tcpm_sop_type type) +void pe_report_error(int port, enum pe_error e, enum tcpci_msg_type type) { mock_pe_port[port].mock_pe_error = e; mock_pe_port[port].sop = type; @@ -110,7 +110,7 @@ void pd_set_src_caps(int port, int cnt, uint32_t *src_caps) void pd_request_power_swap(int port) {} -int pd_get_rev(int port, enum tcpm_sop_type type) +int pd_get_rev(int port, enum tcpci_msg_type type) { return IS_ENABLED(CONFIG_USB_PD_REV30) ? PD_REV30 : PD_REV20; } diff --git a/common/mock/usb_prl_mock.c b/common/mock/usb_prl_mock.c index ae7874d4ac..d5f4781829 100644 --- a/common/mock/usb_prl_mock.c +++ b/common/mock/usb_prl_mock.c @@ -26,11 +26,11 @@ struct extended_msg tx_emsg[CONFIG_USB_PD_PORT_MAX_COUNT]; struct mock_prl_port_t { enum pd_ctrl_msg_type last_ctrl_msg; enum pd_data_msg_type last_data_msg; - enum tcpm_sop_type last_tx_type; + enum tcpci_msg_type last_tx_type; bool message_sent; bool message_received; enum pe_error error; - enum tcpm_sop_type error_tx_type; + enum tcpci_msg_type error_tx_type; }; struct mock_prl_port_t mock_prl_port[CONFIG_USB_PD_PORT_MAX_COUNT]; @@ -46,8 +46,8 @@ void mock_prl_reset(void) memset(mock_prl_port, 0, sizeof(mock_prl_port)); for (port = 0 ; port < CONFIG_USB_PD_PORT_MAX_COUNT ; ++port) { - mock_prl_port[port].last_tx_type = TCPC_TX_INVALID; - mock_prl_port[port].error_tx_type = TCPC_TX_INVALID; + mock_prl_port[port].last_tx_type = TCPCI_MSG_INVALID; + mock_prl_port[port].error_tx_type = TCPCI_MSG_INVALID; } } @@ -58,10 +58,10 @@ void prl_execute_hard_reset(int port) { mock_prl_port[port].last_ctrl_msg = 0; mock_prl_port[port].last_data_msg = 0; - mock_prl_port[port].last_tx_type = TCPC_TX_HARD_RESET; + mock_prl_port[port].last_tx_type = TCPCI_MSG_TX_HARD_RESET; } -enum pd_rev_type prl_get_rev(int port, enum tcpm_sop_type partner) +enum pd_rev_type prl_get_rev(int port, enum tcpci_msg_type partner) { return PD_REV30; } @@ -82,7 +82,7 @@ __overridable bool prl_is_busy(int port) void prl_reset_soft(int port) {} -void prl_send_ctrl_msg(int port, enum tcpm_sop_type type, +void prl_send_ctrl_msg(int port, enum tcpci_msg_type type, enum pd_ctrl_msg_type msg) { mock_prl_port[port].last_ctrl_msg = msg; @@ -90,7 +90,7 @@ void prl_send_ctrl_msg(int port, enum tcpm_sop_type type, mock_prl_port[port].last_tx_type = type; } -void prl_send_data_msg(int port, enum tcpm_sop_type type, +void prl_send_data_msg(int port, enum tcpci_msg_type type, enum pd_data_msg_type msg) { mock_prl_port[port].last_data_msg = msg; @@ -98,17 +98,17 @@ void prl_send_data_msg(int port, enum tcpm_sop_type type, mock_prl_port[port].last_tx_type = type; } -void prl_send_ext_data_msg(int port, enum tcpm_sop_type type, +void prl_send_ext_data_msg(int port, enum tcpci_msg_type type, enum pd_ext_msg_type msg) {} -void prl_set_rev(int port, enum tcpm_sop_type partner, +void prl_set_rev(int port, enum tcpci_msg_type partner, enum pd_rev_type rev) {} int mock_prl_wait_for_tx_msg(int port, - enum tcpm_sop_type tx_type, + enum tcpci_msg_type tx_type, enum pd_ctrl_msg_type ctrl_msg, enum pd_data_msg_type data_msg, int timeout) @@ -116,7 +116,7 @@ int mock_prl_wait_for_tx_msg(int port, uint64_t end_time = get_time().val + timeout; while (get_time().val < end_time) { - if (mock_prl_port[port].last_tx_type != TCPC_TX_INVALID) { + if (mock_prl_port[port].last_tx_type != TCPCI_MSG_INVALID) { TEST_EQ(mock_prl_port[port].last_tx_type, tx_type, "%d"); TEST_EQ(mock_prl_port[port].last_ctrl_msg, @@ -153,7 +153,7 @@ void mock_prl_clear_last_sent_msg(int port) { mock_prl_port[port].last_data_msg = 0; mock_prl_port[port].last_ctrl_msg = 0; - mock_prl_port[port].last_tx_type = TCPC_TX_INVALID; + mock_prl_port[port].last_tx_type = TCPCI_MSG_INVALID; } timestamp_t prl_get_tcpc_tx_success_ts(int port) @@ -171,7 +171,7 @@ void mock_prl_message_received(int port) } void mock_prl_report_error(int port, enum pe_error e, - enum tcpm_sop_type tx_type) + enum tcpci_msg_type tx_type) { mock_prl_port[port].error = e; mock_prl_port[port].error_tx_type = tx_type; @@ -189,12 +189,12 @@ void prl_run(int port, int evt, int en) pe_message_received(port); mock_prl_port[port].message_received = 0; } - if (mock_prl_port[port].error_tx_type != TCPC_TX_INVALID) { + if (mock_prl_port[port].error_tx_type != TCPCI_MSG_INVALID) { ccprints("pe_error %d", mock_prl_port[port].error); pe_report_error(port, mock_prl_port[port].error, mock_prl_port[port].error_tx_type); mock_prl_port[port].error = 0; - mock_prl_port[port].error_tx_type = TCPC_TX_INVALID; + mock_prl_port[port].error_tx_type = TCPCI_MSG_INVALID; } } diff --git a/common/mock/usb_tc_sm_mock.c b/common/mock/usb_tc_sm_mock.c index f2c2ecf5c8..d55def12e2 100644 --- a/common/mock/usb_tc_sm_mock.c +++ b/common/mock/usb_tc_sm_mock.c @@ -31,7 +31,7 @@ void mock_tc_port_reset(void) mock_tc_port[port].pd_enable = 0; mock_tc_port[port].msg_tx_id = 0; mock_tc_port[port].msg_rx_id = 0; - mock_tc_port[port].sop = TCPC_TX_INVALID; + mock_tc_port[port].sop = TCPCI_MSG_INVALID; mock_tc_port[port].lcl_rp = TYPEC_RP_RESERVED; mock_tc_port[port].attached_snk = 0; mock_tc_port[port].attached_src = 0; diff --git a/common/usb_common.c b/common/usb_common.c index 0aab746f44..2515caf287 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -361,7 +361,7 @@ __overridable bool board_is_dts_port(int port) return true; } -int pd_get_retry_count(int port, enum tcpm_sop_type type) +int pd_get_retry_count(int port, enum tcpci_msg_type type) { /* PD 3.0 6.7.7: nRetryCount = 2; PD 2.0 6.6.9: nRetryCount = 3 */ return pd_get_rev(port, type) == PD_REV30 ? 2 : 3; @@ -809,7 +809,7 @@ static void pd_usb_billboard_deferred(void) * 1. Will we have multiple type-C port UFPs * 2. Will there be other modes applicable to DFPs besides DP */ - if (!pd_alt_mode(0, TCPC_TX_SOP, USB_SID_DISPLAYPORT)) + if (!pd_alt_mode(0, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT)) usb_connect(); } } diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c index 3c5d133bc4..366647a7b9 100644 --- a/common/usb_pd_alt_mode_dfp.c +++ b/common/usb_pd_alt_mode_dfp.c @@ -58,7 +58,7 @@ __overridable const struct svdm_response svdm_rsp = { .modes = NULL, }; -static int pd_get_mode_idx(int port, enum tcpm_sop_type type, +static int pd_get_mode_idx(int port, enum tcpci_msg_type type, uint16_t svid) { int amode_idx; @@ -73,7 +73,7 @@ static int pd_get_mode_idx(int port, enum tcpm_sop_type type, return -1; } -static int pd_allocate_mode(int port, enum tcpm_sop_type type, +static int pd_allocate_mode(int port, enum tcpci_msg_type type, uint16_t svid) { int i, j; @@ -183,7 +183,7 @@ void pd_prepare_sysjump(void) int pd_dfp_dp_get_pin_mode(int port, uint32_t status) { struct svdm_amode_data *modep = - pd_get_amode_data(port, TCPC_TX_SOP, USB_SID_DISPLAYPORT); + pd_get_amode_data(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); uint32_t mode_caps; uint32_t pin_caps; int mf_pref; @@ -226,7 +226,7 @@ int pd_dfp_dp_get_pin_mode(int port, uint32_t status) } struct svdm_amode_data *pd_get_amode_data(int port, - enum tcpm_sop_type type, uint16_t svid) + enum tcpci_msg_type type, uint16_t svid) { int idx = pd_get_mode_idx(port, type, svid); struct partner_active_modes *active = @@ -240,7 +240,7 @@ struct svdm_amode_data *pd_get_amode_data(int port, * Enter default mode ( payload[0] == 0 ) or attempt to enter mode via svid & * opos */ -uint32_t pd_dfp_enter_mode(int port, enum tcpm_sop_type type, +uint32_t pd_dfp_enter_mode(int port, enum tcpci_msg_type type, uint16_t svid, int opos) { int mode_idx = pd_allocate_mode(port, type, svid); @@ -280,7 +280,7 @@ uint32_t pd_dfp_enter_mode(int port, enum tcpm_sop_type type, } /* TODO(b/170372521) : Incorporate exit mode specific changes to DPM SM */ -int pd_dfp_exit_mode(int port, enum tcpm_sop_type type, uint16_t svid, +int pd_dfp_exit_mode(int port, enum tcpci_msg_type type, uint16_t svid, int opos) { struct svdm_amode_data *modep; @@ -344,7 +344,7 @@ void dfp_consume_attention(int port, uint32_t *payload) uint16_t svid = PD_VDO_VID(payload[0]); int opos = PD_VDO_OPOS(payload[0]); struct svdm_amode_data *modep = - pd_get_amode_data(port, TCPC_TX_SOP, svid); + pd_get_amode_data(port, TCPCI_MSG_SOP, svid); if (!modep || !validate_mode_request(modep, svid, opos)) return; @@ -353,14 +353,14 @@ void dfp_consume_attention(int port, uint32_t *payload) modep->fx->attention(port, payload); } -void dfp_consume_identity(int port, enum tcpm_sop_type type, int cnt, +void dfp_consume_identity(int port, enum tcpci_msg_type type, int cnt, uint32_t *payload) { int ptype; struct pd_discovery *disc; size_t identity_size; - if (type == TCPC_TX_SOP_PRIME && + if (type == TCPCI_MSG_SOP_PRIME && !IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) { CPRINTF("ERR:Unexpected cable response\n"); return; @@ -396,7 +396,7 @@ void dfp_consume_identity(int port, enum tcpm_sop_type type, int cnt, pd_set_identity_discovery(port, type, PD_DISC_COMPLETE); } -void dfp_consume_svids(int port, enum tcpm_sop_type type, int cnt, +void dfp_consume_svids(int port, enum tcpci_msg_type type, int cnt, uint32_t *payload) { int i; @@ -441,7 +441,7 @@ void dfp_consume_svids(int port, enum tcpm_sop_type type, int cnt, pd_set_svids_discovery(port, type, PD_DISC_COMPLETE); } -void dfp_consume_modes(int port, enum tcpm_sop_type type, int cnt, +void dfp_consume_modes(int port, enum tcpci_msg_type type, int cnt, uint32_t *payload) { int svid_idx; @@ -488,14 +488,14 @@ void dfp_consume_modes(int port, enum tcpm_sop_type type, int cnt, PD_DISC_COMPLETE); } -int pd_alt_mode(int port, enum tcpm_sop_type type, uint16_t svid) +int pd_alt_mode(int port, enum tcpci_msg_type type, uint16_t svid) { struct svdm_amode_data *modep = pd_get_amode_data(port, type, svid); return (modep) ? modep->opos : -1; } -void pd_set_identity_discovery(int port, enum tcpm_sop_type type, +void pd_set_identity_discovery(int port, enum tcpci_msg_type type, enum pd_discovery_state disc) { struct pd_discovery *pd = pd_get_am_discovery(port, type); @@ -504,7 +504,7 @@ void pd_set_identity_discovery(int port, enum tcpm_sop_type type, } enum pd_discovery_state pd_get_identity_discovery(int port, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { struct pd_discovery *disc = pd_get_am_discovery(port, type); @@ -512,7 +512,7 @@ enum pd_discovery_state pd_get_identity_discovery(int port, } const union disc_ident_ack *pd_get_identity_response(int port, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { if (type >= DISCOVERY_TYPE_COUNT) return NULL; @@ -523,7 +523,7 @@ const union disc_ident_ack *pd_get_identity_response(int port, uint16_t pd_get_identity_vid(int port) { const union disc_ident_ack *resp = pd_get_identity_response(port, - TCPC_TX_SOP); + TCPCI_MSG_SOP); return resp->idh.usb_vendor_id; } @@ -531,7 +531,7 @@ uint16_t pd_get_identity_vid(int port) uint16_t pd_get_identity_pid(int port) { const union disc_ident_ack *resp = pd_get_identity_response(port, - TCPC_TX_SOP); + TCPCI_MSG_SOP); return resp->product.product_id; } @@ -539,12 +539,12 @@ uint16_t pd_get_identity_pid(int port) uint8_t pd_get_product_type(int port) { const union disc_ident_ack *resp = pd_get_identity_response(port, - TCPC_TX_SOP); + TCPCI_MSG_SOP); return resp->idh.product_type; } -void pd_set_svids_discovery(int port, enum tcpm_sop_type type, +void pd_set_svids_discovery(int port, enum tcpci_msg_type type, enum pd_discovery_state disc) { struct pd_discovery *pd = pd_get_am_discovery(port, type); @@ -553,28 +553,28 @@ void pd_set_svids_discovery(int port, enum tcpm_sop_type type, } enum pd_discovery_state pd_get_svids_discovery(int port, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { struct pd_discovery *disc = pd_get_am_discovery(port, type); return disc->svids_discovery; } -int pd_get_svid_count(int port, enum tcpm_sop_type type) +int pd_get_svid_count(int port, enum tcpci_msg_type type) { struct pd_discovery *disc = pd_get_am_discovery(port, type); return disc->svid_cnt; } -uint16_t pd_get_svid(int port, uint16_t svid_idx, enum tcpm_sop_type type) +uint16_t pd_get_svid(int port, uint16_t svid_idx, enum tcpci_msg_type type) { struct pd_discovery *disc = pd_get_am_discovery(port, type); return disc->svids[svid_idx].svid; } -void pd_set_modes_discovery(int port, enum tcpm_sop_type type, +void pd_set_modes_discovery(int port, enum tcpci_msg_type type, uint16_t svid, enum pd_discovery_state disc) { struct pd_discovery *pd = pd_get_am_discovery(port, type); @@ -592,7 +592,7 @@ void pd_set_modes_discovery(int port, enum tcpm_sop_type type, } enum pd_discovery_state pd_get_modes_discovery(int port, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { const struct svid_mode_data *mode_data = pd_get_next_mode(port, type); @@ -606,7 +606,7 @@ enum pd_discovery_state pd_get_modes_discovery(int port, return mode_data->discovery; } -int pd_get_mode_vdo_for_svid(int port, enum tcpm_sop_type type, +int pd_get_mode_vdo_for_svid(int port, enum tcpci_msg_type type, uint16_t svid, uint32_t *vdo_out) { int idx; @@ -628,7 +628,7 @@ int pd_get_mode_vdo_for_svid(int port, enum tcpm_sop_type type, } struct svid_mode_data *pd_get_next_mode(int port, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { struct pd_discovery *disc = pd_get_am_discovery(port, type); struct svid_mode_data *failed_mode_data = NULL; @@ -663,14 +663,14 @@ struct svid_mode_data *pd_get_next_mode(int port, } uint32_t *pd_get_mode_vdo(int port, uint16_t svid_idx, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { struct pd_discovery *disc = pd_get_am_discovery(port, type); return disc->svids[svid_idx].mode_vdo; } -bool pd_is_mode_discovered_for_svid(int port, enum tcpm_sop_type type, +bool pd_is_mode_discovered_for_svid(int port, enum tcpci_msg_type type, uint16_t svid) { const struct pd_discovery *disc = pd_get_am_discovery(port, type); @@ -696,7 +696,7 @@ void notify_sysjump_ready(void) task_set_event(sysjump_task_waiting, TASK_EVENT_SYSJUMP_READY); } -static inline bool is_pd_rev3(int port, enum tcpm_sop_type type) +static inline bool is_pd_rev3(int port, enum tcpci_msg_type type) { return pd_get_rev(port, type) == PD_REV30; } @@ -711,7 +711,7 @@ static inline bool is_pd_rev3(int port, enum tcpm_sop_type type) bool is_vpd_ct_supported(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union vpd_vdo vpd = disc->identity.product_t1.vpd; return vpd.ct_support; @@ -720,7 +720,7 @@ bool is_vpd_ct_supported(int port) uint8_t get_vpd_ct_gnd_impedance(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union vpd_vdo vpd = disc->identity.product_t1.vpd; return vpd.gnd_impedance; @@ -729,7 +729,7 @@ uint8_t get_vpd_ct_gnd_impedance(int port) uint8_t get_vpd_ct_vbus_impedance(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union vpd_vdo vpd = disc->identity.product_t1.vpd; return vpd.vbus_impedance; @@ -738,7 +738,7 @@ uint8_t get_vpd_ct_vbus_impedance(int port) uint8_t get_vpd_ct_current_support(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union vpd_vdo vpd = disc->identity.product_t1.vpd; return vpd.ct_current_support; @@ -747,7 +747,7 @@ uint8_t get_vpd_ct_current_support(int port) uint8_t get_vpd_ct_max_vbus_voltage(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union vpd_vdo vpd = disc->identity.product_t1.vpd; return vpd.max_vbus_voltage; @@ -756,7 +756,7 @@ uint8_t get_vpd_ct_max_vbus_voltage(int port) uint8_t get_vpd_ct_vdo_version(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union vpd_vdo vpd = disc->identity.product_t1.vpd; return vpd.vdo_version; @@ -765,7 +765,7 @@ uint8_t get_vpd_ct_vdo_version(int port) uint8_t get_vpd_ct_firmware_verion(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union vpd_vdo vpd = disc->identity.product_t1.vpd; return vpd.firmware_version; @@ -774,7 +774,7 @@ uint8_t get_vpd_ct_firmware_verion(int port) uint8_t get_vpd_ct_hw_version(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union vpd_vdo vpd = disc->identity.product_t1.vpd; return vpd.hw_version; @@ -790,7 +790,7 @@ uint8_t get_vpd_ct_hw_version(int port) enum idh_ptype get_usb_pd_cable_type(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); return disc->identity.idh.product_type; } @@ -798,10 +798,10 @@ enum idh_ptype get_usb_pd_cable_type(int port) bool is_usb2_cable_support(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); return disc->identity.idh.product_type == IDH_PTYPE_PCABLE || - pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME) < VDM_VER20 || + pd_get_vdo_ver(port, TCPCI_MSG_SOP_PRIME) < VDM_VER20 || disc->identity.product_t2.a2_rev30.usb_20_support == USB2_SUPPORTED; } @@ -809,9 +809,9 @@ bool is_usb2_cable_support(int port) bool is_cable_speed_gen2_capable(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); - switch (pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME)) { + switch (pd_get_vdo_ver(port, TCPCI_MSG_SOP_PRIME)) { case PD_REV20: return disc->identity.product_t1.p_rev20.ss == USB_R20_SS_U31_GEN1_GEN2; @@ -829,12 +829,12 @@ bool is_cable_speed_gen2_capable(int port) bool is_active_cable_element_retimer(int port) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); /* Ref: USB PD Spec 2.0 Table 6-29 Active Cable VDO * Revision 2 Active cables do not have Active element support. */ - return is_pd_rev3(port, TCPC_TX_SOP_PRIME) && + return is_pd_rev3(port, TCPCI_MSG_SOP_PRIME) && disc->identity.idh.product_type == IDH_PTYPE_ACABLE && disc->identity.product_t2.a2_rev30.active_elem == ACTIVE_RETIMER; @@ -848,7 +848,7 @@ bool is_active_cable_element_retimer(int port) * ############################################################################ */ -uint32_t pd_get_tbt_mode_vdo(int port, enum tcpm_sop_type type) +uint32_t pd_get_tbt_mode_vdo(int port, enum tcpci_msg_type type) { uint32_t tbt_mode_vdo[PDO_MODES]; @@ -884,7 +884,7 @@ static bool is_tbt_cable_superspeed(int port) !IS_ENABLED(CONFIG_USB_PD_DECODE_SOP)) return false; - disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + disc = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); /* Product type is Active cable, hence don't check for speed */ if (disc->identity.idh.product_type == IDH_PTYPE_ACABLE) @@ -894,7 +894,7 @@ static bool is_tbt_cable_superspeed(int port) return false; if (IS_ENABLED(CONFIG_USB_PD_REV30) && - is_pd_rev3(port, TCPC_TX_SOP_PRIME)) + is_pd_rev3(port, TCPCI_MSG_SOP_PRIME)) return disc->identity.product_t1.p_rev30.ss == USB_R30_SS_U32_U40_GEN1 || disc->identity.product_t1.p_rev30.ss == @@ -932,7 +932,7 @@ enum tbt_compat_cable_speed get_tbt_cable_speed(int port) return TBT_SS_RES_0; cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); max_tbt_speed = board_get_max_tbt_speed(port); /* @@ -949,7 +949,7 @@ enum tbt_compat_cable_speed get_tbt_cable_speed(int port) if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) return TBT_SS_RES_0; - disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + disc = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); cable_tbt_speed = usb_rev30_to_tbt_speed(disc->identity.product_t1.p_rev30.ss); } else { @@ -960,15 +960,15 @@ enum tbt_compat_cable_speed get_tbt_cable_speed(int port) max_tbt_speed : cable_tbt_speed; } -int enter_tbt_compat_mode(int port, enum tcpm_sop_type sop, +int enter_tbt_compat_mode(int port, enum tcpci_msg_type sop, uint32_t *payload) { union tbt_dev_mode_enter_cmd enter_dev_mode = { .raw_value = 0 }; union tbt_mode_resp_device dev_mode_resp; union tbt_mode_resp_cable cable_mode_resp; - enum tcpm_sop_type enter_mode_sop = - sop == TCPC_TX_SOP_PRIME_PRIME ? - TCPC_TX_SOP_PRIME : sop; + enum tcpci_msg_type enter_mode_sop = + sop == TCPCI_MSG_SOP_PRIME_PRIME ? + TCPCI_MSG_SOP_PRIME : sop; /* Table F-12 TBT3 Cable Enter Mode Command */ /* @@ -988,13 +988,13 @@ int enter_tbt_compat_mode(int port, enum tcpm_sop_type sop, usb_mux_set_safe_mode(port); /* For TBT3 Cable Enter Mode Command, number of Objects is 1 */ - if ((sop == TCPC_TX_SOP_PRIME) || - (sop == TCPC_TX_SOP_PRIME_PRIME)) + if ((sop == TCPCI_MSG_SOP_PRIME) || + (sop == TCPCI_MSG_SOP_PRIME_PRIME)) return 1; - dev_mode_resp.raw_value = pd_get_tbt_mode_vdo(port, TCPC_TX_SOP); + dev_mode_resp.raw_value = pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP); cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); /* Table F-13 TBT3 Device Enter Mode Command */ enter_dev_mode.vendor_spec_b1 = dev_mode_resp.vendor_spec_b1; @@ -1021,7 +1021,7 @@ int enter_tbt_compat_mode(int port, enum tcpm_sop_type sop, enum tbt_compat_rounded_support get_tbt_rounded_support(int port) { union tbt_mode_resp_cable cable_mode_resp = { - .raw_value = pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME) }; + .raw_value = pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME) }; /* tbt_rounded_support is zero when uninitialized */ return cable_mode_resp.tbt_rounded; @@ -1065,9 +1065,9 @@ enum usb_rev30_ss get_usb4_cable_speed(int port) USB_R30_SS_U40_GEN3 : USB_R30_SS_U32_U40_GEN2; if ((get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) && - is_pd_rev3(port, TCPC_TX_SOP_PRIME)) { + is_pd_rev3(port, TCPCI_MSG_SOP_PRIME)) { struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); union active_cable_vdo1_rev30 a_rev30 = disc->identity.product_t1.a_rev30; @@ -1093,14 +1093,14 @@ uint32_t get_enter_usb_msg_payload(int port) if (!IS_ENABLED(CONFIG_USB_PD_USB4)) return 0; - disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + disc = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); eudo.mode = USB_PD_40; eudo.usb4_drd_cap = IS_ENABLED(CONFIG_USB_PD_USB4_DRD); eudo.usb3_drd_cap = IS_ENABLED(CONFIG_USB_PD_USB32_DRD); eudo.cable_speed = get_usb4_cable_speed(port); if (disc->identity.idh.product_type == IDH_PTYPE_ACABLE) { - if (is_pd_rev3(port, TCPC_TX_SOP_PRIME)) { + if (is_pd_rev3(port, TCPCI_MSG_SOP_PRIME)) { enum retimer_active_element active_element = disc->identity.product_t2.a2_rev30.active_elem; eudo.cable_type = active_element == ACTIVE_RETIMER ? @@ -1108,7 +1108,7 @@ uint32_t get_enter_usb_msg_payload(int port) CABLE_TYPE_ACTIVE_REDRIVER; } else { cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); eudo.cable_type = cable_mode_resp.retimer_type == USB_RETIMER ? @@ -1117,7 +1117,7 @@ uint32_t get_enter_usb_msg_payload(int port) } } else { cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); eudo.cable_type = cable_mode_resp.tbt_active_passive == TBT_CABLE_ACTIVE ? @@ -1212,7 +1212,7 @@ __overridable int svdm_enter_dp_mode(int port, uint32_t mode_caps) __overridable int svdm_dp_status(int port, uint32_t *payload) { - int opos = pd_alt_mode(port, TCPC_TX_SOP, USB_SID_DISPLAYPORT); + int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); payload[0] = VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_STATUS | VDO_OPOS(opos)); @@ -1256,7 +1256,7 @@ static mux_state_t svdm_dp_get_mux_mode(int port) __overridable int svdm_dp_config(int port, uint32_t *payload) { - int opos = pd_alt_mode(port, TCPC_TX_SOP, USB_SID_DISPLAYPORT); + int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); uint8_t pin_mode = get_dp_pin_mode(port); mux_state_t mux_mode = svdm_dp_get_mux_mode(port); /* Default dp_port_mf_allow is true */ diff --git a/common/usb_pd_console_cmd.c b/common/usb_pd_console_cmd.c index 9746904a1d..984f9def91 100644 --- a/common/usb_pd_console_cmd.c +++ b/common/usb_pd_console_cmd.c @@ -18,17 +18,17 @@ static void dump_pe(int port) struct svdm_amode_data *modep; uint32_t mode_caps; const union disc_ident_ack *resp; - enum tcpm_sop_type type; + enum tcpci_msg_type type; /* TODO(b/152417597): Output SOP' discovery results */ const struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP); + pd_get_am_discovery(port, TCPCI_MSG_SOP); static const char * const idh_ptype_names[] = { "UNDEF", "Hub", "Periph", "PCable", "ACable", "AMA", "RSV6", "RSV7"}; static const char * const tx_names[] = {"SOP", "SOP'", "SOP''"}; - for (type = TCPC_TX_SOP; type < DISCOVERY_TYPE_COUNT; type++) { + for (type = TCPCI_MSG_SOP; type < DISCOVERY_TYPE_COUNT; type++) { resp = pd_get_identity_response(port, type); if (pd_get_identity_discovery(port, type) != PD_DISC_COMPLETE) { ccprintf("No %s identity discovered yet.\n", @@ -52,20 +52,20 @@ static void dump_pe(int port) ccprintf("\n"); } - if (pd_get_svid_count(port, TCPC_TX_SOP) < 1) { + if (pd_get_svid_count(port, TCPCI_MSG_SOP) < 1) { ccprintf("No SVIDS discovered yet.\n"); return; } /* TODO(b/152418267): Display discovered SVIDs and modes for SOP' */ - for (i = 0; i < pd_get_svid_count(port, TCPC_TX_SOP); i++) { + for (i = 0; i < pd_get_svid_count(port, TCPCI_MSG_SOP); i++) { ccprintf("SVID[%d]: %04x MODES:", i, disc->svids[i].svid); for (j = 0; j < disc->svids[j].mode_cnt; j++) ccprintf(" [%d] %08x", j + 1, disc->svids[i].mode_vdo[j]); ccprintf("\n"); - modep = pd_get_amode_data(port, TCPC_TX_SOP, + modep = pd_get_amode_data(port, TCPCI_MSG_SOP, disc->svids[i].svid); if (modep) { mode_caps = modep->data->mode_vdo[modep->opos - 1]; @@ -134,10 +134,10 @@ static int command_cable(int argc, char **argv) } ccprintf("%s\n", cable_type[ptype]); - cable_rev = pd_get_rev(port, TCPC_TX_SOP_PRIME); - disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + cable_rev = pd_get_rev(port, TCPCI_MSG_SOP_PRIME); + disc = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); /* Cable revision */ diff --git a/common/usb_pd_host_cmd.c b/common/usb_pd_host_cmd.c index c800c20478..4261e8c1f0 100644 --- a/common/usb_pd_host_cmd.c +++ b/common/usb_pd_host_cmd.c @@ -118,7 +118,7 @@ static enum ec_status hc_remote_pd_set_amode(struct host_cmd_handler_args *args) switch (p->cmd) { case PD_EXIT_MODE: - if (pd_dfp_exit_mode(p->port, TCPC_TX_SOP, p->svid, p->opos)) + if (pd_dfp_exit_mode(p->port, TCPCI_MSG_SOP, p->svid, p->opos)) pd_send_vdm(p->port, p->svid, CMD_EXIT_MODE | VDO_OPOS(p->opos), NULL, 0); else { @@ -127,7 +127,7 @@ static enum ec_status hc_remote_pd_set_amode(struct host_cmd_handler_args *args) } break; case PD_ENTER_MODE: - if (pd_dfp_enter_mode(p->port, TCPC_TX_SOP, p->svid, p->opos)) + if (pd_dfp_enter_mode(p->port, TCPCI_MSG_SOP, p->svid, p->opos)) pd_send_vdm(p->port, p->svid, CMD_ENTER_MODE | VDO_OPOS(p->opos), NULL, 0); break; @@ -173,20 +173,20 @@ static enum ec_status hc_remote_pd_get_amode(struct host_cmd_handler_args *args) /* no more to send */ /* TODO(b/148528713): Use TCPMv2's separate storage for SOP'. */ - if (p->svid_idx >= pd_get_svid_count(p->port, TCPC_TX_SOP)) { + if (p->svid_idx >= pd_get_svid_count(p->port, TCPCI_MSG_SOP)) { r->svid = 0; args->response_size = sizeof(r->svid); return EC_RES_SUCCESS; } - r->svid = pd_get_svid(p->port, p->svid_idx, TCPC_TX_SOP); + r->svid = pd_get_svid(p->port, p->svid_idx, TCPCI_MSG_SOP); r->opos = 0; - memcpy(r->vdo, pd_get_mode_vdo(p->port, p->svid_idx, TCPC_TX_SOP), + memcpy(r->vdo, pd_get_mode_vdo(p->port, p->svid_idx, TCPCI_MSG_SOP), sizeof(uint32_t) * PDO_MODES); - modep = pd_get_amode_data(p->port, TCPC_TX_SOP, r->svid); + modep = pd_get_amode_data(p->port, TCPCI_MSG_SOP, r->svid); if (modep) - r->opos = pd_alt_mode(p->port, TCPC_TX_SOP, r->svid); + r->opos = pd_alt_mode(p->port, TCPCI_MSG_SOP, r->svid); args->response_size = sizeof(*r); return EC_RES_SUCCESS; @@ -253,8 +253,8 @@ static uint8_t get_pd_control_flags(int port) if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) return 0; - cable_resp.raw_value = pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); - device_resp.raw_value = pd_get_tbt_mode_vdo(port, TCPC_TX_SOP); + cable_resp.raw_value = pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); + device_resp.raw_value = pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP); /* * Ref: USB Type-C Cable and Connector Specification diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index e91b99393b..959feb4728 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -247,7 +247,7 @@ static inline bool is_limit_tbt_cable_speed(int port) return !!(cable[port].flags & CABLE_FLAGS_TBT_COMPAT_LIMIT_SPEED); } -static bool is_intel_svid(int port, enum tcpm_sop_type type) +static bool is_intel_svid(int port, enum tcpci_msg_type type) { int i; @@ -314,7 +314,7 @@ static inline void disable_usb4_mode(int port) static bool is_cable_ready_to_enter_usb4(int port, int cnt) { /* TODO: USB4 enter mode for Active cables */ - struct pd_discovery *disc = &discovery[port][TCPC_TX_SOP_PRIME]; + struct pd_discovery *disc = &discovery[port][TCPCI_MSG_SOP_PRIME]; if (IS_ENABLED(CONFIG_USB_PD_USB4) && (get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE) && is_vdo_present(cnt, VDO_INDEX_PTYPE_CABLE1)) { @@ -369,13 +369,13 @@ static int dfp_discover_svids(uint32_t *payload) return 1; } -struct pd_discovery *pd_get_am_discovery(int port, enum tcpm_sop_type type) +struct pd_discovery *pd_get_am_discovery(int port, enum tcpci_msg_type type) { return &discovery[port][type]; } struct partner_active_modes * -pd_get_partner_active_modes(int port, enum tcpm_sop_type type) +pd_get_partner_active_modes(int port, enum tcpci_msg_type type) { assert(type < AMODE_TYPE_COUNT); return &partner_amodes[port][type]; @@ -395,7 +395,7 @@ void pd_set_dfp_enter_mode_flag(int port, bool set) */ static int dfp_discover_modes(int port, uint32_t *payload) { - struct pd_discovery *disc = pd_get_am_discovery(port, TCPC_TX_SOP); + struct pd_discovery *disc = pd_get_am_discovery(port, TCPCI_MSG_SOP); uint16_t svid = disc->svids[disc->svid_idx].svid; if (disc->svid_idx >= disc->svid_cnt) @@ -425,10 +425,10 @@ static bool is_usb4_vdo(int port, int cnt, uint32_t *payload) static int process_am_discover_ident_sop(int port, int cnt, uint32_t head, uint32_t *payload, - enum tcpm_sop_type *rtype) + enum tcpci_msg_type *rtype) { pd_dfp_discovery_init(port); - dfp_consume_identity(port, TCPC_TX_SOP, cnt, payload); + dfp_consume_identity(port, TCPCI_MSG_SOP, cnt, payload); if (IS_ENABLED(CONFIG_USB_PD_DECODE_SOP) && is_sop_prime_ready(port) && board_is_tbt_usb4_port(port)) { @@ -448,7 +448,7 @@ static int process_am_discover_ident_sop(int port, int cnt, uint32_t head, if (is_modal(port, cnt, payload) || is_usb4_vdo(port, cnt, payload)) { - *rtype = TCPC_TX_SOP_PRIME; + *rtype = TCPCI_MSG_SOP_PRIME; return dfp_discover_ident(payload); } } @@ -459,7 +459,7 @@ static int process_am_discover_ident_sop(int port, int cnt, uint32_t head, static int process_am_discover_ident_sop_prime(int port, int cnt, uint32_t head, uint32_t *payload) { - dfp_consume_identity(port, TCPC_TX_SOP_PRIME, cnt, payload); + dfp_consume_identity(port, TCPCI_MSG_SOP_PRIME, cnt, payload); cable[port].rev = PD_HEADER_REV(head); /* @@ -491,13 +491,13 @@ static int process_am_discover_ident_sop_prime(int port, int cnt, uint32_t head, } static int process_am_discover_svids(int port, int cnt, uint32_t *payload, - enum tcpm_sop_type sop, - enum tcpm_sop_type *rtype) + enum tcpci_msg_type sop, + enum tcpci_msg_type *rtype) { /* * The pd_discovery structure stores SOP and SOP' discovery results * separately, but TCPMv1 depends on one-dimensional storage of SVIDs - * and modes. Therefore, always use TCPC_TX_SOP in TCPMv1. + * and modes. Therefore, always use TCPCI_MSG_SOP in TCPMv1. */ dfp_consume_svids(port, sop, cnt, payload); @@ -527,12 +527,12 @@ static int process_am_discover_svids(int port, int cnt, uint32_t *payload, return 0; } - if (sop == TCPC_TX_SOP_PRIME) + if (sop == TCPCI_MSG_SOP_PRIME) limit_tbt_cable_speed(port); else disable_tbt_compat_mode(port); - } else if (sop == TCPC_TX_SOP) { - *rtype = TCPC_TX_SOP_PRIME; + } else if (sop == TCPCI_MSG_SOP) { + *rtype = TCPCI_MSG_SOP_PRIME; return dfp_discover_svids(payload); } } @@ -541,21 +541,21 @@ static int process_am_discover_svids(int port, int cnt, uint32_t *payload, } static int process_tbt_compat_discover_modes(int port, - enum tcpm_sop_type sop, + enum tcpci_msg_type sop, uint32_t *payload, - enum tcpm_sop_type *rtype) + enum tcpci_msg_type *rtype) { int rsize; /* Initialize transmit type to SOP */ - *rtype = TCPC_TX_SOP; + *rtype = TCPCI_MSG_SOP; /* * For active cables, Enter mode: SOP', SOP'', SOP * Ref: USB Type-C Cable and Connector Specification, figure F-1: TBT3 * Discovery Flow and Section F.2.7 TBT3 Cable Enter Mode Command. */ - if (sop == TCPC_TX_SOP_PRIME) { + if (sop == TCPCI_MSG_SOP_PRIME) { /* Store Discover Mode SOP' response */ cable[port].cable_mode_resp.raw_value = payload[1]; @@ -580,7 +580,7 @@ static int process_tbt_compat_discover_modes(int port, * otherwise send TBT3 Device Enter Mode (SOP). */ if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) - *rtype = TCPC_TX_SOP_PRIME; + *rtype = TCPCI_MSG_SOP_PRIME; rsize = enter_tbt_compat_mode(port, *rtype, payload); } else { @@ -596,31 +596,31 @@ static int process_tbt_compat_discover_modes(int port, rsize = enter_tbt_compat_mode(port, *rtype, payload); } else { /* Discover modes for SOP' */ - discovery[port][TCPC_TX_SOP].svid_idx--; + discovery[port][TCPCI_MSG_SOP].svid_idx--; rsize = dfp_discover_modes(port, payload); - *rtype = TCPC_TX_SOP_PRIME; + *rtype = TCPCI_MSG_SOP_PRIME; } } return rsize; } -static int obj_cnt_enter_tbt_compat_mode(int port, enum tcpm_sop_type sop, +static int obj_cnt_enter_tbt_compat_mode(int port, enum tcpci_msg_type sop, uint32_t *payload, - enum tcpm_sop_type *rtype) + enum tcpci_msg_type *rtype) { - struct pd_discovery *disc = &discovery[port][TCPC_TX_SOP_PRIME]; + struct pd_discovery *disc = &discovery[port][TCPCI_MSG_SOP_PRIME]; /* Enter mode SOP' for active cables */ - if (sop == TCPC_TX_SOP_PRIME) { + if (sop == TCPCI_MSG_SOP_PRIME) { /* Check if the cable has a SOP'' controller */ if (disc->identity.product_t1.a_rev20.sop_p_p) - *rtype = TCPC_TX_SOP_PRIME_PRIME; + *rtype = TCPCI_MSG_SOP_PRIME_PRIME; return enter_tbt_compat_mode(port, *rtype, payload); } /* Enter Mode SOP'' for active cables with SOP'' controller */ - if (sop == TCPC_TX_SOP_PRIME_PRIME) + if (sop == TCPCI_MSG_SOP_PRIME_PRIME) return enter_tbt_compat_mode(port, *rtype, payload); /* Update Mux state to Thunderbolt-compatible mode. */ @@ -631,7 +631,7 @@ static int obj_cnt_enter_tbt_compat_mode(int port, enum tcpm_sop_type sop, #endif /* CONFIG_USB_PD_ALT_MODE_DFP */ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, - uint32_t head, enum tcpm_sop_type *rtype) + uint32_t head, enum tcpci_msg_type *rtype) { int cmd = PD_VDO_CMD(payload[0]); int cmd_type = PD_VDO_CMDT(payload[0]); @@ -640,11 +640,11 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, int rsize = 1; /* VDM header at a minimum */ #ifdef CONFIG_USB_PD_ALT_MODE_DFP - enum tcpm_sop_type sop = PD_HEADER_GET_SOP(head); + enum tcpci_msg_type sop = PD_HEADER_GET_SOP(head); #endif /* Transmit SOP messages by default */ - *rtype = TCPC_TX_SOP; + *rtype = TCPCI_MSG_SOP; payload[0] &= ~VDO_CMDT_MASK; *rpayload = payload; @@ -700,19 +700,20 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, payload[0] |= VDO_CMDT(CMDT_RSP_BUSY); rsize = 1; } - payload[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)); + payload[0] |= + VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)); } else if (cmd_type == CMDT_RSP_ACK) { #ifdef CONFIG_USB_PD_ALT_MODE_DFP struct svdm_amode_data *modep; - modep = pd_get_amode_data(port, TCPC_TX_SOP, + modep = pd_get_amode_data(port, TCPCI_MSG_SOP, PD_VDO_VID(payload[0])); #endif switch (cmd) { #ifdef CONFIG_USB_PD_ALT_MODE_DFP case CMD_DISCOVER_IDENT: /* Received a SOP' Discover Ident msg */ - if (sop == TCPC_TX_SOP_PRIME) { + if (sop == TCPCI_MSG_SOP_PRIME) { rsize = process_am_discover_ident_sop_prime( port, cnt, head, payload); /* Received a SOP Discover Ident Message */ @@ -744,7 +745,7 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, */ disable_tbt_compat_mode(port); payload[0] = pd_dfp_enter_mode( - port, TCPC_TX_SOP, 0, 0); + port, TCPCI_MSG_SOP, 0, 0); if (payload[0]) rsize = 1; } @@ -761,8 +762,8 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, rsize = 0; } else { if (!modep->opos) - pd_dfp_enter_mode(port, TCPC_TX_SOP, 0, - 0); + pd_dfp_enter_mode(port, TCPCI_MSG_SOP, + 0, 0); if (modep->opos) { rsize = modep->fx->status(port, @@ -801,7 +802,8 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, } payload[0] |= VDO_CMDT(CMDT_INIT); - payload[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)); + payload[0] |= + VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)); #ifdef CONFIG_USB_PD_ALT_MODE_DFP } else if (cmd_type == CMDT_RSP_BUSY) { switch (cmd) { @@ -825,7 +827,7 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, } else if (cmd_type == CMDT_RSP_NAK) { /* Passive cable Nacked for Discover SVID */ if (cmd == CMD_DISCOVER_SVID && is_tbt_compat_enabled(port) && - sop == TCPC_TX_SOP_PRIME && + sop == TCPCI_MSG_SOP_PRIME && get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE) { limit_tbt_cable_speed(port); rsize = dfp_discover_modes(port, payload); @@ -844,7 +846,7 @@ int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, #else int pd_svdm(int port, int cnt, uint32_t *payload, uint32_t **rpayload, - uint32_t head, enum tcpm_sop_type *rtype) + uint32_t head, enum tcpci_msg_type *rtype) { return 0; } diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index e20fa11aee..378960c91e 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -268,7 +268,7 @@ static struct pd_protocol { /* next Vendor Defined Message to send */ uint32_t vdo_data[VDO_MAX_SIZE]; /* type of transmit message (SOP/SOP'/SOP'') */ - enum tcpm_sop_type xmit_type; + enum tcpci_msg_type xmit_type; uint8_t vdo_count; /* VDO to retry if UFP responder replied busy. */ uint32_t vdo_retry; @@ -345,13 +345,13 @@ static inline void set_state_timeout(int port, pd[port].timeout_state = timeout_state; } -int pd_get_rev(int port, enum tcpm_sop_type type) +int pd_get_rev(int port, enum tcpci_msg_type type) { #ifdef CONFIG_USB_PD_REV30 /* TCPMv1 Only stores PD revision for SOP and SOP' types */ ASSERT(type < NUM_SOP_STAR_TYPES - 1); - if (type == TCPC_TX_SOP_PRIME) + if (type == TCPCI_MSG_SOP_PRIME) return get_usb_pd_cable_revision(port); return pd[port].rev; @@ -360,10 +360,10 @@ int pd_get_rev(int port, enum tcpm_sop_type type) #endif } -int pd_get_vdo_ver(int port, enum tcpm_sop_type type) +int pd_get_vdo_ver(int port, enum tcpci_msg_type type) { #ifdef CONFIG_USB_PD_REV30 - if (type == TCPC_TX_SOP_PRIME) + if (type == TCPCI_MSG_SOP_PRIME) return vdo_ver[get_usb_pd_cable_revision(port)]; return vdo_ver[pd[port].rev]; @@ -681,15 +681,15 @@ static bool consume_sop_repeat_message(int port, uint8_t msg_id) static bool consume_repeat_message(int port, uint32_t msg_header) { uint8_t msg_id = PD_HEADER_ID(msg_header); - enum tcpm_sop_type sop = PD_HEADER_GET_SOP(msg_header); + enum tcpci_msg_type sop = PD_HEADER_GET_SOP(msg_header); /* If repeat message ignore, except softreset control request. */ if (PD_HEADER_TYPE(msg_header) == PD_CTRL_SOFT_RESET && PD_HEADER_CNT(msg_header) == 0) { return false; - } else if (sop == TCPC_TX_SOP_PRIME) { + } else if (sop == TCPCI_MSG_SOP_PRIME) { return consume_sop_prime_repeat_msg(port, msg_id); - } else if (sop == TCPC_TX_SOP_PRIME_PRIME) { + } else if (sop == TCPCI_MSG_SOP_PRIME_PRIME) { return consume_sop_prime_prime_repeat_msg(port, msg_id); } else { return consume_sop_repeat_message(port, msg_id); @@ -835,7 +835,7 @@ static inline void set_state(int port, enum pd_states next_state) charge_manager_update_dualrole(port, CAP_UNKNOWN); #endif #ifdef CONFIG_USB_PD_ALT_MODE_DFP - if (pd_dfp_exit_mode(port, TCPC_TX_SOP, 0, 0)) + if (pd_dfp_exit_mode(port, TCPCI_MSG_SOP, 0, 0)) usb_mux_set_safe_mode(port); #endif /* @@ -908,7 +908,7 @@ void pd_transmit_complete(int port, int status) task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_TX); } -static int pd_transmit(int port, enum tcpm_sop_type type, +static int pd_transmit(int port, enum tcpci_msg_type type, uint16_t header, const uint32_t *data, enum ams_seq ams) { int evt; @@ -961,7 +961,7 @@ static int pd_transmit(int port, enum tcpm_sop_type type, */ sink_can_xmit(port, SINK_TX_NG); sink_ng = 1; - } else if (type != TCPC_TX_HARD_RESET) { + } else if (type != TCPCI_MSG_TX_HARD_RESET) { enum tcpc_cc_voltage_status cc1, cc2; tcpm_get_cc(port, &cc1, &cc2); @@ -1004,7 +1004,7 @@ static int send_control(int port, int type) int bit_len; uint16_t header = PD_HEADER(type, pd[port].power_role, pd[port].data_role, pd[port].msg_id, 0, - pd_get_rev(port, TCPC_TX_SOP), 0); + pd_get_rev(port, TCPCI_MSG_SOP), 0); /* * For PD 3.0, collision avoidance logic needs to know if this message * will begin a new Atomic Message Sequence (AMS) @@ -1013,7 +1013,7 @@ static int send_control(int port, int type) ? AMS_START : AMS_RESPONSE; - bit_len = pd_transmit(port, TCPC_TX_SOP, header, NULL, ams); + bit_len = pd_transmit(port, TCPCI_MSG_SOP, header, NULL, ams); if (debug_level >= 2) CPRINTF("C%d CTRL[%d]>%d\n", port, type, bit_len); @@ -1042,13 +1042,13 @@ static int send_source_cap(int port, enum ams_seq ams) /* No source capabilities defined, sink only */ header = PD_HEADER(PD_CTRL_REJECT, pd[port].power_role, pd[port].data_role, pd[port].msg_id, 0, - pd_get_rev(port, TCPC_TX_SOP), 0); + pd_get_rev(port, TCPCI_MSG_SOP), 0); else header = PD_HEADER(PD_DATA_SOURCE_CAP, pd[port].power_role, pd[port].data_role, pd[port].msg_id, src_pdo_cnt, - pd_get_rev(port, TCPC_TX_SOP), 0); + pd_get_rev(port, TCPCI_MSG_SOP), 0); - bit_len = pd_transmit(port, TCPC_TX_SOP, header, src_pdo, ams); + bit_len = pd_transmit(port, TCPCI_MSG_SOP, header, src_pdo, ams); if (debug_level >= 2) CPRINTF("C%d srcCAP>%d\n", port, bit_len); @@ -1135,7 +1135,7 @@ static int send_battery_cap(int port, uint32_t *payload) } } - bit_len = pd_transmit(port, TCPC_TX_SOP, header, (uint32_t *)msg, + bit_len = pd_transmit(port, TCPCI_MSG_SOP, header, (uint32_t *)msg, AMS_RESPONSE); if (debug_level >= 2) CPRINTF("C%d batCap>%d\n", port, bit_len); @@ -1203,7 +1203,7 @@ static int send_battery_status(int port, uint32_t *payload) msg = BSDO_CAP(BSDO_CAP_UNKNOWN); } - bit_len = pd_transmit(port, TCPC_TX_SOP, header, &msg, AMS_RESPONSE); + bit_len = pd_transmit(port, TCPCI_MSG_SOP, header, &msg, AMS_RESPONSE); if (debug_level >= 2) CPRINTF("C%d batStat>%d\n", port, bit_len); @@ -1217,9 +1217,9 @@ static void send_sink_cap(int port) int bit_len; uint16_t header = PD_HEADER(PD_DATA_SINK_CAP, pd[port].power_role, pd[port].data_role, pd[port].msg_id, pd_snk_pdo_cnt, - pd_get_rev(port, TCPC_TX_SOP), 0); + pd_get_rev(port, TCPCI_MSG_SOP), 0); - bit_len = pd_transmit(port, TCPC_TX_SOP, header, pd_snk_pdo, + bit_len = pd_transmit(port, TCPCI_MSG_SOP, header, pd_snk_pdo, AMS_RESPONSE); if (debug_level >= 2) CPRINTF("C%d snkCAP>%d\n", port, bit_len); @@ -1230,10 +1230,10 @@ static int send_request(int port, uint32_t rdo) int bit_len; uint16_t header = PD_HEADER(PD_DATA_REQUEST, pd[port].power_role, pd[port].data_role, pd[port].msg_id, 1, - pd_get_rev(port, TCPC_TX_SOP), 0); + pd_get_rev(port, TCPCI_MSG_SOP), 0); /* Note: ams will need to be AMS_START if used for PPS keep alive */ - bit_len = pd_transmit(port, TCPC_TX_SOP, header, &rdo, AMS_RESPONSE); + bit_len = pd_transmit(port, TCPCI_MSG_SOP, header, &rdo, AMS_RESPONSE); if (debug_level >= 2) CPRINTF("C%d REQ>%d\n", port, bit_len); @@ -1250,9 +1250,9 @@ static int send_bist_cmd(int port) int bit_len; uint16_t header = PD_HEADER(PD_DATA_BIST, pd[port].power_role, pd[port].data_role, pd[port].msg_id, 1, - pd_get_rev(port, TCPC_TX_SOP), 0); + pd_get_rev(port, TCPCI_MSG_SOP), 0); - bit_len = pd_transmit(port, TCPC_TX_SOP, header, &bdo, AMS_START); + bit_len = pd_transmit(port, TCPCI_MSG_SOP, header, &bdo, AMS_START); CPRINTF("C%d BIST>%d\n", port, bit_len); return bit_len; @@ -1260,7 +1260,7 @@ static int send_bist_cmd(int port) #endif static void queue_vdm(int port, uint32_t *header, const uint32_t *data, - int data_cnt, enum tcpm_sop_type type) + int data_cnt, enum tcpci_msg_type type) { pd[port].vdo_count = data_cnt + 1; pd[port].vdo_data[0] = header[0]; @@ -1276,7 +1276,7 @@ static void handle_vdm_request(int port, int cnt, uint32_t *payload, { int rlen = 0; uint32_t *rdata; - enum tcpm_sop_type rtype = TCPC_TX_SOP; + enum tcpci_msg_type rtype = TCPCI_MSG_SOP; if (pd[port].vdm_state == VDM_STATE_BUSY) { /* If UFP responded busy retry after timeout */ @@ -1371,7 +1371,7 @@ void pd_execute_hard_reset(int port) invalidate_last_message_id(port); tcpm_set_rx_enable(port, 0); #ifdef CONFIG_USB_PD_ALT_MODE_DFP - if (pd_dfp_exit_mode(port, TCPC_TX_SOP, 0, 0)) + if (pd_dfp_exit_mode(port, TCPCI_MSG_SOP, 0, 0)) usb_mux_set_safe_mode(port); #endif @@ -1637,7 +1637,7 @@ static void handle_data_request(int port, uint32_t head, /* currently only support sending bist carrier mode 2 */ if ((payload[0] >> 28) == 5) { /* bist data object mode is 2 */ - pd_transmit(port, TCPC_TX_BIST_MODE_2, 0, + pd_transmit(port, TCPCI_MSG_TX_BIST_MODE_2, 0, NULL, AMS_RESPONSE); /* Set to appropriate port disconnected state */ set_state(port, DUAL_ROLE_IF_ELSE(port, @@ -2125,7 +2125,7 @@ void pd_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data, #ifdef CONFIG_USB_PD_REV30 pd[port].vdo_data[0] |= VDO_SVDM_VERS(vdo_ver[pd[port].rev]); #endif - queue_vdm(port, pd[port].vdo_data, data, count, TCPC_TX_SOP); + queue_vdm(port, pd[port].vdo_data, data, count, TCPCI_MSG_SOP); task_wake(PD_PORT_TO_TASK_ID(port)); } @@ -2179,7 +2179,7 @@ static void exit_tbt_mode_sop_prime(int port) if (!IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE)) return; - opos = pd_alt_mode(port, TCPC_TX_SOP, USB_VID_INTEL); + opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_VID_INTEL); if (opos <= 0) return; @@ -2187,9 +2187,9 @@ static void exit_tbt_mode_sop_prime(int port) /* * Note: TCPMv2 contemplates separate discovery structures for each SOP * type. TCPMv1 only uses one discovery structure, so all accesses - * specify TCPC_TX_SOP. + * specify TCPCI_MSG_SOP. */ - if (pd_dfp_exit_mode(port, TCPC_TX_SOP, USB_VID_INTEL, opos)) + if (pd_dfp_exit_mode(port, TCPCI_MSG_SOP, USB_VID_INTEL, opos)) usb_mux_set_safe_mode(port); else return; @@ -2197,12 +2197,12 @@ static void exit_tbt_mode_sop_prime(int port) header = PD_HEADER(PD_DATA_VENDOR_DEF, pd[port].power_role, pd[port].data_role, pd[port].msg_id, (int)pd[port].vdo_count, - pd_get_rev(port, TCPC_TX_SOP), 0); + pd_get_rev(port, TCPCI_MSG_SOP), 0); pd[port].vdo_data[0] = VDO(USB_VID_INTEL, 1, CMD_EXIT_MODE | VDO_OPOS(opos)); - pd_transmit(port, TCPC_TX_SOP_PRIME, header, pd[port].vdo_data, + pd_transmit(port, TCPCI_MSG_SOP_PRIME, header, pd[port].vdo_data, AMS_START); usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, @@ -2213,7 +2213,7 @@ static void pd_vdm_send_state_machine(int port) { int res; uint16_t header; - enum tcpm_sop_type msg_type = pd[port].xmit_type; + enum tcpci_msg_type msg_type = pd[port].xmit_type; switch (pd[port].vdm_state) { case VDM_STATE_READY: @@ -2241,8 +2241,8 @@ static void pd_vdm_send_state_machine(int port) * data role swap takes place during source and sink * negotiation and in case of failure, a soft reset is issued. */ - if ((msg_type == TCPC_TX_SOP_PRIME) || - (msg_type == TCPC_TX_SOP_PRIME_PRIME)) { + if ((msg_type == TCPCI_MSG_SOP_PRIME) || + (msg_type == TCPCI_MSG_SOP_PRIME_PRIME)) { /* Prepare SOP'/SOP'' header and send VDM */ header = PD_HEADER( PD_DATA_VENDOR_DEF, @@ -2250,7 +2250,7 @@ static void pd_vdm_send_state_machine(int port) 0, pd[port].msg_id, (int)pd[port].vdo_count, - pd_get_rev(port, TCPC_TX_SOP), + pd_get_rev(port, TCPCI_MSG_SOP), 0); res = pd_transmit(port, msg_type, header, pd[port].vdo_data, AMS_START); @@ -2275,17 +2275,17 @@ static void pd_vdm_send_state_machine(int port) pd[port].msg_id, (int)pd[port].vdo_count, pd_get_rev - (port, TCPC_TX_SOP), + (port, TCPCI_MSG_SOP), 0); - if ((msg_type == TCPC_TX_SOP_PRIME_PRIME) && + if ((msg_type == TCPCI_MSG_SOP_PRIME_PRIME) && IS_ENABLED(CONFIG_USBC_SS_MUX)) { exit_tbt_mode_sop_prime(port); - } else if (msg_type == TCPC_TX_SOP_PRIME) { + } else if (msg_type == TCPCI_MSG_SOP_PRIME) { pd[port].vdo_data[0] = VDO(USB_SID_PD, 1, CMD_DISCOVER_SVID); } - res = pd_transmit(port, TCPC_TX_SOP, header, + res = pd_transmit(port, TCPCI_MSG_SOP, header, pd[port].vdo_data, AMS_START); reset_pd_cable(port); } @@ -2296,8 +2296,8 @@ static void pd_vdm_send_state_machine(int port) pd[port].data_role, pd[port].msg_id, (int)pd[port].vdo_count, - pd_get_rev(port, TCPC_TX_SOP), 0); - res = pd_transmit(port, TCPC_TX_SOP, header, + pd_get_rev(port, TCPCI_MSG_SOP), 0); + res = pd_transmit(port, TCPCI_MSG_SOP, header, pd[port].vdo_data, AMS_START); } @@ -2391,12 +2391,11 @@ __maybe_unused static void exit_supported_alt_mode(int port) return; for (i = 0; i < supported_modes_cnt; i++) { - int opos = pd_alt_mode(port, TCPC_TX_SOP, + int opos = pd_alt_mode(port, TCPCI_MSG_SOP, supported_modes[i].svid); - if (opos > 0 && - pd_dfp_exit_mode( - port, TCPC_TX_SOP, supported_modes[i].svid, opos)) { + if (opos > 0 && pd_dfp_exit_mode(port, TCPCI_MSG_SOP, + supported_modes[i].svid, opos)) { CPRINTS("C%d Exiting ALT mode with SVID = 0x%x", port, supported_modes[i].svid); usb_mux_set_safe_mode(port); @@ -2821,7 +2820,8 @@ static void pd_send_enter_usb(int port, int *timeout) PD_REV30, 0); - res = pd_transmit(port, TCPC_TX_SOP, header, &usb4_payload, AMS_START); + res = pd_transmit(port, TCPCI_MSG_SOP, header, &usb4_payload, + AMS_START); if (res < 0) { *timeout = 10*MSEC; /* @@ -3071,7 +3071,7 @@ void pd_task(void *u) /* cut the power */ pd_execute_hard_reset(port); /* notify the other side of the issue */ - pd_transmit(port, TCPC_TX_HARD_RESET, 0, NULL, + pd_transmit(port, TCPCI_MSG_TX_HARD_RESET, 0, NULL, AMS_START); } @@ -4569,7 +4569,7 @@ void pd_task(void *u) if (hard_reset_sent) break; - if (pd_transmit(port, TCPC_TX_HARD_RESET, 0, NULL, + if (pd_transmit(port, TCPCI_MSG_TX_HARD_RESET, 0, NULL, AMS_START) < 0) { /* * likely a non-idle channel @@ -4639,7 +4639,7 @@ void pd_task(void *u) PD_STATE_SRC_DISCONNECTED)); break; case PD_STATE_BIST_TX: - pd_transmit(port, TCPC_TX_BIST_MODE_2, 0, NULL, + pd_transmit(port, TCPCI_MSG_TX_BIST_MODE_2, 0, NULL, AMS_START); /* Delay at least enough to finish sending BIST */ timeout = PD_T_BIST_TRANSMIT + 20*MSEC; @@ -4997,7 +4997,7 @@ int pd_is_port_enabled(int port) void pd_send_hpd(int port, enum hpd_event hpd) { uint32_t data[1]; - int opos = pd_alt_mode(port, TCPC_TX_SOP, USB_SID_DISPLAYPORT); + int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); if (!opos) return; diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index fd933d655e..1aaee29abc 100644 --- a/common/usb_pd_tcpc.c +++ b/common/usb_pd_tcpc.c @@ -259,7 +259,7 @@ static struct pd_port_controller { int rx_buf_head, rx_buf_tail; /* Next transmit */ - enum tcpm_sop_type tx_type; + enum tcpci_msg_type tx_type; uint16_t tx_head; uint32_t tx_payload[7]; const uint32_t *tx_data; @@ -721,11 +721,11 @@ int pd_analyze_rx(int port, uint32_t *payload) #ifdef CONFIG_USB_PD_DECODE_SOP /* Encode message address */ if (val == PD_SOP) { - phs.head |= PD_HEADER_SOP(TCPC_TX_SOP); + phs.head |= PD_HEADER_SOP(TCPCI_MSG_SOP); } else if (val == PD_SOP_PRIME) { - phs.head |= PD_HEADER_SOP(TCPC_TX_SOP_PRIME); + phs.head |= PD_HEADER_SOP(TCPCI_MSG_SOP_PRIME); } else if (val == PD_SOP_PRIME_PRIME) { - phs.head |= PD_HEADER_SOP(TCPC_TX_SOP_PRIME_PRIME); + phs.head |= PD_HEADER_SOP(TCPCI_MSG_SOP_PRIME_PRIME); } else { msg = "SOP*"; goto packet_err; @@ -868,19 +868,19 @@ int tcpc_run(int port, int evt) if ((evt & PD_EVENT_TX) && pd[port].rx_enabled) { switch (pd[port].tx_type) { #if defined(CONFIG_USB_VPD) || defined(CONFIG_USB_CTVPD) - case TCPC_TX_SOP_PRIME: + case TCPCI_MSG_SOP_PRIME: #else - case TCPC_TX_SOP: + case TCPCI_MSG_SOP: #endif res = send_validate_message(port, pd[port].tx_head, pd[port].tx_data); break; - case TCPC_TX_BIST_MODE_2: + case TCPCI_MSG_TX_BIST_MODE_2: bist_mode_2_tx(port); res = 0; break; - case TCPC_TX_HARD_RESET: + case TCPCI_MSG_TX_HARD_RESET: res = send_hard_reset(port); break; default: @@ -1128,7 +1128,7 @@ int tcpc_set_rx_enable(int port, int enable) return EC_SUCCESS; } -int tcpc_transmit(int port, enum tcpm_sop_type type, uint16_t header, +int tcpc_transmit(int port, enum tcpci_msg_type type, uint16_t header, const uint32_t *data) { /* Store data to transmit and wake task to send it */ diff --git a/common/usbc/dp_alt_mode.c b/common/usbc/dp_alt_mode.c index 1f62d5fb71..9a3493c6e1 100644 --- a/common/usbc/dp_alt_mode.c +++ b/common/usbc/dp_alt_mode.c @@ -73,7 +73,7 @@ static void dp_entry_failed(int port) dp_state[port] = DP_INACTIVE; } -static bool dp_response_valid(int port, enum tcpm_sop_type type, +static bool dp_response_valid(int port, enum tcpci_msg_type type, char *cmdt, int vdm_cmd) { enum dp_states st = dp_state[port]; @@ -82,11 +82,11 @@ static bool dp_response_valid(int port, enum tcpm_sop_type type, * Check for an unexpected response. * If DP is inactive, ignore the command. */ - if (type != TCPC_TX_SOP || + if (type != TCPCI_MSG_SOP || (st != DP_INACTIVE && state_vdm_cmd[st] != vdm_cmd)) { CPRINTS("C%d: Received unexpected DP VDM %s (cmd %d) from" " %s in state %d", port, cmdt, vdm_cmd, - type == TCPC_TX_SOP ? "port partner" : "cable plug", + type == TCPCI_MSG_SOP ? "port partner" : "cable plug", st); dp_entry_failed(port); return false; @@ -96,9 +96,9 @@ static bool dp_response_valid(int port, enum tcpm_sop_type type, static void dp_exit_to_usb_mode(int port) { - int opos = pd_alt_mode(port, TCPC_TX_SOP, USB_SID_DISPLAYPORT); + int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); - pd_dfp_exit_mode(port, TCPC_TX_SOP, USB_SID_DISPLAYPORT, opos); + pd_dfp_exit_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT, opos); set_usb_mux_with_current_data_role(port); CPRINTS("C%d: Exited DP mode", port); @@ -111,7 +111,7 @@ static void dp_exit_to_usb_mode(int port) ? DP_START : DP_INACTIVE; } -void dp_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, +void dp_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count, uint32_t *vdm) { const struct svdm_amode_data *modep = @@ -171,7 +171,7 @@ void dp_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, } } -void dp_vdm_naked(int port, enum tcpm_sop_type type, uint8_t vdm_cmd) +void dp_vdm_naked(int port, enum tcpci_msg_type type, uint8_t vdm_cmd) { if (!dp_response_valid(port, type, "NAK", vdm_cmd)) return; @@ -210,7 +210,7 @@ void dp_vdm_naked(int port, enum tcpm_sop_type type, uint8_t vdm_cmd) int dp_setup_next_vdm(int port, int vdo_count, uint32_t *vdm) { const struct svdm_amode_data *modep = pd_get_amode_data(port, - TCPC_TX_SOP, USB_SID_DISPLAYPORT); + TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); int vdo_count_ret; if (vdo_count < VDO_MAX_SIZE) @@ -220,13 +220,13 @@ int dp_setup_next_vdm(int port, int vdo_count, uint32_t *vdm) case DP_START: case DP_ENTER_RETRY: /* Enter the first supported mode for DisplayPort. */ - vdm[0] = pd_dfp_enter_mode(port, TCPC_TX_SOP, + vdm[0] = pd_dfp_enter_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT, 0); if (vdm[0] == 0) return -1; /* CMDT_INIT is 0, so this is a no-op */ vdm[0] |= VDO_CMDT(CMDT_INIT); - vdm[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)); + vdm[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)); vdo_count_ret = 1; if (dp_state[port] == DP_START) CPRINTS("C%d: Attempting to enter DP mode", port); @@ -240,7 +240,7 @@ int dp_setup_next_vdm(int port, int vdo_count, uint32_t *vdm) return -1; vdm[0] |= PD_VDO_OPOS(modep->opos); vdm[0] |= VDO_CMDT(CMDT_INIT); - vdm[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)); + vdm[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)); break; case DP_STATUS_ACKED: if (!(modep && modep->opos)) @@ -250,7 +250,7 @@ int dp_setup_next_vdm(int port, int vdo_count, uint32_t *vdm) if (vdo_count_ret == 0) return -1; vdm[0] |= VDO_CMDT(CMDT_INIT); - vdm[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)); + vdm[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)); break; case DP_ENTER_NAKED: case DP_ACTIVE: @@ -275,7 +275,7 @@ int dp_setup_next_vdm(int port, int vdo_count, uint32_t *vdm) vdm[0] |= VDO_OPOS(modep->opos); vdm[0] |= VDO_CMDT(CMDT_INIT); - vdm[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)); + vdm[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)); vdo_count_ret = 1; break; case DP_INACTIVE: diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c index b54848053c..0509add1f8 100644 --- a/common/usbc/tbt_alt_mode.c +++ b/common/usbc/tbt_alt_mode.c @@ -172,7 +172,7 @@ void tbt_exit_mode_request(int port) */ if (tbt_state[port] == TBT_ENTER_SOP) { cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); /* * For Linear re-driver cables, the port enters USB4 mode @@ -185,12 +185,12 @@ void tbt_exit_mode_request(int port) } } -static bool tbt_response_valid(int port, enum tcpm_sop_type type, +static bool tbt_response_valid(int port, enum tcpci_msg_type type, char *cmdt, int vdm_cmd) { enum tbt_states st = tbt_state[port]; union tbt_mode_resp_cable cable_mode_resp = { - .raw_value = pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME) }; + .raw_value = pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME) }; /* * Check for an unexpected response. @@ -201,7 +201,7 @@ static bool tbt_response_valid(int port, enum tcpm_sop_type type, if ((st != TBT_INACTIVE && state_vdm_cmd[st] != vdm_cmd) || (get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE && cable_mode_resp.tbt_active_passive == TBT_CABLE_PASSIVE && - type != TCPC_TX_SOP)) { + type != TCPCI_MSG_SOP)) { tbt_exit_done(port); return false; } @@ -220,7 +220,7 @@ static void tbt_active_cable_exit_mode(int port) { struct pd_discovery *disc; - disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + disc = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); if (disc->identity.product_t1.a_rev20.sop_p_p) tbt_state[port] = TBT_EXIT_SOP_PRIME_PRIME; @@ -244,14 +244,14 @@ bool tbt_cable_entry_required_for_usb4(int port) return false; cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); if (cable_mode_resp.tbt_active_passive == TBT_CABLE_ACTIVE) return true; if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) { - disc_sop_prime = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); - if (pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME) < VDM_VER20 || + disc_sop_prime = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); + if (pd_get_vdo_ver(port, TCPCI_MSG_SOP_PRIME) < VDM_VER20 || disc_sop_prime->identity.product_t1.a_rev30.vdo_ver < VDO_VERSION_1_3) return true; @@ -259,7 +259,7 @@ bool tbt_cable_entry_required_for_usb4(int port) return false; } -void intel_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, +void intel_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count, uint32_t *vdm) { struct pd_discovery *disc; @@ -270,13 +270,13 @@ void intel_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, if (!tbt_response_valid(port, type, "ACK", vdm_cmd)) return; - disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + disc = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); switch (tbt_state[port]) { case TBT_ENTER_SOP_PRIME: tbt_prints("enter mode SOP'", port); cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); /* For LRD cables, Enter mode SOP' -> Enter mode SOP */ if (disc->identity.product_t1.a_rev20.sop_p_p && cable_mode_resp.tbt_active_passive != TBT_CABLE_ACTIVE) { @@ -301,10 +301,10 @@ void intel_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, break; case TBT_ACTIVE: tbt_prints("exit mode SOP", port); - opos_sop = pd_alt_mode(port, TCPC_TX_SOP, USB_VID_INTEL); + opos_sop = pd_alt_mode(port, TCPCI_MSG_SOP, USB_VID_INTEL); /* Clear Thunderbolt related signals */ - pd_dfp_exit_mode(port, TCPC_TX_SOP, USB_VID_INTEL, opos_sop); + pd_dfp_exit_mode(port, TCPCI_MSG_SOP, USB_VID_INTEL, opos_sop); set_usb_mux_with_current_data_role(port); if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) { tbt_active_cable_exit_mode(port); @@ -340,12 +340,12 @@ void intel_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, */ tbt_exit_done(port); opos_sop_prime = - pd_alt_mode(port, TCPC_TX_SOP_PRIME, + pd_alt_mode(port, TCPCI_MSG_SOP_PRIME, USB_VID_INTEL); /* Clear Thunderbolt related signals */ - pd_dfp_exit_mode(port, TCPC_TX_SOP_PRIME, USB_VID_INTEL, - opos_sop_prime); + pd_dfp_exit_mode(port, TCPCI_MSG_SOP_PRIME, + USB_VID_INTEL, opos_sop_prime); set_usb_mux_with_current_data_role(port); } else { tbt_retry_enter_mode(port); @@ -367,7 +367,7 @@ void intel_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, } } -void intel_vdm_naked(int port, enum tcpm_sop_type type, uint8_t vdm_cmd) +void intel_vdm_naked(int port, enum tcpci_msg_type type, uint8_t vdm_cmd) { if (!tbt_response_valid(port, type, "NAK", vdm_cmd)) return; @@ -437,7 +437,7 @@ void intel_vdm_naked(int port, enum tcpm_sop_type type, uint8_t vdm_cmd) static bool tbt_mode_is_supported(int port, int vdo_count) { const struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP); + pd_get_am_discovery(port, TCPCI_MSG_SOP); if (!disc->identity.idh.modal_support) return false; @@ -452,20 +452,20 @@ static bool tbt_mode_is_supported(int port, int vdo_count) */ if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE && !pd_is_mode_discovered_for_svid( - port, TCPC_TX_SOP_PRIME, USB_VID_INTEL)) + port, TCPCI_MSG_SOP_PRIME, USB_VID_INTEL)) return false; return true; } int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm, - enum tcpm_sop_type *tx_type) + enum tcpci_msg_type *tx_type) { struct svdm_amode_data *modep; int vdo_count_ret = 0; union tbt_mode_resp_cable cable_mode_resp; - *tx_type = TCPC_TX_SOP; + *tx_type = TCPCI_MSG_SOP; if (vdo_count < VDO_MAX_SIZE) return -1; @@ -481,36 +481,36 @@ int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm, tbt_prints("retry to enter mode", port); cable_mode_resp.raw_value = - pd_get_tbt_mode_vdo(port, TCPC_TX_SOP_PRIME); + pd_get_tbt_mode_vdo(port, TCPCI_MSG_SOP_PRIME); /* Active cable and LRD cables send Enter Mode SOP' first */ if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE || cable_mode_resp.tbt_active_passive == TBT_CABLE_ACTIVE) { vdo_count_ret = enter_tbt_compat_mode(port, - TCPC_TX_SOP_PRIME, vdm); - *tx_type = TCPC_TX_SOP_PRIME; + TCPCI_MSG_SOP_PRIME, vdm); + *tx_type = TCPCI_MSG_SOP_PRIME; tbt_state[port] = TBT_ENTER_SOP_PRIME; } else { /* Passive cable send Enter Mode SOP */ vdo_count_ret = - enter_tbt_compat_mode(port, TCPC_TX_SOP, vdm); + enter_tbt_compat_mode(port, TCPCI_MSG_SOP, vdm); tbt_state[port] = TBT_ENTER_SOP; } break; case TBT_ENTER_SOP_PRIME: vdo_count_ret = - enter_tbt_compat_mode(port, TCPC_TX_SOP_PRIME, vdm); - *tx_type = TCPC_TX_SOP_PRIME; + enter_tbt_compat_mode(port, TCPCI_MSG_SOP_PRIME, vdm); + *tx_type = TCPCI_MSG_SOP_PRIME; break; case TBT_ENTER_SOP_PRIME_PRIME: vdo_count_ret = enter_tbt_compat_mode( - port, TCPC_TX_SOP_PRIME_PRIME, vdm); - *tx_type = TCPC_TX_SOP_PRIME_PRIME; + port, TCPCI_MSG_SOP_PRIME_PRIME, vdm); + *tx_type = TCPCI_MSG_SOP_PRIME_PRIME; break; case TBT_ENTER_SOP: vdo_count_ret = - enter_tbt_compat_mode(port, TCPC_TX_SOP, vdm); + enter_tbt_compat_mode(port, TCPCI_MSG_SOP, vdm); break; case TBT_EXIT_SOP: case TBT_ACTIVE: @@ -521,7 +521,7 @@ int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm, * is restarted while Thunderbolt mode is active. */ modep = pd_get_amode_data(port, - TCPC_TX_SOP, USB_VID_INTEL); + TCPCI_MSG_SOP, USB_VID_INTEL); if (!(modep && modep->opos)) return -1; @@ -531,12 +531,12 @@ int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm, VDO_OPOS(modep->opos) | VDO_CMDT(CMDT_INIT) | VDO_SVDM_VERS( - pd_get_vdo_ver(port, TCPC_TX_SOP)); + pd_get_vdo_ver(port, TCPCI_MSG_SOP)); vdo_count_ret = 1; break; case TBT_EXIT_SOP_PRIME_PRIME: modep = pd_get_amode_data(port, - TCPC_TX_SOP_PRIME, USB_VID_INTEL); + TCPCI_MSG_SOP_PRIME, USB_VID_INTEL); if (!(modep && modep->opos)) return -1; @@ -546,13 +546,13 @@ int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm, VDO_OPOS(modep->opos) | VDO_CMDT(CMDT_INIT) | VDO_SVDM_VERS(pd_get_vdo_ver(port, - TCPC_TX_SOP_PRIME_PRIME)); + TCPCI_MSG_SOP_PRIME_PRIME)); vdo_count_ret = 1; - *tx_type = TCPC_TX_SOP_PRIME_PRIME; + *tx_type = TCPCI_MSG_SOP_PRIME_PRIME; break; case TBT_EXIT_SOP_PRIME: modep = pd_get_amode_data(port, - TCPC_TX_SOP_PRIME, USB_VID_INTEL); + TCPCI_MSG_SOP_PRIME, USB_VID_INTEL); if (!(modep && modep->opos)) return -1; @@ -561,9 +561,10 @@ int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm, vdm[0] = VDO(USB_VID_INTEL, 1, CMD_EXIT_MODE) | VDO_OPOS(modep->opos) | VDO_CMDT(CMDT_INIT) | - VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME)); + VDO_SVDM_VERS(pd_get_vdo_ver(port, + TCPCI_MSG_SOP_PRIME)); vdo_count_ret = 1; - *tx_type = TCPC_TX_SOP_PRIME; + *tx_type = TCPCI_MSG_SOP_PRIME; break; case TBT_INACTIVE: /* Thunderbolt mode is inactive */ diff --git a/common/usbc/usb_mode.c b/common/usbc/usb_mode.c index 3829d5463f..1620ed4e1f 100644 --- a/common/usbc/usb_mode.c +++ b/common/usbc/usb_mode.c @@ -143,13 +143,13 @@ void enter_usb_failed(int port) usb4_state[port] = USB4_INACTIVE; } -static bool enter_usb_response_valid(int port, enum tcpm_sop_type type) +static bool enter_usb_response_valid(int port, enum tcpci_msg_type type) { /* * Check for an unexpected response. */ if (get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE && - type != TCPC_TX_SOP) { + type != TCPCI_MSG_SOP) { enter_usb_failed(port); return false; } @@ -159,7 +159,7 @@ static bool enter_usb_response_valid(int port, enum tcpm_sop_type type) bool enter_usb_port_partner_is_capable(int port) { const struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP); + pd_get_am_discovery(port, TCPCI_MSG_SOP); if (usb4_state[port] == USB4_INACTIVE) return false; @@ -177,9 +177,9 @@ bool enter_usb_cable_is_capable(int port) return false; } else if (get_usb_pd_cable_type(port) == IDH_PTYPE_ACABLE) { struct pd_discovery *disc_sop_prime = - pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); - if (pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME) >= VDM_VER20 && + if (pd_get_vdo_ver(port, TCPCI_MSG_SOP_PRIME) >= VDM_VER20 && disc_sop_prime->identity.product_t1.a_rev30.vdo_ver >= VDO_VERSION_1_3) { union active_cable_vdo2_rev30 a2_rev30 = @@ -200,14 +200,14 @@ bool enter_usb_cable_is_capable(int port) */ } else { const struct pd_discovery *disc = - pd_get_am_discovery(port, TCPC_TX_SOP); + pd_get_am_discovery(port, TCPCI_MSG_SOP); union tbt_mode_resp_cable cable_mode_resp = { .raw_value = pd_get_tbt_mode_vdo(port, - TCPC_TX_SOP_PRIME) }; + TCPCI_MSG_SOP_PRIME) }; if (!disc->identity.idh.modal_support || !pd_is_mode_discovered_for_svid(port, - TCPC_TX_SOP_PRIME, USB_VID_INTEL) || + TCPCI_MSG_SOP_PRIME, USB_VID_INTEL) || cable_mode_resp.tbt_rounded != TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED) return false; @@ -216,7 +216,7 @@ bool enter_usb_cable_is_capable(int port) return true; } -void enter_usb_accepted(int port, enum tcpm_sop_type type) +void enter_usb_accepted(int port, enum tcpci_msg_type type) { struct pd_discovery *disc; @@ -225,7 +225,7 @@ void enter_usb_accepted(int port, enum tcpm_sop_type type) switch (usb4_state[port]) { case USB4_ENTER_SOP_PRIME: - disc = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + disc = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); if (disc->identity.product_t1.a_rev20.sop_p_p) usb4_state[port] = USB4_ENTER_SOP_PRIME_PRIME; else @@ -254,7 +254,7 @@ void enter_usb_accepted(int port, enum tcpm_sop_type type) } } -void enter_usb_rejected(int port, enum tcpm_sop_type type) +void enter_usb_rejected(int port, enum tcpci_msg_type type) { if (!enter_usb_response_valid(port, type) || usb4_state[port] == USB4_ACTIVE) @@ -263,13 +263,13 @@ void enter_usb_rejected(int port, enum tcpm_sop_type type) enter_usb_failed(port); } -uint32_t enter_usb_setup_next_msg(int port, enum tcpm_sop_type *type) +uint32_t enter_usb_setup_next_msg(int port, enum tcpci_msg_type *type) { struct pd_discovery *disc_sop_prime; switch (usb4_state[port]) { case USB4_START: - disc_sop_prime = pd_get_am_discovery(port, TCPC_TX_SOP_PRIME); + disc_sop_prime = pd_get_am_discovery(port, TCPCI_MSG_SOP_PRIME); /* * Ref: Tiger Lake Platform PD Controller Interface Requirements * for Integrated USBC, section A.2.2: USB4 as DFP. @@ -279,24 +279,24 @@ uint32_t enter_usb_setup_next_msg(int port, enum tcpm_sop_type *type) */ usb_mux_set_safe_mode(port); - if (pd_get_vdo_ver(port, TCPC_TX_SOP_PRIME) < VDM_VER20 || + if (pd_get_vdo_ver(port, TCPCI_MSG_SOP_PRIME) < VDM_VER20 || disc_sop_prime->identity.product_t1.a_rev30.vdo_ver < VDO_VERSION_1_3 || get_usb_pd_cable_type(port) == IDH_PTYPE_PCABLE) { usb4_state[port] = USB4_ENTER_SOP; } else { usb4_state[port] = USB4_ENTER_SOP_PRIME; - *type = TCPC_TX_SOP_PRIME; + *type = TCPCI_MSG_SOP_PRIME; } break; case USB4_ENTER_SOP_PRIME: - *type = TCPC_TX_SOP_PRIME; + *type = TCPCI_MSG_SOP_PRIME; break; case USB4_ENTER_SOP_PRIME_PRIME: - *type = TCPC_TX_SOP_PRIME_PRIME; + *type = TCPCI_MSG_SOP_PRIME_PRIME; break; case USB4_ENTER_SOP: - *type = TCPC_TX_SOP; + *type = TCPCI_MSG_SOP; break; case USB4_ACTIVE: return -1; diff --git a/common/usbc/usb_pd_dp_ufp.c b/common/usbc/usb_pd_dp_ufp.c index 31a3069bb9..0009b5c710 100644 --- a/common/usbc/usb_pd_dp_ufp.c +++ b/common/usbc/usb_pd_dp_ufp.c @@ -104,7 +104,7 @@ static void hpd_to_dp_attention(void) * Construct DP Attention message. This consists of the VDM header and * the DP_STATUS VDO. */ - svdm_header = VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)) | + svdm_header = VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)) | VDO_OPOS(opos) | CMD_ATTENTION; vdm[0] = VDO(USB_SID_DISPLAYPORT, 1, svdm_header); diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index 4fbd496ad4..eb2dfc52c0 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -181,7 +181,7 @@ static bool dpm_mode_entry_requested(int port, enum typec_mode mode) } } -void dpm_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, +void dpm_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count, uint32_t *vdm) { const uint16_t svid = PD_VDO_VID(vdm[0]); @@ -203,7 +203,7 @@ void dpm_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, } } -void dpm_vdm_naked(int port, enum tcpm_sop_type type, uint16_t svid, +void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid, uint8_t vdm_cmd) { switch (svid) { @@ -231,7 +231,7 @@ static void dpm_attempt_mode_entry(int port) { int vdo_count = 0; uint32_t vdm[VDO_MAX_SIZE]; - enum tcpm_sop_type tx_type = TCPC_TX_SOP; + enum tcpci_msg_type tx_type = TCPCI_MSG_SOP; bool enter_mode_requested = IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true; @@ -264,8 +264,8 @@ static void dpm_attempt_mode_entry(int port) * If discovery has not occurred for modes, do not attempt to switch * to alt mode. */ - if (pd_get_svids_discovery(port, TCPC_TX_SOP) != PD_DISC_COMPLETE || - pd_get_modes_discovery(port, TCPC_TX_SOP) != PD_DISC_COMPLETE) + if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE || + pd_get_modes_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE) return; if (dp_entry_is_done(port) || @@ -297,8 +297,9 @@ static void dpm_attempt_mode_entry(int port) /* If not, check if they support Thunderbolt alt mode. */ if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && - board_is_tbt_usb4_port(port) && - pd_is_mode_discovered_for_svid(port, TCPC_TX_SOP, USB_VID_INTEL) && + board_is_tbt_usb4_port(port) && + pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP, + USB_VID_INTEL) && dpm_mode_entry_requested(port, TYPEC_MODE_TBT)) { enter_mode_requested = true; vdo_count = tbt_setup_next_vdm(port, @@ -307,7 +308,7 @@ static void dpm_attempt_mode_entry(int port) /* If not, check if they support DisplayPort alt mode. */ if (vdo_count == 0 && !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE) && - pd_is_mode_discovered_for_svid(port, TCPC_TX_SOP, + pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT) && dpm_mode_entry_requested(port, TYPEC_MODE_DP)) { enter_mode_requested = true; @@ -356,7 +357,7 @@ static void dpm_attempt_mode_exit(int port) { uint32_t vdm = 0; int vdo_count = 0; - enum tcpm_sop_type tx_type = TCPC_TX_SOP; + enum tcpci_msg_type tx_type = TCPCI_MSG_SOP; if (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port)) { @@ -394,7 +395,7 @@ static void dpm_attempt_mode_exit(int port) static void dpm_send_attention_vdm(int port) { /* Set up VDM ATTEN msg that was passed in previously */ - if (pd_setup_vdm_request(port, TCPC_TX_SOP, dpm[port].vdm_attention, + if (pd_setup_vdm_request(port, TCPCI_MSG_SOP, dpm[port].vdm_attention, dpm[port].vdm_cnt) == true) /* Trigger PE to start a VDM command run */ pd_dpm_request(port, DPM_REQUEST_VDM); @@ -601,7 +602,7 @@ void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo) return; /* FRS is only supported in PD 3.0 and higher */ - if (pd_get_rev(port, TCPC_TX_SOP) == PD_REV20) + if (pd_get_rev(port, TCPCI_MSG_SOP) == PD_REV20) return; if ((vsafe5v_pdo & PDO_FIXED_DUAL_ROLE) && frs_current) { diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c index e4d044097b..514ef82036 100644 --- a/common/usbc/usb_pd_host.c +++ b/common/usbc/usb_pd_host.c @@ -24,7 +24,7 @@ static enum ec_status hc_typec_discovery(struct host_cmd_handler_args *args) const struct ec_params_typec_discovery *p = args->params; struct ec_response_typec_discovery *r = args->response; const struct pd_discovery *disc; - enum tcpm_sop_type type; + enum tcpci_msg_type type; /* Confirm the number of HC VDOs matches our stored VDOs */ BUILD_ASSERT(sizeof(r->discovery_vdo) == sizeof(union disc_ident_ack)); @@ -36,7 +36,7 @@ static enum ec_status hc_typec_discovery(struct host_cmd_handler_args *args) return EC_RES_INVALID_PARAM; type = p->partner_type == TYPEC_PARTNER_SOP ? - TCPC_TX_SOP : TCPC_TX_SOP_PRIME; + TCPCI_MSG_SOP : TCPCI_MSG_SOP_PRIME; /* * Clear out access mask so we can track if tasks have touched data @@ -156,10 +156,12 @@ static enum ec_status hc_typec_status(struct host_cmd_handler_args *args) r->events = pd_get_events(p->port); r->sop_revision = r->sop_connected ? - PD_STATUS_REV_SET_MAJOR(pd_get_rev(p->port, TCPC_TX_SOP)) : 0; - r->sop_prime_revision = pd_get_identity_discovery(p->port, - TCPC_TX_SOP_PRIME) == PD_DISC_COMPLETE ? - PD_STATUS_REV_SET_MAJOR(pd_get_rev(p->port, TCPC_TX_SOP_PRIME)) + PD_STATUS_REV_SET_MAJOR(pd_get_rev(p->port, TCPCI_MSG_SOP)) : 0; + r->sop_prime_revision = + pd_get_identity_discovery(p->port, TCPCI_MSG_SOP_PRIME) == + PD_DISC_COMPLETE ? + PD_STATUS_REV_SET_MAJOR(pd_get_rev(p->port, + TCPCI_MSG_SOP_PRIME)) : 0; r->source_cap_count = pd_get_src_cap_cnt(p->port); diff --git a/common/usbc/usb_pe_ctvpd_sm.c b/common/usbc/usb_pe_ctvpd_sm.c index eb7d8a0aa7..346a57a461 100644 --- a/common/usbc/usb_pe_ctvpd_sm.c +++ b/common/usbc/usb_pe_ctvpd_sm.c @@ -111,7 +111,7 @@ void pe_got_hard_reset(int port) /* No implementation needed by this policy engine */ } -void pe_report_error(int port, enum pe_error e, enum tcpm_sop_type type) +void pe_report_error(int port, enum pe_error e, enum tcpci_msg_type type) { /* No implementation needed by this policy engine */ } @@ -210,11 +210,11 @@ static void pe_request_run(const int port) tx_emsg[port].len = 20; /* Set to highest revision supported by both ports. */ - prl_set_rev(port, TCPC_TX_SOP_PRIME, + prl_set_rev(port, TCPCI_MSG_SOP_PRIME, (PD_HEADER_REV(header) > PD_REV30) ? PD_REV30 : PD_HEADER_REV(header)); /* Send the ACK */ - prl_send_data_msg(port, TCPC_TX_SOP_PRIME, + prl_send_data_msg(port, TCPCI_MSG_SOP_PRIME, PD_DATA_VENDOR_DEF); } } diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 3f770a9fb7..f3faa1eabb 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -575,7 +575,7 @@ static struct policy_engine { uint32_t events; /* port address where soft resets are sent */ - enum tcpm_sop_type soft_reset_sop; + enum tcpci_msg_type soft_reset_sop; /* Current limit / voltage based on the last request message */ uint32_t curr_limit; @@ -590,7 +590,7 @@ static struct policy_engine { struct partner_active_modes partner_amodes[AMODE_TYPE_COUNT]; /* Partner type to send */ - enum tcpm_sop_type tx_type; + enum tcpci_msg_type tx_type; /* VDM - used to send information to shared VDM Request state */ uint32_t vdm_cnt; @@ -670,12 +670,12 @@ static const uint8_t vdo_ver[] = { [PD_REV30] = VDM_VER20, }; -int pd_get_rev(int port, enum tcpm_sop_type type) +int pd_get_rev(int port, enum tcpci_msg_type type) { return prl_get_rev(port, type); } -int pd_get_vdo_ver(int port, enum tcpm_sop_type type) +int pd_get_vdo_ver(int port, enum tcpci_msg_type type) { enum pd_rev_type rev = prl_get_rev(port, type); @@ -693,7 +693,7 @@ static void pe_set_ready_state(int port) set_state_pe(port, PE_SNK_READY); } -static inline void send_data_msg(int port, enum tcpm_sop_type type, +static inline void send_data_msg(int port, enum tcpci_msg_type type, enum pd_data_msg_type msg) { /* Clear any previous TX status before sending a new message */ @@ -702,14 +702,14 @@ static inline void send_data_msg(int port, enum tcpm_sop_type type, } static __maybe_unused inline void send_ext_data_msg( - int port, enum tcpm_sop_type type, enum pd_ext_msg_type msg) + int port, enum tcpci_msg_type type, enum pd_ext_msg_type msg) { /* Clear any previous TX status before sending a new message */ PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); prl_send_ext_data_msg(port, type, msg); } -static inline void send_ctrl_msg(int port, enum tcpm_sop_type type, +static inline void send_ctrl_msg(int port, enum tcpci_msg_type type, enum pd_ctrl_msg_type msg) { /* Clear any previous TX status before sending a new message */ @@ -723,18 +723,18 @@ static void set_cable_rev(int port) * If port partner runs PD 2.0, cable communication must * also be PD 2.0 */ - if (prl_get_rev(port, TCPC_TX_SOP) == PD_REV20) { + if (prl_get_rev(port, TCPCI_MSG_SOP) == PD_REV20) { /* * If the cable supports PD 3.0, but the port partner supports PD 2.0, * redo the cable discover with PD 2.0 */ - if (prl_get_rev(port, TCPC_TX_SOP_PRIME) == PD_REV30 && - pd_get_identity_discovery(port, TCPC_TX_SOP_PRIME) == + if (prl_get_rev(port, TCPCI_MSG_SOP_PRIME) == PD_REV30 && + pd_get_identity_discovery(port, TCPCI_MSG_SOP_PRIME) == PD_DISC_COMPLETE) { - pd_set_identity_discovery(port, TCPC_TX_SOP_PRIME, + pd_set_identity_discovery(port, TCPCI_MSG_SOP_PRIME, PD_DISC_NEEDED); } - prl_set_rev(port, TCPC_TX_SOP_PRIME, PD_REV20); + prl_set_rev(port, TCPCI_MSG_SOP_PRIME, PD_REV20); } } @@ -750,7 +750,7 @@ static void pe_init(int port) pe[port].dpm_curr_request = 0; pd_timer_disable_range(port, PE_TIMER_RANGE); pe[port].data_role = pd_get_data_role(port); - pe[port].tx_type = TCPC_TX_INVALID; + pe[port].tx_type = TCPCI_MSG_INVALID; pe[port].events = 0; tc_pd_connection(port, 0); @@ -1034,7 +1034,7 @@ static bool pe_can_send_sop_prime(int port) { if (IS_ENABLED(CONFIG_USBC_VCONN)) { if (PE_CHK_FLAG(port, PE_FLAGS_EXPLICIT_CONTRACT)) { - if (prl_get_rev(port, TCPC_TX_SOP) == PD_REV20) + if (prl_get_rev(port, TCPCI_MSG_SOP) == PD_REV20) return tc_is_vconn_src(port) && pe[port].data_role == PD_ROLE_DFP; else @@ -1064,7 +1064,7 @@ static bool pe_can_send_sop_prime(int port) static bool pe_can_send_sop_vdm(int port, int vdm_cmd) { if (PE_CHK_FLAG(port, PE_FLAGS_EXPLICIT_CONTRACT)) { - if (prl_get_rev(port, TCPC_TX_SOP) == PD_REV20) { + if (prl_get_rev(port, TCPCI_MSG_SOP) == PD_REV20) { if (pe[port].data_role == PD_ROLE_UFP && vdm_cmd != CMD_ATTENTION) { return false; @@ -1082,7 +1082,7 @@ static bool pe_can_send_sop_vdm(int port, int vdm_cmd) return false; } -static void pe_send_soft_reset(const int port, enum tcpm_sop_type type) +static void pe_send_soft_reset(const int port, enum tcpci_msg_type type) { pe[port].soft_reset_sop = type; set_state_pe(port, PE_SEND_SOFT_RESET); @@ -1117,7 +1117,7 @@ static bool pe_check_outgoing_discard(int port) */ if (PE_CHK_FLAG(port, PE_FLAGS_MSG_DISCARDED) && PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) { - enum tcpm_sop_type sop = + enum tcpci_msg_type sop = PD_HEADER_GET_SOP(rx_emsg[port].header); PE_CLR_FLAG(port, PE_FLAGS_MSG_DISCARDED); @@ -1130,7 +1130,7 @@ static bool pe_check_outgoing_discard(int port) return false; } -void pe_report_error(int port, enum pe_error e, enum tcpm_sop_type type) +void pe_report_error(int port, enum pe_error e, enum tcpci_msg_type type) { /* This should only be called from the PD task */ assert(port == TASK_ID_TO_PD_PORT(task_get_current())); @@ -1199,7 +1199,7 @@ void pe_report_error(int port, enum pe_error e, enum tcpm_sop_type type) !PE_CHK_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS)) || e == ERR_TCH_XMIT || (!PE_CHK_FLAG(port, PE_FLAGS_EXPLICIT_CONTRACT) && - type == TCPC_TX_SOP)) { + type == TCPCI_MSG_SOP)) { pe_send_soft_reset(port, type); } /* @@ -1316,10 +1316,11 @@ void pd_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data, int count) { /* Copy VDM Header */ - pe[port].vdm_data[0] = VDO(vid, ((vid & USB_SID_PD) == USB_SID_PD) ? - 1 : (PD_VDO_CMD(cmd) <= CMD_ATTENTION), - VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)) - | cmd); + pe[port].vdm_data[0] = + VDO(vid, ((vid & USB_SID_PD) == USB_SID_PD) ? 1 : + (PD_VDO_CMD(cmd) <= CMD_ATTENTION), + VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)) | + cmd); /* * Copy VDOs after the VDM Header. Note that the count refers to VDO @@ -1334,7 +1335,7 @@ void pd_send_vdm(int port, uint32_t vid, int cmd, const uint32_t *data, * that this function is likely called from outside the PD task. * (b/180465870) */ - pe[port].tx_type = TCPC_TX_SOP; + pe[port].tx_type = TCPCI_MSG_SOP; pd_dpm_request(port, DPM_REQUEST_VDM); task_wake(PD_PORT_TO_TASK_ID(port)); @@ -1475,7 +1476,7 @@ static bool common_src_snk_dpm_requests(int port) DPM_REQUEST_SOFT_RESET_SEND)) { pe_set_dpm_curr_request(port, DPM_REQUEST_SOFT_RESET_SEND); /* Currently only support sending soft reset to SOP */ - pe_send_soft_reset(port, TCPC_TX_SOP); + pe_send_soft_reset(port, TCPCI_MSG_SOP); return true; } else if (PE_CHK_DPM_REQUEST(port, DPM_REQUEST_PORT_DISCOVERY)) { @@ -1516,7 +1517,7 @@ static bool common_src_snk_dpm_requests(int port) DPM_REQUEST_SOP_PRIME_SOFT_RESET_SEND)) { pe_set_dpm_curr_request(port, DPM_REQUEST_SOP_PRIME_SOFT_RESET_SEND); - pe[port].tx_type = TCPC_TX_SOP_PRIME; + pe[port].tx_type = TCPCI_MSG_SOP_PRIME; set_state_pe(port, PE_VCS_CBL_SEND_SOFT_RESET); return true; } @@ -1704,13 +1705,13 @@ static void send_source_cap(int port) if (src_pdo_cnt == 0) { /* No source capabilities defined, sink only */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_REJECT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT); } tx_emsg[port].len = src_pdo_cnt * 4; memcpy(tx_emsg[port].buf, (uint8_t *)src_pdo, tx_emsg[port].len); - send_data_msg(port, TCPC_TX_SOP, PD_DATA_SOURCE_CAP); + send_data_msg(port, TCPCI_MSG_SOP, PD_DATA_SOURCE_CAP); } /* @@ -1730,7 +1731,7 @@ static void pe_send_request_msg(int port) if ((get_usb_pd_cable_type(port) == IDH_PTYPE_VPD) && is_vpd_ct_supported(port)) { union vpd_vdo vpd = pd_get_am_discovery(port, - TCPC_TX_SOP_PRIME)->identity.product_t1.vpd; + TCPCI_MSG_SOP_PRIME)->identity.product_t1.vpd; /* The raw vpd_vdo is passed to pd_build_request */ vpd_vdo = vpd.raw_value; @@ -1752,7 +1753,7 @@ static void pe_send_request_msg(int port) tx_emsg[port].len = 4; memcpy(tx_emsg[port].buf, (uint8_t *)&rdo, tx_emsg[port].len); - send_data_msg(port, TCPC_TX_SOP, PD_DATA_REQUEST); + send_data_msg(port, TCPCI_MSG_SOP, PD_DATA_REQUEST); } static void pe_update_src_pdo_flags(int port, int pdo_cnt, uint32_t *pdos) @@ -1871,38 +1872,38 @@ __maybe_unused static bool pe_attempt_port_discovery(int port) * discovery spacing or BUSY spacing runs out. */ if (pd_timer_is_expired(port, PE_TIMER_DISCOVER_IDENTITY)) { - if (pd_get_identity_discovery(port, TCPC_TX_SOP_PRIME) == + if (pd_get_identity_discovery(port, TCPCI_MSG_SOP_PRIME) == PD_DISC_NEEDED) { - pe[port].tx_type = TCPC_TX_SOP_PRIME; + pe[port].tx_type = TCPCI_MSG_SOP_PRIME; set_state_pe(port, PE_VDM_IDENTITY_REQUEST_CBL); return true; - } else if (pd_get_identity_discovery(port, TCPC_TX_SOP) == + } else if (pd_get_identity_discovery(port, TCPCI_MSG_SOP) == PD_DISC_NEEDED && pe_can_send_sop_vdm(port, CMD_DISCOVER_IDENT)) { - pe[port].tx_type = TCPC_TX_SOP; + pe[port].tx_type = TCPCI_MSG_SOP; set_state_pe(port, PE_INIT_PORT_VDM_IDENTITY_REQUEST); return true; - } else if (pd_get_svids_discovery(port, TCPC_TX_SOP) == + } else if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) == PD_DISC_NEEDED && pe_can_send_sop_vdm(port, CMD_DISCOVER_SVID)) { - pe[port].tx_type = TCPC_TX_SOP; + pe[port].tx_type = TCPCI_MSG_SOP; set_state_pe(port, PE_INIT_VDM_SVIDS_REQUEST); return true; - } else if (pd_get_modes_discovery(port, TCPC_TX_SOP) == + } else if (pd_get_modes_discovery(port, TCPCI_MSG_SOP) == PD_DISC_NEEDED && pe_can_send_sop_vdm(port, CMD_DISCOVER_MODES)) { - pe[port].tx_type = TCPC_TX_SOP; + pe[port].tx_type = TCPCI_MSG_SOP; set_state_pe(port, PE_INIT_VDM_MODES_REQUEST); return true; - } else if (pd_get_svids_discovery(port, TCPC_TX_SOP_PRIME) + } else if (pd_get_svids_discovery(port, TCPCI_MSG_SOP_PRIME) == PD_DISC_NEEDED) { - pe[port].tx_type = TCPC_TX_SOP_PRIME; + pe[port].tx_type = TCPCI_MSG_SOP_PRIME; set_state_pe(port, PE_INIT_VDM_SVIDS_REQUEST); return true; - } else if (pd_get_modes_discovery(port, TCPC_TX_SOP_PRIME) == + } else if (pd_get_modes_discovery(port, TCPCI_MSG_SOP_PRIME) == PD_DISC_NEEDED) { - pe[port].tx_type = TCPC_TX_SOP_PRIME; + pe[port].tx_type = TCPCI_MSG_SOP_PRIME; set_state_pe(port, PE_INIT_VDM_MODES_REQUEST); return true; } @@ -1911,7 +1912,7 @@ __maybe_unused static bool pe_attempt_port_discovery(int port) return false; } -bool pd_setup_vdm_request(int port, enum tcpm_sop_type tx_type, +bool pd_setup_vdm_request(int port, enum tcpci_msg_type tx_type, uint32_t *vdm, uint32_t vdo_cnt) { if (vdo_cnt < VDO_HDR_SIZE || vdo_cnt > VDO_MAX_SIZE) @@ -1985,7 +1986,7 @@ static void pe_update_wait_and_add_jitter_timer(int port) * we start our interrogation. Add some jitter of up to * ~345ms to prevent multiple collisions. */ - if (prl_get_rev(port, TCPC_TX_SOP) == PD_REV20 && + if (prl_get_rev(port, TCPCI_MSG_SOP) == PD_REV20 && PE_CHK_FLAG(port, PE_FLAGS_FIRST_MSG) && pd_timer_is_disabled(port, PE_TIMER_WAIT_AND_ADD_JITTER)) { pd_timer_enable(port, PE_TIMER_WAIT_AND_ADD_JITTER, @@ -2244,12 +2245,13 @@ static void pe_src_discovery_run(int port) * contract, we use it here to ensure we space any potential BUSY * requests properly. */ - if (pd_get_identity_discovery(port, TCPC_TX_SOP_PRIME) == PD_DISC_NEEDED + if (pd_get_identity_discovery(port, TCPCI_MSG_SOP_PRIME) == + PD_DISC_NEEDED && pd_timer_is_expired(port, PE_TIMER_DISCOVER_IDENTITY) && pe_can_send_sop_prime(port) && (pe[port].discover_identity_counter < N_DISCOVER_IDENTITY_PRECONTRACT_LIMIT)) { - pe[port].tx_type = TCPC_TX_SOP_PRIME; + pe[port].tx_type = TCPCI_MSG_SOP_PRIME; set_state_pe(port, PE_VDM_IDENTITY_REQUEST_CBL); return; } @@ -2301,7 +2303,7 @@ static void pe_src_send_capabilities_run(int port) set_state_pe(port, PE_SRC_READY); return; } else if (msg_check == PE_MSG_DISCARDED) { - pe_send_soft_reset(port, TCPC_TX_SOP); + pe_send_soft_reset(port, TCPCI_MSG_SOP); return; } @@ -2345,7 +2347,7 @@ static void pe_src_send_capabilities_run(int port) * Set to highest revision supported by both * ports. */ - prl_set_rev(port, TCPC_TX_SOP, + prl_set_rev(port, TCPCI_MSG_SOP, MIN(PD_REVISION, PD_HEADER_REV(rx_emsg[port].header))); set_cable_rev(port); @@ -2391,7 +2393,7 @@ static void pe_src_send_capabilities_run(int port) if (!PE_CHK_FLAG(port, PE_FLAGS_PD_CONNECTION)) set_state_pe(port, PE_SRC_DISCOVERY); else - pe_send_soft_reset(port, TCPC_TX_SOP); + pe_send_soft_reset(port, TCPCI_MSG_SOP); return; } @@ -2475,9 +2477,9 @@ static void pe_src_transition_supply_entry(int port) /* Send a GotoMin Message or otherwise an Accept Message */ if (PE_CHK_FLAG(port, PE_FLAGS_ACCEPT)) { PE_CLR_FLAG(port, PE_FLAGS_ACCEPT); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_ACCEPT); } else { - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_GOTO_MIN); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_GOTO_MIN); } } @@ -2548,7 +2550,7 @@ static void pe_src_transition_supply_run(int port) pd_timer_disable(port, PE_TIMER_SRC_TRANSITION); /* Transition power supply and send PS_RDY. */ pd_transition_voltage(pe[port].requested_idx); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PS_RDY); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_PS_RDY); PE_SET_FLAG(port, PE_FLAGS_PS_READY); } @@ -2804,7 +2806,7 @@ static void pe_src_capability_response_entry(int port) /* NOTE: Wait messaging should be implemented. */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_REJECT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT); } static void pe_src_capability_response_run(int port) @@ -3130,7 +3132,7 @@ static void pe_snk_evaluate_capability_entry(int port) pe[port].hard_reset_counter = 0; /* Set to highest revision supported by both ports. */ - prl_set_rev(port, TCPC_TX_SOP, + prl_set_rev(port, TCPCI_MSG_SOP, MIN(PD_REVISION, PD_HEADER_REV(rx_emsg[port].header))); set_cable_rev(port); @@ -3179,7 +3181,7 @@ static void pe_snk_select_capability_run(int port) { uint8_t type; uint8_t cnt; - enum tcpm_sop_type sop; + enum tcpci_msg_type sop; enum pe_msg_check msg_check; /* @@ -3199,7 +3201,7 @@ static void pe_snk_select_capability_run(int port) * 2) SE_SNK_READY: goes back to SNK Ready */ if (get_last_state_pe(port) == PE_SNK_EVALUATE_CAPABILITY) - pe_send_soft_reset(port, TCPC_TX_SOP); + pe_send_soft_reset(port, TCPCI_MSG_SOP); else set_state_pe(port, PE_SNK_READY); return; @@ -3730,7 +3732,7 @@ static void pe_snk_get_source_cap_entry(int port) /* Send a Get_Source_Cap Message */ tx_emsg[port].len = 0; - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_GET_SOURCE_CAP); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_GET_SOURCE_CAP); } static void pe_snk_get_source_cap_run(int port) @@ -3857,7 +3859,7 @@ static void pe_soft_reset_entry(int port) { print_current_state(port); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_ACCEPT); } static void pe_soft_reset_run(int port) @@ -3893,10 +3895,10 @@ static void pe_send_not_supported_entry(int port) print_current_state(port); /* Request the Protocol Layer to send a Not_Supported Message. */ - if (prl_get_rev(port, TCPC_TX_SOP) > PD_REV20) - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_NOT_SUPPORTED); + if (prl_get_rev(port, TCPCI_MSG_SOP) > PD_REV20) + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_NOT_SUPPORTED); else - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_REJECT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT); } static void pe_send_not_supported_run(int port) @@ -3954,7 +3956,7 @@ __maybe_unused static void pe_chunk_received_exit(int port) static void pe_src_ping_entry(int port) { print_current_state(port); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PING); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_PING); } static void pe_src_ping_run(int port) @@ -4090,7 +4092,7 @@ static void pe_give_battery_cap_entry(int port) /* Extended Battery Cap data is 9 bytes */ tx_emsg[port].len = 9; - send_ext_data_msg(port, TCPC_TX_SOP, PD_EXT_BATTERY_CAP); + send_ext_data_msg(port, TCPCI_MSG_SOP, PD_EXT_BATTERY_CAP); } static void pe_give_battery_cap_run(int port) @@ -4181,7 +4183,7 @@ static void pe_give_battery_status_entry(int port) /* Battery Status data is 4 bytes */ tx_emsg[port].len = 4; - send_data_msg(port, TCPC_TX_SOP, PD_DATA_BATTERY_STATUS); + send_data_msg(port, TCPCI_MSG_SOP, PD_DATA_BATTERY_STATUS); } static void pe_give_battery_status_run(int port) @@ -4207,7 +4209,7 @@ static void pe_send_alert_entry(int port) pe_set_ready_state(port); /* Request the Protocol Layer to send Alert Message. */ - send_data_msg(port, TCPC_TX_SOP, PD_DATA_ALERT); + send_data_msg(port, TCPCI_MSG_SOP, PD_DATA_ALERT); } static void pe_send_alert_run(int port) @@ -4233,13 +4235,13 @@ static void pe_drs_evaluate_swap_entry(int port) * PE_DRS_UFP_DFP_Evaluate_Swap and * PE_DRS_DFP_UFP_Evaluate_Swap states embedded here. */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_ACCEPT); } else { /* * PE_DRS_UFP_DFP_Reject_Swap and PE_DRS_DFP_UFP_Reject_Swap * states embedded here. */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_REJECT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT); } } @@ -4308,7 +4310,7 @@ static void pe_drs_send_swap_entry(int port) * states embedded here. */ /* Request the Protocol Layer to send a DR_Swap Message */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_DR_SWAP); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_DR_SWAP); pe_sender_response_msg_entry(port); } @@ -4377,12 +4379,12 @@ static void pe_prs_src_snk_evaluate_swap_entry(int port) if (!pd_check_power_swap(port)) { /* PE_PRS_SRC_SNK_Reject_PR_Swap state embedded here */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_REJECT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT); } else { tc_request_power_swap(port); /* PE_PRS_SRC_SNK_Accept_Swap state embedded here */ PE_SET_FLAG(port, PE_FLAGS_ACCEPT); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_ACCEPT); } } @@ -4477,7 +4479,7 @@ static void pe_prs_src_snk_assert_rd_run(int port) static void pe_prs_src_snk_wait_source_on_entry(int port) { print_current_state(port); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PS_RDY); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_PS_RDY); } static void pe_prs_src_snk_wait_source_on_run(int port) @@ -4550,7 +4552,7 @@ static void pe_prs_src_snk_send_swap_entry(int port) pd_timer_disable(port, PE_TIMER_PR_SWAP_WAIT); /* Request the Protocol Layer to send a PR_Swap Message. */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PR_SWAP); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_PR_SWAP); pe_sender_response_msg_entry(port); } @@ -4638,12 +4640,12 @@ static void pe_prs_snk_src_evaluate_swap_entry(int port) if (!pd_check_power_swap(port)) { /* PE_PRS_SNK_SRC_Reject_Swap state embedded here */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_REJECT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT); } else { tc_request_power_swap(port); /* PE_PRS_SNK_SRC_Accept_Swap state embedded here */ PE_SET_FLAG(port, PE_FLAGS_ACCEPT); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_ACCEPT); } } @@ -4799,7 +4801,7 @@ static void pe_prs_snk_src_source_on_run(int port) /* update pe power role */ pe[port].power_role = pd_get_power_role(port); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PS_RDY); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_PS_RDY); /* reset timer so PD_CTRL_PS_RDY isn't sent again */ pd_timer_disable(port, PE_TIMER_PS_SOURCE); } @@ -4850,12 +4852,12 @@ static void pe_prs_snk_src_send_swap_entry(int port) */ if (IS_ENABLED(CONFIG_USB_PD_REV30)) { send_ctrl_msg(port, - TCPC_TX_SOP, + TCPCI_MSG_SOP, pe_in_frs_mode(port) ? PD_CTRL_FR_SWAP : PD_CTRL_PR_SWAP); } else { - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PR_SWAP); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_PR_SWAP); } pe_sender_response_msg_entry(port); } @@ -5044,7 +5046,7 @@ static void pe_bist_tx_entry(int port) * The UUT Shall exit the Continuous BIST Mode within * tBISTContMode of this Continuous BIST Mode being enabled. */ - send_ctrl_msg(port, TCPC_TX_BIST_MODE_2, 0); + send_ctrl_msg(port, TCPCI_MSG_TX_BIST_MODE_2, 0); pd_timer_enable(port, PE_TIMER_BIST_CONT_MODE, PD_T_BIST_CONT_MODE); } else if (mode == BIST_TEST_DATA) { @@ -5105,7 +5107,7 @@ static void pe_snk_give_sink_cap_entry(int port) /* Send a Sink_Capabilities Message */ tx_emsg[port].len = pd_snk_pdo_cnt * 4; memcpy(tx_emsg[port].buf, (uint8_t *)pd_snk_pdo, tx_emsg[port].len); - send_data_msg(port, TCPC_TX_SOP, PD_DATA_SINK_CAP); + send_data_msg(port, TCPCI_MSG_SOP, PD_DATA_SINK_CAP); } static void pe_snk_give_sink_cap_run(int port) @@ -5157,7 +5159,7 @@ static void pe_handle_custom_vdm_request_entry(int port) memcpy(tx_emsg[port].buf, (uint8_t *)rdata, tx_emsg[port].len); send_data_msg(port, sop, PD_DATA_VENDOR_DEF); } else { - if (prl_get_rev(port, TCPC_TX_SOP) > PD_REV20) { + if (prl_get_rev(port, TCPCI_MSG_SOP) > PD_REV20) { set_state_pe(port, PE_SEND_NOT_SUPPORTED); } else { PE_CLR_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS); @@ -5261,7 +5263,7 @@ static enum vdm_response_result parse_vdm_response_common(int port) */ static void pe_vdm_send_request_entry(int port) { - if (pe[port].tx_type == TCPC_TX_INVALID) { + if (pe[port].tx_type == TCPCI_MSG_INVALID) { if (IS_ENABLED(USB_PD_DEBUG_LABELS)) CPRINTS("C%d: %s: Tx type expected to be set, " "returning", @@ -5270,8 +5272,8 @@ static void pe_vdm_send_request_entry(int port) return; } - if ((pe[port].tx_type == TCPC_TX_SOP_PRIME || - pe[port].tx_type == TCPC_TX_SOP_PRIME_PRIME) && + if ((pe[port].tx_type == TCPCI_MSG_SOP_PRIME || + pe[port].tx_type == TCPCI_MSG_SOP_PRIME_PRIME) && !tc_is_vconn_src(port) && port_discovery_vconn_swap_policy(port, PE_FLAGS_VCONN_SWAP_TO_ON)) { if (port_try_vconn_swap(port)) @@ -5311,7 +5313,7 @@ static void pe_vdm_send_request_run(int port) */ if (pd_timer_is_expired(port, PE_TIMER_VDM_RESPONSE)) { CPRINTF("VDM %s Response Timeout\n", - pe[port].tx_type == TCPC_TX_SOP ? + pe[port].tx_type == TCPCI_MSG_SOP ? "Port" : "Cable"); /* * Flag timeout so child state can mark appropriate discovery @@ -5332,7 +5334,7 @@ static void pe_vdm_send_request_exit(int port) PE_CLR_FLAG(port, PE_FLAGS_INTERRUPTIBLE_AMS); /* Invalidate TX type so it must be set before next call */ - pe[port].tx_type = TCPC_TX_INVALID; + pe[port].tx_type = TCPCI_MSG_INVALID; pd_timer_disable(port, PE_TIMER_VDM_RESPONSE); } @@ -5434,7 +5436,7 @@ static void pe_vdm_identity_request_cbl_run(int port) * PD Spec Table 6-2: Revision Interoperability during an * Explicit Contract */ - if (prl_get_rev(port, TCPC_TX_SOP) != PD_REV20) + if (prl_get_rev(port, TCPCI_MSG_SOP) != PD_REV20) prl_set_rev(port, sop, PD_HEADER_REV(rx_emsg[port].header)); break; @@ -5464,7 +5466,7 @@ static void pe_vdm_identity_request_cbl_exit(int port) */ if (PE_CHK_FLAG(port, PE_FLAGS_VDM_REQUEST_TIMEOUT)) { PE_CLR_FLAG(port, PE_FLAGS_VDM_REQUEST_TIMEOUT); - prl_set_rev(port, TCPC_TX_SOP_PRIME, PD_REV20); + prl_set_rev(port, TCPCI_MSG_SOP_PRIME, PD_REV20); } /* @@ -5486,7 +5488,7 @@ static void pe_vdm_identity_request_cbl_exit(int port) * all retries are exhausted in case the cable is * non-compliant about GoodCRC-ing higher revisions */ - prl_set_rev(port, TCPC_TX_SOP_PRIME, PD_REV20); + prl_set_rev(port, TCPCI_MSG_SOP_PRIME, PD_REV20); /* * Set discover identity timer unless BUSY case already did so. @@ -5510,7 +5512,7 @@ static void pe_vdm_identity_request_cbl_exit(int port) /* Do not attempt further discovery if identity discovery failed. */ if (pd_get_identity_discovery(port, pe[port].tx_type) == PD_DISC_FAIL) { pd_set_svids_discovery(port, pe[port].tx_type, PD_DISC_FAIL); - pd_notify_event(port, pe[port].tx_type == TCPC_TX_SOP ? + pd_notify_event(port, pe[port].tx_type == TCPCI_MSG_SOP ? PD_STATUS_EVENT_SOP_DISC_DONE : PD_STATUS_EVENT_SOP_PRIME_DISC_DONE); } @@ -5597,7 +5599,7 @@ static void pe_init_port_vdm_identity_request_exit(int port) /* Do not attempt further discovery if identity discovery failed. */ if (pd_get_identity_discovery(port, pe[port].tx_type) == PD_DISC_FAIL) { pd_set_svids_discovery(port, pe[port].tx_type, PD_DISC_FAIL); - pd_notify_event(port, pe[port].tx_type == TCPC_TX_SOP ? + pd_notify_event(port, pe[port].tx_type == TCPCI_MSG_SOP ? PD_STATUS_EVENT_SOP_DISC_DONE : PD_STATUS_EVENT_SOP_PRIME_DISC_DONE); } @@ -5614,7 +5616,7 @@ static void pe_init_vdm_svids_request_entry(int port) print_current_state(port); - if (pe[port].tx_type == TCPC_TX_SOP_PRIME && + if (pe[port].tx_type == TCPCI_MSG_SOP_PRIME && !pe_can_send_sop_prime(port)) { /* * The parent state already tried to enable SOP' traffic. If it @@ -5690,7 +5692,7 @@ static void pe_init_vdm_svids_request_exit(int port) /* If SVID discovery failed, discovery is done at this point */ if (pd_get_svids_discovery(port, pe[port].tx_type) == PD_DISC_FAIL) - pd_notify_event(port, pe[port].tx_type == TCPC_TX_SOP ? + pd_notify_event(port, pe[port].tx_type == TCPCI_MSG_SOP ? PD_STATUS_EVENT_SOP_DISC_DONE : PD_STATUS_EVENT_SOP_PRIME_DISC_DONE); } @@ -5716,7 +5718,7 @@ static void pe_init_vdm_modes_request_entry(int port) print_current_state(port); - if (pe[port].tx_type == TCPC_TX_SOP_PRIME && + if (pe[port].tx_type == TCPCI_MSG_SOP_PRIME && !pe_can_send_sop_prime(port)) { /* * The parent state already tried to enable SOP' traffic. If it @@ -5800,7 +5802,7 @@ static void pe_init_vdm_modes_request_exit(int port) { if (pd_get_modes_discovery(port, pe[port].tx_type) != PD_DISC_NEEDED) /* Mode discovery done, notify the AP */ - pd_notify_event(port, pe[port].tx_type == TCPC_TX_SOP ? + pd_notify_event(port, pe[port].tx_type == TCPCI_MSG_SOP ? PD_STATUS_EVENT_SOP_DISC_DONE : PD_STATUS_EVENT_SOP_PRIME_DISC_DONE); @@ -5816,8 +5818,8 @@ static void pe_vdm_request_dpm_entry(int port) { print_current_state(port); - if ((pe[port].tx_type == TCPC_TX_SOP_PRIME || - pe[port].tx_type == TCPC_TX_SOP_PRIME_PRIME) && + if ((pe[port].tx_type == TCPCI_MSG_SOP_PRIME || + pe[port].tx_type == TCPCI_MSG_SOP_PRIME_PRIME) && !pe_can_send_sop_prime(port)) { /* * The parent state already tried to enable SOP' traffic. If it @@ -5908,7 +5910,7 @@ static void pe_vdm_request_dpm_run(int port) */ dpm_vdm_acked(port, sop, cnt, payload); - if (sop == TCPC_TX_SOP && svid == USB_SID_DISPLAYPORT && + if (sop == TCPCI_MSG_SOP && svid == USB_SID_DISPLAYPORT && vdm_cmd == CMD_DP_CONFIG) { PE_SET_FLAG(port, PE_FLAGS_VDM_SETUP_DONE); } @@ -5943,7 +5945,7 @@ static void pe_vdm_request_dpm_exit(int port) * current VDM request will be resumed. */ if (!PE_CHK_FLAG(port, PE_FLAGS_VDM_REQUEST_CONTINUE)) - pe[port].tx_type = TCPC_TX_INVALID; + pe[port].tx_type = TCPCI_MSG_INVALID; } /** @@ -6004,7 +6006,7 @@ static void pe_vdm_response_entry(int port) tx_payload[0] &= ~VDO_SVDM_VERS(0x3); /* Add SVDM structured version being used */ - tx_payload[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPC_TX_SOP)); + tx_payload[0] |= VDO_SVDM_VERS(pd_get_vdo_ver(port, TCPCI_MSG_SOP)); /* Use VDM command to select the response handler function */ switch (vdo_cmd) { @@ -6050,7 +6052,7 @@ static void pe_vdm_response_entry(int port) * reply to any SVDM command with a NAK. If the SVDM was an Attention * command, it does not have a response, and exits the function above. */ - if (func && (prl_get_rev(port, TCPC_TX_SOP) != PD_REV20 || + if (func && (prl_get_rev(port, TCPCI_MSG_SOP) != PD_REV20 || pe[port].data_role == PD_ROLE_UFP)) { /* * Execute SVDM response function selected above and set the @@ -6083,7 +6085,7 @@ static void pe_vdm_response_entry(int port) * ECNs 2020-12-10 Table 6-64 Response to an incoming * VDM or TD.PD.VNDI3.E3 VDM Identity steps) */ - if (prl_get_rev(port, TCPC_TX_SOP) == PD_REV30) { + if (prl_get_rev(port, TCPCI_MSG_SOP) == PD_REV30) { set_state_pe(port, PE_SEND_NOT_SUPPORTED); return; } @@ -6093,7 +6095,7 @@ static void pe_vdm_response_entry(int port) /* Send response message. Note len is in bytes, not VDO objects */ tx_emsg[port].len = (vdo_len * sizeof(uint32_t)); - send_data_msg(port, TCPC_TX_SOP, PD_DATA_VENDOR_DEF); + send_data_msg(port, TCPCI_MSG_SOP, PD_DATA_VENDOR_DEF); } static void pe_vdm_response_run(int port) @@ -6143,14 +6145,14 @@ static void pe_enter_usb_entry(int port) return; } - if ((pe[port].tx_type == TCPC_TX_SOP_PRIME || - pe[port].tx_type == TCPC_TX_SOP_PRIME_PRIME) && + if ((pe[port].tx_type == TCPCI_MSG_SOP_PRIME || + pe[port].tx_type == TCPCI_MSG_SOP_PRIME_PRIME) && !tc_is_vconn_src(port)) { if (port_try_vconn_swap(port)) return; } - pe[port].tx_type = TCPC_TX_SOP; + pe[port].tx_type = TCPCI_MSG_SOP; usb4_payload = enter_usb_setup_next_msg(port, &pe[port].tx_type); if (!usb4_payload) { @@ -6260,18 +6262,18 @@ static void pe_vcs_evaluate_swap_entry(int port) /* DPM rejects a VCONN Swap and port is not a VCONN source*/ if (!tc_check_vconn_swap(port) && tc_is_vconn_src(port) < 1) { /* NOTE: PE_VCS_Reject_Swap State embedded here */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_REJECT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT); } /* Port is not ready to perform a VCONN swap */ else if (tc_is_vconn_src(port) < 0) { /* NOTE: PE_VCS_Reject_Swap State embedded here */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_WAIT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_WAIT); } /* Port is ready to perform a VCONN swap */ else { /* NOTE: PE_VCS_Accept_Swap State embedded here */ PE_SET_FLAG(port, PE_FLAGS_ACCEPT); - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_ACCEPT); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_ACCEPT); } } @@ -6311,7 +6313,7 @@ static void pe_vcs_send_swap_entry(int port) print_current_state(port); /* Send a VCONN_Swap Message */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_VCONN_SWAP); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_VCONN_SWAP); pe_sender_response_msg_entry(port); } @@ -6319,7 +6321,7 @@ static void pe_vcs_send_swap_run(int port) { uint8_t type; uint8_t cnt; - enum tcpm_sop_type sop; + enum tcpci_msg_type sop; enum pe_msg_check msg_check; /* @@ -6565,7 +6567,7 @@ static void pe_vcs_send_ps_rdy_swap_entry(int port) /* Check for any interruptions to this non-interruptible AMS */ if (PE_CHK_FLAG(port, PE_FLAGS_MSG_RECEIVED)) { - enum tcpm_sop_type sop = + enum tcpci_msg_type sop = PD_HEADER_GET_SOP(rx_emsg[port].header); PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED); @@ -6576,7 +6578,7 @@ static void pe_vcs_send_ps_rdy_swap_entry(int port) } /* Send a PS_RDY Message */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PS_RDY); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_PS_RDY); } static void pe_vcs_send_ps_rdy_swap_run(int port) @@ -6606,7 +6608,7 @@ static void pe_vcs_send_ps_rdy_swap_run(int port) if (PE_CHK_FLAG(port, PE_FLAGS_PROTOCOL_ERROR)) { PE_CLR_FLAG(port, PE_FLAGS_PROTOCOL_ERROR); /* PS_RDY didn't send, soft reset */ - pe_send_soft_reset(port, TCPC_TX_SOP); + pe_send_soft_reset(port, TCPCI_MSG_SOP); } } @@ -6681,7 +6683,7 @@ static void pe_vcs_cbl_send_soft_reset_entry(int port) return; } - send_ctrl_msg(port, TCPC_TX_SOP_PRIME, PD_CTRL_SOFT_RESET); + send_ctrl_msg(port, TCPCI_MSG_SOP_PRIME, PD_CTRL_SOFT_RESET); pe_sender_response_msg_entry(port); } @@ -6705,8 +6707,8 @@ static void pe_vcs_cbl_send_soft_reset_run(int port) * PD Spec Table 6-2: Revision Interoperability during an * Explicit Contract */ - if (prl_get_rev(port, TCPC_TX_SOP) != PD_REV20) - prl_set_rev(port, TCPC_TX_SOP_PRIME, + if (prl_get_rev(port, TCPCI_MSG_SOP) != PD_REV20) + prl_set_rev(port, TCPCI_MSG_SOP_PRIME, PD_HEADER_REV(rx_emsg[port].header)); } @@ -6752,7 +6754,7 @@ static void pe_dr_get_sink_cap_entry(int port) print_current_state(port); /* Send a Get Sink Cap Message */ - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_GET_SINK_CAP); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_GET_SINK_CAP); pe_sender_response_msg_entry(port); } @@ -6762,7 +6764,7 @@ static void pe_dr_get_sink_cap_run(int port) int cnt; int ext; enum pe_msg_check msg_check; - enum tcpm_sop_type sop; + enum tcpci_msg_type sop; /* * Check the state of the message sent @@ -6787,7 +6789,7 @@ static void pe_dr_get_sink_cap_run(int port) ext = PD_HEADER_EXT(rx_emsg[port].header); sop = PD_HEADER_GET_SOP(rx_emsg[port].header); - if (ext == 0 && sop == TCPC_TX_SOP) { + if (ext == 0 && sop == TCPCI_MSG_SOP) { if ((cnt > 0) && (type == PD_DATA_SINK_CAP)) { uint32_t *payload = (uint32_t *)rx_emsg[port].buf; @@ -6851,7 +6853,7 @@ static void pe_dr_snk_give_source_cap_run(int port) PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE); set_state_pe(port, PE_SNK_READY); } else if (PE_CHK_FLAG(port, PE_FLAGS_MSG_DISCARDED)) { - pe_send_soft_reset(port, TCPC_TX_SOP); + pe_send_soft_reset(port, TCPCI_MSG_SOP); } } @@ -6864,7 +6866,7 @@ static void pe_dr_src_get_source_cap_entry(int port) /* Send a Get_Source_Cap Message */ tx_emsg[port].len = 0; - send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_GET_SOURCE_CAP); + send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_GET_SOURCE_CAP); pe_sender_response_msg_entry(port); } @@ -6988,8 +6990,8 @@ void pd_dfp_discovery_init(int port) PE_CLR_FLAG(port, PE_FLAGS_VDM_SETUP_DONE | PE_FLAGS_MODAL_OPERATION); - atomic_or(&task_access[port][TCPC_TX_SOP], BIT(task_get_current())); - atomic_or(&task_access[port][TCPC_TX_SOP_PRIME], + atomic_or(&task_access[port][TCPCI_MSG_SOP], BIT(task_get_current())); + atomic_or(&task_access[port][TCPCI_MSG_SOP_PRIME], BIT(task_get_current())); memset(pe[port].discovery, 0, sizeof(pe[port].discovery)); @@ -7010,7 +7012,7 @@ void pd_dfp_discovery_init(int port) } __maybe_unused void pd_discovery_access_clear(int port, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) assert(0); @@ -7019,7 +7021,7 @@ __maybe_unused void pd_discovery_access_clear(int port, } __maybe_unused bool pd_discovery_access_validate(int port, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) assert(0); @@ -7028,7 +7030,7 @@ __maybe_unused bool pd_discovery_access_validate(int port, } __maybe_unused struct pd_discovery *pd_get_am_discovery(int port, - enum tcpm_sop_type type) + enum tcpci_msg_type type) { if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) assert(0); @@ -7039,7 +7041,7 @@ __maybe_unused struct pd_discovery *pd_get_am_discovery(int port, } __maybe_unused struct partner_active_modes *pd_get_partner_active_modes( - int port, enum tcpm_sop_type type) + int port, enum tcpci_msg_type type) { if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) assert(0); diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index 0fcc9ba663..a58a579775 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -312,7 +312,7 @@ static struct tx_chunked { /* Message Reception State Machine Object */ static struct protocol_layer_rx { /* received message type */ - enum tcpm_sop_type sop; + enum tcpci_msg_type sop; /* message ids for all valid port partners */ int msg_id[NUM_SOP_STAR_TYPES]; } prl_rx[CONFIG_USB_PD_PORT_MAX_COUNT]; @@ -324,7 +324,7 @@ static struct protocol_layer_tx { /* state machine flags */ uint32_t flags; /* last message type we transmitted */ - enum tcpm_sop_type last_xmit_type; + enum tcpci_msg_type last_xmit_type; /* message id counters for all 6 port partners */ uint32_t msg_id_counter[NUM_SOP_STAR_TYPES]; /* transmit status */ @@ -344,7 +344,7 @@ static struct pd_message { /* message status flags */ uint32_t flags; /* SOP* */ - enum tcpm_sop_type xmit_type; + enum tcpci_msg_type xmit_type; /* type of message */ uint8_t msg_type; /* PD revision */ @@ -566,7 +566,7 @@ static void prl_init(int port) prl_tx[port].flags = 0; if (IS_ENABLED(CONFIG_USB_PD_REV30)) typec_select_src_collision_rp(port, SINK_TX_OK); - prl_tx[port].last_xmit_type = TCPC_TX_SOP; + prl_tx[port].last_xmit_type = TCPCI_MSG_SOP; prl_tx[port].xmit_status = TCPC_TX_UNSET; if (IS_ENABLED(CONFIG_USB_PD_REV30)) { @@ -627,7 +627,7 @@ void prl_hard_reset_complete(int port) } void prl_send_ctrl_msg(int port, - enum tcpm_sop_type type, + enum tcpci_msg_type type, enum pd_ctrl_msg_type msg) { pdmsg[port].xmit_type = type; @@ -647,7 +647,7 @@ void prl_send_ctrl_msg(int port, } void prl_send_data_msg(int port, - enum tcpm_sop_type type, + enum tcpci_msg_type type, enum pd_data_msg_type msg) { pdmsg[port].xmit_type = type; @@ -667,7 +667,7 @@ void prl_send_data_msg(int port, #ifdef CONFIG_USB_PD_EXTENDED_MESSAGES void prl_send_ext_data_msg(int port, - enum tcpm_sop_type type, + enum tcpci_msg_type type, enum pd_ext_msg_type msg) { pdmsg[port].xmit_type = type; @@ -686,11 +686,11 @@ void prl_set_default_pd_revision(int port) * partner doesn't support this revision, the Protocol Engine will * lower this value to the revision supported by the partner. */ - pdmsg[port].rev[TCPC_TX_SOP] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_PRIME_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME] = PD_REVISION; - pdmsg[port].rev[TCPC_TX_SOP_DEBUG_PRIME_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPCI_MSG_SOP] = PD_REVISION; + pdmsg[port].rev[TCPCI_MSG_SOP_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPCI_MSG_SOP_PRIME_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPCI_MSG_SOP_DEBUG_PRIME] = PD_REVISION; + pdmsg[port].rev[TCPCI_MSG_SOP_DEBUG_PRIME_PRIME] = PD_REVISION; } void prl_reset_soft(int port) @@ -772,7 +772,7 @@ void prl_run(int port, int evt, int en) } } -void prl_set_rev(int port, enum tcpm_sop_type type, +void prl_set_rev(int port, enum tcpci_msg_type type, enum pd_rev_type rev) { /* We only store revisions for SOP* types. */ @@ -781,7 +781,7 @@ void prl_set_rev(int port, enum tcpm_sop_type type, pdmsg[port].rev[type] = rev; } -enum pd_rev_type prl_get_rev(int port, enum tcpm_sop_type type) +enum pd_rev_type prl_get_rev(int port, enum tcpci_msg_type type) { /* We only store revisions for SOP* types. */ ASSERT(type < NUM_SOP_STAR_TYPES); @@ -838,7 +838,7 @@ static __maybe_unused int pdmsg_xmit_type_is_rev30(const int port) static bool is_sop_rev30(const int port) { return IS_ENABLED(CONFIG_USB_PD_REV30) && - prl_get_rev(port, TCPC_TX_SOP) == PD_REV30; + prl_get_rev(port, TCPCI_MSG_SOP) == PD_REV30; } /* Common Protocol Layer Message Transmission */ @@ -1053,7 +1053,7 @@ static void prl_tx_layer_reset_for_transmit_run(const int port) static uint32_t get_sop_star_header(const int port) { - const int is_sop_packet = pdmsg[port].xmit_type == TCPC_TX_SOP; + const int is_sop_packet = pdmsg[port].xmit_type == TCPCI_MSG_SOP; int ext; #ifdef CONFIG_USB_PD_EXTENDED_MESSAGES @@ -1280,7 +1280,7 @@ void prl_hr_send_msg_to_phy(const int port) /* Header is not used for hard reset */ const uint32_t header = 0; - pdmsg[port].xmit_type = TCPC_TX_HARD_RESET; + pdmsg[port].xmit_type = TCPCI_MSG_TX_HARD_RESET; /* * These flags could be set if this function is called before the @@ -2191,7 +2191,7 @@ static void prl_rx_wait_for_phy_message(const int port, int evt) */ if (!IS_ENABLED(CONFIG_USB_CTVPD) && !IS_ENABLED(CONFIG_USB_VPD) && - PD_HEADER_GET_SOP(header) != TCPC_TX_SOP && + PD_HEADER_GET_SOP(header) != TCPCI_MSG_SOP && PD_HEADER_PROLE(header) == PD_PLUG_FROM_DFP_UFP) return; diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 26fce67011..041c3c7187 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -531,7 +531,7 @@ void pd_set_src_caps(int port, int cnt, uint32_t *src_caps) { } -int pd_get_rev(int port, enum tcpm_sop_type type) +int pd_get_rev(int port, enum tcpci_msg_type type) { return PD_REV30; } @@ -708,9 +708,9 @@ static void tc_set_modes_exit(int port) { if (IS_ENABLED(CONFIG_USB_PE_SM) && IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) { - pd_dfp_exit_mode(port, TCPC_TX_SOP, 0, 0); - pd_dfp_exit_mode(port, TCPC_TX_SOP_PRIME, 0, 0); - pd_dfp_exit_mode(port, TCPC_TX_SOP_PRIME_PRIME, 0, 0); + pd_dfp_exit_mode(port, TCPCI_MSG_SOP, 0, 0); + pd_dfp_exit_mode(port, TCPCI_MSG_SOP_PRIME, 0, 0); + pd_dfp_exit_mode(port, TCPCI_MSG_SOP_PRIME_PRIME, 0, 0); } } @@ -3930,7 +3930,7 @@ static void pd_chipset_reset(void) return; for (i = 0; i < board_get_usb_pd_port_count(); i++) { - enum tcpm_sop_type tx; + enum tcpci_msg_type tx; /* Do not notify the AP of irrelevant past Hard Resets. */ pd_clear_events(i, PD_STATUS_EVENT_HARD_RESET); @@ -3939,11 +3939,11 @@ static void pd_chipset_reset(void) * Re-set events for SOP and SOP' discovery complete so the * kernel knows to consume discovery information for them. */ - for (tx = TCPC_TX_SOP; tx <= TCPC_TX_SOP_PRIME; tx++) { + for (tx = TCPCI_MSG_SOP; tx <= TCPCI_MSG_SOP_PRIME; tx++) { if (pd_get_identity_discovery(i, tx) != PD_DISC_NEEDED && pd_get_svids_discovery(i, tx) != PD_DISC_NEEDED && pd_get_modes_discovery(i, tx) != PD_DISC_NEEDED) - pd_notify_event(i, tx == TCPC_TX_SOP ? + pd_notify_event(i, tx == TCPCI_MSG_SOP ? PD_STATUS_EVENT_SOP_DISC_DONE : PD_STATUS_EVENT_SOP_PRIME_DISC_DONE); } -- cgit v1.2.1