summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2014-08-18 12:23:01 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-08-28 04:23:55 +0000
commit214f7cf7508ee07902e06b94af893cbfdca5bac1 (patch)
tree1c126c148bd121e7206bec23ffb4d39b545c40fe
parentd9fe6f32c4b6abd624410dd69e2c37b501726467 (diff)
downloadchrome-ec-214f7cf7508ee07902e06b94af893cbfdca5bac1.tar.gz
pd: handle ACCEPT after a soft reset
After sending a soft reset, the port partner is supposed to respond with an ACCEPT. If ACCEPT is not seen within PD_T_SENDER_RESPONSE, we should try a hard reset. This CL also changes the definition of SOFT_RESET state from an artificial delay state to a state waiting for ACCEPT. With this, we are now just waiting in DISCOVERY state after a reset and therefore we can remove the 30ms artificial delay. BUG=chrome-os-partner:31296 TEST=Along with the next CL to send soft reset on dropped ping, check power doesn't drop when a ping is dropped. TEST=Modify Samus to not send ACCEPT when a SOFT_RESET packet is received. Check that we received HARD_RESET after SOFT_RESET. BRANCH=None Change-Id: Iddce33befa0c3c43228e68aac8e481d3da52db2a Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/212924 Reviewed-by: Alec Berg <alecaberg@chromium.org>
-rw-r--r--common/usb_pd_protocol.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 387ea20e82..f23fad06d5 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -626,7 +626,12 @@ static void execute_hard_reset(int port)
static void execute_soft_reset(int port)
{
pd[port].msg_id = 0;
- set_state(port, PD_STATE_SOFT_RESET);
+#ifdef CONFIG_USB_PD_DUAL_ROLE
+ set_state(port, pd[port].role == PD_ROLE_SINK ?
+ PD_STATE_SNK_DISCOVERY : PD_STATE_SRC_DISCOVERY);
+#else
+ set_state(port, PD_STATE_SRC_DISCOVERY);
+#endif
CPRINTF("Soft Reset\n");
}
@@ -638,6 +643,7 @@ void pd_soft_reset(void)
if (pd_is_connected(i)) {
execute_soft_reset(i);
send_control(i, PD_CTRL_SOFT_RESET);
+ set_state(i, PD_STATE_SOFT_RESET);
}
}
@@ -761,6 +767,15 @@ static void handle_ctrl_request(int port, uint16_t head,
break;
#endif /* CONFIG_USB_PD_DUAL_ROLE */
case PD_CTRL_ACCEPT:
+ if (pd[port].task_state == PD_STATE_SOFT_RESET) {
+#ifdef CONFIG_USB_PD_DUAL_ROLE
+ set_state(port, pd[port].role == PD_ROLE_SINK ?
+ PD_STATE_SNK_DISCOVERY :
+ PD_STATE_SRC_DISCOVERY);
+#else
+ set_state(port, PD_STATE_SRC_DISCOVERY);
+#endif
+ }
break;
case PD_CTRL_SOFT_RESET:
execute_soft_reset(port);
@@ -1340,25 +1355,11 @@ void pd_task(void)
break;
#endif /* CONFIG_USB_PD_DUAL_ROLE */
case PD_STATE_SOFT_RESET:
- /*
- * Delay for 30 ms in case the port partner is not
- * ready
- */
- if (pd[port].last_state != pd[port].task_state) {
-#ifdef CONFIG_USB_PD_DUAL_ROLE
- enum pd_states discovery_state =
- (pd[port].role == PD_ROLE_SINK ?
- PD_STATE_SNK_DISCOVERY :
- PD_STATE_SRC_DISCOVERY);
-#else
- enum pd_states discovery_state =
- PD_STATE_SRC_DISCOVERY;
-#endif
+ if (pd[port].last_state != pd[port].task_state)
set_state_timeout(
port,
- get_time().val + (30 * MSEC),
- discovery_state);
- }
+ get_time().val + PD_T_SENDER_RESPONSE,
+ PD_STATE_HARD_RESET);
break;
case PD_STATE_HARD_RESET:
send_hard_reset(port);
@@ -1624,6 +1625,7 @@ static int command_pd(int argc, char **argv)
} else if (!strncasecmp(argv[2], "soft", 4)) {
execute_soft_reset(port);
send_control(port, PD_CTRL_SOFT_RESET);
+ set_state(port, PD_STATE_SOFT_RESET);
task_wake(PORT_TO_TASK_ID(port));
} else if (!strncasecmp(argv[2], "ping", 4)) {
int enable;
@@ -1693,7 +1695,7 @@ static int command_pd(int argc, char **argv)
"SNK_TRANSITION", "SNK_READY",
"SRC_DISCONNECTED", "SRC_DISCOVERY", "SRC_NEGOCIATE",
"SRC_ACCEPTED", "SRC_TRANSITION", "SRC_READY",
- "HARD_RESET", "BIST",
+ "SOFT_RESET", "HARD_RESET", "BIST",
};
ccprintf("Port C%d, %s - Role: %s Polarity: CC%d State: %s\n",
port, pd_comm_enabled ? "Enabled" : "Disabled",