From 9b2fa9111e3f92590f6a6f28b36aebf18cc15bb0 Mon Sep 17 00:00:00 2001 From: Eric Herrmann Date: Mon, 30 Nov 2020 12:24:18 -0800 Subject: SYV682x: Stop VCONN configuration if there is OVP If a VBAT OVP is triggered while VCONN is being configured, a PPC re-init will reset the PPC. But, the VCONN configuration would undo this because it is a RMW. Instead, if VBAT OVP is triggered, don't update the VCONN state. BUG=b:171461736 TEST=On a Voxel which experiences VBAT OVPs, ensure that it recovers from these TEST=make buildall BRANCH=None Signed-off-by: Eric Herrmann Change-Id: I427c43144c8774627783908c0d921fa170686f7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2572236 Reviewed-by: Keith Short --- driver/ppc/syv682x.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'driver') diff --git a/driver/ppc/syv682x.c b/driver/ppc/syv682x.c index ed3fc5a502..3d2142e76f 100644 --- a/driver/ppc/syv682x.c +++ b/driver/ppc/syv682x.c @@ -274,7 +274,7 @@ static void syv682x_handle_status_interrupt(int port, int regval) } } -static void syv682x_handle_control_4_interrupt(int port, int regval) +static int syv682x_handle_control_4_interrupt(int port, int regval) { /* * VCONN OC is actually notifying that it is current limiting @@ -305,13 +305,16 @@ static void syv682x_handle_control_4_interrupt(int port, int regval) * On VBAT OVP, CC/VCONN are cut. Re-enable before sending the hard * reset using a PPC re-init. We could reconfigure CC based on flags, * but these will be updated anyway due to a hard reset so just re-init - * for simplicity. + * for simplicity. If this happens return an error since this isn't + * recoverable. */ if (regval & SYV682X_CONTROL_4_VBAT_OVP) { ppc_prints("VBAT or CC OVP!", port); syv682x_init(port); pd_handle_cc_overvoltage(port); + return EC_ERROR_UNKNOWN; } + return EC_SUCCESS; } static int syv682x_vbus_sink_enable(int port, int enable) @@ -457,7 +460,9 @@ static int syv682x_set_vconn(int port, int enable) * register value to see if there are interrupts to avoid race * conditions with the interrupt handler */ - syv682x_handle_control_4_interrupt(port, regval); + rv = syv682x_handle_control_4_interrupt(port, regval); + if (rv) + return rv; regval &= ~(SYV682X_CONTROL_4_VCONN2 | SYV682X_CONTROL_4_VCONN1); if (enable) { -- cgit v1.2.1