diff options
author | Denis Brockus <dbrockus@chromium.org> | 2019-12-10 10:24:12 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-12-12 03:53:55 +0000 |
commit | 896271dad5edbfaad2b0ff10a6fb1dcfb1143089 (patch) | |
tree | 01ae1278294b969fc70d0b6f15f963b2c2bc7e19 /common | |
parent | 40b6c5de590e6290e6b516c380f6b59efbff4fa3 (diff) | |
download | chrome-ec-896271dad5edbfaad2b0ff10a6fb1dcfb1143089.tar.gz |
tcpci: change connect to auto discharge disconnect
It was originally thought the connect/disconnect would be
a good generic way to set/clear auto_discharge_disconnect
but it was not working reliably. Although the points that
we are calling to perform this enable/disable are close to
the connect/disconnect, there is more fine tuning required
to make this work.
BUG=b:144126745,chromium:951683
BRANCH=none
TEST=attach/disconnect charger with and without AP running
TEST=attach/disconnect device with AP running
Change-Id: Ib1418771aec6d0a52895972e4db6881b072c0c3d
Signed-off-by: Denis Brockus <dbrockus@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1960514
Reviewed-by: Edward Hill <ecgh@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/usb_pd_protocol.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 3a9e77d8d2..37d9dafd86 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -19,6 +19,8 @@ #include "registers.h" #include "system.h" #include "task.h" +#include "tcpci.h" +#include "tcpm.h" #include "timer.h" #include "util.h" #include "usb_charge.h" @@ -730,6 +732,8 @@ static inline void set_state(int port, enum pd_states next_state) * since we've detected a disconnect. */ ppc_clear_oc_event_counter(port); + /* Disable Auto Discharge Disconnect */ + tcpm_enable_auto_discharge_disconnect(port, 0); } #endif /* CONFIG_USBC_PPC && CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE */ @@ -844,6 +848,9 @@ static inline void set_state(int port, enum pd_states next_state) /* detect USB PD cc disconnect */ if (IS_ENABLED(CONFIG_COMMON_RUNTIME)) hook_notify(HOOK_USB_PD_DISCONNECT); + + /* Disable Auto Discharge Disconnect */ + tcpm_enable_auto_discharge_disconnect(port, 0); } #ifdef CONFIG_LOW_POWER_IDLE @@ -3345,6 +3352,9 @@ void pd_task(void *u) /* initial data role for source is DFP */ pd_set_data_role(port, PD_ROLE_DFP); + /* Enable Auto Discharge Disconnect */ + tcpm_enable_auto_discharge_disconnect(port, 1); + if (new_cc_state == PD_CC_UFP_DEBUG_ACC) pd[port].flags |= PD_FLAGS_TS_DTS_PARTNER; @@ -3973,6 +3983,8 @@ void pd_task(void *u) pd[port].msg_id = 0; /* initial data role for sink is UFP */ pd_set_data_role(port, PD_ROLE_UFP); + /* Enable Auto Discharge Disconnect */ + tcpm_enable_auto_discharge_disconnect(port, 1); #if defined(CONFIG_CHARGE_MANAGER) typec_curr = usb_get_typec_current_limit( pd[port].polarity, cc1, cc2); |