diff options
author | Diana Z <dzigterman@chromium.org> | 2021-02-04 13:30:03 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-02-09 17:16:45 +0000 |
commit | 14b9c0fe159a3928697c92b35fba0bb2d1c6372a (patch) | |
tree | 1cdb7b4ea97e01bbd4e99e6a888e3ef863873f19 | |
parent | 1636ac582c463cb28a3b8c949ee1eaae49445719 (diff) | |
download | chrome-ec-14b9c0fe159a3928697c92b35fba0bb2d1c6372a.tar.gz |
TCPMv2: Check charge port when booting
When booting into S0, take the current charge port into account when
deciding whether to power role swap. If the port has been selected from
the UI as a charge port, then refrain from swapping and continue to
charge from it.
BRANCH=None
BUG=b:179334214,b:179095748,b:178070314
TEST=on madoo, connect to magolor and select charging from magolor on
the UI. Go through suspend and shutdown iterations and confirm that
madoo continues to charge from magolor
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I40ef73309f75372b0a34a7542282244ff30868ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2676924
Reviewed-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2681288
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
Tested-by: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | common/mock/charge_manager_mock.c | 5 | ||||
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/common/mock/charge_manager_mock.c b/common/mock/charge_manager_mock.c index a61552240f..11661d2b2e 100644 --- a/common/mock/charge_manager_mock.c +++ b/common/mock/charge_manager_mock.c @@ -31,6 +31,11 @@ int charge_manager_get_selected_charge_port(void) return 0; } +int charge_manager_get_active_charge_port(void) +{ + return 0; +} + int charge_manager_get_vbus_voltage(int port) { return mock_ctrl_charge_manager.vbus_voltage_mv; diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index c49ce15918..ec94201e78 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -1406,13 +1406,16 @@ static bool pd_can_source_from_device(const int pdo_cnt, const uint32_t *pdos) void pd_resume_check_pr_swap_needed(int port) { /* - * Explicit contract, current power role of SNK and the device - * indicates it should not power us then trigger a PR_Swap + * Explicit contract, current power role of SNK, the device + * indicates it should not power us, and device isn't selected + * as the charging port (ex. through the GUI) then trigger a PR_Swap */ if (pe_is_explicit_contract(port) && pd_get_power_role(port) == PD_ROLE_SINK && !pd_can_source_from_device(pd_get_src_cap_cnt(port), - pd_get_src_caps(port))) + pd_get_src_caps(port)) && + (!IS_ENABLED(CONFIG_CHARGE_MANAGER) || + charge_manager_get_active_charge_port() != port)) pd_dpm_request(port, DPM_REQUEST_PR_SWAP); } |