diff options
author | Diana Z <dzigterman@chromium.org> | 2020-10-30 14:18:56 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-11-17 16:44:16 +0000 |
commit | 51484d77533e60cdfe21902eaf759c3be14df40a (patch) | |
tree | d28d5db09af798fd2972a4c4f902d770a951fe1a /common/usb_pd_protocol.c | |
parent | 15b590a0999752abe28584a0c502fe9435ec7e41 (diff) | |
download | chrome-ec-51484d77533e60cdfe21902eaf759c3be14df40a.tar.gz |
TCPM: Add OCP module
Currently, the overcurrent protection is tracked in the PPC code.
However, as different chips are able to report overcurrent move this
code into a generic module.
Logic for not sourcing Vbus or Vconn on latched ports moves into
the TC layer, and an overridable board overcurrent function is provided
for boards which have no special actions to take.
BRANCH=None
BUG=b:171501161
TEST=make -j buildall; TCPMv2 tested with following drawcia patch
Signed-off-by: Diana Z <dzigterman@chromium.org>
Change-Id: I75919e345a5b0bce4a0b67432a13515e7716cf6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2532676
Reviewed-by: Keith Short <keithshort@chromium.org>
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/usb_pd_protocol.c')
-rw-r--r-- | common/usb_pd_protocol.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c index 4b1a79d07c..5bc3e0a1e2 100644 --- a/common/usb_pd_protocol.c +++ b/common/usb_pd_protocol.c @@ -30,6 +30,7 @@ #include "usb_pd.h" #include "usb_pd_tcpm.h" #include "usb_pd_tcpc.h" +#include "usbc_ocp.h" #include "usbc_ppc.h" #include "version.h" #include "vboot.h" @@ -717,13 +718,17 @@ static inline void set_state(int port, enum pd_states next_state) /* If we're entering DRP_AUTO_TOGGLE, there is no sink connected. */ if (next_state == PD_STATE_DRP_AUTO_TOGGLE) { ppc_dev_is_connected(port, PPC_DEV_DISCONNECTED); - /* - * Clear the overcurrent event counter - * since we've detected a disconnect. - */ - ppc_clear_oc_event_counter(port); /* Disable Auto Discharge Disconnect */ tcpm_enable_auto_discharge_disconnect(port, 0); + + if (IS_ENABLED(CONFIG_USBC_OCP)) { + usbc_ocp_snk_is_connected(port, false); + /* + * Clear the overcurrent event counter + * since we've detected a disconnect. + */ + usbc_ocp_clear_event_counter(port); + } } #endif /* CONFIG_USBC_PPC && CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE */ @@ -756,13 +761,18 @@ static inline void set_state(int port, enum pd_states next_state) */ if (!cc_is_at_least_one_rd(cc1, cc2)) { ppc_dev_is_connected(port, PPC_DEV_DISCONNECTED); - /* - * Clear the overcurrent event counter - * since we've detected a disconnect. - */ - ppc_clear_oc_event_counter(port); + + if (IS_ENABLED(CONFIG_USBC_OCP)) { + usbc_ocp_snk_is_connected(port, false); + /* + * Clear the overcurrent event counter + * since we've detected a disconnect. + */ + usbc_ocp_clear_event_counter(port); + } } #endif /* CONFIG_USBC_PPC */ + /* Clear the holdoff timer since the port is disconnected. */ pd[port].ready_state_holdoff_timer = 0; @@ -3343,7 +3353,7 @@ void pd_task(void *u) * If the port is latched off, just continue to * monitor for a detach. */ - if (ppc_is_port_latched_off(port)) + if (usbc_ocp_is_port_latched_off(port)) break; #endif /* CONFIG_USBC_PPC */ @@ -3354,6 +3364,8 @@ void pd_task(void *u) /* Inform PPC that a sink is connected. */ ppc_dev_is_connected(port, PPC_DEV_SNK); #endif /* CONFIG_USBC_PPC */ + if (IS_ENABLED(CONFIG_USBC_OCP)) + usbc_ocp_snk_is_connected(port, true); if (new_cc_state == PD_CC_UFP_DEBUG_ACC) { pd[port].polarity = board_get_src_dts_polarity( @@ -4034,6 +4046,8 @@ void pd_task(void *u) /* Inform PPC that a source is connected. */ ppc_dev_is_connected(port, PPC_DEV_SRC); #endif /* CONFIG_USBC_PPC */ + if (IS_ENABLED(CONFIG_USBC_OCP)) + usbc_ocp_snk_is_connected(port, false); /* If PD comm is enabled, enable TCPC RX */ if (pd_comm_is_enabled(port)) |