summaryrefslogtreecommitdiff
path: root/include/usbc_ppc.h
diff options
context:
space:
mode:
authorEric Yilun Lin <yllin@chromium.org>2020-09-25 16:21:27 +0800
committerCommit Bot <commit-bot@chromium.org>2020-10-08 06:00:54 +0000
commit853e6337629e3ef27e430075b7f3276f3832fa03 (patch)
treec6d1b50a55c1440f65c43a3e40d04c19df494467 /include/usbc_ppc.h
parent5b62424750cd8b486966d851a5a4d34bfe430d39 (diff)
downloadchrome-ec-853e6337629e3ef27e430075b7f3276f3832fa03.tar.gz
usbc_ppc: inform the PPC of the power role of the connected device
On some of the PPC (e.g. syv682) that support manually force discharge function doesn't automatically turn off discharge FET when VBUS meets vSafe0V. The original flow is disabling discharge on pd_set_power_supply_ready and enabling discharge on pd_power_supply_reset, and since there is no automatic turning off the discharge circuit, the FET will still be on when a SNK device connected. We fix this by informing the PPC on a device is connected or disconnected so that PPC can control the FET by requests. BUG=b:160548079, b:148870148, b:163143427 TEST=make buildall TEST=TCPMv2: on asurada C0/C1(syv682) and volteer C0(sn5s330)/C1(syv682) port, and enable force discharge mode (CL:2423665), plug sink and source device and ensure Vconn and Vbus are off within tVconnOff and tVBusOff respectively. Plug a DRP hub and then plug adapter in it, and it meets tVconnOff and tVbusOff. TEST=TCPMv1: tested the same steps as above on Asurada. BRANCH=NONE Change-Id: I8ed0e18fce2d402ff24fce6bab393cc618dfac09 Signed-off-by: Eric Yilun Lin <yllin@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2434590 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Tested-by: Eric Herrmann <eherrmann@chromium.org>
Diffstat (limited to 'include/usbc_ppc.h')
-rw-r--r--include/usbc_ppc.h30
1 files changed, 24 insertions, 6 deletions
diff --git a/include/usbc_ppc.h b/include/usbc_ppc.h
index 00a2911363..fbff51b596 100644
--- a/include/usbc_ppc.h
+++ b/include/usbc_ppc.h
@@ -23,6 +23,13 @@
*/
#define PPC_OC_COOLDOWN_DELAY_US (2 * SECOND)
+/* The role of connected device. */
+enum ppc_device_role {
+ PPC_DEV_SNK,
+ PPC_DEV_SRC,
+ PPC_DEV_DISCONNECTED,
+};
+
/*
* NOTE: The pointers to functions in the ppc_drv structure can now be NULL
* which will indicate and return NOT_IMPLEMENTED from the main calling
@@ -94,6 +101,17 @@ struct ppc_drv {
*/
int (*discharge_vbus)(int port, int enable);
+ /**
+ * Inform the PPC of the device is connected or disconnected.
+ *
+ * @param port: The Type-C port number.
+ * @param dev: PPC_DEV_SNK if a sink is connected, PPC_DEV_SRC if a
+ * source is connected, PPC_DEV_DISCONNECTED if the device
+ * is disconnected.
+ * @return EC_SUCCESS on success, error otherwise.
+ */
+ int (*dev_is_connected)(int port, enum ppc_device_role dev);
+
#ifdef CONFIG_USBC_PPC_SBU
/**
* Turn on/off the SBU FETs.
@@ -239,15 +257,15 @@ int ppc_is_sourcing_vbus(int port);
int ppc_is_vbus_present(int port);
/**
- * Inform the PPC module that a sink is connected.
+ * Inform the PPC module that a device (either sink or source) is connected.
*
- * This is used such that it can determine when to clear the overcurrent events
- * counter for a port.
+ * This is used such that it can determine when to clear the overcurrent events,
+ * and disable discharge VBUS on a source device connected.
* @param port: The Type-C port number.
- * @param is_connected: 1: if sink is connected on this port, 0: if not
- * connected.
+ * @param dev: PPC_DEV_SNK if a sink is connected, PPC_DEV_SRC if a source is
+ * connected, PPC_DEV_DISCONNECTED if the device is disconnected.
*/
-void ppc_sink_is_connected(int port, int is_connected);
+int ppc_dev_is_connected(int port, enum ppc_device_role dev);
/**
* Inform the PPC of the polarity of the CC pins.