summaryrefslogtreecommitdiff
path: root/common/usb_common.c
diff options
context:
space:
mode:
authorDiana Z <dzigterman@chromium.org>2020-10-30 14:18:56 -0600
committerCommit Bot <commit-bot@chromium.org>2020-11-17 16:44:16 +0000
commit51484d77533e60cdfe21902eaf759c3be14df40a (patch)
treed28d5db09af798fd2972a4c4f902d770a951fe1a /common/usb_common.c
parent15b590a0999752abe28584a0c502fe9435ec7e41 (diff)
downloadchrome-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_common.c')
-rw-r--r--common/usb_common.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/common/usb_common.c b/common/usb_common.c
index c9100d15ad..7d4a0df99e 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -25,6 +25,7 @@
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usbc_ocp.h"
#include "usbc_ppc.h"
#include "util.h"
@@ -462,7 +463,7 @@ static void pd_send_hard_reset(int port)
task_set_event(PD_PORT_TO_TASK_ID(port), PD_EVENT_SEND_HARD_RESET, 0);
}
-#ifdef CONFIG_USBC_PPC
+#ifdef CONFIG_USBC_OCP
static uint32_t port_oc_reset_req;
@@ -493,18 +494,23 @@ DECLARE_DEFERRED(re_enable_ports);
void pd_handle_overcurrent(int port)
{
+ if ((port < 0) || (port >= board_get_usb_pd_port_count())) {
+ CPRINTS("%s(%d) Invalid port!", __func__, port);
+ return;
+ }
+
CPRINTS("C%d: overcurrent!", port);
if (IS_ENABLED(CONFIG_USB_PD_LOGGING))
pd_log_event(PD_EVENT_PS_FAULT, PD_LOG_PORT_SIZE(port, 0),
- PS_FAULT_OCP, NULL);
+ PS_FAULT_OCP, NULL);
/* No action to take if disconnected, just log. */
if (pd_is_disconnected(port))
return;
/* Keep track of the overcurrent events. */
- ppc_add_oc_event(port);
+ usbc_ocp_add_event(port);
/* Let the board specific code know about the OC event. */
board_overcurrent_event(port, 1);
@@ -514,7 +520,7 @@ void pd_handle_overcurrent(int port)
hook_call_deferred(&re_enable_ports_data, SECOND);
}
-#endif /* CONFIG_USBC_PPC */
+#endif /* CONFIG_USBC_OCP */
__maybe_unused void pd_handle_cc_overvoltage(int port)
{