From 7d794116deacb595952ebd126cf9c05ea15b9b10 Mon Sep 17 00:00:00 2001 From: Karthikeyan Ramasubramanian Date: Tue, 15 Jan 2019 12:11:29 -0700 Subject: driver/ppc/nx20p348.c: Handle overcurrent event Currently the overcurrent event is logged but not handled. Report the overcurrent event to the USB PD framework which in turn will handle the overcurrent event further. BUG=b:115475862 BRANCH=octopus TEST=Boot to ChromeOS in grabbiter. No overcurrent events reported when the sink is drawing <= 3.20 A. Overcurrent events are reported when the sink is drawing > 3.25 A. After 3 reports, the port is latched off and power delivery is stopped. The port is re-enabled only after the sink is disconnected. Also when the sink is drawing current at 3.24 A, there is one report of overcurrent. The port gets disabled in response to that event. But the port is re-enabled after 1 second since overcurrent event is reported only once. After the port is re-enabled, the sink is able to draw the set current. When the overcurrent event is reported, I can see in the kernel logs that the overcurrent condition is detected by the kernel. EC Logs: [3391.984462 C1: PPC detected Vbus overcurrent!] [3391.984953 C1: overcurrent!] [3392.044935 C1: PPC detected Vbus overcurrent!] [3392.045425 C1: overcurrent!] [3392.061404 C1: PPC detected Vbus overcurrent!] [3392.061894 C1: overcurrent!] [3392.062142 C1: OC event limit reached! Source path disabled until physical disconnect.] [3392.077226 C1: PPC detected Vbus overcurrent!] [3392.077532 C1: overcurrent!] [3392.077891 C1: OC event limit reached! Source path disabled until physical disconnect.] [3392.092660 C1: PPC detected Vbus overcurrent!] [3392.092966 C1: overcurrent!] [3392.093213 C1: OC event limit reached! Source path disabled until physical disconnect.] Kernel Logs: [ 3356.560456] usb usb2-port1: over-current condition [ 3356.768434] usb usb2-port2: over-current condition [ 3356.976446] usb usb2-port4: over-current condition [ 3357.184441] usb usb2-port5: over-current condition [ 3357.392445] usb usb2-port6: over-current condition Change-Id: I0af69a132fdd1dd5bab4d530c3b060b2a5aea501 Signed-off-by: Karthikeyan Ramasubramanian Reviewed-on: https://chromium-review.googlesource.com/1412448 Commit-Ready: Karthikeyan Ramasubramanian Tested-by: Karthikeyan Ramasubramanian Reviewed-by: Jett Rink --- driver/ppc/nx20p348x.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/driver/ppc/nx20p348x.c b/driver/ppc/nx20p348x.c index 8a0d45851e..35202c8fe8 100644 --- a/driver/ppc/nx20p348x.c +++ b/driver/ppc/nx20p348x.c @@ -15,6 +15,7 @@ #include "tcpm.h" #include "usb_charge.h" #include "usb_pd_tcpm.h" +#include "usb_pd.h" #include "usbc_ppc.h" #include "util.h" @@ -322,11 +323,7 @@ static void nx20p348x_handle_interrupt(int port) /* Check for 5V OC interrupt */ if (reg & NX20P348X_INT1_OC_5VSRC) { CPRINTS("C%d: PPC detected Vbus overcurrent!", port); - /* - * TODO (b/69935262): The overcurrent action hasn't - * been completed yet, but is required for TI PPC. When that - * work is complete, tie it in here. - */ + pd_handle_overcurrent(port); } /* Check for Vbus reverse current protection */ -- cgit v1.2.1