summaryrefslogtreecommitdiff
path: root/include/usbc_ppc.h
diff options
context:
space:
mode:
authorAseda Aboagye <aaboagye@google.com>2017-11-29 23:26:36 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-12-06 01:08:24 -0800
commitfb32b6d30cf55408f4bdb36b729c99452f6e8e11 (patch)
tree8506ce54893a0cf9953ea7bcaaf29d96eb1b0df9 /include/usbc_ppc.h
parentfb43b2f4869182e9337c031a4d516ce820fe78d1 (diff)
downloadchrome-ec-fb32b6d30cf55408f4bdb36b729c99452f6e8e11.tar.gz
ppc: Create generic PPC driver framework.
This commit introduces a driver framework for power path controllers. It provides some common PPC APIs as well as allowing a board to use multiple different PPCs drivers/parts. This should make it easier to add PPC drivers in the future. BUG=None BRANCH=None TEST=`make -j buildall` TEST=Flash zoombini; verify PPC works as expected. TEST=Flash meowth; verify PPC works as expected. Change-Id: Icfb99f384610590b431456cfd28d4aff18442cb2 Signed-off-by: Aseda Aboagye <aaboagye@google.com> Reviewed-on: https://chromium-review.googlesource.com/807630 Commit-Ready: Aseda Aboagye <aaboagye@chromium.org> Tested-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Edward Hill <ecgh@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'include/usbc_ppc.h')
-rw-r--r--include/usbc_ppc.h70
1 files changed, 64 insertions, 6 deletions
diff --git a/include/usbc_ppc.h b/include/usbc_ppc.h
index 0af3e766e3..05e671728a 100644
--- a/include/usbc_ppc.h
+++ b/include/usbc_ppc.h
@@ -8,30 +8,88 @@
#include "common.h"
-
/* Common APIs for USB Type-C Power Path Controllers (PPC) */
+struct ppc_drv {
+ /**
+ * Initialize the PPC.
+ *
+ * @param port: The Type-C port number.
+ * @return EC_SUCCESS when init was successful, error otherwise.
+ */
+ int (*init)(int port);
+
+ /**
+ * Is the port sourcing Vbus?
+ *
+ * @param port: The Type-C port number.
+ * @return 1 if sourcing Vbus, 0 if not.
+ */
+ int (*is_sourcing_vbus)(int port);
+
+ /**
+ * Turn on/off the charge path FET, such that current flows into the
+ * system.
+ *
+ * @param port: The Type-C port number.
+ * @param enable: 1: Turn on the FET, 0: turn off the FET.
+ * @return EC_SUCCESS on success, error otherwise.
+ */
+ int (*vbus_sink_enable)(int port, int enable);
+
+ /**
+ * Turn on/off the source path FET, such that current flows from the
+ * system.
+ *
+ * @param port: The Type-C port number.
+ * @param enable: 1: Turn on the FET, 0: turn off the FET.
+ * @return EC_SUCCESS on success, error otherwise.
+ */
+ int (*vbus_source_enable)(int port, int enable);
+
+#ifdef CONFIG_CMD_PPC_DUMP
+ /**
+ * Perform a register dump of the PPC.
+ *
+ * @param port: The Type-C port number.
+ * @return EC_SUCCESS on success, error otherwise.
+ */
+ int (*reg_dump)(int port);
+#endif /* defined(CONFIG_CMD_PPC_DUMP) */
+};
+
+struct ppc_config_t {
+ int i2c_port;
+ int i2c_addr;
+ const struct ppc_drv *drv;
+};
+
+extern const struct ppc_config_t ppc_chips[];
+extern const unsigned int ppc_cnt;
+
/**
* Is the port sourcing Vbus?
*
- * @param port: The type c port.
+ * @param port: The Type-C port number.
* @return 1 if sourcing Vbus, 0 if not.
*/
int ppc_is_sourcing_vbus(int port);
/**
- * Allow current to flow into the system.
+ * Turn on/off the charge path FET, such that current flows into the
+ * system.
*
- * @param port: The Type-C port's FET to open.
+ * @param port: The Type-C port number.
* @param enable: 1: Turn on the FET, 0: turn off the FET.
* @return EC_SUCCESS on success, error otherwise.
*/
int ppc_vbus_sink_enable(int port, int enable);
/**
- * Allow current out of the system.
+ * Turn on/off the source path FET, such that current flows from the
+ * system.
*
- * @param port: The Type-C port's FET to open.
+ * @param port: The Type-C port number.
* @param enable: 1: Turn on the FET, 0: turn off the FET.
* @return EC_SUCCESS on success, error otherwise.
*/