summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2020-02-12 12:25:34 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-24 20:48:57 +0000
commit5f505564df053199fd93b6b29247d6510ac38321 (patch)
treeecd383dbf0d84260bbd4be8c096ff1c608e5c2d8
parentc06e040dcd91b0da76e2a82d41a034b5954c763c (diff)
downloadchrome-ec-5f505564df053199fd93b6b29247d6510ac38321.tar.gz
TCPMv1/v2: Move pd_set_polarity() to common file
BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: Idf6908bfc3e79a960a7de6e4249c2f50b41b56e6 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2052645 Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/usb_common.c8
-rw-r--r--common/usb_pd_protocol.c14
-rw-r--r--common/usbc/usb_tc_ctvpd_sm.c14
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c10
-rw-r--r--common/usbc/usb_tc_vpd_sm.c2
-rw-r--r--common/usbc/usbc_task.c8
-rw-r--r--include/usb_pd.h8
-rw-r--r--include/usb_tc_sm.h8
8 files changed, 32 insertions, 40 deletions
diff --git a/common/usb_common.c b/common/usb_common.c
index a0fe959a3b..d1db0b2b3e 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -167,6 +167,14 @@ bool pd_is_debug_acc(int port)
cc_state == PD_CC_DFP_DEBUG_ACC;
}
+void pd_set_polarity(int port, enum tcpc_cc_polarity polarity)
+{
+ tcpm_set_polarity(port, polarity);
+
+ if (IS_ENABLED(CONFIG_USBC_PPC_POLARITY))
+ ppc_set_polarity(port, polarity);
+}
+
__overridable int pd_board_check_request(uint32_t rdo, int pdo_cnt)
{
return EC_SUCCESS;
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 19fb1c5c70..035e6b970f 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -381,14 +381,6 @@ void pd_vbus_low(int port)
#endif
-static void set_polarity(int port, enum tcpc_cc_polarity polarity)
-{
- tcpm_set_polarity(port, polarity);
-#ifdef CONFIG_USBC_PPC_POLARITY
- ppc_set_polarity(port, polarity);
-#endif /* defined(CONFIG_USBC_PPC_POLARITY) */
-}
-
#ifdef CONFIG_USBC_VCONN
static void set_vconn(int port, int enable)
{
@@ -3170,7 +3162,7 @@ void pd_task(void *u)
#endif
(PD_ROLE_DEFAULT(port) == PD_ROLE_SOURCE &&
pd[port].task_state == PD_STATE_SRC_READY))) {
- set_polarity(port, pd[port].polarity);
+ pd_set_polarity(port, pd[port].polarity);
tcpm_set_msg_header(port, pd[port].power_role,
pd[port].data_role);
tcpm_set_rx_enable(port, 1);
@@ -3396,7 +3388,7 @@ void pd_task(void *u)
pd[port].polarity =
get_src_polarity(cc1, cc2);
}
- set_polarity(port, pd[port].polarity);
+ pd_set_polarity(port, pd[port].polarity);
/* initial data role for source is DFP */
pd_set_data_role(port, PD_ROLE_DFP);
@@ -4053,7 +4045,7 @@ void pd_task(void *u)
if (IS_ENABLED(CONFIG_COMMON_RUNTIME))
hook_notify(HOOK_USB_PD_CONNECT);
pd[port].polarity = get_snk_polarity(cc1, cc2);
- set_polarity(port, pd[port].polarity);
+ pd_set_polarity(port, pd[port].polarity);
/* reset message ID on connection */
pd[port].msg_id = 0;
/* initial data role for sink is UFP */
diff --git a/common/usbc/usb_tc_ctvpd_sm.c b/common/usbc/usb_tc_ctvpd_sm.c
index 07b0fc5aae..194bb664fe 100644
--- a/common/usbc/usb_tc_ctvpd_sm.c
+++ b/common/usbc/usb_tc_ctvpd_sm.c
@@ -418,7 +418,7 @@ static void tc_attached_snk_entry(const int port)
/* Enable PD */
tc[port].pd_enable = 1;
- set_polarity(port, 0);
+ pd_set_polarity(port, 0);
/*
* This state can only be entered from states AttachWait.SNK
@@ -679,7 +679,7 @@ static void tc_attached_src_entry(const int port)
/* Enable PD */
tc[port].pd_enable = 1;
- set_polarity(port, 0);
+ pd_set_polarity(port, 0);
/* Connect Charge-Through VBUS to Host VBUS */
vpd_vbus_pass_en(1);
@@ -879,7 +879,7 @@ static void tc_ct_try_snk_entry(const int port)
/* Enable PD */
tc[port].pd_enable = 1;
- set_polarity(port, 0);
+ pd_set_polarity(port, 0);
tc[port].cc_state = PD_CC_UNSET;
tc[port].next_role_swap = get_time().val + PD_T_DRP_TRY;
@@ -975,7 +975,7 @@ static void tc_ct_attach_wait_unsupported_entry(const int port)
/* Enable PD */
tc[port].pd_enable = 1;
- set_polarity(port, 0);
+ pd_set_polarity(port, 0);
tc[port].cc_state = PD_CC_UNSET;
}
@@ -1105,7 +1105,7 @@ static void tc_ct_unattached_unsupported_entry(const int port)
/* Enable PD */
tc[port].pd_enable = 1;
- set_polarity(port, 0);
+ pd_set_polarity(port, 0);
tc[port].next_role_swap = get_time().val + PD_T_DRP_SRC;
}
@@ -1173,7 +1173,7 @@ static void tc_ct_unattached_vpd_entry(const int port)
/* Enable PD */
tc[port].pd_enable = 1;
- set_polarity(port, 0);
+ pd_set_polarity(port, 0);
tc[port].cc_state = PD_CC_UNSET;
}
@@ -1380,7 +1380,7 @@ static void tc_ct_attach_wait_vpd_entry(const int port)
/* Enable PD */
tc[port].pd_enable = 1;
- set_polarity(port, 0);
+ pd_set_polarity(port, 0);
tc[port].cc_state = PD_CC_UNSET;
}
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 4e2627a325..4ed9057e6a 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -1842,7 +1842,7 @@ static void tc_attached_snk_entry(const int port)
/* Get connector orientation */
tcpm_get_cc(port, &cc1, &cc2);
tc[port].polarity = get_snk_polarity(cc1, cc2);
- set_polarity(port, tc[port].polarity);
+ pd_set_polarity(port, tc[port].polarity);
/*
* Initial data role for sink is UFP
@@ -2032,7 +2032,7 @@ static void tc_unoriented_dbg_acc_src_entry(const int port)
/* Get connector orientation */
tcpm_get_cc(port, &cc1, &cc2);
tc[port].polarity = (cc1 != TYPEC_CC_VOLT_RD);
- set_polarity(port, tc[port].polarity);
+ pd_set_polarity(port, tc[port].polarity);
/*
* Initial data role for sink is DFP
@@ -2193,7 +2193,7 @@ static void tc_dbg_acc_snk_entry(const int port)
/* Get connector orientation */
tcpm_get_cc(port, &cc1, &cc2);
tc[port].polarity = get_snk_polarity(cc1, cc2);
- set_polarity(port, tc[port].polarity);
+ pd_set_polarity(port, tc[port].polarity);
/*
* Initial data role for sink is UFP
@@ -2508,7 +2508,7 @@ static void tc_attached_src_entry(const int port)
/* Get connector orientation */
tcpm_get_cc(port, &cc1, &cc2);
tc[port].polarity = get_src_polarity(cc1, cc2);
- set_polarity(port, tc[port].polarity);
+ pd_set_polarity(port, tc[port].polarity);
/*
* Initial data role for sink is DFP
@@ -2542,7 +2542,7 @@ static void tc_attached_src_entry(const int port)
/* Get connector orientation */
tcpm_get_cc(port, &cc1, &cc2);
tc[port].polarity = get_src_polarity(cc1, cc2);
- set_polarity(port, tc[port].polarity);
+ pd_set_polarity(port, tc[port].polarity);
/*
* Initial data role for sink is DFP
diff --git a/common/usbc/usb_tc_vpd_sm.c b/common/usbc/usb_tc_vpd_sm.c
index 62eceef8f2..93c12ffbd7 100644
--- a/common/usbc/usb_tc_vpd_sm.c
+++ b/common/usbc/usb_tc_vpd_sm.c
@@ -276,7 +276,7 @@ static void tc_attached_snk_entry(const int port)
/* Enable PD */
tc[port].pd_enable = 1;
- set_polarity(port, 0);
+ pd_set_polarity(port, 0);
}
static void tc_attached_snk_run(const int port)
diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c
index d4cc36147a..9571c25d5a 100644
--- a/common/usbc/usbc_task.c
+++ b/common/usbc/usbc_task.c
@@ -52,14 +52,6 @@ void tc_start_event_loop(int port)
task_set_event(PD_PORT_TO_TASK_ID(port), TASK_EVENT_WAKE, 0);
}
-void set_polarity(int port, int polarity)
-{
- tcpm_set_polarity(port, polarity);
-
- if (IS_ENABLED(CONFIG_USBC_PPC_POLARITY))
- ppc_set_polarity(port, polarity);
-}
-
/* High-priority interrupt tasks implementations */
#if defined(HAS_TASK_PD_INT_C0) || defined(HAS_TASK_PD_INT_C1) || \
defined(HAS_TASK_PD_INT_C2)
diff --git a/include/usb_pd.h b/include/usb_pd.h
index b48e5dc8a7..dda61be685 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -2467,6 +2467,14 @@ bool pd_partner_is_ufp(int port);
*/
bool pd_is_debug_acc(int port);
+/**
+ * Sets the polarity of the port
+ *
+ * @param port USB-C port number
+ * @param polarity 0 for CC1, else 1 for CC2
+ */
+void pd_set_polarity(int port, enum tcpc_cc_polarity polarity);
+
/*
* Notify the AP that we have entered into DisplayPort Alternate Mode. This
* sets a DP_ALT_MODE_ENTERED MKBP event which may wake the AP.
diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h
index c797318b91..c3bb080d78 100644
--- a/include/usb_tc_sm.h
+++ b/include/usb_tc_sm.h
@@ -282,14 +282,6 @@ enum tcpc_cc_polarity get_snk_polarity(enum tcpc_cc_voltage_status cc1,
int tc_restart_tcpc(int port);
/**
- * Sets the polarity of the port
- *
- * @param port USB-C port number
- * @param polarity 0 for CC1, else 1 for CC2
- */
-void set_polarity(int port, int polarity);
-
-/**
* Called by the state machine framework to initialize the
* TypeC state machine
*