diff options
-rw-r--r-- | common/mock/tcpc_mock.c | 2 | ||||
-rw-r--r-- | common/usb_common.c | 7 | ||||
-rw-r--r-- | common/usb_pd_protocol.c | 18 | ||||
-rw-r--r-- | common/usbc/usb_tc_drp_acc_trysrc_sm.c | 9 | ||||
-rw-r--r-- | driver/tcpm/anx74xx.c | 10 | ||||
-rw-r--r-- | driver/tcpm/fusb302.c | 10 | ||||
-rw-r--r-- | driver/tcpm/it83xx.c | 10 | ||||
-rw-r--r-- | driver/tcpm/mt6370.c | 10 | ||||
-rw-r--r-- | driver/tcpm/tcpci.c | 14 | ||||
-rw-r--r-- | fuzz/usb_pd_fuzz.c | 6 | ||||
-rw-r--r-- | include/usb_pd_tcpm.h | 8 |
11 files changed, 8 insertions, 96 deletions
diff --git a/common/mock/tcpc_mock.c b/common/mock/tcpc_mock.c index 4a9b21b5cc..8a01c0991d 100644 --- a/common/mock/tcpc_mock.c +++ b/common/mock/tcpc_mock.c @@ -52,7 +52,7 @@ static int mock_set_cc(int port, int pull) return EC_SUCCESS; } -static int mock_set_polarity(int port, int polarity) +static int mock_set_polarity(int port, enum tcpc_cc_polarity polarity) { return EC_SUCCESS; } diff --git a/common/usb_common.c b/common/usb_common.c index 660098b5cd..756aef8f64 100644 --- a/common/usb_common.c +++ b/common/usb_common.c @@ -104,9 +104,6 @@ typec_current_t usb_get_typec_current_limit(enum tcpc_cc_polarity polarity, enum tcpc_cc_polarity get_snk_polarity(enum tcpc_cc_voltage_status cc1, enum tcpc_cc_voltage_status cc2) { - if (cc_is_open(cc1, cc2)) - return POLARITY_NONE; - /* The following assumes: * * TYPEC_CC_VOLT_RP_3_0 > TYPEC_CC_VOLT_RP_1_5 @@ -122,10 +119,6 @@ enum tcpc_cc_polarity get_snk_polarity(enum tcpc_cc_voltage_status cc1, enum tcpc_cc_polarity get_src_polarity(enum tcpc_cc_voltage_status cc1, enum tcpc_cc_voltage_status cc2) { - if (cc_is_open(cc1, cc2) || - cc_is_snk_dbg_acc(cc1, cc2)) - return POLARITY_NONE; - return (cc1 == TYPEC_CC_VOLT_RD) ? POLARITY_CC1 : POLARITY_CC2; } diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index d248c67036..f272dfa8f0 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -849,22 +849,9 @@ static inline void set_state(int port, enum pd_states next_state) /* Invalidate message IDs. */ invalidate_last_message_id(port); - if (not_auto_toggling) { - /* - * On disconnect set the resistor on both CC lines so - * we can detect a connection with either polarity. - * If we are in dual role toggle, then this will happen - * automatically as it needs, so don't adjust the role - * in that case. - */ - pd[port].polarity = POLARITY_NONE; - if (tcpm_set_polarity(port, POLARITY_NONE)) - CPRINTS("C%d failed to set polarity", - port); - + if (not_auto_toggling) /* Disable Auto Discharge Disconnect */ tcpm_enable_auto_discharge_disconnect(port, 0); - } /* detect USB PD cc disconnect */ if (IS_ENABLED(CONFIG_COMMON_RUNTIME)) @@ -2959,9 +2946,6 @@ void pd_task(void *u) pd[port].flags |= PD_FLAGS_LPM_ENGAGED; #endif - /* Start as not connected */ - pd[port].polarity = POLARITY_NONE; - #ifdef CONFIG_COMMON_RUNTIME pd_init_tasks(); #endif diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c index 5fd8d2727f..7e068bc71f 100644 --- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c +++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c @@ -1013,9 +1013,6 @@ static void restart_tc_sm(int port, enum usb_tc_state start_state) void tc_state_init(int port) { - /* Start as not connected */ - tc[port].polarity = POLARITY_NONE; - /* Unattached.SNK is the default starting state. */ restart_tc_sm(port, TC_UNATTACHED_SNK); @@ -2057,9 +2054,6 @@ static void tc_attached_snk_exit(const int port) */ if (TC_CHK_FLAG(port, TC_FLAGS_VCONN_ON)) set_vconn(port, 0); - - /* Unattached should not have a polarity */ - tc[port].polarity = POLARITY_NONE; } /* Clear flags after checking Vconn status */ @@ -2803,9 +2797,6 @@ static void tc_attached_src_exit(const int port) /* Disable VCONN if not power role swapping */ if (TC_CHK_FLAG(port, TC_FLAGS_VCONN_ON)) set_vconn(port, 0); - - /* Unattached should not have a polarity */ - tc[port].polarity = POLARITY_NONE; } /* Clear PR swap flag after checking for Vconn */ diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c index 7cdde05410..0e9635e6b1 100644 --- a/driver/tcpm/anx74xx.c +++ b/driver/tcpm/anx74xx.c @@ -765,16 +765,6 @@ static int anx74xx_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) { int reg, mux_state, rv = EC_SUCCESS; - /* - * TCPCI sets the CC lines based on polarity. If it is set to - * no connection then both CC lines are driven, otherwise only - * one is driven. This driver does not appear to do this. If - * that changes, this would be the location you would want to - * adjust the CC lines for the current polarity - */ - if (polarity == POLARITY_NONE) - return EC_SUCCESS; - rv |= tcpc_read(port, ANX74XX_REG_CC_SOFTWARE_CTRL, ®); if (polarity_rm_dts(polarity)) /* Inform ANX to use CC2 */ reg &= ~ANX74XX_REG_SELECT_CC1; diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c index 691e876435..8a8acd5897 100644 --- a/driver/tcpm/fusb302.c +++ b/driver/tcpm/fusb302.c @@ -568,16 +568,6 @@ static int fusb302_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) /* Port polarity : 0 => CC1 is CC line, 1 => CC2 is CC line */ int reg; - /* - * TCPCI sets the CC lines based on polarity. If it is set to - * no connection then both CC lines are driven, otherwise only - * one is driven. This driver does not appear to do this. If - * that changes, this would be the location you would want to - * adjust the CC lines for the current polarity - */ - if (polarity == POLARITY_NONE) - return EC_SUCCESS; - tcpc_read(port, TCPC_REG_SWITCHES0, ®); /* clear VCONN switch bits */ diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c index 22a0b0075d..d3c36ee1fc 100644 --- a/driver/tcpm/it83xx.c +++ b/driver/tcpm/it83xx.c @@ -483,16 +483,6 @@ static int it83xx_tcpm_set_cc(int port, int pull) static int it83xx_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) { - /* - * TCPCI sets the CC lines based on polarity. If it is set to - * no connection then both CC lines are driven, otherwise only - * one is driven. This driver does not appear to do this. If - * that changes, this would be the location you would want to - * adjust the CC lines for the current polarity - */ - if (polarity == POLARITY_NONE) - return EC_SUCCESS; - it83xx_select_polarity(port, polarity); return EC_SUCCESS; diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c index 26bfdd9690..eb0b0fc2e9 100644 --- a/driver/tcpm/mt6370.c +++ b/driver/tcpm/mt6370.c @@ -169,16 +169,6 @@ static int mt6370_set_polarity(int port, enum tcpc_cc_polarity polarity) { enum tcpc_cc_voltage_status cc1, cc2; - /* - * TCPCI sets the CC lines based on polarity. If it is set to - * no connection then both CC lines are driven, otherwise only - * one is driven. This driver does not appear to do this. If - * that changes, this would be the location you would want to - * adjust the CC lines for the current polarity - */ - if (polarity == POLARITY_NONE) - return EC_SUCCESS; - mt6370_polarity = polarity; mt6370_get_cc(port, &cc1, &cc2); return tcpci_tcpm_set_polarity(port, polarity); diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c index b4f33187cd..2e1b535055 100644 --- a/driver/tcpm/tcpci.c +++ b/driver/tcpm/tcpci.c @@ -403,20 +403,6 @@ int tcpci_enter_low_power_mode(int port) int tcpci_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) { - int rv; - - /* - * TCPCI sets the CC lines based on polarity. If it is set to - * no connection or SRC Debug Accessory then both CC lines are - * driven, otherwise only one is driven. - */ - rv = tcpm_set_cc(port, tcpci_get_cached_pull(port)); - if (rv) - return rv; - - if (polarity == POLARITY_NONE) - return EC_SUCCESS; - return tcpc_update8(port, TCPC_REG_TCPC_CTRL, TCPC_REG_TCPC_CTRL_SET(1), diff --git a/fuzz/usb_pd_fuzz.c b/fuzz/usb_pd_fuzz.c index 1d44921817..7b7b9bfc5a 100644 --- a/fuzz/usb_pd_fuzz.c +++ b/fuzz/usb_pd_fuzz.c @@ -31,7 +31,11 @@ static int mock_tcpm_select_rp_value(int port, int rp) } static int mock_tcpm_set_cc(int port, int pull) { return EC_SUCCESS; } -static int mock_tcpm_set_polarity(int port, int polarity) { return EC_SUCCESS; } +static int mock_tcpm_set_polarity(int port, enum tcpc_cc_polarity polarity) +{ + return EC_SUCCESS; +} + static int mock_tcpm_set_vconn(int port, int enable) { return EC_SUCCESS; } static int mock_tcpm_set_msg_header(int port, int power_role, int data_role) { return EC_SUCCESS; } diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h index d0953ab74e..527388d73e 100644 --- a/include/usb_pd_tcpm.h +++ b/include/usb_pd_tcpm.h @@ -51,12 +51,6 @@ enum tcpc_rp_value { enum tcpc_cc_polarity { /* - * _NONE: either disconnected or connected to a SNK Debug - * Accessory - */ - POLARITY_NONE = -1, - - /* * _CCx: is used to indicate the polarity while not connected to * a Debug Accessory. Only one CC line will assert a resistor and * the other will be open. @@ -87,7 +81,7 @@ static inline enum tcpc_cc_polarity polarity_rm_dts( enum tcpc_cc_polarity polarity) { BUILD_ASSERT(POLARITY_COUNT == 4); - return (polarity == POLARITY_NONE) ? polarity : polarity & BIT(0); + return polarity & BIT(0); } enum tcpm_transmit_type { |