summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/build.mk1
-rw-r--r--common/usb_pd_dual_role.c20
-rw-r--r--common/usb_pd_policy.c11
-rw-r--r--common/usbc/usb_pe_drp_sm.c12
4 files changed, 21 insertions, 23 deletions
diff --git a/common/build.mk b/common/build.mk
index 26294af9db..0ed19666a9 100644
--- a/common/build.mk
+++ b/common/build.mk
@@ -150,6 +150,7 @@ ifeq ($(CONFIG_USB_SM_FRAMEWORK),)
common-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_protocol.o usb_pd_policy.o
endif
common-$(CONFIG_USB_PD_ALT_MODE_DFP)+=usb_pd_alt_mode_dfp.o
+common-$(CONFIG_USB_PD_DUAL_ROLE)+=usb_pd_dual_role.o
common-$(CONFIG_USB_PD_LOGGING)+=event_log.o pd_log.o
common-$(CONFIG_USB_PD_TCPC)+=usb_pd_tcpc.o
common-$(CONFIG_USB_UPDATE)+=usb_update.o update_fw.o
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));
+}
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index 6300b47a80..caa008fda6 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -107,17 +107,6 @@ unsigned pd_get_max_voltage(void)
{
return max_request_mv;
}
-
-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 == 0x1012 || pid == 0x1013));
-}
#endif /* CONFIG_USB_PD_DUAL_ROLE */
static struct pd_cable cable[CONFIG_USB_PD_PORT_MAX_COUNT];
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index 704ea3d0b7..baaeb48ba4 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -4467,18 +4467,6 @@ unsigned int pd_get_max_voltage(void)
return max_request_mv;
}
-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));
-}
-
void pd_dfp_pe_init(int port)
{
memset(&pe[port].am_policy, 0, sizeof(struct pd_policy));