diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/mock/tcpc_mock.c | 2 | ||||
-rw-r--r-- | common/mock/tcpci_i2c_mock.c | 11 | ||||
-rw-r--r-- | common/mock/usb_pd_dpm_mock.c | 5 | ||||
-rw-r--r-- | common/mock/usb_pe_sm_mock.c | 5 | ||||
-rw-r--r-- | common/mock/usb_prl_mock.c | 19 | ||||
-rw-r--r-- | common/usb_common.c | 2 | ||||
-rw-r--r-- | common/usb_pd_alt_mode_dfp.c | 52 | ||||
-rw-r--r-- | common/usb_pd_console_cmd.c | 3 | ||||
-rw-r--r-- | common/usb_pd_policy.c | 27 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 16 | ||||
-rw-r--r-- | common/usb_pd_tcpc.c | 4 | ||||
-rw-r--r-- | common/usbc/dp_alt_mode.c | 6 | ||||
-rw-r--r-- | common/usbc/tbt_alt_mode.c | 9 | ||||
-rw-r--r-- | common/usbc/usb_mode.c | 9 | ||||
-rw-r--r-- | common/usbc/usb_pd_dpm.c | 9 | ||||
-rw-r--r-- | common/usbc/usb_pd_host.c | 3 | ||||
-rw-r--r-- | common/usbc/usb_pe_ctvpd_sm.c | 3 | ||||
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 38 | ||||
-rw-r--r-- | common/usbc/usb_prl_sm.c | 16 | ||||
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 5 |
20 files changed, 128 insertions, 116 deletions
diff --git a/common/mock/tcpc_mock.c b/common/mock/tcpc_mock.c index d000133a2a..b12267401f 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_transmit_type type, +static int mock_transmit(int port, enum tcpm_sop_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 a9cc09fb54..f11d12c7d6 100644 --- a/common/mock/tcpci_i2c_mock.c +++ b/common/mock/tcpci_i2c_mock.c @@ -8,6 +8,7 @@ #include "tcpm/tcpci.h" #include "test_util.h" #include "timer.h" +#include "usb_pd_tcpm.h" #ifndef TEST_BUILD #error "Mocks should only be in the test build." @@ -180,7 +181,7 @@ static bool debug_accessory_indicator_supported(void) return true; } -static int verify_transmit(enum tcpm_transmit_type want_tx_type, +static int verify_transmit(enum tcpm_sop_type want_tx_type, int want_tx_retry, enum pd_ctrl_msg_type want_ctrl_msg, enum pd_data_msg_type want_data_msg, @@ -229,7 +230,7 @@ static int verify_transmit(enum tcpm_transmit_type want_tx_type, return EC_ERROR_UNKNOWN; } -int verify_tcpci_transmit(enum tcpm_transmit_type tx_type, +int verify_tcpci_transmit(enum tcpm_sop_type tx_type, enum pd_ctrl_msg_type ctrl_msg, enum pd_data_msg_type data_msg) { @@ -238,7 +239,7 @@ int verify_tcpci_transmit(enum tcpm_transmit_type tx_type, VERIFY_TIMEOUT); } -int verify_tcpci_tx_timeout(enum tcpm_transmit_type tx_type, +int verify_tcpci_tx_timeout(enum tcpm_sop_type tx_type, enum pd_ctrl_msg_type ctrl_msg, enum pd_data_msg_type data_msg, int timeout) @@ -248,7 +249,7 @@ int verify_tcpci_tx_timeout(enum tcpm_transmit_type tx_type, timeout); } -int verify_tcpci_tx_retry_count(enum tcpm_transmit_type tx_type, +int verify_tcpci_tx_retry_count(enum tcpm_sop_type tx_type, enum pd_ctrl_msg_type ctrl_msg, enum pd_data_msg_type data_msg, int retry_count) @@ -258,7 +259,7 @@ int verify_tcpci_tx_retry_count(enum tcpm_transmit_type tx_type, VERIFY_TIMEOUT); } -int verify_tcpci_tx_with_data(enum tcpm_transmit_type tx_type, +int verify_tcpci_tx_with_data(enum tcpm_sop_type tx_type, enum pd_data_msg_type data_msg, uint8_t *data, int data_bytes, diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c index 3da96fea2d..9bec8358dd 100644 --- a/common/mock/usb_pd_dpm_mock.c +++ b/common/mock/usb_pd_dpm_mock.c @@ -11,6 +11,7 @@ #include "usb_pd.h" #include "mock/usb_pd_dpm_mock.h" #include "memory.h" +#include "usb_pd_tcpm.h" #ifndef TEST_BUILD #error "Mocks should only be in the test build." @@ -30,12 +31,12 @@ void dpm_init(int port) dpm[port].mode_exit_request = false; } -void dpm_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count, +void dpm_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, uint32_t *vdm) { } -void dpm_vdm_naked(int port, enum tcpm_transmit_type type, uint16_t svid, +void dpm_vdm_naked(int port, enum tcpm_sop_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 150cbb51e6..a237102a74 100644 --- a/common/mock/usb_pe_sm_mock.c +++ b/common/mock/usb_pe_sm_mock.c @@ -11,6 +11,7 @@ #include "usb_pe_sm.h" #include "mock/usb_pe_sm_mock.h" #include "memory.h" +#include "usb_pd_tcpm.h" #ifndef CONFIG_COMMON_RUNTIME #define cprints(format, args...) @@ -45,7 +46,7 @@ void mock_pe_port_reset(void) } } -void pe_report_error(int port, enum pe_error e, enum tcpm_transmit_type type) +void pe_report_error(int port, enum pe_error e, enum tcpm_sop_type type) { mock_pe_port[port].mock_pe_error = e; mock_pe_port[port].sop = type; @@ -109,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_transmit_type type) +int pd_get_rev(int port, enum tcpm_sop_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 9caf63fbf4..ae7874d4ac 100644 --- a/common/mock/usb_prl_mock.c +++ b/common/mock/usb_prl_mock.c @@ -13,6 +13,7 @@ #include "task.h" #include "test_util.h" #include "timer.h" +#include "usb_pd_tcpm.h" #ifndef TEST_BUILD #error "Mocks should only be in the test build." @@ -25,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_transmit_type last_tx_type; + enum tcpm_sop_type last_tx_type; bool message_sent; bool message_received; enum pe_error error; - enum tcpm_transmit_type error_tx_type; + enum tcpm_sop_type error_tx_type; }; struct mock_prl_port_t mock_prl_port[CONFIG_USB_PD_PORT_MAX_COUNT]; @@ -60,7 +61,7 @@ void prl_execute_hard_reset(int port) mock_prl_port[port].last_tx_type = TCPC_TX_HARD_RESET; } -enum pd_rev_type prl_get_rev(int port, enum tcpm_transmit_type partner) +enum pd_rev_type prl_get_rev(int port, enum tcpm_sop_type partner) { return PD_REV30; } @@ -81,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_transmit_type type, +void prl_send_ctrl_msg(int port, enum tcpm_sop_type type, enum pd_ctrl_msg_type msg) { mock_prl_port[port].last_ctrl_msg = msg; @@ -89,7 +90,7 @@ void prl_send_ctrl_msg(int port, enum tcpm_transmit_type type, mock_prl_port[port].last_tx_type = type; } -void prl_send_data_msg(int port, enum tcpm_transmit_type type, +void prl_send_data_msg(int port, enum tcpm_sop_type type, enum pd_data_msg_type msg) { mock_prl_port[port].last_data_msg = msg; @@ -97,17 +98,17 @@ void prl_send_data_msg(int port, enum tcpm_transmit_type type, mock_prl_port[port].last_tx_type = type; } -void prl_send_ext_data_msg(int port, enum tcpm_transmit_type type, +void prl_send_ext_data_msg(int port, enum tcpm_sop_type type, enum pd_ext_msg_type msg) {} -void prl_set_rev(int port, enum tcpm_transmit_type partner, +void prl_set_rev(int port, enum tcpm_sop_type partner, enum pd_rev_type rev) {} int mock_prl_wait_for_tx_msg(int port, - enum tcpm_transmit_type tx_type, + enum tcpm_sop_type tx_type, enum pd_ctrl_msg_type ctrl_msg, enum pd_data_msg_type data_msg, int timeout) @@ -170,7 +171,7 @@ void mock_prl_message_received(int port) } void mock_prl_report_error(int port, enum pe_error e, - enum tcpm_transmit_type tx_type) + enum tcpm_sop_type tx_type) { mock_prl_port[port].error = e; mock_prl_port[port].error_tx_type = tx_type; diff --git a/common/usb_common.c b/common/usb_common.c index 9e17c0d98c..a77771d9e4 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_transmit_type type) +int pd_get_retry_count(int port, enum tcpm_sop_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; diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c index 3c43b847d6..3c5d133bc4 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_transmit_type type, +static int pd_get_mode_idx(int port, enum tcpm_sop_type type, uint16_t svid) { int amode_idx; @@ -73,7 +73,7 @@ static int pd_get_mode_idx(int port, enum tcpm_transmit_type type, return -1; } -static int pd_allocate_mode(int port, enum tcpm_transmit_type type, +static int pd_allocate_mode(int port, enum tcpm_sop_type type, uint16_t svid) { int i, j; @@ -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_transmit_type type, uint16_t svid) + enum tcpm_sop_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_transmit_type type, +uint32_t pd_dfp_enter_mode(int port, enum tcpm_sop_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_transmit_type type, } /* TODO(b/170372521) : Incorporate exit mode specific changes to DPM SM */ -int pd_dfp_exit_mode(int port, enum tcpm_transmit_type type, uint16_t svid, +int pd_dfp_exit_mode(int port, enum tcpm_sop_type type, uint16_t svid, int opos) { struct svdm_amode_data *modep; @@ -353,7 +353,7 @@ void dfp_consume_attention(int port, uint32_t *payload) modep->fx->attention(port, payload); } -void dfp_consume_identity(int port, enum tcpm_transmit_type type, int cnt, +void dfp_consume_identity(int port, enum tcpm_sop_type type, int cnt, uint32_t *payload) { int ptype; @@ -396,7 +396,7 @@ void dfp_consume_identity(int port, enum tcpm_transmit_type type, int cnt, pd_set_identity_discovery(port, type, PD_DISC_COMPLETE); } -void dfp_consume_svids(int port, enum tcpm_transmit_type type, int cnt, +void dfp_consume_svids(int port, enum tcpm_sop_type type, int cnt, uint32_t *payload) { int i; @@ -441,7 +441,7 @@ void dfp_consume_svids(int port, enum tcpm_transmit_type type, int cnt, pd_set_svids_discovery(port, type, PD_DISC_COMPLETE); } -void dfp_consume_modes(int port, enum tcpm_transmit_type type, int cnt, +void dfp_consume_modes(int port, enum tcpm_sop_type type, int cnt, uint32_t *payload) { int svid_idx; @@ -488,14 +488,14 @@ void dfp_consume_modes(int port, enum tcpm_transmit_type type, int cnt, PD_DISC_COMPLETE); } -int pd_alt_mode(int port, enum tcpm_transmit_type type, uint16_t svid) +int pd_alt_mode(int port, enum tcpm_sop_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_transmit_type type, +void pd_set_identity_discovery(int port, enum tcpm_sop_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_transmit_type type, } enum pd_discovery_state pd_get_identity_discovery(int port, - enum tcpm_transmit_type type) + enum tcpm_sop_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_transmit_type type) + enum tcpm_sop_type type) { if (type >= DISCOVERY_TYPE_COUNT) return NULL; @@ -544,7 +544,7 @@ uint8_t pd_get_product_type(int port) return resp->idh.product_type; } -void pd_set_svids_discovery(int port, enum tcpm_transmit_type type, +void pd_set_svids_discovery(int port, enum tcpm_sop_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_transmit_type type, } enum pd_discovery_state pd_get_svids_discovery(int port, - enum tcpm_transmit_type type) + enum tcpm_sop_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_transmit_type type) +int pd_get_svid_count(int port, enum tcpm_sop_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_transmit_type type) +uint16_t pd_get_svid(int port, uint16_t svid_idx, enum tcpm_sop_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_transmit_type type, +void pd_set_modes_discovery(int port, enum tcpm_sop_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_transmit_type type, } enum pd_discovery_state pd_get_modes_discovery(int port, - enum tcpm_transmit_type type) + enum tcpm_sop_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_transmit_type type, +int pd_get_mode_vdo_for_svid(int port, enum tcpm_sop_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_transmit_type type, } struct svid_mode_data *pd_get_next_mode(int port, - enum tcpm_transmit_type type) + enum tcpm_sop_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_transmit_type type) + enum tcpm_sop_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_transmit_type type, +bool pd_is_mode_discovered_for_svid(int port, enum tcpm_sop_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_transmit_type type) +static inline bool is_pd_rev3(int port, enum tcpm_sop_type type) { return pd_get_rev(port, type) == PD_REV30; } @@ -848,7 +848,7 @@ bool is_active_cable_element_retimer(int port) * ############################################################################ */ -uint32_t pd_get_tbt_mode_vdo(int port, enum tcpm_transmit_type type) +uint32_t pd_get_tbt_mode_vdo(int port, enum tcpm_sop_type type) { uint32_t tbt_mode_vdo[PDO_MODES]; @@ -960,13 +960,13 @@ 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_transmit_type sop, +int enter_tbt_compat_mode(int port, enum tcpm_sop_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_transmit_type enter_mode_sop = + enum tcpm_sop_type enter_mode_sop = sop == TCPC_TX_SOP_PRIME_PRIME ? TCPC_TX_SOP_PRIME : sop; diff --git a/common/usb_pd_console_cmd.c b/common/usb_pd_console_cmd.c index 1448424213..9746904a1d 100644 --- a/common/usb_pd_console_cmd.c +++ b/common/usb_pd_console_cmd.c @@ -8,6 +8,7 @@ #include "console.h" #include "usb_pd.h" #include "util.h" +#include "usb_pd_tcpm.h" #ifdef CONFIG_USB_PD_ALT_MODE_DFP #ifdef CONFIG_CMD_USB_PD_PE @@ -17,7 +18,7 @@ static void dump_pe(int port) struct svdm_amode_data *modep; uint32_t mode_caps; const union disc_ident_ack *resp; - enum tcpm_transmit_type type; + enum tcpm_sop_type type; /* TODO(b/152417597): Output SOP' discovery results */ const struct pd_discovery *disc = pd_get_am_discovery(port, TCPC_TX_SOP); diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c index 3ba2ea0c5c..e91b99393b 100644 --- a/common/usb_pd_policy.c +++ b/common/usb_pd_policy.c @@ -26,6 +26,7 @@ #include "usb_common.h" #include "usb_mux.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" #include "usbc_ppc.h" #ifdef CONFIG_COMMON_RUNTIME @@ -246,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_transmit_type type) +static bool is_intel_svid(int port, enum tcpm_sop_type type) { int i; @@ -368,13 +369,13 @@ static int dfp_discover_svids(uint32_t *payload) return 1; } -struct pd_discovery *pd_get_am_discovery(int port, enum tcpm_transmit_type type) +struct pd_discovery *pd_get_am_discovery(int port, enum tcpm_sop_type type) { return &discovery[port][type]; } struct partner_active_modes * -pd_get_partner_active_modes(int port, enum tcpm_transmit_type type) +pd_get_partner_active_modes(int port, enum tcpm_sop_type type) { assert(type < AMODE_TYPE_COUNT); return &partner_amodes[port][type]; @@ -424,7 +425,7 @@ 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_transmit_type *rtype) + enum tcpm_sop_type *rtype) { pd_dfp_discovery_init(port); dfp_consume_identity(port, TCPC_TX_SOP, cnt, payload); @@ -490,8 +491,8 @@ 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_transmit_type sop, - enum tcpm_transmit_type *rtype) + enum tcpm_sop_type sop, + enum tcpm_sop_type *rtype) { /* * The pd_discovery structure stores SOP and SOP' discovery results @@ -540,9 +541,9 @@ static int process_am_discover_svids(int port, int cnt, uint32_t *payload, } static int process_tbt_compat_discover_modes(int port, - enum tcpm_transmit_type sop, + enum tcpm_sop_type sop, uint32_t *payload, - enum tcpm_transmit_type *rtype) + enum tcpm_sop_type *rtype) { int rsize; @@ -604,9 +605,9 @@ static int process_tbt_compat_discover_modes(int port, return rsize; } -static int obj_cnt_enter_tbt_compat_mode(int port, enum tcpm_transmit_type sop, +static int obj_cnt_enter_tbt_compat_mode(int port, enum tcpm_sop_type sop, uint32_t *payload, - enum tcpm_transmit_type *rtype) + enum tcpm_sop_type *rtype) { struct pd_discovery *disc = &discovery[port][TCPC_TX_SOP_PRIME]; @@ -630,7 +631,7 @@ static int obj_cnt_enter_tbt_compat_mode(int port, enum tcpm_transmit_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_transmit_type *rtype) + uint32_t head, enum tcpm_sop_type *rtype) { int cmd = PD_VDO_CMD(payload[0]); int cmd_type = PD_VDO_CMDT(payload[0]); @@ -639,7 +640,7 @@ 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_transmit_type sop = PD_HEADER_GET_SOP(head); + enum tcpm_sop_type sop = PD_HEADER_GET_SOP(head); #endif /* Transmit SOP messages by default */ @@ -843,7 +844,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_transmit_type *rtype) + uint32_t head, enum tcpm_sop_type *rtype) { return 0; } diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 510f0447b4..e20fa11aee 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_transmit_type xmit_type; + enum tcpm_sop_type xmit_type; uint8_t vdo_count; /* VDO to retry if UFP responder replied busy. */ uint32_t vdo_retry; @@ -345,7 +345,7 @@ static inline void set_state_timeout(int port, pd[port].timeout_state = timeout_state; } -int pd_get_rev(int port, enum tcpm_transmit_type type) +int pd_get_rev(int port, enum tcpm_sop_type type) { #ifdef CONFIG_USB_PD_REV30 /* TCPMv1 Only stores PD revision for SOP and SOP' types */ @@ -360,7 +360,7 @@ int pd_get_rev(int port, enum tcpm_transmit_type type) #endif } -int pd_get_vdo_ver(int port, enum tcpm_transmit_type type) +int pd_get_vdo_ver(int port, enum tcpm_sop_type type) { #ifdef CONFIG_USB_PD_REV30 if (type == TCPC_TX_SOP_PRIME) @@ -681,7 +681,7 @@ 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_transmit_type sop = PD_HEADER_GET_SOP(msg_header); + enum tcpm_sop_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 && @@ -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_transmit_type type, +static int pd_transmit(int port, enum tcpm_sop_type type, uint16_t header, const uint32_t *data, enum ams_seq ams) { int evt; @@ -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_transmit_type type) + int data_cnt, enum tcpm_sop_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_transmit_type rtype = TCPC_TX_SOP; + enum tcpm_sop_type rtype = TCPC_TX_SOP; if (pd[port].vdm_state == VDM_STATE_BUSY) { /* If UFP responded busy retry after timeout */ @@ -2213,7 +2213,7 @@ static void pd_vdm_send_state_machine(int port) { int res; uint16_t header; - enum tcpm_transmit_type msg_type = pd[port].xmit_type; + enum tcpm_sop_type msg_type = pd[port].xmit_type; switch (pd[port].vdm_state) { case VDM_STATE_READY: diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c index 118c11f1e6..325af57af8 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_transmit_type tx_type; + enum tcpm_sop_type tx_type; uint16_t tx_head; uint32_t tx_payload[7]; const uint32_t *tx_data; @@ -1128,7 +1128,7 @@ int tcpc_set_rx_enable(int port, int enable) return EC_SUCCESS; } -int tcpc_transmit(int port, enum tcpm_transmit_type type, uint16_t header, +int tcpc_transmit(int port, enum tcpm_sop_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 eb42dfef0f..1f62d5fb71 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_transmit_type type, +static bool dp_response_valid(int port, enum tcpm_sop_type type, char *cmdt, int vdm_cmd) { enum dp_states st = dp_state[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_transmit_type type, int vdo_count, +void dp_vdm_acked(int port, enum tcpm_sop_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_transmit_type type, int vdo_count, } } -void dp_vdm_naked(int port, enum tcpm_transmit_type type, uint8_t vdm_cmd) +void dp_vdm_naked(int port, enum tcpm_sop_type type, uint8_t vdm_cmd) { if (!dp_response_valid(port, type, "NAK", vdm_cmd)) return; diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c index fdee453904..b54848053c 100644 --- a/common/usbc/tbt_alt_mode.c +++ b/common/usbc/tbt_alt_mode.c @@ -18,6 +18,7 @@ #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_tbt.h" +#include "usb_pd_tcpm.h" #include "usb_pe_sm.h" #include "usb_tbt_alt_mode.h" @@ -184,7 +185,7 @@ void tbt_exit_mode_request(int port) } } -static bool tbt_response_valid(int port, enum tcpm_transmit_type type, +static bool tbt_response_valid(int port, enum tcpm_sop_type type, char *cmdt, int vdm_cmd) { enum tbt_states st = tbt_state[port]; @@ -258,7 +259,7 @@ bool tbt_cable_entry_required_for_usb4(int port) return false; } -void intel_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count, +void intel_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, uint32_t *vdm) { struct pd_discovery *disc; @@ -366,7 +367,7 @@ void intel_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count, } } -void intel_vdm_naked(int port, enum tcpm_transmit_type type, uint8_t vdm_cmd) +void intel_vdm_naked(int port, enum tcpm_sop_type type, uint8_t vdm_cmd) { if (!tbt_response_valid(port, type, "NAK", vdm_cmd)) return; @@ -458,7 +459,7 @@ static bool tbt_mode_is_supported(int port, int vdo_count) } int tbt_setup_next_vdm(int port, int vdo_count, uint32_t *vdm, - enum tcpm_transmit_type *tx_type) + enum tcpm_sop_type *tx_type) { struct svdm_amode_data *modep; int vdo_count_ret = 0; diff --git a/common/usbc/usb_mode.c b/common/usbc/usb_mode.c index 54034c8f19..3829d5463f 100644 --- a/common/usbc/usb_mode.c +++ b/common/usbc/usb_mode.c @@ -19,6 +19,7 @@ #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_dpm.h" +#include "usb_pd_tcpm.h" #include "usb_pe_sm.h" #include "usbc_ppc.h" @@ -142,7 +143,7 @@ void enter_usb_failed(int port) usb4_state[port] = USB4_INACTIVE; } -static bool enter_usb_response_valid(int port, enum tcpm_transmit_type type) +static bool enter_usb_response_valid(int port, enum tcpm_sop_type type) { /* * Check for an unexpected response. @@ -215,7 +216,7 @@ bool enter_usb_cable_is_capable(int port) return true; } -void enter_usb_accepted(int port, enum tcpm_transmit_type type) +void enter_usb_accepted(int port, enum tcpm_sop_type type) { struct pd_discovery *disc; @@ -253,7 +254,7 @@ void enter_usb_accepted(int port, enum tcpm_transmit_type type) } } -void enter_usb_rejected(int port, enum tcpm_transmit_type type) +void enter_usb_rejected(int port, enum tcpm_sop_type type) { if (!enter_usb_response_valid(port, type) || usb4_state[port] == USB4_ACTIVE) @@ -262,7 +263,7 @@ void enter_usb_rejected(int port, enum tcpm_transmit_type type) enter_usb_failed(port); } -uint32_t enter_usb_setup_next_msg(int port, enum tcpm_transmit_type *type) +uint32_t enter_usb_setup_next_msg(int port, enum tcpm_sop_type *type) { struct pd_discovery *disc_sop_prime; diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index 55dace1aaf..4fbd496ad4 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -20,6 +20,7 @@ #include "usb_mode.h" #include "usb_pd.h" #include "usb_pd_dpm.h" +#include "usb_pd_tcpm.h" #include "usb_tbt_alt_mode.h" #ifdef CONFIG_COMMON_RUNTIME @@ -180,7 +181,7 @@ static bool dpm_mode_entry_requested(int port, enum typec_mode mode) } } -void dpm_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count, +void dpm_vdm_acked(int port, enum tcpm_sop_type type, int vdo_count, uint32_t *vdm) { const uint16_t svid = PD_VDO_VID(vdm[0]); @@ -202,7 +203,7 @@ void dpm_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count, } } -void dpm_vdm_naked(int port, enum tcpm_transmit_type type, uint16_t svid, +void dpm_vdm_naked(int port, enum tcpm_sop_type type, uint16_t svid, uint8_t vdm_cmd) { switch (svid) { @@ -230,7 +231,7 @@ static void dpm_attempt_mode_entry(int port) { int vdo_count = 0; uint32_t vdm[VDO_MAX_SIZE]; - enum tcpm_transmit_type tx_type = TCPC_TX_SOP; + enum tcpm_sop_type tx_type = TCPC_TX_SOP; bool enter_mode_requested = IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true; @@ -355,7 +356,7 @@ static void dpm_attempt_mode_exit(int port) { uint32_t vdm = 0; int vdo_count = 0; - enum tcpm_transmit_type tx_type = TCPC_TX_SOP; + enum tcpm_sop_type tx_type = TCPC_TX_SOP; if (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port)) { diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c index c72e16afe9..e4d044097b 100644 --- a/common/usbc/usb_pd_host.c +++ b/common/usbc/usb_pd_host.c @@ -12,6 +12,7 @@ #include "host_command.h" #include "usb_mux.h" #include "usb_pd.h" +#include "usb_pd_tcpm.h" #include "util.h" #define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) @@ -23,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_transmit_type type; + enum tcpm_sop_type type; /* Confirm the number of HC VDOs matches our stored VDOs */ BUILD_ASSERT(sizeof(r->discovery_vdo) == sizeof(union disc_ident_ack)); diff --git a/common/usbc/usb_pe_ctvpd_sm.c b/common/usbc/usb_pe_ctvpd_sm.c index 06a9137a2d..eb7d8a0aa7 100644 --- a/common/usbc/usb_pe_ctvpd_sm.c +++ b/common/usbc/usb_pe_ctvpd_sm.c @@ -11,6 +11,7 @@ #include "usb_pd_tcpm.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" +#include "usb_pd_tcpm.h" #include "usb_tc_sm.h" #include "usb_emsg.h" #include "usb_sm.h" @@ -110,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_transmit_type type) +void pe_report_error(int port, enum pe_error e, enum tcpm_sop_type type) { /* No implementation needed by this policy engine */ } diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 05d498f0d9..3f770a9fb7 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_transmit_type soft_reset_sop; + enum tcpm_sop_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_transmit_type tx_type; + enum tcpm_sop_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_transmit_type type) +int pd_get_rev(int port, enum tcpm_sop_type type) { return prl_get_rev(port, type); } -int pd_get_vdo_ver(int port, enum tcpm_transmit_type type) +int pd_get_vdo_ver(int port, enum tcpm_sop_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_transmit_type type, +static inline void send_data_msg(int port, enum tcpm_sop_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_transmit_type type, } static __maybe_unused inline void send_ext_data_msg( - int port, enum tcpm_transmit_type type, enum pd_ext_msg_type msg) + int port, enum tcpm_sop_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_transmit_type type, +static inline void send_ctrl_msg(int port, enum tcpm_sop_type type, enum pd_ctrl_msg_type msg) { /* Clear any previous TX status before sending a new message */ @@ -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_transmit_type type) +static void pe_send_soft_reset(const int port, enum tcpm_sop_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_transmit_type sop = + enum tcpm_sop_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_transmit_type type) +void pe_report_error(int port, enum pe_error e, enum tcpm_sop_type type) { /* This should only be called from the PD task */ assert(port == TASK_ID_TO_PD_PORT(task_get_current())); @@ -1911,7 +1911,7 @@ __maybe_unused static bool pe_attempt_port_discovery(int port) return false; } -bool pd_setup_vdm_request(int port, enum tcpm_transmit_type tx_type, +bool pd_setup_vdm_request(int port, enum tcpm_sop_type tx_type, uint32_t *vdm, uint32_t vdo_cnt) { if (vdo_cnt < VDO_HDR_SIZE || vdo_cnt > VDO_MAX_SIZE) @@ -3179,7 +3179,7 @@ static void pe_snk_select_capability_run(int port) { uint8_t type; uint8_t cnt; - enum tcpm_transmit_type sop; + enum tcpm_sop_type sop; enum pe_msg_check msg_check; /* @@ -6319,7 +6319,7 @@ static void pe_vcs_send_swap_run(int port) { uint8_t type; uint8_t cnt; - enum tcpm_transmit_type sop; + enum tcpm_sop_type sop; enum pe_msg_check msg_check; /* @@ -6565,7 +6565,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_transmit_type sop = + enum tcpm_sop_type sop = PD_HEADER_GET_SOP(rx_emsg[port].header); PE_CLR_FLAG(port, PE_FLAGS_MSG_RECEIVED); @@ -6762,7 +6762,7 @@ static void pe_dr_get_sink_cap_run(int port) int cnt; int ext; enum pe_msg_check msg_check; - enum tcpm_transmit_type sop; + enum tcpm_sop_type sop; /* * Check the state of the message sent @@ -7010,7 +7010,7 @@ void pd_dfp_discovery_init(int port) } __maybe_unused void pd_discovery_access_clear(int port, - enum tcpm_transmit_type type) + enum tcpm_sop_type type) { if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) assert(0); @@ -7019,7 +7019,7 @@ __maybe_unused void pd_discovery_access_clear(int port, } __maybe_unused bool pd_discovery_access_validate(int port, - enum tcpm_transmit_type type) + enum tcpm_sop_type type) { if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) assert(0); @@ -7028,7 +7028,7 @@ __maybe_unused bool pd_discovery_access_validate(int port, } __maybe_unused struct pd_discovery *pd_get_am_discovery(int port, - enum tcpm_transmit_type type) + enum tcpm_sop_type type) { if (!IS_ENABLED(CONFIG_USB_PD_ALT_MODE_DFP)) assert(0); @@ -7039,7 +7039,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_transmit_type type) + int port, enum tcpm_sop_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 1d77de1aa4..c09854bb46 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_transmit_type sop; + enum tcpm_sop_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_transmit_type last_xmit_type; + enum tcpm_sop_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_transmit_type xmit_type; + enum tcpm_sop_type xmit_type; /* type of message */ uint8_t msg_type; /* PD revision */ @@ -627,7 +627,7 @@ void prl_hard_reset_complete(int port) } void prl_send_ctrl_msg(int port, - enum tcpm_transmit_type type, + enum tcpm_sop_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_transmit_type type, + enum tcpm_sop_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_transmit_type type, + enum tcpm_sop_type type, enum pd_ext_msg_type msg) { pdmsg[port].xmit_type = type; @@ -772,7 +772,7 @@ void prl_run(int port, int evt, int en) } } -void prl_set_rev(int port, enum tcpm_transmit_type type, +void prl_set_rev(int port, enum tcpm_sop_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_transmit_type type, pdmsg[port].rev[type] = rev; } -enum pd_rev_type prl_get_rev(int port, enum tcpm_transmit_type type) +enum pd_rev_type prl_get_rev(int port, enum tcpm_sop_type type) { /* We only store revisions for SOP* types. */ ASSERT(type < NUM_SOP_STAR_TYPES); diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index f3b914dcf5..80ccb3124e 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -15,6 +15,7 @@ #include "usb_mux.h" #include "usb_pd.h" #include "usb_pd_dpm.h" +#include "usb_pd_tcpm.h" #include "usb_pd_timer.h" #include "usb_pe_sm.h" #include "usb_prl_sm.h" @@ -530,7 +531,7 @@ void pd_set_src_caps(int port, int cnt, uint32_t *src_caps) { } -int pd_get_rev(int port, enum tcpm_transmit_type type) +int pd_get_rev(int port, enum tcpm_sop_type type) { return PD_REV30; } @@ -3938,7 +3939,7 @@ static void pd_chipset_reset(void) return; for (i = 0; i < board_get_usb_pd_port_count(); i++) { - enum tcpm_transmit_type tx; + enum tcpm_sop_type tx; /* Do not notify the AP of irrelevant past Hard Resets. */ pd_clear_events(i, PD_STATUS_EVENT_HARD_RESET); |