From ed62e258393049c8da6ccd3ded8ac67e0cea58eb Mon Sep 17 00:00:00 2001 From: Ruibin Chang Date: Tue, 7 Dec 2021 18:33:17 +0800 Subject: TCPMv2: don't set the sleep mask for TCPC embedded in EC Don't set the sleep mask for TCPC embedded in EC, ex.ITE it83xx and it8xxx2 series. So I create a overridable tc_update_pd_sleep_mask() function for ITE to implement. BUG=none BRANCH=none TEST=make build all Signed-off-by: Ruibin Chang Change-Id: I331115d107240da827f5b391fcd3a94a84f086c4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3329641 Reviewed-by: Aseda Aboagye --- common/usbc/usb_tc_drp_acc_trysrc_sm.c | 13 ++++++++++--- include/usb_tc_sm.h | 9 +++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 9e03875eb0..726958ba03 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -825,6 +825,10 @@ int tc_is_attached_snk(int port) return IS_ATTACHED_SNK(port); } +__overridable void tc_update_pd_sleep_mask(int port) +{ +} + void tc_pd_connection(int port, int en) { if (en) { @@ -836,9 +840,10 @@ void tc_pd_connection(int port, int en) TC_SET_FLAG(port, TC_FLAGS_PARTNER_PD_CAPABLE); /* If a PD device is attached then disable deep sleep */ if (IS_ENABLED(CONFIG_LOW_POWER_IDLE) && - !IS_ENABLED(CONFIG_USB_PD_TCPC_ON_CHIP)) { + IS_ENABLED(CONFIG_USB_PD_TCPC_ON_CHIP)) + tc_update_pd_sleep_mask(port); + else if (IS_ENABLED(CONFIG_LOW_POWER_IDLE)) disable_sleep(SLEEP_MASK_USB_PD); - } /* * Update the mux state, only when the PD capable flag @@ -852,7 +857,9 @@ void tc_pd_connection(int port, int en) TC_CLR_FLAG(port, TC_FLAGS_PARTNER_PD_CAPABLE); /* If a PD device isn't attached then enable deep sleep */ if (IS_ENABLED(CONFIG_LOW_POWER_IDLE) && - !IS_ENABLED(CONFIG_USB_PD_TCPC_ON_CHIP)) { + IS_ENABLED(CONFIG_USB_PD_TCPC_ON_CHIP)) + tc_update_pd_sleep_mask(port); + else if (IS_ENABLED(CONFIG_LOW_POWER_IDLE)) { int i; /* If all ports are not connected, allow the sleep */ diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h index 80a69279a2..4aaacd522b 100644 --- a/include/usb_tc_sm.h +++ b/include/usb_tc_sm.h @@ -180,6 +180,15 @@ void tc_request_power_swap(int port); */ void tc_pr_swap_complete(int port, bool success); +/** + * The Type-C state machine updates the SLEEP_MASK_USB_PD mask for the + * case that TCPC wants to set/clear SLEEP_MASK_USB_PD mask only by + * itself, ex. TCPC embedded in EC. + * + * @param port USB_C port number + */ +__override_proto void tc_update_pd_sleep_mask(int port); + /** * Instructs the Attached.SNK to stop drawing power. This function is called * from the Policy Engine and only has effect if the current Type-C state -- cgit v1.2.1