diff options
author | Abe Levkoy <alevkoy@chromium.org> | 2020-11-17 18:20:29 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-22 00:01:57 +0000 |
commit | 251827028c193eea50630ece1b22b4513e167cd2 (patch) | |
tree | 96b267fd8272fb734fe4671169472b79c7376f6d | |
parent | 2034650b0b3aeb6685f26334491e9f5cacbe915e (diff) | |
download | chrome-ec-251827028c193eea50630ece1b22b4513e167cd2.tar.gz |
TCPMv2: Support BIST Test Mode
After the first BIST Test Data packet, enable BIST Test Mode if the TCPC
supports it (currently just TCPCI). While in BIST Test Mode, mask
ALERT.ReceivedSOP*MessageStatus. Unmask it when the test ends, due to
Hard Reset or to detach.
BUG=b:173023378,b:169385081,b:172709198,b:173028832,b:173028791
BUG=b:173141941,b:173142113
TEST=Complete TDA.2.1.2.2 BMC PHY RX INT REJ on volteer without running
out of Rx buffer space or watchdog timeout (still fail though)
BRANCH=firmware-volteer-13521.B-master
Signed-off-by: Abe Levkoy <alevkoy@chromium.org>
Change-Id: I03bbc4cfacceebd0334aa814e11a16e09177a322
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2545667
Reviewed-by: Diana Z <dzigterman@chromium.org>
-rw-r--r-- | common/usbc/usb_pe_drp_sm.c | 8 | ||||
-rw-r--r-- | driver/tcpm/anx7447.c | 1 | ||||
-rw-r--r-- | driver/tcpm/anx74xx.c | 1 | ||||
-rw-r--r-- | driver/tcpm/anx7688.c | 1 | ||||
-rw-r--r-- | driver/tcpm/fusb307.c | 1 | ||||
-rw-r--r-- | driver/tcpm/mt6370.c | 1 | ||||
-rw-r--r-- | driver/tcpm/nct38xx.c | 1 | ||||
-rw-r--r-- | driver/tcpm/ps8xxx.c | 1 | ||||
-rw-r--r-- | driver/tcpm/raa489000.c | 1 | ||||
-rw-r--r-- | driver/tcpm/rt1715.c | 1 | ||||
-rw-r--r-- | driver/tcpm/tcpci.c | 16 | ||||
-rw-r--r-- | driver/tcpm/tusb422.c | 1 | ||||
-rw-r--r-- | include/driver/tcpm/tcpci.h | 4 | ||||
-rw-r--r-- | include/driver/tcpm/tcpm.h | 11 | ||||
-rw-r--r-- | include/usb_pd_tcpm.h | 12 |
15 files changed, 61 insertions, 0 deletions
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c index fe2c7baec2..128a5027da 100644 --- a/common/usbc/usb_pe_drp_sm.c +++ b/common/usbc/usb_pe_drp_sm.c @@ -968,6 +968,9 @@ void pe_got_hard_reset(int port) */ pe[port].power_role = pd_get_power_role(port); + /* Exit BIST Test mode, in case the TCPC entered it. */ + tcpc_set_bist_test_mode(port, false); + if (pe[port].power_role == PD_ROLE_SOURCE) set_state_pe(port, PE_SRC_HARD_RESET_RECEIVED); else @@ -1444,6 +1447,9 @@ static void pe_handle_detach(void) pe_set_snk_caps(port, 0, NULL); dpm_remove_sink(port); + + /* Exit BIST Test mode, in case the TCPC entered it. */ + tcpc_set_bist_test_mode(port, false); } DECLARE_HOOK(HOOK_USB_PD_DISCONNECT, pe_handle_detach, HOOK_PRIO_DEFAULT); @@ -4855,6 +4861,8 @@ static void pe_bist_tx_entry(int port) * response to received Messages.... The test Shall be ended by * sending Hard Reset Signaling to reset the UUT. */ + if (tcpc_set_bist_test_mode(port, true) != EC_SUCCESS) + CPRINTS("C%d: Failed to enter BIST Test Mode", port); pe[port].bist_cont_mode_timer = TIMER_DISABLED; } else { /* Ignore unsupported BIST messages. */ diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c index 3fbafbf8da..e7203947ee 100644 --- a/driver/tcpm/anx7447.c +++ b/driver/tcpm/anx7447.c @@ -832,6 +832,7 @@ const struct tcpm_drv anx7447_tcpm_drv = { #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &tcpci_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, #ifdef CONFIG_CMD_TCPC_DUMP .dump_registers = &anx7447_dump_registers, #endif diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index c6cd1b9d6e..f45f7cd25e 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -1186,6 +1186,7 @@ const struct tcpm_drv anx74xx_tcpm_drv = { .drp_toggle = &anx74xx_tcpc_drp_toggle, .enter_low_power_mode = &anx74xx_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, }; #ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC diff --git a/driver/tcpm/anx7688.c b/driver/tcpm/anx7688.c index 1fa18f6b8b..9a2ed85de1 100644 --- a/driver/tcpm/anx7688.c +++ b/driver/tcpm/anx7688.c @@ -209,6 +209,7 @@ const struct tcpm_drv anx7688_tcpm_drv = { .get_message_raw = &tcpci_tcpm_get_message_raw, .transmit = &tcpci_tcpm_transmit, .tcpc_alert = &anx7688_tcpc_alert, + .set_bist_test_mode = &tcpci_set_bist_test_mode, }; #ifdef CONFIG_USB_PD_TCPM_MUX diff --git a/driver/tcpm/fusb307.c b/driver/tcpm/fusb307.c index 6001b717e2..e8804a2661 100644 --- a/driver/tcpm/fusb307.c +++ b/driver/tcpm/fusb307.c @@ -98,5 +98,6 @@ const struct tcpm_drv fusb307_tcpm_drv = { #if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) .drp_toggle = &tcpci_tcpc_drp_toggle, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, }; diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c index 3716cc28ea..2adaac1901 100644 --- a/driver/tcpm/mt6370.c +++ b/driver/tcpm/mt6370.c @@ -218,4 +218,5 @@ const struct tcpm_drv mt6370_tcpm_drv = { #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &mt6370_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, }; diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c index f700d880e7..ee02ddb851 100644 --- a/driver/tcpm/nct38xx.c +++ b/driver/tcpm/nct38xx.c @@ -268,6 +268,7 @@ const struct tcpm_drv nct38xx_tcpm_drv = { #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &tcpci_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, #ifdef CONFIG_USB_PD_FRS_TCPC .set_frs_enable = &tcpci_tcpc_fast_role_swap_enable, #endif diff --git a/driver/tcpm/ps8xxx.c b/driver/tcpm/ps8xxx.c index b5c78aa367..ba79cb5c3b 100644 --- a/driver/tcpm/ps8xxx.c +++ b/driver/tcpm/ps8xxx.c @@ -626,6 +626,7 @@ const struct tcpm_drv ps8xxx_tcpm_drv = { #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &ps8xxx_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, }; #ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC diff --git a/driver/tcpm/raa489000.c b/driver/tcpm/raa489000.c index 73f709bcf7..b8a08ac484 100644 --- a/driver/tcpm/raa489000.c +++ b/driver/tcpm/raa489000.c @@ -265,6 +265,7 @@ const struct tcpm_drv raa489000_tcpm_drv = { #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &raa489000_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, .tcpc_enable_auto_discharge_disconnect = &tcpci_tcpc_enable_auto_discharge_disconnect, .debug_detach = &raa489000_debug_detach, diff --git a/driver/tcpm/rt1715.c b/driver/tcpm/rt1715.c index 33f4f244ae..90aa28138a 100644 --- a/driver/tcpm/rt1715.c +++ b/driver/tcpm/rt1715.c @@ -80,4 +80,5 @@ const struct tcpm_drv rt1715_tcpm_drv = { #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &tcpci_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, }; diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index ba313350e9..0f03f06a35 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -10,6 +10,8 @@ #include "compile_time_macros.h" #include "console.h" #include "ec_commands.h" +#include "hooks.h" +#include "i2c.h" #include "ps8xxx.h" #include "task.h" #include "tcpm/tcpci.h" @@ -1062,6 +1064,19 @@ static int tcpci_handle_fault(int port, int fault) return rv; } +enum ec_error_list tcpci_set_bist_test_mode(const int port, + const bool enable) +{ + int rv; + + rv = tcpc_update8(port, TCPC_REG_TCPC_CTRL, + TCPC_REG_TCPC_CTRL_BIST_TEST_MODE, + enable ? MASK_SET : MASK_CLR); + rv |= tcpc_update16(port, TCPC_REG_ALERT_MASK, + TCPC_REG_ALERT_RX_STATUS, enable ? MASK_CLR : MASK_SET); + return rv; +} + static int tcpci_clear_fault(int port, int fault) { int rv; @@ -1778,6 +1793,7 @@ const struct tcpm_drv tcpci_tcpm_drv = { #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &tcpci_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, #ifdef CONFIG_CMD_TCPC_DUMP .dump_registers = &tcpc_dump_std_registers, #endif diff --git a/driver/tcpm/tusb422.c b/driver/tcpm/tusb422.c index 4ea50764fb..511c18853f 100644 --- a/driver/tcpm/tusb422.c +++ b/driver/tcpm/tusb422.c @@ -183,6 +183,7 @@ const struct tcpm_drv tusb422_tcpm_drv = { #ifdef CONFIG_USB_PD_TCPC_LOW_POWER .enter_low_power_mode = &tcpci_enter_low_power_mode, #endif + .set_bist_test_mode = &tcpci_set_bist_test_mode, #ifdef CONFIG_USB_PD_FRS_TCPC .set_frs_enable = &tusb422_set_frs_enable, #endif diff --git a/include/driver/tcpm/tcpci.h b/include/driver/tcpm/tcpci.h index 44af755c8b..8e2d288fa0 100644 --- a/include/driver/tcpm/tcpci.h +++ b/include/driver/tcpm/tcpci.h @@ -9,6 +9,7 @@ #define __CROS_EC_USB_PD_TCPM_TCPCI_H #include "config.h" +#include "ec_commands.h" #include "tcpm/tcpm.h" #include "usb_mux.h" #include "usb_pd_tcpm.h" @@ -67,6 +68,7 @@ */ #define TCPC_REG_TCPC_CTRL_EN_LOOK4CONNECTION_ALERT BIT(6) #define TCPC_REG_TCPC_CTRL_DEBUG_ACC_CONTROL BIT(4) +#define TCPC_REG_TCPC_CTRL_BIST_TEST_MODE BIT(1) #define TCPC_REG_ROLE_CTRL 0x1a #define TCPC_REG_ROLE_CTRL_DRP_MASK BIT(6) @@ -265,6 +267,8 @@ int tcpci_tcpc_drp_toggle(int port); #ifdef CONFIG_USB_PD_TCPC_LOW_POWER int tcpci_enter_low_power_mode(int port); #endif +enum ec_error_list tcpci_set_bist_test_mode(const int port, + const bool enable); #ifdef CONFIG_USB_PD_DISCHARGE_TCPC void tcpci_tcpc_discharge_vbus(int port, int enable); #endif diff --git a/include/driver/tcpm/tcpm.h b/include/driver/tcpm/tcpm.h index 9a00a4f402..092b266784 100644 --- a/include/driver/tcpm/tcpm.h +++ b/include/driver/tcpm/tcpm.h @@ -353,6 +353,17 @@ static inline int tcpm_get_chip_info(int port, int live, return EC_ERROR_UNIMPLEMENTED; } +static inline enum ec_error_list tcpc_set_bist_test_mode(int port, bool enable) +{ + const struct tcpm_drv *tcpc; + int rv = EC_SUCCESS; + + tcpc = tcpc_config[port].drv; + if (tcpc->set_bist_test_mode) + rv = tcpc->set_bist_test_mode(port, enable); + return rv; +} + #ifdef CONFIG_USB_PD_FRS_TCPC static inline int tcpm_set_frs_enable(int port, int enable) { diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index 8cc5543c53..885ca24f71 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -9,6 +9,7 @@ #define __CROS_EC_USB_PD_TCPM_H #include <stdbool.h> +#include "common.h" #include "ec_commands.h" #include "i2c.h" @@ -445,6 +446,17 @@ struct tcpm_drv { */ int (*handle_fault)(int port, int fault); + /** + * Controls BIST Test Mode (or analogous functionality) in the TCPC and + * associated behavior changes. Disables message Rx alerts while the + * port is in Test Mode. + * + * @param port USB-C port number + * @param enable true to enter BIST Test Mode; false to exit + * @return EC_SUCCESS or error code + */ + enum ec_error_list (*set_bist_test_mode)(int port, bool enable); + #ifdef CONFIG_CMD_TCPC_DUMP /** * Dump TCPC registers |