@@ -1070,7 +1070,10 @@ void tc_state_init(int port)
1070
1070
* change the data role when we get to the state.
1071
1071
*/
1072
1072
TC_SET_FLAG (port , TC_FLAGS_TC_WARM_ATTACHED_SNK );
1073
- set_state_tc (port , TC_ATTACHED_SNK );
1073
+ set_state_tc (port ,
1074
+ (saved_flgs [port ] & PD_BBRMFLG_DBGACC_ROLE )
1075
+ ? TC_DBG_ACC_SNK
1076
+ : TC_ATTACHED_SNK );
1074
1077
} else {
1075
1078
restart_tc_sm (port , TC_UNATTACHED_SNK );
1076
1079
/*
@@ -2107,6 +2110,9 @@ static void tc_unoriented_dbg_acc_src_entry(const int port)
2107
2110
/* Enable auto discharge disconnect, if not PR Swapping */
2108
2111
if (!TC_CHK_FLAG (port , TC_FLAGS_PR_SWAP_IN_PROGRESS ))
2109
2112
tcpm_enable_auto_discharge_disconnect (port , 1 );
2113
+
2114
+ /* Save our current connection is a DEBUG ACCESSORY */
2115
+ pd_update_saved_port_flags (port , PD_BBRMFLG_DBGACC_ROLE , 1 );
2110
2116
}
2111
2117
2112
2118
static void tc_unoriented_dbg_acc_src_run (const int port )
@@ -2208,6 +2214,9 @@ static void tc_unoriented_dbg_acc_src_exit(const int port)
2208
2214
2209
2215
/* Clear PR swap flag */
2210
2216
TC_CLR_FLAG (port , TC_FLAGS_DO_PR_SWAP );
2217
+
2218
+ /* Save our current connection is not a DEBUG ACCESSORY */
2219
+ pd_update_saved_port_flags (port , PD_BBRMFLG_DBGACC_ROLE , 0 );
2211
2220
}
2212
2221
2213
2222
/**
@@ -2247,10 +2256,16 @@ static void tc_dbg_acc_snk_entry(const int port)
2247
2256
pd_set_polarity (port , tc [port ].polarity );
2248
2257
2249
2258
/*
2250
- * Initial data role for sink is UFP
2259
+ * Initial data role for sink is UFP unless this is a warm
2260
+ * attach. If it is a warm attach, the data role will be
2261
+ * restored to the current connect role and will already
2262
+ * have called tc_set_data_role with the appropriate role.
2251
2263
* This also sets the usb mux
2252
2264
*/
2253
- tc_set_data_role (port , PD_ROLE_UFP );
2265
+ if (TC_CHK_FLAG (port , TC_FLAGS_TC_WARM_ATTACHED_SNK ))
2266
+ TC_CLR_FLAG (port , TC_FLAGS_TC_WARM_ATTACHED_SNK );
2267
+ else
2268
+ tc_set_data_role (port , PD_ROLE_UFP );
2254
2269
2255
2270
if (IS_ENABLED (CONFIG_CHARGE_MANAGER )) {
2256
2271
tc [port ].typec_curr =
@@ -2272,6 +2287,9 @@ static void tc_dbg_acc_snk_entry(const int port)
2272
2287
/* Enable auto discharge disconnect, if not PR Swapping */
2273
2288
if (!TC_CHK_FLAG (port , TC_FLAGS_PR_SWAP_IN_PROGRESS ))
2274
2289
tcpm_enable_auto_discharge_disconnect (port , 1 );
2290
+
2291
+ /* Save our current connection is a DEBUG ACCESSORY */
2292
+ pd_update_saved_port_flags (port , PD_BBRMFLG_DBGACC_ROLE , 1 );
2275
2293
}
2276
2294
2277
2295
static void tc_dbg_acc_snk_run (const int port )
@@ -2350,6 +2368,9 @@ static void tc_dbg_acc_snk_exit(const int port)
2350
2368
2351
2369
/* Stop drawing power */
2352
2370
sink_stop_drawing_current (port );
2371
+
2372
+ /* Save our current connection is not a DEBUG ACCESSORY */
2373
+ pd_update_saved_port_flags (port , PD_BBRMFLG_DBGACC_ROLE , 0 );
2353
2374
}
2354
2375
2355
2376
/**
0 commit comments