summaryrefslogtreecommitdiff
path: root/common/usbc/usb_pe_drp_sm.c
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-06-08 10:26:50 -0600
committerCommit Bot <commit-bot@chromium.org>2021-06-09 23:49:49 +0000
commite693376b111b7589ff4b89eefe90a5521e36c5e1 (patch)
tree1fd7eb0eb21a54f95c341449babf60c782c345d5 /common/usbc/usb_pe_drp_sm.c
parenta608b1bd1e6f2e901faf9ae896b9838c83323e2a (diff)
downloadchrome-ec-e693376b111b7589ff4b89eefe90a5521e36c5e1.tar.gz
TCPMv2: Cancel SNK PR swap if we can now charge
Some port partners may offer a very low initial source capbility (ex. 5V at 100mA) and then very quickly follow with full source capabilities. When this happens, cancel any queued PR swap requests since we now wish to charge from this port partner. BRANCH=None BUG=b:190506779 TEST=on guybrush, ensure Apple 3-in-1 connects without any unnecessary PR swaps Signed-off-by: Diana Z <dzigterman@chromium.org> Change-Id: Ia51efc8e17d950a0abb818b7da0f99d598affbe3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2947622 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'common/usbc/usb_pe_drp_sm.c')
-rw-r--r--common/usbc/usb_pe_drp_sm.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index ac146a381f..58bdbd6530 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -3068,13 +3068,17 @@ static void pe_snk_evaluate_capability_entry(int port)
/* Parse source caps if they have changed */
if (pe[port].src_cap_cnt != num ||
- memcmp(pdo, pe[port].src_caps, num << 2))
+ memcmp(pdo, pe[port].src_caps, num << 2)) {
/*
* If port policy preference is to be a power role source,
- * then request a power role swap.
+ * then request a power role swap. If we'd previously queued a
+ * PR swap but can now charge from this device, clear it.
*/
if (!pd_can_charge_from_device(port, num, pdo))
pd_request_power_swap(port);
+ else
+ PE_CLR_DPM_REQUEST(port, DPM_REQUEST_PR_SWAP);
+ }
pe_update_src_pdo_flags(port, num, pdo);
pd_set_src_caps(port, num, pdo);