diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index dd84d80cc8..4f27ff4477 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -1575,6 +1575,9 @@ void pd_task(void) #ifndef CONFIG_USB_PD_VBUS_DETECT_NONE int snk_hard_reset_vbus_off = 0; #endif +#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE + const int auto_toggle_supported = tcpm_auto_toggle_supported(port); +#endif #ifdef CONFIG_CHARGE_MANAGER int typec_curr = 0, typec_curr_change = 0; #endif /* CONFIG_CHARGE_MANAGER */ @@ -1729,7 +1732,8 @@ void pd_task(void) * Attempt TCPC auto DRP toggle if it is * not already auto toggling and not try.src */ - if (!(pd[port].flags & PD_FLAGS_TCPC_DRP_TOGGLE) && + if (auto_toggle_supported && + !(pd[port].flags & PD_FLAGS_TCPC_DRP_TOGGLE) && !(pd[port].flags & PD_FLAGS_TRY_SRC) && (cc1 == TYPEC_CC_VOLT_OPEN && cc2 == TYPEC_CC_VOLT_OPEN)) { @@ -2208,7 +2212,8 @@ void pd_task(void) * Attempt TCPC auto DRP toggle if it is * not already auto toggling and not try.src */ - if (!(pd[port].flags & PD_FLAGS_TCPC_DRP_TOGGLE) && + if (auto_toggle_supported && + !(pd[port].flags & PD_FLAGS_TCPC_DRP_TOGGLE) && !(pd[port].flags & PD_FLAGS_TRY_SRC) && (cc1 == TYPEC_CC_VOLT_OPEN && cc2 == TYPEC_CC_VOLT_OPEN)) { @@ -2817,6 +2822,8 @@ defined(CONFIG_CASE_CLOSED_DEBUG_EXTERNAL) { enum pd_states next_state; + assert(auto_toggle_supported); + /* Check for connection */ tcpm_get_cc(port, &cc1, &cc2); diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index 08525a0d08..0501788080 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -548,21 +548,6 @@ static int anx74xx_tcpm_set_cc(int port, int pull) return rv; } -#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE -static int anx74xx_tcpc_drp_toggle(int port) -{ - int rv; - - /* Disable CC software Control */ - rv = anx74xx_cc_software_ctrl(port, 0); - -#ifdef CONFIG_USB_PD_TCPC_LOW_POWER - anx74xx_set_power_mode(port, ANX74XX_STANDBY_MODE); -#endif - return rv; -} -#endif - static int anx74xx_tcpm_set_polarity(int port, int polarity) { int reg, mux_state, rv = EC_SUCCESS; @@ -924,9 +909,6 @@ const struct tcpm_drv anx74xx_tcpm_drv = { #ifdef CONFIG_USB_PD_DISCHARGE_TCPC .tcpc_discharge_vbus = &anx74xx_tcpc_discharge_vbus, #endif -#ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE - .drp_toggle = &anx74xx_tcpc_drp_toggle, -#endif }; #ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h index 57950dc34d..1c7c6edff3 100644 --- a/driver/tcpm/tcpm.h +++ b/driver/tcpm/tcpm.h @@ -137,6 +137,11 @@ static inline void tcpc_discharge_vbus(int port, int enable) } #ifdef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE +static inline int tcpm_auto_toggle_supported(int port) +{ + return !!tcpc_config[port].drv->drp_toggle; +} + static inline int tcpm_set_drp_toggle(int port) { return tcpc_config[port].drv->drp_toggle(port);