summaryrefslogtreecommitdiff
path: root/driver/tcpm/tcpm.h
diff options
context:
space:
mode:
authorJett Rink <jettrink@chromium.org>2018-06-28 15:31:40 -0600
committerchrome-bot <chrome-bot@chromium.org>2018-07-18 18:15:26 -0700
commit16a8f8f4fa5bce677f202ff78892f3f50978065b (patch)
tree5b2b2b9bbe9c79632b00dc1c1d893a598add556a /driver/tcpm/tcpm.h
parentd22bdeeaecd864835eacb9c22e05f09050fb0237 (diff)
downloadchrome-ec-16a8f8f4fa5bce677f202ff78892f3f50978065b.tar.gz
tcpc: debounce entry into low-power mode
We need to keep track of the low-power mode hardware state for each TCPC so we can put a TCPC back into low power mode when it exits low power mode before the software TCPM state machine wants it out of low power mode. This change also breaks the low power mode entry out of the drp_toggle method into its own method: enter_low_power_mode. BRANCH=none BUG=b:77544959 TEST=Verified Analogix does not get into low-power mode loop. Tested other SRC/SNK capabilities as well. Tested the device will go back into low power mode if the AP access the TCPC via the 'ectool usbpdmuxinfo' command. Change-Id: I2fdefeda2bf13c2b79d988f0017629115438d313 Signed-off-by: Jett Rink <jettrink@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1119255 Reviewed-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'driver/tcpm/tcpm.h')
-rw-r--r--driver/tcpm/tcpm.h38
1 files changed, 33 insertions, 5 deletions
diff --git a/driver/tcpm/tcpm.h b/driver/tcpm/tcpm.h
index 091527e68a..3b3198d84e 100644
--- a/driver/tcpm/tcpm.h
+++ b/driver/tcpm/tcpm.h
@@ -13,6 +13,7 @@
#include "gpio.h"
#include "i2c.h"
#include "usb_pd_tcpm.h"
+#include "usb_pd.h"
#include "util.h"
#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) && \
@@ -27,30 +28,46 @@ extern const struct tcpc_config_t tcpc_config[];
/* I2C wrapper functions - get I2C port / slave addr from config struct. */
static inline int tcpc_write(int port, int reg, int val)
{
- return i2c_write8(tcpc_config[port].i2c_host_port,
+ int rv = i2c_write8(tcpc_config[port].i2c_host_port,
tcpc_config[port].i2c_slave_addr,
reg, val);
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ pd_device_accessed(port);
+#endif
+ return rv;
}
static inline int tcpc_write16(int port, int reg, int val)
{
- return i2c_write16(tcpc_config[port].i2c_host_port,
+ int rv = i2c_write16(tcpc_config[port].i2c_host_port,
tcpc_config[port].i2c_slave_addr,
reg, val);
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ pd_device_accessed(port);
+#endif
+ return rv;
}
static inline int tcpc_read(int port, int reg, int *val)
{
- return i2c_read8(tcpc_config[port].i2c_host_port,
+ int rv = i2c_read8(tcpc_config[port].i2c_host_port,
tcpc_config[port].i2c_slave_addr,
reg, val);
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ pd_device_accessed(port);
+#endif
+ return rv;
}
static inline int tcpc_read16(int port, int reg, int *val)
{
- return i2c_read16(tcpc_config[port].i2c_host_port,
+ int rv = i2c_read16(tcpc_config[port].i2c_host_port,
tcpc_config[port].i2c_slave_addr,
reg, val);
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ pd_device_accessed(port);
+#endif
+ return rv;
}
static inline int tcpc_xfer(int port,
@@ -58,11 +75,15 @@ static inline int tcpc_xfer(int port,
uint8_t *in, int in_size,
int flags)
{
- return i2c_xfer(tcpc_config[port].i2c_host_port,
+ int rv = i2c_xfer(tcpc_config[port].i2c_host_port,
tcpc_config[port].i2c_slave_addr,
out, out_size,
in, in_size,
flags);
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+ pd_device_accessed(port);
+#endif
+ return rv;
}
static inline void tcpc_lock(int port, int lock)
@@ -183,6 +204,13 @@ static inline int tcpm_set_drp_toggle(int port, int enable)
}
#endif
+#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
+static inline int tcpm_enter_low_power_mode(int port)
+{
+ return tcpc_config[port].drv->enter_low_power_mode(port);
+}
+#endif
+
#ifdef CONFIG_CMD_I2C_STRESS_TEST_TCPC
static inline int tcpc_i2c_read(const int port, const int addr,
const int reg, int *data)