summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2020-07-14 14:48:46 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-17 02:57:14 +0000
commitdfc32ffc88ca7b9fe95623ee6c715e49c33bec24 (patch)
treeeffcda83c2fc9e3c482fcc0057526474fbf25e83
parent5270ea2b0cfc2ce699281c2e59ffce3546551d7e (diff)
downloadchrome-ec-dfc32ffc88ca7b9fe95623ee6c715e49c33bec24.tar.gz
TCPMv2: Add common function for DPM entry and exit mode
Added a common entry point into DPM for entering or exiting modes. BUG=b:155890173 BRANCH=None TEST=Tested on volteer, able to enter and exit 1. DisplayPort mode with type-C dock 2. Thunderbolt mode with a Thunderbolt dock Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I3bb996d96d0fff543ad7a2e1dc8e09d0b17d0171 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2299840 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--common/usbc/usb_pd_dpm.c23
-rw-r--r--common/usbc/usb_pe_drp_sm.c22
-rw-r--r--include/usb_pd_dpm.h14
-rw-r--r--test/fake_usbc.c6
4 files changed, 22 insertions, 43 deletions
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c
index e2f2c4d356..b84b5b075f 100644
--- a/common/usbc/usb_pd_dpm.c
+++ b/common/usbc/usb_pd_dpm.c
@@ -93,14 +93,16 @@ void dpm_vdm_naked(int port, enum tcpm_transmit_type type, uint16_t svid,
}
}
-void dpm_attempt_mode_entry(int port)
+/*
+ * The call to this function requests that the PE send one VDM, whichever is
+ * next in the mode entry sequence. This only happens if preconditions for mode
+ * entry are met.
+ */
+static void dpm_attempt_mode_entry(int port)
{
int vdo_count = 0;
uint32_t vdm[VDO_MAX_SIZE];
- if (dpm[port].mode_entry_done)
- return;
-
if (pd_get_data_role(port) != PD_ROLE_DFP)
return;
/*
@@ -172,15 +174,12 @@ void dpm_attempt_mode_entry(int port)
pe_dpm_request(port, DPM_REQUEST_VDM);
}
-void dpm_attempt_mode_exit(int port)
+static void dpm_attempt_mode_exit(int port)
{
int opos;
uint16_t svid;
uint32_t vdm;
- if (!dpm[port].mode_exit_request)
- return;
-
/* TODO: Add exit mode support for SOP' and SOP'' */
if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
@@ -214,3 +213,11 @@ void dpm_attempt_mode_exit(int port)
pe_dpm_request(port, DPM_REQUEST_VDM);
}
}
+
+void dpm_run(int port)
+{
+ if (dpm[port].mode_exit_request)
+ dpm_attempt_mode_exit(port);
+ else if (!dpm[port].mode_entry_done)
+ dpm_attempt_mode_entry(port);
+}
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index beffd61d60..5a76b00a7a 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -2084,16 +2084,8 @@ static void pe_src_ready_run(int port)
return;
}
- /*
- * TODO b/155890173: Combine the entry and exit mode requests
- * so that there is only a single entry point into DPM.
- */
-
- /* No DPM requests; attempt mode exit if needed */
- dpm_attempt_mode_exit(port);
-
- /* No DPM requests; attempt mode entry if needed */
- dpm_attempt_mode_entry(port);
+ /* No DPM requests; attempt mode entry/exit if needed */
+ dpm_run(port);
}
}
@@ -2834,15 +2826,9 @@ static void pe_snk_ready_run(int port)
return;
}
- /*
- * TODO b/155890173: Combine the entry and exit mode requests
- * so that there is only a single entry point into DPM.
- */
- /* No DPM requests; attempt mode exit if needed */
- dpm_attempt_mode_exit(port);
+ /* No DPM requests; attempt mode entry/exit if needed */
+ dpm_run(port);
- /* No DPM requests; attempt mode entry if needed */
- dpm_attempt_mode_entry(port);
}
}
diff --git a/include/usb_pd_dpm.h b/include/usb_pd_dpm.h
index d431256e18..2948fd3fbd 100644
--- a/include/usb_pd_dpm.h
+++ b/include/usb_pd_dpm.h
@@ -57,20 +57,10 @@ void dpm_vdm_naked(int port, enum tcpm_transmit_type type, uint16_t svid,
uint8_t vdm_cmd);
/*
- * Drives the Policy Engine through the mode entry/configuration process. Each
- * call to this function requests that the PE send one VDM, whichever is next in
- * the mode entry sequence. This only happens if preconditions for mode entry
- * are met.
+ * Drives the Policy Engine through entry/exit mode process
*
* @param port USB-C port number
*/
-void dpm_attempt_mode_entry(int port);
-
-/*
- * Drives the Policy Engine through exit mode process for each active mode
- *
- * @param port USB-C port number
- */
-void dpm_attempt_mode_exit(int port);
+void dpm_run(int port);
#endif /* __CROS_EC_USB_DPM_H */
diff --git a/test/fake_usbc.c b/test/fake_usbc.c
index 37d1c0bf09..0f92379b38 100644
--- a/test/fake_usbc.c
+++ b/test/fake_usbc.c
@@ -270,11 +270,7 @@ void dpm_set_mode_exit_request(int port)
{
}
-void dpm_attempt_mode_entry(int port)
-{
-}
-
-void dpm_attempt_mode_exit(int port)
+void dpm_run(int port)
{
}