summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuibin Chang <Ruibin.Chang@ite.com.tw>2021-12-10 16:00:21 +0800
committerCommit Bot <commit-bot@chromium.org>2021-12-17 07:11:17 +0000
commit9b972a0f21c95d49ffbe2e42adb7400714eda516 (patch)
tree8b57e07ab8481b6eda92579360444769b64c9db9
parenta499d8fd40ffe43c654e2dd60fb21193aba52f8f (diff)
downloadchrome-ec-9b972a0f21c95d49ffbe2e42adb7400714eda516.tar.gz
driver/tcpm/it83xx, it8xxx2: ITE inactive port return from HOOK
If it isn't ITE active port, then return from HOOK_CONNECT/DISCONNECT function. BUG=none BRANCH=none TEST=on board drawcia, verify the ITE inactive port return from HOOK_CONNECT/DISCONNECT function. Signed-off-by: Ruibin Chang <Ruibin.Chang@ite.com.tw> Change-Id: Ie010abfcebd709db7231f0727ba07d1be29d2b6f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3329643 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--driver/tcpm/it83xx.c20
-rw-r--r--driver/tcpm/it8xxx2.c20
-rw-r--r--include/config.h4
3 files changed, 44 insertions, 0 deletions
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index 085f09eb7e..c809cce153 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -828,6 +828,16 @@ static void it83xx_tcpm_hook_connect(void)
{
int port = TASK_ID_TO_PD_PORT(task_get_current());
+ /*
+ * If it isn't ITE active port, then return.
+ *
+ * NOTE: If we don't use all the ITE pd ports on a board, then we
+ * need to start from port0 to use the ITE pd port. If we
+ * start from port1, then port1 HOOK function never works.
+ */
+ if (port > (CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT - 1))
+ return;
+
#ifdef CONFIG_USB_PD_TCPMV2
/*
* There are five cases that hook_connect() be called by TCPMv2:
@@ -866,6 +876,16 @@ static void it83xx_tcpm_hook_disconnect(void)
{
int port = TASK_ID_TO_PD_PORT(task_get_current());
+ /*
+ * If it isn't ITE active port, then return.
+ *
+ * NOTE: If we don't use all the ITE pd ports on a board, then we
+ * need to start from port0 to use the ITE pd port. If we
+ * start from port1, then port1 HOOK function never works.
+ */
+ if (port > (CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT - 1))
+ return;
+
if (IS_ENABLED(IT83XX_INTC_PLUG_IN_OUT_SUPPORT))
/*
* Switch to detect plug in and enable detect plug in interrupt,
diff --git a/driver/tcpm/it8xxx2.c b/driver/tcpm/it8xxx2.c
index f8102827de..7bed654132 100644
--- a/driver/tcpm/it8xxx2.c
+++ b/driver/tcpm/it8xxx2.c
@@ -886,6 +886,16 @@ static void it8xxx2_tcpm_hook_connect(void)
{
int port = TASK_ID_TO_PD_PORT(task_get_current());
+ /*
+ * If it isn't ITE active port, then return.
+ *
+ * NOTE: If we don't use all the ITE pd ports on a board, then we
+ * need to start from port0 to use the ITE pd port. If we
+ * start from port1, then port1 HOOK function never works.
+ */
+ if (port > (CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT - 1))
+ return;
+
#ifdef CONFIG_USB_PD_TCPMV2
/*
* There are five cases that hook_connect() be called by TCPMv2:
@@ -924,6 +934,16 @@ static void it8xxx2_tcpm_hook_disconnect(void)
{
int port = TASK_ID_TO_PD_PORT(task_get_current());
+ /*
+ * If it isn't ITE active port, then return.
+ *
+ * NOTE: If we don't use all the ITE pd ports on a board, then we
+ * need to start from port0 to use the ITE pd port. If we
+ * start from port1, then port1 HOOK function never works.
+ */
+ if (port > (CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT - 1))
+ return;
+
if (IS_ENABLED(IT83XX_INTC_PLUG_IN_OUT_SUPPORT))
/*
* Switch to detect plug in and enable detect plug in interrupt,
diff --git a/include/config.h b/include/config.h
index 1c5fcdcb93..733bc1cdb9 100644
--- a/include/config.h
+++ b/include/config.h
@@ -5960,6 +5960,10 @@
/*
* Define CONFIG_USB_PD_TCPC_ON_CHIP if we use ITE series TCPM driver
* on the board.
+ *
+ * NOTE: If we don't use all the ITE pd ports on a board, then we need to
+ * start from port0 to use the ITE pd port. If we start from port1,
+ * then port1 HOOK function never works.
*/
#ifdef CONFIG_USB_PD_TCPM_ITE_ON_CHIP
#define CONFIG_USB_PD_TCPC_ON_CHIP