@@ -96,11 +96,10 @@ static int ktu1125_dump(int port)
9696/* helper */
9797static int ktu1125_power_path_control (int port , int enable )
9898{
99- int status = enable ? set_flags (port , KTU1125_CTRL_SW_CFG ,
100- KTU1125_SW_AB_EN ) :
101- clr_flags (port , KTU1125_CTRL_SW_CFG ,
102- KTU1125_SW_AB_EN | KTU1125_CC1S_VCONN |
103- KTU1125_CC2S_VCONN );
99+ int status =
100+ enable ?
101+ set_flags (port , KTU1125_CTRL_SW_CFG , KTU1125_SW_AB_EN ) :
102+ clr_flags (port , KTU1125_CTRL_SW_CFG , KTU1125_SW_AB_EN );
104103
105104 if (status ) {
106105 CPRINTS ("ppc p%d: Failed to %s power path" , port ,
@@ -345,11 +344,19 @@ static int ktu1125_discharge_vbus(int port, int enable)
345344#ifdef CONFIG_USBC_PPC_VCONN
346345static int ktu1125_set_vconn (int port , int enable )
347346{
348- int status = enable ? set_flags (port , KTU1125_CTRL_SW_CFG ,
349- KTU1125_VCONN_EN ) :
350- clr_flags (port , KTU1125_CTRL_SW_CFG ,
351- KTU1125_VCONN_EN | KTU1125_CC1S_VCONN |
352- KTU1125_CC2S_VCONN );
347+ int polarity ;
348+ int status ;
349+ int flags = KTU1125_VCONN_EN ;
350+
351+ polarity = polarity_rm_dts (pd_get_polarity (port ));
352+
353+ if (enable ) {
354+ flags |= polarity ? KTU1125_CC2S_VCONN : KTU1125_CC1S_VCONN ;
355+ status = set_flags (port , KTU1125_SET_SW_CFG , flags );
356+ } else {
357+ flags |= KTU1125_CC1S_VCONN | KTU1125_CC2S_VCONN ;
358+ status = clr_flags (port , KTU1125_SET_SW_CFG , flags );
359+ }
353360
354361 return status ;
355362}
0 commit comments