diff options
author | Diana Z <dzigterman@chromium.org> | 2020-12-16 23:29:04 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-12-24 01:11:02 +0000 |
commit | fca75f573ff913a5be050c7a13e7dcda6be68da2 (patch) | |
tree | dc192d0343545550a4f88df2d91f813d58d27d1a /common | |
parent | c9cc5600573a6a28bd0a66d43916e969bd403bbd (diff) | |
download | chrome-ec-fca75f573ff913a5be050c7a13e7dcda6be68da2.tar.gz |
TCPMv2: Update source-out configs
Now that the DPM will be handling source-out decisions for TCPMv2,
remove references to its old configuration options from TCPMv2 boards in
order to avoid any confusion as to what code is running now. Also
remove the charge manager notifications of sink attach/detach since the
policy is being centralized into the DPM.
Note that the previous configuration options only ever allocated one 3.0
A port, and so the default number of 3.0 A ports has been set to 1.
BRANCH=None
BUG=b:168862110,b:141690755
TEST=make -j buildall
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: Ie452e3da32b04226503539daa67b6b9f4a58aa58
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2597431
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/mock/usb_pd_dpm_mock.c | 6 | ||||
-rw-r--r-- | common/usb_common.c | 6 | ||||
-rw-r--r-- | common/usbc/usb_pd_dpm.c | 27 | ||||
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 8 |
4 files changed, 25 insertions, 22 deletions
diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c index a68f56ae3b..8edae9ee0b 100644 --- a/common/mock/usb_pd_dpm_mock.c +++ b/common/mock/usb_pd_dpm_mock.c @@ -55,3 +55,9 @@ void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo) void dpm_remove_sink(int port) { } + +int dpm_get_source_pdo(const uint32_t **src_pdo, const int port) +{ + *src_pdo = pd_src_pdo; + return pd_src_pdo_cnt; +} diff --git a/common/usb_common.c b/common/usb_common.c index 36e94dd540..05f464cc00 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -24,6 +24,7 @@ #include "usb_common.h" #include "usb_mux.h" #include "usb_pd.h" +#include "usb_pd_dpm.h" #include "usb_pd_tcpm.h" #include "usbc_ocp.h" #include "usbc_ppc.h" @@ -263,7 +264,10 @@ int pd_check_requested_voltage(uint32_t rdo, const int port) int idx = RDO_POS(rdo); uint32_t pdo; uint32_t pdo_ma; -#if defined(CONFIG_USB_PD_DYNAMIC_SRC_CAP) || \ +#if defined(CONFIG_USB_PD_TCPMV2) && defined(CONFIG_USB_PE_SM) + const uint32_t *src_pdo; + const int pdo_cnt = dpm_get_source_pdo(&src_pdo, port); +#elif defined(CONFIG_USB_PD_DYNAMIC_SRC_CAP) || \ defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) const uint32_t *src_pdo; const int pdo_cnt = charge_manager_get_source_pdo(&src_pdo, port); diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c index d607485ae4..6643fed42c 100644 --- a/common/usbc/usb_pd_dpm.c +++ b/common/usbc/usb_pd_dpm.c @@ -376,9 +376,6 @@ static int count_port_bits(uint32_t bitmask) return total; } -/* TODO(b/141690755): Move to config.h */ -#define CONFIG_USB_PD_3A_PORTS 1 - /* * Centralized, mutex-controlled updates to the claimed 3.0 A ports */ @@ -416,6 +413,9 @@ unlock: /* Process sink's first Sink_Capabilities PDO for port current consideration */ void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo) { + if (CONFIG_USB_PD_3A_PORTS == 0) + return; + /* Verify partner supplied valid vSafe5V fixed object first */ if ((vsafe5v_pdo & PDO_TYPE_MASK) != PDO_TYPE_FIXED) return; @@ -434,6 +434,9 @@ void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo) void dpm_remove_sink(int port) { + if (CONFIG_USB_PD_3A_PORTS == 0) + return; + if (!(BIT(port) & sink_max_pdo_requested)) return; @@ -442,25 +445,21 @@ void dpm_remove_sink(int port) balance_source_ports(); } -#if defined(CONFIG_USB_PD_DYNAMIC_SRC_CAP) || \ - defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) /* - * Charge manager APIs - * TODO(b/141690755): Remove and replace with DPM calls + * Note: all ports receive the 1.5 A source offering until they are found to + * match a criteria on the 3.0 A priority list (ex. though sink capability + * probing), at which point they will be offered a new 3.0 A source capability. */ -void charge_manager_source_port(int port, int enable) -{ - /* No-op present for linking */ -} - -int charge_manager_get_source_pdo(const uint32_t **src_pdo, const int port) +int dpm_get_source_pdo(const uint32_t **src_pdo, const int port) { + /* Max PDO may not exist on boards which don't offer 3 A */ +#if CONFIG_USB_PD_3A_PORTS > 0 if (max_current_claimed & BIT(port)) { *src_pdo = pd_src_pdo_max; return pd_src_pdo_max_cnt; } +#endif *src_pdo = pd_src_pdo; return pd_src_pdo_cnt; } -#endif diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index 2a116f0cf4..8e2ff806e6 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -1549,14 +1549,8 @@ static void print_current_state(const int port) static void send_source_cap(int port) { -#if defined(CONFIG_USB_PD_DYNAMIC_SRC_CAP) || \ - defined(CONFIG_USB_PD_MAX_SINGLE_SOURCE_CURRENT) const uint32_t *src_pdo; - const int src_pdo_cnt = charge_manager_get_source_pdo(&src_pdo, port); -#else - const uint32_t *src_pdo = pd_src_pdo; - const int src_pdo_cnt = pd_src_pdo_cnt; -#endif + const int src_pdo_cnt = dpm_get_source_pdo(&src_pdo, port); if (src_pdo_cnt == 0) { /* No source capabilities defined, sink only */ |