summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/usbc/usb_pe_drp_sm.c20
-rw-r--r--common/usbc/usb_prl_sm.c6
-rw-r--r--common/usbc/usb_tc_ctvpd_sm.c4
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c10
-rw-r--r--common/usbc/usb_tc_vpd_sm.c4
-rw-r--r--common/usbc/usbc_task.c2
-rw-r--r--include/usb_pd.h9
-rw-r--r--include/usb_tc_sm.h17
-rw-r--r--test/fake_usbc.c9
-rw-r--r--test/usb_prl.c4
10 files changed, 31 insertions, 54 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 748b940284..089f698329 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -511,11 +511,11 @@ static void pe_init(int port)
pe[port].dpm_request = 0;
pe[port].source_cap_timer = TIMER_DISABLED;
pe[port].no_response_timer = TIMER_DISABLED;
- pe[port].data_role = tc_get_data_role(port);
+ pe[port].data_role = pd_get_data_role(port);
tc_pd_connection(port, 0);
- if (tc_get_power_role(port) == PD_ROLE_SOURCE)
+ if (pd_get_power_role(port) == PD_ROLE_SOURCE)
set_state_pe(port, PE_SRC_STARTUP);
else
set_state_pe(port, PE_SNK_STARTUP);
@@ -597,7 +597,7 @@ void pe_got_hard_reset(int port)
* PE_SNK_Transition_to_default state when:
* 1) Hard Reset Signaling is detected.
*/
- pe[port].power_role = tc_get_power_role(port);
+ pe[port].power_role = pd_get_power_role(port);
if (pe[port].power_role == PD_ROLE_SOURCE)
set_state_pe(port, PE_SRC_HARD_RESET_RECEIVED);
@@ -899,7 +899,7 @@ static void pe_update_pdo_flags(int port, uint32_t pdo)
#ifdef CONFIG_CHARGE_MANAGER
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
int charge_whitelisted =
- (tc_get_power_role(port) == PD_ROLE_SINK &&
+ (pd_get_power_role(port) == PD_ROLE_SINK &&
pd_charge_from_device(pd_get_identity_vid(port),
pd_get_identity_pid(port)));
#else
@@ -1092,7 +1092,7 @@ static void pe_src_startup_entry(int port)
prl_reset(port);
/* Set initial data role */
- pe[port].data_role = tc_get_data_role(port);
+ pe[port].data_role = pd_get_data_role(port);
/* Set initial power role */
pe[port].power_role = PD_ROLE_SOURCE;
@@ -1840,7 +1840,7 @@ static void pe_snk_startup_entry(int port)
prl_reset(port);
/* Set initial data role */
- pe[port].data_role = tc_get_data_role(port);
+ pe[port].data_role = pd_get_data_role(port);
/* Set initial power role */
pe[port].power_role = PD_ROLE_SINK;
@@ -2863,11 +2863,11 @@ static void pe_drs_change_entry(int port)
static void pe_drs_change_run(int port)
{
/* Wait until the data role is changed */
- if (pe[port].data_role == tc_get_data_role(port))
+ if (pe[port].data_role == pd_get_data_role(port))
return;
/* Update the data role */
- pe[port].data_role = tc_get_data_role(port);
+ pe[port].data_role = pd_get_data_role(port);
if (pe[port].data_role == PD_ROLE_DFP)
PE_CLR_FLAG(port, PE_FLAGS_DR_SWAP_TO_DFP);
@@ -3062,7 +3062,7 @@ static void pe_prs_src_snk_wait_source_on_run(int port)
PE_CLR_FLAG(port, PE_FLAGS_TX_COMPLETE);
/* Update pe power role */
- pe[port].power_role = tc_get_power_role(port);
+ pe[port].power_role = pd_get_power_role(port);
pe[port].ps_source_timer = get_time().val + PD_T_PS_SOURCE_ON;
}
@@ -3306,7 +3306,7 @@ static void pe_prs_snk_src_source_on_run(int port)
return;
/* update pe power role */
- pe[port].power_role = tc_get_power_role(port);
+ pe[port].power_role = pd_get_power_role(port);
prl_send_ctrl_msg(port, TCPC_TX_SOP, PD_CTRL_PS_RDY);
/* reset timer so PD_CTRL_PS_RDY isn't sent again */
pe[port].ps_source_timer = TIMER_DISABLED;
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index b0f186cc62..174746a70d 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -490,7 +490,7 @@ static void prl_tx_wait_for_message_request_run(const int port)
if ((prl_get_rev(port, pdmsg[port].xmit_type) == PD_REV30) &&
PRL_TX_CHK_FLAG(port,
(PRL_FLAGS_START_AMS | PRL_FLAGS_END_AMS))) {
- if (tc_get_power_role(port) == PD_ROLE_SOURCE) {
+ if (pd_get_power_role(port) == PD_ROLE_SOURCE) {
/*
* Start of SRC AMS notification received from
* Policy Engine
@@ -638,9 +638,9 @@ static uint32_t get_sop_star_header(const int port)
return PD_HEADER(
pdmsg[port].msg_type,
is_sop_packet ?
- tc_get_power_role(port) : tc_get_cable_plug(port),
+ pd_get_power_role(port) : tc_get_cable_plug(port),
is_sop_packet ?
- tc_get_data_role(port) : 0,
+ pd_get_data_role(port) : 0,
prl_tx[port].msg_id_counter[pdmsg[port].xmit_type],
pdmsg[port].data_objs,
pdmsg[port].rev[pdmsg[port].xmit_type],
diff --git a/common/usbc/usb_tc_ctvpd_sm.c b/common/usbc/usb_tc_ctvpd_sm.c
index 4d0b6664f0..07b0fc5aae 100644
--- a/common/usbc/usb_tc_ctvpd_sm.c
+++ b/common/usbc/usb_tc_ctvpd_sm.c
@@ -134,7 +134,7 @@ static void set_state_tc(const int port, enum usb_tc_state new_state);
/* Public TypeC functions */
-enum pd_power_role tc_get_power_role(int port)
+enum pd_power_role pd_get_power_role(int port)
{
/* Vconn power device is always the sink */
return PD_ROLE_SINK;
@@ -146,7 +146,7 @@ enum pd_cable_plug tc_get_cable_plug(int port)
return PD_PLUG_FROM_CABLE;
}
-enum pd_data_role tc_get_data_role(int port)
+enum pd_data_role pd_get_data_role(int port)
{
/* Vconn power device doesn't have a data role, but UFP matches SNK */
return PD_ROLE_UFP;
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 4af6d7ed45..cbfbdfc6b1 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -872,16 +872,6 @@ void tc_state_init(int port)
tc[port].low_power_time = get_time().val + PD_LPM_DEBOUNCE_US;
}
-enum pd_power_role tc_get_power_role(int port)
-{
- return tc[port].power_role;
-}
-
-enum pd_data_role tc_get_data_role(int port)
-{
- return tc[port].data_role;
-}
-
enum pd_cable_plug tc_get_cable_plug(int port)
{
/*
diff --git a/common/usbc/usb_tc_vpd_sm.c b/common/usbc/usb_tc_vpd_sm.c
index 8dfed4226b..62eceef8f2 100644
--- a/common/usbc/usb_tc_vpd_sm.c
+++ b/common/usbc/usb_tc_vpd_sm.c
@@ -92,7 +92,7 @@ void tc_state_init(int port)
tc[port].flags = 0;
}
-enum pd_power_role tc_get_power_role(int port)
+enum pd_power_role pd_get_power_role(int port)
{
/* Vconn power device is always the sink */
return PD_ROLE_SINK;
@@ -104,7 +104,7 @@ enum pd_cable_plug tc_get_cable_plug(int port)
return PD_PLUG_FROM_CABLE;
}
-enum pd_data_role tc_get_data_role(int port)
+enum pd_data_role pd_get_data_role(int port)
{
/* Vconn power device doesn't have a data role, but UFP match SNK */
return PD_ROLE_UFP;
diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c
index dd0f73f0d4..e743d38110 100644
--- a/common/usbc/usbc_task.c
+++ b/common/usbc/usbc_task.c
@@ -88,7 +88,7 @@ void set_usb_mux_with_current_data_role(int port)
* If new data role isn't DFP and we only support DFP, also disconnect.
*/
else if (IS_ENABLED(CONFIG_USBC_SS_MUX_DFP_ONLY) &&
- tc_get_data_role(port) != PD_ROLE_DFP)
+ pd_get_data_role(port) != PD_ROLE_DFP)
usb_mux_set(port, TYPEC_MUX_NONE, USB_SWITCH_DISCONNECT,
tc_get_polarity(port));
/*
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 9537ae1a8c..7fed1d48ac 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1290,7 +1290,14 @@ enum pd_dual_role_states pd_get_dual_role(int port);
void pd_set_dual_role(int port, enum pd_dual_role_states state);
/**
- * Get role, from among PD_ROLE_SINK and PD_ROLE_SOURCE
+ * Get current data role
+ *
+ * @param port Port number from which to get role
+ */
+enum pd_data_role pd_get_data_role(int port);
+
+/**
+ * Get current power role
*
* @param port Port number from which to get role
*/
diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h
index 4782dcbfe9..3c6d95fc33 100644
--- a/include/usb_tc_sm.h
+++ b/include/usb_tc_sm.h
@@ -9,6 +9,7 @@
#define __CROS_EC_USB_TC_H
#include "usb_sm.h"
+#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#define TC_SET_FLAG(port, flag) atomic_or(&tc[port].flags, (flag))
@@ -48,22 +49,6 @@ int tc_is_attached_src(int port);
int tc_is_attached_snk(int port);
/**
- * Get current data role
- *
- * @param port USB-C port number
- * @return PD data role
- */
-enum pd_data_role tc_get_data_role(int port);
-
-/**
- * Get current power role
- *
- * @param port USB-C port number
- * @return PD power role
- */
-enum pd_power_role tc_get_power_role(int port);
-
-/**
* Get cable plug setting. This should be constant per build. This replaces
* the power role bit in PD header for SOP' and SOP" packets.
*
diff --git a/test/fake_usbc.c b/test/fake_usbc.c
index ef32e60d91..873668c9f6 100644
--- a/test/fake_usbc.c
+++ b/test/fake_usbc.c
@@ -27,7 +27,7 @@ void pd_request_vconn_swap_on(int port)
static enum pd_data_role data_role;
-__overridable enum pd_data_role tc_get_data_role(int port)
+__overridable enum pd_data_role pd_get_data_role(int port)
{
return data_role;
}
@@ -37,7 +37,7 @@ __overridable void tc_set_data_role(int port, enum pd_data_role role)
}
static enum pd_power_role power_role;
-__overridable enum pd_power_role tc_get_power_role(int port)
+__overridable enum pd_power_role pd_get_power_role(int port)
{
return power_role;
}
@@ -131,8 +131,3 @@ enum pd_dual_role_states pd_get_dual_role(int port)
{
return PD_DRP_TOGGLE_ON;
}
-
-__overridable enum pd_power_role pd_get_power_role(int port)
-{
- return PD_ROLE_SINK;
-}
diff --git a/test/usb_prl.c b/test/usb_prl.c
index 425ba8ceca..198cfdd0f3 100644
--- a/test/usb_prl.c
+++ b/test/usb_prl.c
@@ -717,12 +717,12 @@ static void enable_prl(int port, int en)
prl_set_rev(port, TCPC_TX_SOP, pd_port[port].rev);
}
-enum pd_power_role tc_get_power_role(int port)
+enum pd_power_role pd_get_power_role(int port)
{
return pd_port[port].power_role;
}
-enum pd_data_role tc_get_data_role(int port)
+enum pd_data_role pd_get_data_role(int port)
{
return pd_port[port].data_role;
}