Skip to content

Commit 12c3acd

Browse files
brockus-zephyrCommit Bot
authored and
Commit Bot
committed
tcpmv2: warm start DBG_ACC_SNK correctly
DBG_ACC_SNK connections are warm starting in ATTACHED_SNK and this is not correct. Added BBRMFLG to keep track and jump back to the correct SNK entry state. BUG=none BRANCH=none TEST=connect a DBGACC and reboot should reconnect DBGACC Signed-off-by: Denis Brockus <[email protected]> Change-Id: I4a17c2487a18ed0e4d58954e8d5ade08b4d44fff Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2191815 Tested-by: Denis Brockus <[email protected]> Reviewed-by: Diana Z <[email protected]> Commit-Queue: Denis Brockus <[email protected]> Auto-Submit: Denis Brockus <[email protected]>
1 parent 467afef commit 12c3acd

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

Diff for: common/usbc/usb_tc_drp_acc_trysrc_sm.c

+24-3
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,10 @@ void tc_state_init(int port)
10701070
* change the data role when we get to the state.
10711071
*/
10721072
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);
10741077
} else {
10751078
restart_tc_sm(port, TC_UNATTACHED_SNK);
10761079
/*
@@ -2107,6 +2110,9 @@ static void tc_unoriented_dbg_acc_src_entry(const int port)
21072110
/* Enable auto discharge disconnect, if not PR Swapping */
21082111
if (!TC_CHK_FLAG(port, TC_FLAGS_PR_SWAP_IN_PROGRESS))
21092112
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);
21102116
}
21112117

21122118
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)
22082214

22092215
/* Clear PR swap flag */
22102216
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);
22112220
}
22122221

22132222
/**
@@ -2247,10 +2256,16 @@ static void tc_dbg_acc_snk_entry(const int port)
22472256
pd_set_polarity(port, tc[port].polarity);
22482257

22492258
/*
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.
22512263
* This also sets the usb mux
22522264
*/
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);
22542269

22552270
if (IS_ENABLED(CONFIG_CHARGE_MANAGER)) {
22562271
tc[port].typec_curr =
@@ -2272,6 +2287,9 @@ static void tc_dbg_acc_snk_entry(const int port)
22722287
/* Enable auto discharge disconnect, if not PR Swapping */
22732288
if (!TC_CHK_FLAG(port, TC_FLAGS_PR_SWAP_IN_PROGRESS))
22742289
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);
22752293
}
22762294

22772295
static void tc_dbg_acc_snk_run(const int port)
@@ -2350,6 +2368,9 @@ static void tc_dbg_acc_snk_exit(const int port)
23502368

23512369
/* Stop drawing power */
23522370
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);
23532374
}
23542375

23552376
/**

Diff for: include/usb_pd.h

+1
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,7 @@ enum pd_states {
889889
#define PD_BBRMFLG_POWER_ROLE BIT(1)
890890
#define PD_BBRMFLG_DATA_ROLE BIT(2)
891891
#define PD_BBRMFLG_VCONN_ROLE BIT(3)
892+
#define PD_BBRMFLG_DBGACC_ROLE BIT(4)
892893

893894
/* Initial value for CC debounce variable */
894895
#define PD_CC_UNSET -1

0 commit comments

Comments
 (0)