summaryrefslogtreecommitdiff
path: root/include/usb_pd_dpm.h
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 /include/usb_pd_dpm.h
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 'include/usb_pd_dpm.h')
-rw-r--r--include/usb_pd_dpm.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/include/usb_pd_dpm.h b/include/usb_pd_dpm.h
new file mode 100644
index 0000000000..22fb2d71bd
--- /dev/null
+++ b/include/usb_pd_dpm.h
@@ -0,0 +1,62 @@
+/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * Device Policy Manager implementation
+ * Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3
+ */
+
+#ifndef __CROS_EC_USB_DPM_H
+#define __CROS_EC_USB_DPM_H
+
+/*
+ * Initializes DPM state for a port.
+ *
+ * @param port USB-C port number
+ */
+void dpm_init(int port);
+
+/*
+ * Informs the DPM that the mode entry sequence (including appropriate
+ * configuration) is done for a port.
+ *
+ * @param port USB-C port number
+ */
+void dpm_set_mode_entry_done(int port);
+
+/*
+ * Informs the DPM that a VDM ACK was received.
+ *
+ * @param port USB-C port number
+ * @param type Transmit type (SOP, SOP') for received ACK
+ * @param vdo_count The number of VDOs in vdm; must be at least 1
+ * @param vdm The VDM payload of the ACK
+ */
+void dpm_vdm_acked(int port, enum tcpm_transmit_type type, int vdo_count,
+ uint32_t *vdm);
+
+/*
+ * Informs the DPM that a VDM NAK was received. Also applies when a VDM request
+ * received a Not Supported response or timed out waiting for a response.
+ *
+ * @param port USB-C port number
+ * @param type Transmit type (SOP, SOP') for request
+ * @param svid The SVID of the request
+ * @param vdm_cmd The VDM command of the request
+ */
+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.
+ *
+ * @param port USB-C port number
+ */
+void dpm_attempt_mode_entry(int port);
+
+#endif /* __CROS_EC_USB_DPM_H */