mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-29 10:00:51 +00:00
pd: changes to actions to take on PD disconnect
Changed actions to take on PD disconnect to do all the same actions for source and sink disconnect. With power and data swap commands, there are potential bugs with state variables not getting cleared properly when separated source and sink disconnects are seperated out. Also changed code to only take those actions on PD disconnect whereas before it was also happening on dual role toggle. BUG=none BRANCH=samus TEST=load onto samus, make sure it takes disconnect actions on when zinger is unplugged. Change-Id: I455f4970517477d4ffd38059110521b228282763 Signed-off-by: Alec Berg <alecaberg@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/229621 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
committed by
chrome-internal-fetch
parent
f154a8b95d
commit
feecd2ac58
@@ -332,10 +332,25 @@ static inline void set_state(int port, enum pd_states next_state)
|
||||
set_state_timeout(port, 0, 0);
|
||||
pd[port].task_state = next_state;
|
||||
|
||||
if (last_state == next_state)
|
||||
return;
|
||||
#ifdef CONFIG_USB_PD_DUAL_ROLE
|
||||
/* Ignore dual-role toggling between sink and source */
|
||||
if ((last_state == PD_STATE_SNK_DISCONNECTED &&
|
||||
next_state == PD_STATE_SRC_DISCONNECTED) ||
|
||||
(last_state == PD_STATE_SRC_DISCONNECTED &&
|
||||
next_state == PD_STATE_SNK_DISCONNECTED))
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_USB_PD_DUAL_ROLE
|
||||
if (next_state == PD_STATE_SRC_DISCONNECTED ||
|
||||
next_state == PD_STATE_SNK_DISCONNECTED) {
|
||||
#else
|
||||
if (next_state == PD_STATE_SRC_DISCONNECTED) {
|
||||
#endif
|
||||
pd[port].dev_id = 0;
|
||||
pd[port].flags &= ~PD_FLAGS_RESET_ON_DISCONNECT_MASK;
|
||||
pd[port].data_role = PD_ROLE_DFP;
|
||||
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
|
||||
pd_exit_mode(port, NULL);
|
||||
#else
|
||||
@@ -348,12 +363,6 @@ static inline void set_state(int port, enum pd_states next_state)
|
||||
pd_set_vconn(port, pd[port].polarity, 0);
|
||||
#endif
|
||||
}
|
||||
#ifdef CONFIG_USB_PD_DUAL_ROLE
|
||||
else if (next_state == PD_STATE_SNK_DISCONNECTED) {
|
||||
pd[port].flags &= ~PD_FLAGS_RESET_ON_DISCONNECT_MASK;
|
||||
pd[port].data_role = PD_ROLE_UFP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_LOW_POWER_IDLE
|
||||
/* If any PD port is connected, then disable deep sleep */
|
||||
@@ -367,16 +376,6 @@ static inline void set_state(int port, enum pd_states next_state)
|
||||
disable_sleep(SLEEP_MASK_USB_PD);
|
||||
#endif
|
||||
|
||||
/* Log state transition, except for toggling between sink and source */
|
||||
if (last_state == next_state)
|
||||
return;
|
||||
#ifdef CONFIG_USB_PD_DUAL_ROLE
|
||||
if ((last_state == PD_STATE_SNK_DISCONNECTED &&
|
||||
next_state == PD_STATE_SRC_DISCONNECTED) ||
|
||||
(last_state == PD_STATE_SRC_DISCONNECTED &&
|
||||
next_state == PD_STATE_SNK_DISCONNECTED))
|
||||
return;
|
||||
#endif
|
||||
CPRINTF("C%d st%d\n", port, next_state);
|
||||
}
|
||||
|
||||
@@ -1511,6 +1510,8 @@ void pd_task(void)
|
||||
pd_select_polarity(port, pd[port].polarity);
|
||||
/* reset message ID counter on connection */
|
||||
pd[port].msg_id = 0;
|
||||
/* initial data role for source is DFP */
|
||||
pd[port].data_role = PD_ROLE_DFP;
|
||||
/* Set to USB SS initially */
|
||||
#ifdef CONFIG_USBC_SS_MUX
|
||||
board_set_usb_mux(port, TYPEC_MUX_USB,
|
||||
@@ -1756,6 +1757,8 @@ void pd_task(void)
|
||||
pd[port].polarity);
|
||||
/* reset message ID on connection */
|
||||
pd[port].msg_id = 0;
|
||||
/* initial data role for sink is UFP */
|
||||
pd[port].data_role = PD_ROLE_UFP;
|
||||
#ifdef CONFIG_CHARGE_MANAGER
|
||||
initialized[port] = 1;
|
||||
typec_set_input_current_limit(
|
||||
|
||||
Reference in New Issue
Block a user