diff options
author | Diana Z <dzigterman@chromium.org> | 2021-02-01 14:54:38 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-08 19:20:15 +0000 |
commit | 98bad5c43361a26cb8ea2a9b46b1291b911a0ef5 (patch) | |
tree | 9ed4cabcdc3b59f3aff246a1eb35d5748e931f1d /common/charge_manager.c | |
parent | cdaeab64862d0f6c6915e078ae5721f359760efe (diff) | |
download | chrome-ec-98bad5c43361a26cb8ea2a9b46b1291b911a0ef5.tar.gz |
TCPMv2: Report correct source-out current in host command
The EC_CMD_USB_PD_POWER_INFO host command was still querying the older
charge_manager source current tracking. Instead, when TCPMv2 is defined
the DPM should be treated as the authority for source-out current.
BRANCH=None
BUG=b:177714628
TEST=on drawcia, connect hub requiring 3A and confirm that value is
reported from "ectool usbpdpower"
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I65f4fb976f0ab90f4d20f6573c1002ed80ff9532
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2676081
Reviewed-by: Keith Short <keithshort@chromium.org>
Diffstat (limited to 'common/charge_manager.c')
-rw-r--r-- | common/charge_manager.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/common/charge_manager.c b/common/charge_manager.c index a6307fe318..e113179372 100644 --- a/common/charge_manager.c +++ b/common/charge_manager.c @@ -18,6 +18,7 @@ #include "tcpm/tcpm.h" #include "timer.h" #include "usb_pd.h" +#include "usb_pd_dpm.h" #include "usb_pd_tcpm.h" #include "util.h" @@ -108,7 +109,8 @@ static int override_port = OVERRIDE_OFF; static int delayed_override_port = OVERRIDE_OFF; static timestamp_t delayed_override_deadline; -static uint8_t source_port_rp[CONFIG_USB_PD_PORT_MAX_COUNT]; +/* Source-out Rp values for TCPMv1 */ +__maybe_unused static uint8_t source_port_rp[CONFIG_USB_PD_PORT_MAX_COUNT]; #ifdef CONFIG_USB_PD_MAX_TOTAL_SOURCE_CURRENT /* 3A on one port and 1.5A on the rest */ @@ -226,7 +228,7 @@ static void charge_manager_init(void) charge_ceil[i][j] = CHARGE_CEIL_NONE; if (!is_pd_port(i)) dualrole_capability[i] = CAP_DEDICATED; - if (is_pd_port(i)) + if (is_pd_port(i) && !IS_ENABLED(CONFIG_USB_PD_TCPMV2)) source_port_rp[i] = CONFIG_USB_PD_PULLUP; } } @@ -269,7 +271,7 @@ static int charge_manager_is_seeded(void) * @param port Charge port. * @return Charge current (mA). */ -static int charge_manager_get_source_current(int port) +__maybe_unused static int charge_manager_get_source_current(int port) { if (!is_pd_port(port)) return 0; @@ -409,8 +411,13 @@ static void charge_manager_fill_power_info(int port, r->meas.voltage_max = 0; r->meas.voltage_now = r->role == USB_PD_PORT_POWER_SOURCE ? 5000 : 0; - r->meas.current_max = - charge_manager_get_source_current(port); + /* TCPMv2 tracks source-out current in the DPM */ + if (IS_ENABLED(CONFIG_USB_PD_TCPMV2)) + r->meas.current_max = + dpm_get_source_current(port); + else + r->meas.current_max = + charge_manager_get_source_current(port); r->max_power = 0; } else { r->type = USB_CHG_TYPE_NONE; |