summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-10-16 10:48:34 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2019-05-07 15:36:08 +0000
commitf4e321b6fddae70a1a284f8e872f8315654f0bf8 (patch)
treec01ff97fa1551dab0d573ab1800d23dabc463d05
parent5a71651ca098a17ffb50d4b04014110b9b27227a (diff)
downloadchrome-ec-f4e321b6fddae70a1a284f8e872f8315654f0bf8.tar.gz
pd_protocol: Don't clear PD flags while debouncing.
The PD_FLAGS_TRY_SRC flag was being cleared every time we entered the *_DISCONNECTED state. However, this would lead to a case where if the state machine was debouncing the CC lines and decided to re-enter the SRC_DISCONNECTED state, the Try.Src flag would be cleared and the state machine would not transition to the TryWait.SNK state after timing out. We shouldn't clear any flags when transitioning back to the disconnected state from the debounce state as the two states here are really the same states in the state diagram. This commit simply only clears the PD flags when we're transitioning to the disconnected state but not from a debounce state. This also keeps the Try.Src flag set if the previous state was a debounce as it means the state machine decided it didn't meet the condition to exit and should continue waiting before transitioning to TryWait.SNK. BUG=b:115452695 BRANCH=master TEST=Flash nocturne; boot to S0, plug in Apple 87W USB-C charger with eMarked cable, verify we form an explicit 45W contract. Change-Id: I6d8f5d69b8bd0d25ac7af008bbbe91f2658cdfe2 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/1286299 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 1f30c7483fa5621e9d67c5977709dce73f31a66d) Reviewed-on: https://chromium-review.googlesource.com/1591483 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> (cherry picked from commit 96840904c1e25a5b04e1e796cf286adfe4e6beeb) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1598284 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Diana Z <dzigterman@chromium.org> Tested-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--common/usb_pd_protocol.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 81b918dc05..2062ff8047 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -687,6 +687,15 @@ static inline void set_state(int port, enum pd_states next_state)
/* Clear the SNK_READY holdoff timer. */
pd[port].snk_ready_holdoff_timer = 0;
+ /*
+ * We should not clear any flags when transitioning back to the
+ * disconnected state from the debounce state as the two states
+ * here are really the same states in the state diagram.
+ */
+ if (last_state != PD_STATE_SNK_DISCONNECTED_DEBOUNCE &&
+ last_state != PD_STATE_SRC_DISCONNECTED_DEBOUNCE)
+ pd[port].flags &= ~PD_FLAGS_RESET_ON_DISCONNECT_MASK;
+
/* Clear the input current limit */
pd_set_input_current_limit(port, 0, 0);
#ifdef CONFIG_CHARGE_MANAGER
@@ -717,7 +726,6 @@ static inline void set_state(int port, enum pd_states next_state)
pd[port].rev = PD_REV30;
#endif
pd[port].dev_id = 0;
- pd[port].flags &= ~PD_FLAGS_RESET_ON_DISCONNECT_MASK;
#ifdef CONFIG_CHARGE_MANAGER
charge_manager_update_dualrole(port, CAP_UNKNOWN);
#endif