From d831100df926df2e1d987fc64e6ac6733989ad91 Mon Sep 17 00:00:00 2001 From: Koro Chen Date: Wed, 15 Jun 2016 13:53:26 +0800 Subject: [PATCH] pd: Set PD_FLAGS_VBUS_NEVER_LOW after tcpm_init When we jump from RO to RW, tcpc_vbus declared in tcpci.c is initialized to 0. So even if we had VBUS present before, PD_FLAGS_VBUS_NEVER_LOW is not set and soft reset cannot be used later when source cap is timeout. This causes power loss and reboot when we boot up system without battery. Set PD_FLAGS_VBUS_NEVER_LOW after tcpm_init() so we can refresh tcpc_vbus from TCPC first. BUG=chrome-os-partner:53496 BRANCH=none TEST=test on elm. Remove battery and boot up successfully only with AC. Use "sysjump rw" command and ec won't reboot by pd hard reset. Change-Id: Id4737f076a9572cb540310f9fdce062198257967 Signed-off-by: Koro Chen Reviewed-on: https://chromium-review.googlesource.com/352833 Reviewed-by: Rong Chang --- common/usb_pd_protocol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index a13b295503..2b6d39fd82 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1411,6 +1411,10 @@ void pd_task(void) /* Ensure the power supply is in the default state */ pd_power_supply_reset(port); + /* Initialize TCPM driver and wait for TCPC to be ready */ + res = tcpm_init(port); + CPRINTS("TCPC p%d init %s", port, res ? "failed" : "ready"); + #ifdef CONFIG_USB_PD_DUAL_ROLE /* * If VBUS is high, then initialize flag for VBUS has always been @@ -1420,10 +1424,6 @@ void pd_task(void) pd[port].flags = pd_is_vbus_present(port) ? PD_FLAGS_VBUS_NEVER_LOW : 0; #endif - /* Initialize TCPM driver and wait for TCPC to be ready */ - res = tcpm_init(port); - CPRINTS("TCPC p%d init %s", port, res ? "failed" : "ready"); - /* Disable TCPC RX until connection is established */ tcpm_set_rx_enable(port, 0);