From 7a23aa72bf86aab4e5edd4cbf1fc47aabb0e8b31 Mon Sep 17 00:00:00 2001 From: Jett Rink Date: Fri, 9 Feb 2018 08:31:02 -0700 Subject: [PATCH] usb-pd: Clear active contract bit before browning out system In the case where we are resetting Vbus and it is our only power source, then we will brown out before we set the active port to 0. BRANCH=none BUG=none TEST=Did a cold reset on grunt with no battery power. System booted as normal. Change-Id: I3823af6b0475e4cf8abbe12dd8ae4ceef26d1eab Signed-off-by: Jett Rink Reviewed-on: https://chromium-review.googlesource.com/911613 Reviewed-by: Aseda Aboagye Reviewed-by: Edward Hill --- common/usb_pd_protocol.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 7eb6ece81f..af623fbcbe 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1853,13 +1853,18 @@ static void pd_partner_port_reset(int port) (RESET_FLAG_BROWNOUT | RESET_FLAG_POWER_ON)) return; + /* + * Clear the active contract bit before we apply Rp in case we + * intentionally brown out because we cut off our only power supply. + */ + pd_set_saved_active(port, 0); + /* Provide Rp for 200 msec. or until we no longer have VBUS. */ tcpm_set_cc(port, TYPEC_CC_RP); timeout = get_time().val + 200 * MSEC; while (get_time().val < timeout && pd_is_vbus_present(port)) msleep(10); - pd_set_saved_active(port, 0); } #endif /* CONFIG_USB_PD_DUAL_ROLE */