summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuibin Chang <Ruibin.Chang@ite.com.tw>2018-09-03 16:59:05 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-09-07 07:18:07 -0700
commit09d4918f464b69390f0c2d12cdd8c6aeafcb2cae (patch)
tree8e9c5fe4c694d61e587f47d362f9e58eefee1df3
parenta38f3f48b4eb046e0015b10b3d09decdff50d560 (diff)
downloadchrome-ec-09d4918f464b69390f0c2d12cdd8c6aeafcb2cae.tar.gz
tcpm:it83xx: GRL-USB-PD TDA2.1.2.2 BIST test
In our design once enter BIST test data mode, Hw don't interrupt Fw due to any Rx received packet. But when port partner re-connect in this mode, it will cause that our pd port doesn't respond packet which port partner transmits. When port partner disconnects, so we need to reset our pd port protocol layer and PHY to leave BIST test data mode and let Hw can interrupt Fw. With this modify it can pass GRL-USB-PD compliance TDA2.1.2.2 test item. BUG=b:112602596 BRANCH=none TEST=GRL-USB-PD compliance test. Change-Id: I30526b5d796e3eabc9af2f524071c98bb0ef5abf Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Reviewed-on: https://chromium-review.googlesource.com/1170718 Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r--common/hooks.c1
-rw-r--r--common/usb_pd_protocol.c5
-rw-r--r--core/cortex-m/ec.lds.S4
-rw-r--r--core/cortex-m0/ec.lds.S4
-rw-r--r--core/host/host_exe.lds4
-rw-r--r--core/minute-ia/ec.lds.S4
-rw-r--r--core/nds32/ec.lds.S4
-rw-r--r--driver/tcpm/it83xx.c10
-rw-r--r--include/hooks.h7
-rw-r--r--include/link_defs.h2
10 files changed, 45 insertions, 0 deletions
diff --git a/common/hooks.c b/common/hooks.c
index bee2d5fc63..ff85e2cfd2 100644
--- a/common/hooks.c
+++ b/common/hooks.c
@@ -56,6 +56,7 @@ static const struct hook_ptrs hook_list[] = {
#endif
{__hooks_tick, __hooks_tick_end},
{__hooks_second, __hooks_second_end},
+ {__hooks_usb_pd_disconnect, __hooks_usb_pd_disconnect_end},
};
/* Times for deferrable functions */
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index c4bcb2eae7..878d2e64f7 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -650,6 +650,11 @@ static inline void set_state(int port, enum pd_states next_state)
#endif
/* Disable TCPC RX */
tcpm_set_rx_enable(port, 0);
+
+#ifdef CONFIG_COMMON_RUNTIME
+ /* detect USB PD cc disconnect */
+ hook_notify(HOOK_USB_PD_DISCONNECT);
+#endif
}
#ifdef CONFIG_LOW_POWER_IDLE
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index df7aea5fde..5b628f897f 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -223,6 +223,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_SECOND))
__hooks_second_end = .;
+ __hooks_usb_pd_disconnect = .;
+ KEEP(*(.rodata.HOOK_USB_PD_DISCONNECT))
+ __hooks_usb_pd_disconnect_end = .;
+
__deferred_funcs = .;
KEEP(*(.rodata.deferred))
__deferred_funcs_end = .;
diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S
index 68cfa6aa6f..2b4a88d85a 100644
--- a/core/cortex-m0/ec.lds.S
+++ b/core/cortex-m0/ec.lds.S
@@ -158,6 +158,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_SECOND))
__hooks_second_end = .;
+ __hooks_usb_pd_disconnect = .;
+ KEEP(*(.rodata.HOOK_USB_PD_DISCONNECT))
+ __hooks_usb_pd_disconnect_end = .;
+
__deferred_funcs = .;
KEEP(*(.rodata.deferred))
__deferred_funcs_end = .;
diff --git a/core/host/host_exe.lds b/core/host/host_exe.lds
index 8d59109b94..f4e72ec0d7 100644
--- a/core/host/host_exe.lds
+++ b/core/host/host_exe.lds
@@ -97,6 +97,10 @@ SECTIONS {
*(.rodata.HOOK_SECOND)
__hooks_second_end = .;
+ __hooks_usb_pd_disconnect = .;
+ *(.rodata.HOOK_USB_PD_DISCONNECT)
+ __hooks_usb_pd_disconnect_end = .;
+
__deferred_funcs = .;
*(.rodata.deferred)
__deferred_funcs_end = .;
diff --git a/core/minute-ia/ec.lds.S b/core/minute-ia/ec.lds.S
index 88cc0d61e2..e39342ece8 100644
--- a/core/minute-ia/ec.lds.S
+++ b/core/minute-ia/ec.lds.S
@@ -128,6 +128,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_SECOND))
__hooks_second_end = .;
+ __hooks_usb_pd_disconnect = .;
+ KEEP(*(.rodata.HOOK_USB_PD_DISCONNECT))
+ __hooks_usb_pd_disconnect_end = .;
+
__deferred_funcs = .;
KEEP(*(.rodata.deferred))
__deferred_funcs_end = .;
diff --git a/core/nds32/ec.lds.S b/core/nds32/ec.lds.S
index 999eb8fbc6..7048fe0cfd 100644
--- a/core/nds32/ec.lds.S
+++ b/core/nds32/ec.lds.S
@@ -155,6 +155,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_SECOND))
__hooks_second_end = .;
+ __hooks_usb_pd_disconnect = .;
+ KEEP(*(.rodata.HOOK_USB_PD_DISCONNECT))
+ __hooks_usb_pd_disconnect_end = .;
+
__deferred_funcs = .;
KEEP(*(.rodata.deferred))
__deferred_funcs_end = .;
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index b959eb6c89..23f88fe980 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -16,6 +16,7 @@
#include "util.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "hooks.h"
#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \
defined(CONFIG_USB_PD_VBUS_DETECT_TCPC) || \
@@ -575,6 +576,15 @@ static int it83xx_tcpm_get_chip_info(int port, int renew,
return EC_SUCCESS;
}
+static void it83xx_tcpm_sw_reset(void)
+{
+ int port = TASK_ID_TO_PD_PORT(task_get_current());
+ /* exit BIST test data mode */
+ USBPD_SW_RESET(port);
+}
+
+DECLARE_HOOK(HOOK_USB_PD_DISCONNECT, it83xx_tcpm_sw_reset, HOOK_PRIO_DEFAULT);
+
const struct tcpm_drv it83xx_tcpm_drv = {
.init = &it83xx_tcpm_init,
.release = &it83xx_tcpm_release,
diff --git a/include/hooks.h b/include/hooks.h
index 85ab1db8da..c1e0d49abe 100644
--- a/include/hooks.h
+++ b/include/hooks.h
@@ -201,6 +201,13 @@ enum hook_type {
* Hook routines will be called from the TICK task.
*/
HOOK_SECOND,
+
+ /*
+ * Detect USB PD cc disconnect.
+ *
+ * Hook routines will be called from the PD task.
+ */
+ HOOK_USB_PD_DISCONNECT,
};
struct hook_data {
diff --git a/include/link_defs.h b/include/link_defs.h
index b4488c076a..61648baa0f 100644
--- a/include/link_defs.h
+++ b/include/link_defs.h
@@ -68,6 +68,8 @@ extern const struct hook_data __hooks_tick[];
extern const struct hook_data __hooks_tick_end[];
extern const struct hook_data __hooks_second[];
extern const struct hook_data __hooks_second_end[];
+extern const struct hook_data __hooks_usb_pd_disconnect[];
+extern const struct hook_data __hooks_usb_pd_disconnect_end[];
/* Deferrable functions and firing times*/
extern const struct deferred_data __deferred_funcs[];