summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2020-09-04 13:27:56 +0200
committerCommit Bot <commit-bot@chromium.org>2020-09-11 00:33:32 +0000
commit56618fa0256003920c0c714048b3121b0fc643af (patch)
tree3b565fc135d5f97e3ed5399e43e6c19ab0a7b3d8
parent791c0ac14a8d3679b8c284cf9ecc294d23666bad (diff)
downloadchrome-ec-56618fa0256003920c0c714048b3121b0fc643af.tar.gz
TCPMv2: Obtain correct dual role state when going suspend
Some boards (eg. eve) don't source VBUS in S3 state. In this case DRP state should be set to force sink instead of toggle off. This CL introduces pd_get_drp_state_in_suspend() function and uses it to obtain correct DRP state when entering suspend. Default implementation of pd_get_drp_state_in_suspend() returns PD_DRP_TOGGLE_OFF, so this commit introduces no functional changes. BUG=b:162254118 BRANCH=none TEST=No functional changes in this CL make -j buildall Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: Iacf8fcdbad027563015f593653d3ed8a49752131 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2395558 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--common/usb_common.c6
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c6
-rw-r--r--include/usb_pd.h8
3 files changed, 17 insertions, 3 deletions
diff --git a/common/usb_common.c b/common/usb_common.c
index 9a467ed96d..afd67bf0cd 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -548,6 +548,12 @@ __overridable void pd_execute_data_swap(int port,
{
}
+__overridable enum pd_dual_role_states pd_get_drp_state_in_suspend(void)
+{
+ /* Disable dual role when going to suspend */
+ return PD_DRP_TOGGLE_OFF;
+}
+
__overridable void pd_try_execute_vconn_swap(int port, int flags)
{
/*
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index 4f1b29249f..b789191bb5 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -1342,7 +1342,7 @@ void tc_state_init(int port)
if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
pd_set_dual_role_and_event(port, PD_DRP_FORCE_SINK, 0);
else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND))
- pd_set_dual_role_and_event(port, PD_DRP_TOGGLE_OFF, 0);
+ pd_set_dual_role_and_event(port, pd_get_drp_state_in_suspend(), 0);
else /* CHIPSET_STATE_ON */
pd_set_dual_role_and_event(port, PD_DRP_TOGGLE_ON, 0);
@@ -3439,7 +3439,7 @@ static void pd_chipset_suspend(void)
for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
pd_set_dual_role_and_event(i,
- PD_DRP_TOGGLE_OFF,
+ pd_get_drp_state_in_suspend(),
PD_EVENT_UPDATE_DUAL_ROLE
| PD_EVENT_POWER_STATE_CHANGE);
}
@@ -3455,7 +3455,7 @@ static void pd_chipset_startup(void)
for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
set_usb_mux_with_current_data_role(i);
pd_set_dual_role_and_event(i,
- PD_DRP_TOGGLE_OFF,
+ pd_get_drp_state_in_suspend(),
PD_EVENT_UPDATE_DUAL_ROLE
| PD_EVENT_POWER_STATE_CHANGE);
/*
diff --git a/include/usb_pd.h b/include/usb_pd.h
index b546a286f4..e013779106 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -1572,6 +1572,14 @@ __override_proto void pd_execute_data_swap(int port,
enum pd_data_role data_role);
/**
+ * Get desired dual role state when chipset is suspended.
+ * Under some circumstances we are not allowed to be source
+ * during suspend. This function should return appropriate state.
+ */
+
+__override_proto enum pd_dual_role_states pd_get_drp_state_in_suspend(void);
+
+/**
* Get PD device info used for VDO_CMD_SEND_INFO / VDO_CMD_READ_INFO
*
* @param info_data pointer to info data array