summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--driver/tcpm/it83xx.c26
-rw-r--r--driver/tcpm/it8xxx2.c26
2 files changed, 42 insertions, 10 deletions
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index 4b3e67ca1a..8c45b0e6b3 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -15,6 +15,7 @@
#include "tcpm/tcpci.h"
#include "timer.h"
#include "util.h"
+#include "usb_common.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "hooks.h"
@@ -410,6 +411,22 @@ static void it83xx_init(enum usbpd_port port, int role)
((CONFIG_PD_RETRY_COUNT + 1) << 4);
/* Disable Rx decode */
it83xx_tcpm_set_rx_enable(port, 0);
+ if (IS_ENABLED(CONFIG_USB_PD_TCPMV1)) {
+ uint8_t flags = 0;
+ /*
+ * If explicit contract is set in bbram when EC boot up, then
+ * TCPMv1 set soft reset as first state instead of
+ * unattached.SNK, so we need to enable BMC PHY for tx module.
+ *
+ * NOTE: If the platform is without battery and connects to
+ * adapter, then cold reset EC, our Rd is always asserted on cc,
+ * so adapter keeps providing 5v and data in BBRAM are still
+ * alive.
+ */
+ if ((pd_get_saved_port_flags(port, &flags) == EC_SUCCESS) &&
+ (flags & PD_BBRMFLG_EXPLICIT_CONTRACT))
+ USBPD_ENABLE_BMC_PHY(port);
+ }
/* W/C status */
IT83XX_USBPD_ISR(port) = 0xff;
/* enable cc, select cc1 and Rd. */
@@ -767,7 +784,7 @@ void set_pd_sleep_mask(int port)
bool prevent_deep_sleep = false;
/*
- * Set SLEEP_MASK_USB_PD for deep sleep mode in TCPMv2:
+ * Set SLEEP_MASK_USB_PD for deep sleep mode:
* 1.Enable deep sleep mode, when all ITE ports are in Unattach.SRC/SNK
* state (HOOK_DISCONNECT called) and other ports aren't pd_capable().
* 2.Disable deep sleep mode, when one of ITE port is in Attach.SRC/SNK
@@ -797,11 +814,11 @@ void set_pd_sleep_mask(int port)
enable_sleep(SLEEP_MASK_USB_PD);
}
-#ifdef CONFIG_USB_PD_TCPMV2
static void it83xx_tcpm_hook_connect(void)
{
int port = TASK_ID_TO_PD_PORT(task_get_current());
+#ifdef CONFIG_USB_PD_TCPMV2
/*
* There are five cases that hook_connect() be called by TCPMv2:
* 1)AttachWait.SNK -> Attached.SNK: disable detect interrupt.
@@ -817,17 +834,16 @@ static void it83xx_tcpm_hook_connect(void)
* SRC_DISCONNECT and SNK_DISCONNECT in TCPMv1. Every time we go to
* Try.SRC/TryWait.SNK state, the plug in interrupt will be enabled and
* fire for 3), 4), 5) cases, then set correctly for the SRC detect plug
- * out or the SNK disable detect, so TCPMv1 needn't hook connection.
+ * out or the SNK disable detect, so TCPMv1 needn't this.
*/
it83xx_tcpm_switch_plug_out_type(port);
-
+#endif
/* Enable PD PHY Tx and Rx module since type-c has connected. */
USBPD_ENABLE_BMC_PHY(port);
set_pd_sleep_mask(port);
}
DECLARE_HOOK(HOOK_USB_PD_CONNECT, it83xx_tcpm_hook_connect, HOOK_PRIO_DEFAULT);
-#endif
static void it83xx_tcpm_hook_disconnect(void)
{
diff --git a/driver/tcpm/it8xxx2.c b/driver/tcpm/it8xxx2.c
index a8d98becd4..6b7466ae07 100644
--- a/driver/tcpm/it8xxx2.c
+++ b/driver/tcpm/it8xxx2.c
@@ -14,6 +14,7 @@
#include "task.h"
#include "timer.h"
#include "util.h"
+#include "usb_common.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "hooks.h"
@@ -759,6 +760,22 @@ static void it8xxx2_init(enum usbpd_port port, int role)
(CONFIG_PD_RETRY_COUNT << 6);
/* Disable Rx decode */
it8xxx2_tcpm_set_rx_enable(port, 0);
+ if (IS_ENABLED(CONFIG_USB_PD_TCPMV1)) {
+ uint8_t flags = 0;
+ /*
+ * If explicit contract is set in bbram when EC boot up, then
+ * TCPMv1 set soft reset as first state instead of
+ * unattached.SNK, so we need to enable BMC PHY for tx module.
+ *
+ * NOTE: If the platform is without battery and connects to
+ * adapter, then cold reset EC, our Rd is always asserted on cc,
+ * so adapter keeps providing 5v and data in BBRAM are still
+ * alive.
+ */
+ if ((pd_get_saved_port_flags(port, &flags) == EC_SUCCESS) &&
+ (flags & PD_BBRMFLG_EXPLICIT_CONTRACT))
+ USBPD_ENABLE_BMC_PHY(port);
+ }
/* Disable all interrupts */
IT83XX_USBPD_IMR(port) = 0xff;
/* W/C status */
@@ -819,7 +836,7 @@ static void it8xxx2_set_pd_sleep_mask(int port)
bool prevent_deep_sleep = false;
/*
- * Set SLEEP_MASK_USB_PD for deep sleep mode in TCPMv2:
+ * Set SLEEP_MASK_USB_PD for deep sleep mode:
* 1.Enable deep sleep mode, when all ITE ports are in Unattach.SRC/SNK
* state (HOOK_DISCONNECT called) and other ports aren't pd_capable().
* 2.Disable deep sleep mode, when one of ITE port is in Attach.SRC/SNK
@@ -849,11 +866,11 @@ static void it8xxx2_set_pd_sleep_mask(int port)
enable_sleep(SLEEP_MASK_USB_PD);
}
-#ifdef CONFIG_USB_PD_TCPMV2
static void it8xxx2_tcpm_hook_connect(void)
{
int port = TASK_ID_TO_PD_PORT(task_get_current());
+#ifdef CONFIG_USB_PD_TCPMV2
/*
* There are five cases that hook_connect() be called by TCPMv2:
* 1)AttachWait.SNK -> Attached.SNK: disable detect interrupt.
@@ -869,17 +886,16 @@ static void it8xxx2_tcpm_hook_connect(void)
* SRC_DISCONNECT and SNK_DISCONNECT in TCPMv1. Every time we go to
* Try.SRC/TryWait.SNK state, the plug in interrupt will be enabled and
* fire for 3), 4), 5) cases, then set correctly for the SRC detect plug
- * out or the SNK disable detect, so TCPMv1 needn't hook connection.
+ * out or the SNK disable detect, so TCPMv1 needn't this.
*/
it8xxx2_tcpm_switch_plug_out_type(port);
-
+#endif
/* Enable PD PHY Tx and Rx module since type-c has connected. */
USBPD_ENABLE_BMC_PHY(port);
it8xxx2_set_pd_sleep_mask(port);
}
DECLARE_HOOK(HOOK_USB_PD_CONNECT, it8xxx2_tcpm_hook_connect, HOOK_PRIO_DEFAULT);
-#endif
static void it8xxx2_tcpm_hook_disconnect(void)
{