From 0c331e6fcbe5f227e106485ea0477935d802cf4e Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Mon, 29 Jun 2015 17:22:42 -0700 Subject: [PATCH] pi3usb9281: fix BC1.2 re-detection when using USB device mode When the USB2.0 port is used in device mode, having the D+/D- lines connected just before resetting the PI3USB9281 (for the 2nd detection used a BC1.2 debouncing) triggers a misdetection where DCP chargers are seen as Apple 2.4A chargers. To avoid this, disconnect the D+/D- lines and let them relax before triggering the PI3USB9281 reset. Signed-off-by: Vincent Palatin BRANCH=smaug BUG=chrome-os-partner:42048 TEST=connect and disconnect a DCP charger to the Smaug type-C port with the AP running, see it constantly detected as DCP and no Pericom interrupt storm. Change-Id: I8f6043439c2c6b52f2689b4947baffe51f62eba8 Reviewed-on: https://chromium-review.googlesource.com/282594 Reviewed-by: Shawn N Reviewed-by: Alec Berg Trybot-Ready: Vincent Palatin Tested-by: Vincent Palatin Commit-Queue: Vincent Palatin --- common/usb_charger.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/usb_charger.c b/common/usb_charger.c index b003f415e4..1e78ddc38d 100644 --- a/common/usb_charger.c +++ b/common/usb_charger.c @@ -69,6 +69,14 @@ void usb_charger_task(void) if (device_type || PI3USB9281_CHG_STATUS_ANY(charger_status)) { msleep(USB_CHG_DEBOUNCE_DELAY_MS); + /* next operation might trigger a detach interrupt */ + pi3usb9281_disable_interrupts(port); + /* Ensure D+/D- are open before resetting */ + pi3usb9281_set_switch_manual(port, 1); + pi3usb9281_set_pins(port, 0); + /* Let D+/D- relax to their idle state */ + msleep(40); + /* * Trigger chip reset to refresh detection registers. * WARNING: This reset is acceptable for samus_pd,