From 90d13cec6728a45ff1720325cf50ac21ec890e5c Mon Sep 17 00:00:00 2001 From: Diana Z Date: Mon, 29 Mar 2021 14:21:35 -0600 Subject: RAA489000: Check battery level in debug detach Since our debug detach routine requires setting our CC's to open, we may end up losing Vbus. Protect ourselves by checking the battery level prior to allowing this to be set. BRANCH=None BUG=b:183619502 TEST=make -j buildall Signed-off-by: Diana Z Change-Id: I45acb7bce2f9a312c2f35ec74dc4563a947ee059 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2792689 Reviewed-by: Aseda Aboagye --- driver/tcpm/raa489000.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/driver/tcpm/raa489000.c b/driver/tcpm/raa489000.c index 252f59f0b5..abb92e656f 100644 --- a/driver/tcpm/raa489000.c +++ b/driver/tcpm/raa489000.c @@ -255,7 +255,12 @@ int raa489000_debug_detach(int port) * 1. Set POWER_CONTROL. AutoDischargeDisconnect=1 * 2. Set ROLE_CONTROL=0x0F(OPEN,OPEN) * 3. Set POWER_CONTROL. AutoDischargeDisconnect=0 + * + * Only if we have sufficient battery. Otherwise, we would risk + * brown-out during the CC open set. */ + if (!pd_is_battery_capable()) + return EC_SUCCESS; tcpci_tcpc_enable_auto_discharge_disconnect(port, 1); -- cgit v1.2.1