diff options
author | Keith Short <keithshort@chromium.org> | 2020-06-19 13:21:09 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-26 02:31:20 +0000 |
commit | 44923f73697eb73f8ec4084e9ec4b8e3e952dce1 (patch) | |
tree | 0eb0aadc1c76f15af389c374ba28ea15c825572d | |
parent | 79abd55b25ea66e89d94e12a5897a13f70dc9e68 (diff) | |
download | chrome-ec-44923f73697eb73f8ec4084e9ec4b8e3e952dce1.tar.gz |
tcpmv2: Add delay when exiting low-power mode
Adds a 25ms delay when exiting low power mode. Some TCPCs are slow to
update the CC_STATUS register when exiting low power mode when a non-PD
charger is connected.
BUG=b:155364505
BRANCH=none
TEST=make buildall
TEST=connect 15W non-PD charger to Volteer C1 port. Verify charging
starts.
Signed-off-by: Keith Short <keithshort@chromium.org>
Change-Id: I0d4514447799acd60ffbcd52a62bff8bffb58b42
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2259272
Reviewed-by: Denis Brockus <dbrockus@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 9d17e2f10c..b5f2e5ebbb 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -113,6 +113,15 @@ #define PD_LPM_DEBOUNCE_US (100 * MSEC) /* + * This delay is not part of the USB Type-C specification or the USB port + * controller specification. Some TCPCs require extra time before the CC_STATUS + * register is updated when exiting low power mode. + * The PS8815 TCPC in particular was measured to take 8-10 ms from low power + * exit before the first update to CC_STATUS. + */ +#define PD_LPM_EXIT_DEBOUNCE_US (25*MSEC) + +/* * The TypeC state machine uses this bit to disable/enable PD * This bit corresponds to bit-0 of pd_disabled_mask */ @@ -289,6 +298,8 @@ static struct type_c { uint64_t timeout; /* Time to enter low power mode */ uint64_t low_power_time; + /* Time to debounce exit low power mode */ + uint64_t low_power_exit_time; /* Tasks to notify after TCPC has been reset */ int tasks_waiting_on_reset; /* Tasks preventing TCPC from entering low power mode */ @@ -2832,8 +2843,18 @@ static void tc_low_power_mode_entry(const int port) static void tc_low_power_mode_run(const int port) { - if (TC_CHK_FLAG(port, TC_FLAGS_CHECK_CONNECTION)) - check_drp_connection(port); + if (TC_CHK_FLAG(port, TC_FLAGS_CHECK_CONNECTION)) { + uint64_t now = get_time().val; + + if (tc[port].low_power_exit_time == 0) { + tc[port].low_power_exit_time = now + + PD_LPM_EXIT_DEBOUNCE_US; + } else if (now > tc[port].low_power_exit_time) { + CPRINTS("TCPC p%d Exit Low Power Mode", port); + check_drp_connection(port); + } + return; + } if (tc[port].tasks_preventing_lpm) tc[port].low_power_time = get_time().val + PD_LPM_DEBOUNCE_US; @@ -2845,6 +2866,8 @@ static void tc_low_power_mode_run(const int port) tcpm_enter_low_power_mode(port); TC_CLR_FLAG(port, TC_FLAGS_LPM_TRANSITION); tc_pause_event_loop(port); + + tc[port].low_power_exit_time = 0; } } #endif /* CONFIG_USB_PD_TCPC_LOW_POWER */ |