summaryrefslogtreecommitdiff
path: root/test/usb_pd.c
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2018-11-06 12:09:51 -0800
committerCommit Bot <commit-bot@chromium.org>2019-06-21 17:24:21 +0000
commitc00ca2d3d8e8662dd048f107999f09fee4a301f4 (patch)
treee723052f8f5c8fd8e2562c627df57bfbe151da1f /test/usb_pd.c
parent71601aaaaf592225cb0834ce2b287c2fede02f16 (diff)
downloadchrome-ec-c00ca2d3d8e8662dd048f107999f09fee4a301f4.tar.gz
pd_protocol: Don't DRP toggle lower than S0.
Currently our USB PD protocol stack has "low power mode" tightly coupled with PD_STATE_DRP_AUTO_TOGGLE. In addition, it has the side effect of us dual role toggling (and resolving as sources) even though we have no intention of being a source. (e.g. DRP toggle in S0, once we suspend we're still toggling, even after shutting down to S5, we're still toggling.) This commit makes it such that we not dual role toggle in those lower power states, but instead behave properly as a sink and present only the Rd's. It also fixes a bug where if a port was previously sourcing in S0 and remained sourcing in suspend, if the sink was unplugged the port would be stuck presenting Rp's until a sink was plugged and unplugged again. BUG=chromium:902437 BUG=b:119055792 BRANCH=firmware-nocturne-10984.B TEST=Flash nocturne, use twinkie verify port does not dual role toggle in suspend or off. TEST=Verify that TCPC goes into low power mode in SNK_DISCONNECTED. TEST=Verify that charging works in suspend and off. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/1320909 Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Change-Id: Ie44581a1a1a82cf29a786b57a71ce70760862ca2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1667940 Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> Auto-Submit: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'test/usb_pd.c')
-rw-r--r--test/usb_pd.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/usb_pd.c b/test/usb_pd.c
index 9365983b35..2ca0d1d115 100644
--- a/test/usb_pd.c
+++ b/test/usb_pd.c
@@ -276,6 +276,8 @@ static void plug_in_source(int port, int polarity)
pd_port[port].has_vbus = 1;
pd_port[port].partner_role = PD_ROLE_SOURCE;
pd_port[port].partner_polarity = polarity;
+ /* Indicate that the CC lines have changed. */
+ task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0);
}
static void plug_in_sink(int port, int polarity)
@@ -283,6 +285,8 @@ static void plug_in_sink(int port, int polarity)
pd_port[port].has_vbus = 0;
pd_port[port].partner_role = PD_ROLE_SINK;
pd_port[port].partner_polarity = polarity;
+ /* Indicate that the CC lines have changed. */
+ task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0);
}
static void unplug(int port)
@@ -291,6 +295,8 @@ static void unplug(int port)
pd_port[port].msg_rx_id = 0;
pd_port[port].has_vbus = 0;
pd_port[port].partner_role = -1;
+ /* Indicate that the CC lines have changed. */
+ task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_CC, 0);
task_wake(PD_PORT_TO_TASK_ID(port));
usleep(30 * MSEC);
}