diff options
author | Vijay Hiremath <vijay.p.hiremath@intel.com> | 2020-02-10 17:22:37 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-12 20:05:32 +0000 |
commit | 7bbdd3cc90d174343cdc863515258de339f4c4dc (patch) | |
tree | fc11b65b5f175baa185829d3c13d9098d8cac1e9 | |
parent | 8d3e54731e8f2a47a1822d08f4a403aef28be1de (diff) | |
download | chrome-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>
-rw-r--r-- | common/build.mk | 1 | ||||
-rw-r--r-- | common/usb_pd_dual_role.c | 20 | ||||
-rw-r--r-- | common/usb_pd_policy.c | 11 | ||||
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 12 |
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)); |