summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2020-09-17 10:44:37 -0700
committerCommit Bot <commit-bot@chromium.org>2020-09-18 02:14:57 +0000
commit5f1e3efd6aaa2da43dfcbeb78f79d9fecb8223ba (patch)
tree6145015855b3777ee40c197e39bea1915bb43491
parent60ea1ec3d80123784872dcf38627b89c149a4469 (diff)
downloadchrome-ec-5f1e3efd6aaa2da43dfcbeb78f79d9fecb8223ba.tar.gz
it83xx: Only consider ITE C ports for sleep mask
The TCPMvX frameworks do not clear the sleep mask for USB PD if the device is using on "off chip" TCPC like the one embedded in the ITE EC. Therefore, the ITE driver would take care of this. This commit fixes a bug in the ITE TCPC driver which assumed that boards which are using the ITE TCPC would be using it for all ports. This caused the driver to never allow deep sleep even if no devices were connected. BUG=b:168783892 BRANCH=None TEST=Build and flash drawcia. Unplug all devices and verify that the sleep mask is 0 when the AP is off. Signed-off-by: Aseda Aboagye <aaboagye@google.com> Change-Id: I312f0f2a24d2783291f3c52612e62bc61e4ccca2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2416994 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/tcpm/it83xx.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index 2ba9815a85..8e6abbc15b 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -602,6 +602,7 @@ static int it83xx_tcpm_set_msg_header(int port, int power_role, int data_role)
static int it83xx_tcpm_set_rx_enable(int port, int enable)
{
int i;
+ bool prevent_deep_sleep = false;
if (enable) {
IT83XX_USBPD_IMR(port) &= ~USBPD_REG_MASK_MSG_RX_DONE;
@@ -626,14 +627,27 @@ static int it83xx_tcpm_set_rx_enable(int port, int enable)
* PD port Rx is enabled, then disable EC deep sleep.
*/
for (i = 0; i < CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT; ++i) {
- if (IT83XX_USBPD_GCR(i) & USBPD_REG_MASK_BMC_PHY)
+ if (IT83XX_USBPD_GCR(i) & USBPD_REG_MASK_BMC_PHY) {
+ prevent_deep_sleep = true;
break;
+ }
}
- if (i == board_get_usb_pd_port_count())
- enable_sleep(SLEEP_MASK_USB_PD);
- else
+ /*
+ * Check if any other ports have a PD port partner connected. Deep
+ * sleep is forbidden if any PD port partner is connected. Above, we
+ * only checked for the ITE ports.
+ */
+ if (!prevent_deep_sleep) {
+ for (; i < board_get_usb_pd_port_count(); i++)
+ if (pd_capable(i))
+ prevent_deep_sleep = true;
+ }
+
+ if (prevent_deep_sleep)
disable_sleep(SLEEP_MASK_USB_PD);
+ else
+ enable_sleep(SLEEP_MASK_USB_PD);
return EC_SUCCESS;
}