summaryrefslogtreecommitdiff
path: root/common/usb_pd_policy.c
diff options
context:
space:
mode:
authorAyushee <ayushee.shah@intel.com>2020-07-01 14:37:12 -0700
committerCommit Bot <commit-bot@chromium.org>2020-07-06 21:07:18 +0000
commit90b879c1817b7ef92bf7b7c1930aebf63dcc6bfe (patch)
treee185ea7f0fd39780af1d6f4a52c9b3e4b9bbf4f1 /common/usb_pd_policy.c
parent1da311fab28081b89afa34f725aa800ca970ace1 (diff)
downloadchrome-ec-90b879c1817b7ef92bf7b7c1930aebf63dcc6bfe.tar.gz
usb_pd: Move 'is_vdo_present()' and 'is_usb4_vdo()' to TCPMv1
BUG=b:156749387 BRANCH=None TEST=make buildall -j Signed-off-by: Ayushee <ayushee.shah@intel.com> Change-Id: I8ecffd3084de472ec3d145c3ff69df1ca2d89a56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2278562 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_policy.c')
-rw-r--r--common/usb_pd_policy.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index 53b460cd97..47c035e37a 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -191,6 +191,11 @@ static struct pd_discovery
static struct partner_active_modes
partner_amodes[CONFIG_USB_PD_PORT_MAX_COUNT][AMODE_TYPE_COUNT];
+static bool is_vdo_present(int cnt, int index)
+{
+ return cnt > index;
+}
+
static bool is_modal(int port, int cnt, const uint32_t *payload)
{
return is_vdo_present(cnt, VDO_INDEX_IDH) &&
@@ -384,6 +389,23 @@ void pd_set_dfp_enter_mode_flag(int port, bool set)
{
}
+static bool is_usb4_vdo(int port, int cnt, uint32_t *payload)
+{
+ enum idh_ptype ptype = PD_IDH_PTYPE(payload[VDO_I(IDH)]);
+
+ if (IS_PD_IDH_UFP_PTYPE(ptype)) {
+ /*
+ * Ref: USB Type-C Cable and Connector Specification
+ * Figure 5-1 USB4 Discovery and Entry Flow Model
+ * Device USB4 VDO detection.
+ */
+ return IS_ENABLED(CONFIG_USB_PD_USB4) &&
+ is_vdo_present(cnt, VDO_INDEX_PTYPE_UFP1_VDO) &&
+ PD_PRODUCT_IS_USB4(payload[VDO_INDEX_PTYPE_UFP1_VDO]);
+ }
+ return false;
+}
+
static int process_am_discover_ident_sop(int port, int cnt,
uint32_t head, uint32_t *payload,
enum tcpm_transmit_type *rtype)