summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2021-03-29 14:21:35 -0600
committerCommit Bot <commit-bot@chromium.org>2021-04-07 16:55:31 +0000
commit90d13cec6728a45ff1720325cf50ac21ec890e5c (patch)
treea2e385a26f0d71ddfaa3619f4a4fd1814d75ef81
parent0ca1bc44fc5195535ded889f3cfa8ad3e1124aba (diff)
downloadchrome-ec-90d13cec6728a45ff1720325cf50ac21ec890e5c.tar.gz
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 <dzigterman@chromium.org> Change-Id: I45acb7bce2f9a312c2f35ec74dc4563a947ee059 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2792689 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/tcpm/raa489000.c5
1 files changed, 5 insertions, 0 deletions
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);