diff options
-rw-r--r-- | common/usbc/usb_prl_sm.c | 4 | ||||
-rw-r--r-- | common/usbc/usb_tc_ctvpd_sm.c | 11 | ||||
-rw-r--r-- | test/fake_usbc.c | 15 |
3 files changed, 22 insertions, 8 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index 5805d1278e..769a103fe5 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -467,10 +467,10 @@ static void prl_tx_phy_layer_reset_entry(const int port) { if (IS_ENABLED(CONFIG_USB_TYPEC_CTVPD) || IS_ENABLED(CONFIG_USB_TYPEC_VPD)) { - vpd_rx_enable(1); + vpd_rx_enable(pd_is_connected(port)); } else { tcpm_clear_pending_messages(port); - tcpm_set_rx_enable(port, 1); + tcpm_set_rx_enable(port, pd_is_connected(port)); } } diff --git a/common/usbc/usb_tc_ctvpd_sm.c b/common/usbc/usb_tc_ctvpd_sm.c index 194bb664fe..804c733485 100644 --- a/common/usbc/usb_tc_ctvpd_sm.c +++ b/common/usbc/usb_tc_ctvpd_sm.c @@ -222,6 +222,17 @@ test_mockable_static void print_current_state(const int port) CPRINTS("C%d: %s", port, tc_state_names[get_state_tc(port)]); } +int pd_is_connected(int port) +{ + return (get_state_tc(port) == TC_ATTACHED_SNK) || + (get_state_tc(port) == TC_ATTACHED_SRC); +} + +bool pd_is_disconnected(int port) +{ + return !pd_is_connected(port); +} + /** * Disabled * diff --git a/test/fake_usbc.c b/test/fake_usbc.c index c9163f1cfe..bbc565a14d 100644 --- a/test/fake_usbc.c +++ b/test/fake_usbc.c @@ -178,12 +178,20 @@ uint8_t pd_get_src_cap_cnt(int port) } #endif -#ifndef CONFIG_USB_TYPEC_DRP_ACC_TRYSRC +#if !defined(CONFIG_USB_TYPEC_DRP_ACC_TRYSRC) && \ + !defined(CONFIG_USB_TYPEC_CTVPD) +int pd_is_connected(int port) +{ + return true; +} + bool pd_is_disconnected(int port) { return false; } +#endif /* !CONFIG_USB_TYPEC_DRP_ACC_TRYSRC && !CONFIG_USB_TYPEC_CTVPD */ +#ifndef CONFIG_USB_TYPEC_DRP_ACC_TRYSRC void pd_set_dual_role(int port, enum pd_dual_role_states state) { } @@ -213,11 +221,6 @@ enum pd_cc_states pd_get_task_cc_state(int port) return PD_CC_NONE; } -int pd_is_connected(int port) -{ - return true; -} - bool pd_get_partner_unconstr_power(int port) { return 0; |