summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorWai-Hong Tam <waihong@google.com>2020-09-09 17:20:13 -0700
committerCommit Bot <commit-bot@chromium.org>2020-09-11 01:18:07 +0000
commit2f97dfd60564f835b6ae5995b149cb2cb1d4893c (patch)
treec0c9c2d9ccffe428c1a2b236ca077d4084efee1f /common
parentc5e05e5fea98ab9080cd4d98d957d16401aebaef (diff)
downloadchrome-ec-2f97dfd60564f835b6ae5995b149cb2cb1d4893c.tar.gz
TCPMv2: Block enabling PD in RO for non-EFS2 and dead-battery
If enable PD in RO on a non-EFS2 device, a hard reset will be issued when sysjump to RW that makes the device brownout on the dead-battery case. For this special case, disable PD in RO as a workaround. BRANCH=None BUG=b:166307654,b:168134171 TEST=Tested on Pompom, without battery attached. EC warm reset and sysjump to RW won't cause the board power-lost. EC warm reset may be brownout but the next boot is fine. Change-Id: Ie6e7687aa8e160012f9bbd725e0fbcbacae94cf2 Signed-off-by: Wai-Hong Tam <waihong@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2402150 Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index b789191bb5..9f99626549 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -581,8 +581,23 @@ void tc_request_power_swap(int port)
static bool pd_comm_allowed_by_policy(void)
{
- return IS_ENABLED(CONFIG_SYSTEM_UNLOCKED) || system_is_in_rw() ||
- vboot_allow_usb_pd();
+ if (system_is_in_rw())
+ return true;
+
+ if (vboot_allow_usb_pd())
+ return true;
+
+ /*
+ * If enable PD in RO on a non-EFS2 device, a hard reset will be issued
+ * when sysjump to RW that makes the device brownout on the dead-battery
+ * case. Disable PD for this special case as a workaround.
+ */
+ if (IS_ENABLED(CONFIG_SYSTEM_UNLOCKED) &&
+ (IS_ENABLED(CONFIG_VBOOT_EFS2) ||
+ usb_get_battery_soc() >= CONFIG_USB_PD_TRY_SRC_MIN_BATT_SOC))
+ return true;
+
+ return false;
}
static void tc_policy_pd_enable(int port, int en)