summaryrefslogtreecommitdiff
path: root/common/usb_pd_dual_role.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2020-02-10 17:22:37 -0800
committerCommit Bot <commit-bot@chromium.org>2020-02-12 20:05:32 +0000
commit7bbdd3cc90d174343cdc863515258de339f4c4dc (patch)
treefc11b65b5f175baa185829d3c13d9098d8cac1e9 /common/usb_pd_dual_role.c
parent8d3e54731e8f2a47a1822d08f4a403aef28be1de (diff)
downloadchrome-ec-7bbdd3cc90d174343cdc863515258de339f4c4dc.tar.gz
TCPMv1/v2: Move pd_charge_from_device() to common file
BUG=b:148528713 BRANCH=none TEST=make buildall -j Change-Id: I2327ceaf6be76a0428981106aaeb3ffbb2018049 Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2051217 Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/usb_pd_dual_role.c')
-rw-r--r--common/usb_pd_dual_role.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/usb_pd_dual_role.c b/common/usb_pd_dual_role.c
new file mode 100644
index 0000000000..f00b5981b9
--- /dev/null
+++ b/common/usb_pd_dual_role.c
@@ -0,0 +1,20 @@
+/* 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.
+ *
+ * Dual Role (Source & Sink) USB-PD module.
+ */
+
+#include "usb_pd.h"
+
+int pd_charge_from_device(uint16_t vid, uint16_t pid)
+{
+ /* TODO: rewrite into table if we get more of these */
+ /*
+ * White-list Apple charge-through accessory since it doesn't set
+ * unconstrained bit, but we still need to charge from it when
+ * we are a sink.
+ */
+ return (vid == USB_VID_APPLE &&
+ (pid == USB_PID1_APPLE || pid == USB_PID2_APPLE));
+}