summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-08-18 12:56:25 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-28 04:24:01 +0000
commit251f3b0f0beb66cbdd37b7e04828689c3a5b9a25 (patch)
treeb1cef4942223ad8e4424d239ac27f3daa454c616
parent214f7cf7508ee07902e06b94af893cbfdca5bac1 (diff)
downloadchrome-ec-251f3b0f0beb66cbdd37b7e04828689c3a5b9a25.tar.gz
pd: Try soft reset if ping fails
If a ping is dropped, instead of cutting power immediately, we should first try soft reset. If the soft reset packet is not received or an ACCEPT packet is not seen in time, we'll then perform hard reset. BUG=chrome-os-partner:31296 TEST=Add a console command to drop pings on Samus. Check that when a ping is dropped, the power is not cut and the connection is re-established. BRANCH=None Change-Id: Ifbee4124d55a9a7857a019ca823698f32911f3c7 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/212925 Reviewed-by: Alec Berg <alecaberg@chromium.org> Reviewed-by: Todd Broch <tbroch@chromium.org>
-rw-r--r--common/usb_pd_protocol.c38
1 files changed, 24 insertions, 14 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index f23fad06d5..0bf158c790 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -1258,22 +1258,32 @@ void pd_task(void)
}
break;
case PD_STATE_SRC_READY:
- if (pd[port].ping_enabled) {
- /* Verify that the sink is alive */
- res = send_control(port, PD_CTRL_PING);
- if (res >= 0) {
- /* schedule next keep-alive */
- timeout = PD_T_SOURCE_ACTIVITY;
- } else {
- /* The sink died ... */
- pd_power_supply_reset(port);
- set_state(port,
- PD_STATE_SRC_DISCONNECTED);
- timeout = PD_T_SEND_SOURCE_CAP;
- }
- } else {
+ if (!pd[port].ping_enabled) {
+ timeout = PD_T_SOURCE_ACTIVITY;
+ break;
+ }
+
+ /* Verify that the sink is alive */
+ res = send_control(port, PD_CTRL_PING);
+ if (res >= 0) {
+ /* schedule next keep-alive */
timeout = PD_T_SOURCE_ACTIVITY;
+ break;
+ }
+
+ timeout = 10 * MSEC;
+
+ /* Ping dropped. Try soft reset. */
+ execute_soft_reset(port);
+ res = send_control(port, PD_CTRL_SOFT_RESET);
+
+ if (res >= 0) {
+ set_state(port, PD_STATE_SOFT_RESET);
+ break;
}
+
+ /* Soft reset failed. Let's try hard reset. */
+ set_state(port, PD_STATE_HARD_RESET);
break;
#ifdef CONFIG_USB_PD_DUAL_ROLE
case PD_STATE_SUSPENDED: