summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2018-10-09 10:26:48 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-09 21:14:49 -0700
commit1028c039fb14ddf523bcf0786ed39e8a2c57648f (patch)
treed6360e704e8fb354140ac882d59609902ba13abb
parentbb3f5b55257bf9ae1a0c695e4b8f870932137472 (diff)
downloadchrome-ec-1028c039fb14ddf523bcf0786ed39e8a2c57648f.tar.gz
tcpc: Check battery present to enable PD_SUSPEND
When doing TCPC firmware update, it suspends the PD port. There is a check to make sure if the battery level is enough for the update process. But when no battery presents, it still does the update. Should also check the battery present. Otherwise, the update process will make the power lost and result a reboot loop. BRANCH=none BUG=b:117498337 TEST=Do TCPC firmware update on the charging port and no battery: Saw AP console: Protect aux fw 0 Update aux fw 1 ps8751.1: PD_SUSPEND busy! Could be only power source. Protect aux fw 1 Saw EC console: [9.165306 C1: Cannot suspend for upgrade, no battery!] TEST=Do TCPC firmware update on the charging port and battery plugged: Saw AP console: Protect aux fw 0 Update aux fw 1 ps8751.1: found SPI flash ID 0x1c11 ps8751.1: erased 20KB in 434ms ps8751.1: verified 0KB in 0s ps8751.1: programming 20KB... Change-Id: I4ed3929d3234d115596f04245e698de8b1b3e662 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/1271257 Reviewed-by: Furquan Shaikh <furquan@chromium.org>
-rw-r--r--common/usb_pd_protocol.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index c5ab8ca9a2..f0d649929c 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -4937,6 +4937,11 @@ static int pd_control(struct host_cmd_handler_args *args)
* to ask the battery directly.
*/
battery_get_params(&batt);
+ if (batt.is_present != BP_YES) {
+ CPRINTS("C%d: Cannot suspend for upgrade, no "
+ "battery!", cmd->chip);
+ return EC_RES_BUSY;
+ }
if (batt.remaining_capacity <
MIN_BATTERY_FOR_TCPC_UPGRADE_MAH ||
batt.flags & BATT_FLAG_BAD_REMAINING_CAPACITY) {