From a0c5faf1a106bcc3771f63ebda8b1fac1877b95d Mon Sep 17 00:00:00 2001 From: Alec Berg Date: Mon, 19 Jan 2015 13:24:24 -0800 Subject: [PATCH] pd: fix bug where sysjump could cause PD state to wedge Fix bug in USB PD initialization after a sysjump. Since the CC pull resistors weren't being initialized after a sysjump, we would sometimes end up stuck in sink debounce state because we would have Rp applied and our initial state of sink disconnected would think that a source was attached. And since we continued to apply Rp, we would never make a connection with a charger, so we would be stuck in sink debounce until a reboot. BUG=chrome-os-partner:35608 BRANCH=samus TEST=load on samus and keep rebooting and sysjumping and making sure that we don't falsely go to the sink debounce state. Change-Id: Ic81fe02be78f3f4ffe00e3e3e378f5befe8545a5 Signed-off-by: Alec Berg Reviewed-on: https://chromium-review.googlesource.com/241874 Reviewed-by: Vincent Palatin --- common/usb_pd_protocol.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 8b03f38798..bc662abb77 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1746,6 +1746,14 @@ void pd_task(void) timestamp_t now; int caps_count = 0, hard_reset_sent = 0; +#ifdef CONFIG_USB_PD_DUAL_ROLE + /* + * Set CC pull resistors, and charge_en and vbus_en GPIOs to match + * the initial role. + */ + pd_set_host_mode(port, PD_ROLE_DEFAULT == PD_ROLE_SOURCE); +#endif + /* Initialize TX pins and put them in Hi-Z */ pd_tx_init();