summaryrefslogtreecommitdiff
path: root/common/usb_pd_alt_mode_dfp.c
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2020-05-14 10:41:45 -0600
committerCommit Bot <commit-bot@chromium.org>2020-06-10 01:25:03 +0000
commitbf24e746f41621ff2fbb72bf8067e9b672e79eb9 (patch)
treeaf1173f6e743e3ac93bb1e3adbc1c772c361bbd1 /common/usb_pd_alt_mode_dfp.c
parentb5d255029d4662dca049b9754a5c159871a4b92d (diff)
downloadchrome-ec-bf24e746f41621ff2fbb72bf8067e9b672e79eb9.tar.gz
TCPMv2: Separate DPM and DP from PE
Create separate modules representing DisplayPort (which decides whether and how we can set up the DP alt mode) and the Device Policy Manager (which decides whether we should). The end goal is to have essentially all code with DP-specific decisions or information in the DP module and all code with DPM-specific decisions or information in the DPM module. This will allow the PE to map as directly as practical to its behaviors defined in the PD spec. Essentially detach PE_DO_PORT_DISCOVERY from the rest of the PE state machine in preparation for deleting it. This change paves the way for 1) Allowing the AP to drive mode entry and 2) Allowing new alt modes to be supported via largely self-contained modules. BUG=b:155890173 TEST=Attach DP dongle; observe discovery and DP setup via Twinkie BRANCH=none Change-Id: Ie63a2e62d1ac6178722477dc53244898a04ef92f Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2203842 Reviewed-by: Diana Z <dzigterman@chromium.org>
Diffstat (limited to 'common/usb_pd_alt_mode_dfp.c')
-rw-r--r--common/usb_pd_alt_mode_dfp.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c
index e4a7eb294a..42b7c9e465 100644
--- a/common/usb_pd_alt_mode_dfp.c
+++ b/common/usb_pd_alt_mode_dfp.c
@@ -11,6 +11,7 @@
#include "task_id.h"
#include "timer.h"
#include "usb_charge.h"
+#include "usb_dp_alt_mode.h"
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
@@ -85,6 +86,12 @@ static int pd_allocate_mode(int port, uint16_t svid)
for (j = 0; j < disc->svid_cnt; j++) {
struct svid_mode_data *svidp = &disc->svids[j];
+ /*
+ * Looking for a match between supported_modes and
+ * discovered SVIDs; must also match the passed-in SVID
+ * if that was non-zero. Otherwise, go to the next
+ * discovered SVID.
+ */
if ((svidp->svid != supported_modes[i].svid) ||
(svid && (svidp->svid != svid)))
continue;
@@ -571,6 +578,22 @@ uint32_t *pd_get_mode_vdo(int port, uint16_t svid_idx,
return disc->svids[svid_idx].mode_vdo;
}
+bool pd_is_mode_discovered_for_svid(int port, enum tcpm_transmit_type type,
+ uint16_t svid)
+{
+ const struct pd_discovery *disc = pd_get_am_discovery(port, type);
+ const struct svid_mode_data *mode_data;
+
+ for (mode_data = disc->svids; mode_data < disc->svids + disc->svid_cnt;
+ ++mode_data) {
+ if (mode_data->svid == svid &&
+ mode_data->discovery == PD_DISC_COMPLETE)
+ return true;
+ }
+
+ return false;
+}
+
void notify_sysjump_ready(void)
{
/*
@@ -1187,6 +1210,9 @@ __overridable void svdm_exit_dp_mode(int port)
if (port == USB_PD_PORT_TCPC_MST)
baseboard_mst_enable_control(port, 0);
#endif
+#ifdef CONFIG_USB_PD_TCPMV2
+ dp_reset_next_command(port);
+#endif
}
__overridable int svdm_enter_gfu_mode(int port, uint32_t mode_caps)