From 9b972a0f21c95d49ffbe2e42adb7400714eda516 Mon Sep 17 00:00:00 2001 From: Ruibin Chang Date: Fri, 10 Dec 2021 16:00:21 +0800 Subject: 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 Change-Id: Ie010abfcebd709db7231f0727ba07d1be29d2b6f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3329643 Reviewed-by: Aseda Aboagye --- driver/tcpm/it83xx.c | 20 ++++++++++++++++++++ driver/tcpm/it8xxx2.c | 20 ++++++++++++++++++++ include/config.h | 4 ++++ 3 files changed, 44 insertions(+) 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 -- cgit v1.2.1