diff options
Diffstat (limited to 'common/usbc/usb_tc_drp_acc_trysrc_sm.c')
-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 |