summaryrefslogtreecommitdiff
path: root/include
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 /include
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 'include')
-rw-r--r--include/config.h16
-rw-r--r--include/usbc_ocp.h51
-rw-r--r--include/usbc_ppc.h44
3 files changed, 67 insertions, 44 deletions
diff --git a/include/config.h b/include/config.h
index b3a92c859d..4891b36617 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4361,6 +4361,12 @@
*/
#undef CONFIG_USB_PID
+/*
+ * Track overcurrent events for sinking partners coming from some component on
+ * the board. Auto-enabled for drivers which contain support for this feature.
+ */
+#undef CONFIG_USBC_OCP
+
/* PPC needs to be informed of CC polarity */
#undef CONFIG_USBC_PPC_POLARITY
@@ -5202,6 +5208,16 @@
#endif
/*****************************************************************************/
+/* Define CONFIG_USBC_OCP if a component can detect overcurrent */
+#if defined(CONFIG_USBC_PPC_AOZ1380) || \
+ defined(CONFIG_USBC_PPC_NX20P3481) || \
+ defined(CONFIG_USBC_PPC_NX20P3483) || \
+ defined(CONFIG_USBC_PPC_SN5S330) || \
+ defined(CONFIG_USBC_PPC_SYV682X)
+#define CONFIG_USBC_OCP
+#endif
+
+/*****************************************************************************/
/*
* Define CONFIG_USB_PD_VBUS_MEASURE_CHARGER if the charger on the board
* supports VBUS measurement.
diff --git a/include/usbc_ocp.h b/include/usbc_ocp.h
new file mode 100644
index 0000000000..d31ce57724
--- /dev/null
+++ b/include/usbc_ocp.h
@@ -0,0 +1,51 @@
+/* Copyright 2020 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_USBC_OCP_H
+#define __CROS_EC_USBC_OCP_H
+
+/* Common APIs for USB Type-C Overcurrent Protection (OCP) Module */
+
+/**
+ * Increment the overcurrent event counter.
+ *
+ * @param port: The Type-C port that has overcurrented.
+ * @return EC_SUCCESS on success, EC_ERROR_INVAL if non-existent port.
+ */
+int usbc_ocp_add_event(int port);
+
+/**
+ * Clear the overcurrent event counter
+ *
+ * @param port: The Type-C port number.
+ * @return EC_SUCCESS on success, EC_ERROR_INVAL if non-existent port
+ */
+int usbc_ocp_clear_event_counter(int port);
+
+/**
+ * Is the port latched off due to multiple overcurrent events in succession?
+ *
+ * @param port: The Type-C port number.
+ * @return 1 if the port is latched off, 0 if it is not latched off.
+ */
+int usbc_ocp_is_port_latched_off(int port);
+
+/**
+ * Register a port as having a sink connected
+ *
+ * @param port: The Type-C port number.
+ * @param connected: true if sink is now connected on port
+ */
+void usbc_ocp_snk_is_connected(int port, bool connected);
+
+/**
+ * Board specific callback when a port overcurrents.
+ *
+ * @param port: The Type-C port which overcurrented.
+ * @param is_overcurrented: 1 if port overcurrented, 0 if the condition is gone.
+ */
+__override_proto void board_overcurrent_event(int port, int is_overcurrented);
+
+#endif /* !defined(__CROS_EC_USBC_OCP_H) */
diff --git a/include/usbc_ppc.h b/include/usbc_ppc.h
index fbff51b596..8c18857961 100644
--- a/include/usbc_ppc.h
+++ b/include/usbc_ppc.h
@@ -11,18 +11,6 @@
/* Common APIs for USB Type-C Power Path Controllers (PPC) */
-/*
- * Number of times a port may overcurrent before we latch off the port until a
- * physical disconnect is detected.
- */
-#define PPC_OC_CNT_THRESH 3
-
-/*
- * Number of seconds until a latched-off port is re-enabled for sourcing after
- * detecting a physical disconnect.
- */
-#define PPC_OC_COOLDOWN_DELAY_US (2 * SECOND)
-
/* The role of connected device. */
enum ppc_device_role {
PPC_DEV_SNK,
@@ -200,22 +188,6 @@ int ppc_prints(const char *string, int port);
int ppc_err_prints(const char *string, int port, int error);
/**
- * Increment the overcurrent event counter.
- *
- * @param port: The Type-C port that has overcurrented.
- * @return EC_SUCCESS on success, EC_ERROR_INVAL if non-existent port.
- */
-int ppc_add_oc_event(int port);
-
-/**
- * Clear the overcurrent event counter.
- *
- * @param port: The Type-C port's counter to clear.
- * @return EC_SUCCESS on success, EC_ERROR_INVAL if non-existent port.
- */
-int ppc_clear_oc_event_counter(int port);
-
-/**
* Discharge PD VBUS on src/sink disconnect & power role swap
*
* @param port: The Type-C port number.
@@ -233,14 +205,6 @@ int ppc_discharge_vbus(int port, int enable);
int ppc_init(int port);
/**
- * Is the port latched off due to multiple overcurrent events in succession?
- *
- * @param port: The Type-C port number.
- * @return 1 if the port is latched off, 0 if it is not latched off.
- */
-int ppc_is_port_latched_off(int port);
-
-/**
* Is the port sourcing Vbus?
*
* @param port: The Type-C port number.
@@ -322,14 +286,6 @@ int ppc_vbus_sink_enable(int port, int enable);
int ppc_vbus_source_enable(int port, int enable);
/**
- * Board specific callback when a port overcurrents.
- *
- * @param port: The Type-C port which overcurrented.
- * @param is_overcurrented: 1 if port overcurrented, 0 if the condition is gone.
- */
-void board_overcurrent_event(int port, int is_overcurrented);
-
-/**
* Put the PPC into its lowest power state. In this state it should still fire
* interrupts if Vbus changes etc. This is called by board-specific code when
* appropriate.