diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-10-18 23:03:09 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-11-05 19:24:34 +0000 |
commit | a311557a3165950a5ef3d0a36e46764ecb428f32 (patch) | |
tree | bad21b73cb0cf601d06e1913a1d209096bdbb69e /common | |
parent | c1c881e4c88b298f34a5e776ec2bb1291a4c3d4d (diff) | |
download | chrome-ec-a311557a3165950a5ef3d0a36e46764ecb428f32.tar.gz |
tree: Create usb_pd_pdo.c
genvif depends on usb_pd_policy.c. However, the usb_pd_policy.c files
often depend on other symbols that are not included when building
genvif. genvif only needs the pd_src_pdo and pd_src_pdo_count variables
(and charge_manager_get_source_pdo() in one case). Extract these
variables into their own files.
BRANCH=none
BUG=b:172020503
TEST=CC=clang make BOARD=zinger -j
TEST=make buildall
TEST=compare generated *_vif.xml files before and after change:
=> MATCH
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I765750cd86243a0a355dcc6a29b80fc23403d99f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3231026
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/build.mk | 5 | ||||
-rw-r--r-- | common/usb_common.c | 24 | ||||
-rw-r--r-- | common/usb_pd_pdo.c | 33 | ||||
-rw-r--r-- | common/usbc/usb_pd_dpm.c | 1 |
4 files changed, 37 insertions, 26 deletions
diff --git a/common/build.mk b/common/build.mk index 3405a34a2b..901d0d3c9d 100644 --- a/common/build.mk +++ b/common/build.mk @@ -168,9 +168,10 @@ common-$(CONFIG_USB_PORT_POWER_DUMB)+=usb_port_power_dumb.o common-$(CONFIG_USB_PORT_POWER_SMART)+=usb_port_power_smart.o common-$(CONFIG_HAS_TASK_PD_INT)+=usbc_intr_task.o ifneq ($(CONFIG_USB_POWER_DELIVERY),) -common-$(CONFIG_USB_POWER_DELIVERY)+=usb_common.o +common-$(CONFIG_USB_POWER_DELIVERY)+=usb_common.o usb_pd_pdo.o ifneq ($(CONFIG_USB_PD_TCPMV1),) -common-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_protocol.o usb_pd_policy.o +common-$(CONFIG_USB_POWER_DELIVERY)+=usb_pd_protocol.o usb_pd_policy.o \ + usb_pd_pdo.o endif common-$(CONFIG_USB_PD_DUAL_ROLE)+=usb_pd_dual_role.o common-$(CONFIG_USB_PD_HOST_CMD)+=usb_pd_host_cmd.o diff --git a/common/usb_common.c b/common/usb_common.c index 6c51da3358..02344fa3f5 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -698,30 +698,6 @@ __overridable void typec_set_source_current_limit(int p, enum tcpc_rp_value rp) ppc_set_vbus_source_current_limit(p, rp); } -/* ---------------- Power Data Objects (PDOs) ----------------- */ -#ifndef CONFIG_USB_PD_CUSTOM_PDO -#define PDO_FIXED_FLAGS (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP |\ - PDO_FIXED_COMM_CAP) - -const uint32_t pd_src_pdo[] = { - PDO_FIXED(5000, 1500, PDO_FIXED_FLAGS), -}; -const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); -const uint32_t pd_src_pdo_max[] = { - PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS), -}; -const int pd_src_pdo_max_cnt = ARRAY_SIZE(pd_src_pdo_max); - -const uint32_t pd_snk_pdo[] = { - PDO_FIXED(5000, - GENERIC_MIN((PD_OPERATING_POWER_MW / 5), PD_MAX_CURRENT_MA), - PDO_FIXED_FLAGS), - PDO_BATT(4750, PD_MAX_VOLTAGE_MV, PD_OPERATING_POWER_MW), - PDO_VAR(4750, PD_MAX_VOLTAGE_MV, PD_MAX_CURRENT_MA), -}; -const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); -#endif /* CONFIG_USB_PD_CUSTOM_PDO */ - /* ----------------- Vendor Defined Messages ------------------ */ #if defined(CONFIG_USB_PE_SM) && !defined(CONFIG_USB_VPD) && \ !defined(CONFIG_USB_CTVPD) diff --git a/common/usb_pd_pdo.c b/common/usb_pd_pdo.c new file mode 100644 index 0000000000..cfa355bf0e --- /dev/null +++ b/common/usb_pd_pdo.c @@ -0,0 +1,33 @@ +/* Copyright 2021 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. + */ + +#include "usb_pd.h" +#include "util.h" +#include "usb_pd_pdo.h" + +#ifndef CONFIG_USB_PD_CUSTOM_PDO + +#define PDO_FIXED_FLAGS \ + (PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP | PDO_FIXED_COMM_CAP) + +const uint32_t pd_src_pdo[] = { + PDO_FIXED(5000, 1500, PDO_FIXED_FLAGS), +}; +const int pd_src_pdo_cnt = ARRAY_SIZE(pd_src_pdo); +const uint32_t pd_src_pdo_max[] = { + PDO_FIXED(5000, 3000, PDO_FIXED_FLAGS), +}; +const int pd_src_pdo_max_cnt = ARRAY_SIZE(pd_src_pdo_max); + +const uint32_t pd_snk_pdo[] = { + PDO_FIXED(5000, + GENERIC_MIN((PD_OPERATING_POWER_MW / 5), PD_MAX_CURRENT_MA), + PDO_FIXED_FLAGS), + PDO_BATT(4750, PD_MAX_VOLTAGE_MV, PD_OPERATING_POWER_MW), + PDO_VAR(4750, PD_MAX_VOLTAGE_MV, PD_MAX_CURRENT_MA), +}; +const int pd_snk_pdo_cnt = ARRAY_SIZE(pd_snk_pdo); + +#endif /* CONFIG_USB_PD_CUSTOM_PDO */ diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index eb2dfc52c0..e3a392d5dc 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -21,6 +21,7 @@ #include "usb_pd.h" #include "usb_pd_dpm.h" #include "usb_pd_tcpm.h" +#include "usb_pd_pdo.h" #include "usb_tbt_alt_mode.h" #ifdef CONFIG_COMMON_RUNTIME |