diff options
author | Patryk Duda <pdk@semihalf.com> | 2021-03-17 15:14:38 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-03-25 16:38:20 +0000 |
commit | 1faf0dd6c7848348489691cbb15d67e87a7cd6ca (patch) | |
tree | dc23d403b68cf23fc36e5c59e42f1aa3e5811297 | |
parent | 9ff965d972a1a8dc4fdcb9133e17a903bdd4fc73 (diff) | |
download | chrome-ec-1faf0dd6c7848348489691cbb15d67e87a7cd6ca.tar.gz |
TCPMv2: Do not apply CC Open when running without battery
This patch prevents applying CC Open when there is no battery.
On some boards EC RO doesn't save power-on reset flag in BBRAM when
EC reboot by Cr50 is expected. This behaviour was implemented in
CL:2255830. Brown-out reset flag is implemented only for LM4 chips.
Also we don't have access to information stored by TCPMv1 in BBRAM.
This functionality was removed from TCPMv2 in CL:2271002, so we can't
really determine if we should apply CC Open and from that time we are
applying CC Open always, except power-on and brown-out reset flags.
This patch adds missing battery to list of exceptions.
BUG=b:161775827
BRANCH=none
TEST=Flash EC ToT on Fleex. Disconnect battery physically and plug
charger. Check if ChromeOS boots successfully.
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: Icc22fcce595693c744e1a55b905cdd58b5e7bfbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2767638
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Diana Z <dzigterman@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2785213
Tested-by: Abe Levkoy <alevkoy@chromium.org>
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 27 |
1 files changed, 25 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 4867ae28d4..8daf8704e2 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -1518,6 +1518,13 @@ void tc_state_init(int port) #endif /* + * We are going to apply CC open (start with ErrorRecovery state) + * unless there is something which forbids us to do that (one of + * conditions below is true) + */ + first_state = TC_ERROR_RECOVERY; + + /* * If we just lost power, don't apply CC open. Otherwise we would boot * loop, and if this is a fresh power on, then we know there isn't any * stale PD state as well. @@ -1525,12 +1532,28 @@ void tc_state_init(int port) if (system_get_reset_flags() & (EC_RESET_FLAG_BROWNOUT | EC_RESET_FLAG_POWER_ON)) { first_state = TC_UNATTACHED_SNK; + } + + /* + * If this is non-EFS2 device, battery is not present and EC RO doesn't + * keep power-on reset flag after reset caused by H1, then don't apply + * CC open because it will cause brown out. + * + * Please note that we are checking if CONFIG_BOARD_RESET_AFTER_POWER_ON + * is defined now, but actually we need to know if it was enabled in + * EC RO! It was assumed that if CONFIG_BOARD_RESET_AFTER_POWER_ON is + * defined now it was defined in EC RO too. + */ + if (!IS_ENABLED(CONFIG_BOARD_RESET_AFTER_POWER_ON) && + !IS_ENABLED(CONFIG_VBOOT_EFS2) && IS_ENABLED(CONFIG_BATTERY) && + (battery_is_present() == BP_NO)) { + first_state = TC_UNATTACHED_SNK; + } + if (first_state == TC_UNATTACHED_SNK) { /* Turn off any previous sourcing */ tc_src_power_off(port); set_vconn(port, 0); - } else { - first_state = TC_ERROR_RECOVERY; } #ifdef CONFIG_USB_PD_TCPC_BOARD_INIT |