summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-10-16 10:48:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-05-04 03:17:42 -0700
commit96840904c1e25a5b04e1e796cf286adfe4e6beeb (patch)
tree5128545265b7806e44b457e5188246b20011f0f6 /common
parent48521e7a690a8db6b7dac1272667c4717ed7684d (diff)
downloadchrome-ec-96840904c1e25a5b04e1e796cf286adfe4e6beeb.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>
Diffstat (limited to 'common')
-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 b6b987b3da..cb2d51ee56 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -694,6 +694,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
@@ -733,7 +742,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