summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2019-08-01 14:10:07 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-08 02:00:18 +0000
commitbda667fd25c0247e01bc538be4dd191fb6b3a8cf (patch)
tree109706fc6169339ebf1fa369f45b19983f33041d /common
parente8dd8120c87f7dc8b8faa61af2b87fed2583f5cb (diff)
downloadchrome-ec-bda667fd25c0247e01bc538be4dd191fb6b3a8cf.tar.gz
pd: Don't request LPM in DRP_TOGGLE if cc is not open
Currently, LPM_REQUESTED flag is always set in the DRP_AUTO_TOGGLE state. This is true even when the next state will be SNK_DISCONNECTED or SRC_DISCONNECTED. This setting makes sense for SNK_DISCONNECTED as when the AP is not in S0, then auto toggling will be disabled so the PD state machine should remain in SNK_DISCONNECTED until something is attached. But for the transition from DRP_TOGGLE to SRC_DISCONNECTED should only happen when either an adapter gets attached while the AP is in S0, or the chipset enters S0 with an adapter already attached. This 2nd case is problematic as if LPM_REQUESTED is set and there is no CC event pending, the PD task will get suspended (wait = -1) and therefore remain in SRC_DISCONNECTED. This CL modifies the existing logic to not set LPM_REQUESTED when something is attached as given by the CC1 and CC2 values. BUG=b:137697655 BRANCH=none TEST=Tested both EC reboot and resume from suspend with a USB stick connected via a type C->A adapter and verified that the PD state machine advances to PD_STATE_SRC_DISCOVERY as expected and the USB stick enumerates. Change-Id: I6afbd642ce38134ddabd20f7dc5e15f937b9810a Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1730967 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_pd_protocol.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index d4677fbefa..3f82341d2b 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -4513,10 +4513,13 @@ void pd_task(void *u)
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
/*
- * Always stay in low power mode since we are waiting
- * for a connection.
+ * The next state is not determined just by what is
+ * attached, but also depends on DRP_STATE. Regardless
+ * of next state, if nothing is attached, then always
+ * request low power mode.
*/
- pd[port].flags |= PD_FLAGS_LPM_REQUESTED;
+ if (cc_is_open(cc1, cc2))
+ pd[port].flags |= PD_FLAGS_LPM_REQUESTED;
#endif
if (next_state == PD_STATE_SNK_DISCONNECTED) {