summaryrefslogtreecommitdiff
path: root/driver/tcpm
diff options
context:
space:
mode:
authorYilun Lin <yllin@google.com>2018-11-14 14:29:19 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-11-19 03:26:25 -0800
commitec46635948f5073ecb608e799b738f954bfd7fbd (patch)
tree0a2bccf5e7505c339aa4c33249830b70e48e71cb /driver/tcpm
parentb4ef387f133991454ec890342f8fc651dab3c80a (diff)
downloadchrome-ec-ec46635948f5073ecb608e799b738f954bfd7fbd.tar.gz
kukui: Fix shipping mode VSYS leakage.
Follow the cut-off procedure recommended by Richtek. Also, tcpc_read/tcpc_write function will wake the TCPC up from low power mode and thus causing the TCPC re-init again, and this will break the register state we set. So, here we use mt6370_i2c_read/write to replace tcpc_read/write. TEST=boot system; Exec cutoff, and check that Vsys equals to zero. BUG=b:116682788 BRANCH=None Change-Id: I5cbd0df490ddb64b9376507e42a259c008c3ba16 Signed-off-by: Yilun Lin <yllin@google.com> Reviewed-on: https://chromium-review.googlesource.com/1335289 Commit-Ready: Yilun Lin <yllin@chromium.org> Tested-by: Yilun Lin <yllin@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'driver/tcpm')
-rw-r--r--driver/tcpm/mt6370.c23
-rw-r--r--driver/tcpm/mt6370.h13
2 files changed, 36 insertions, 0 deletions
diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c
index a77dd96b57..dba3a045a0 100644
--- a/driver/tcpm/mt6370.c
+++ b/driver/tcpm/mt6370.c
@@ -19,6 +19,13 @@
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args)
+/* i2c_write function which won't wake TCPC from low power mode. */
+static int mt6370_i2c_write8(int port, int reg, int val)
+{
+ return i2c_write8(tcpc_config[port].i2c_host_port,
+ tcpc_config[port].i2c_slave_addr, reg, val);
+}
+
static int mt6370_init(int port)
{
int rv;
@@ -118,6 +125,22 @@ static int mt6370_enter_low_power_mode(int port)
}
#endif
+int mt6370_vconn_discharge(int port)
+{
+ /*
+ * Write to mt6370 in low-power mode may return fail, but it is
+ * actually written. So we just ignore its return value.
+ */
+ mt6370_i2c_write8(port, MT6370_REG_OVP_FLAG_SEL,
+ MT6370_REG_DISCHARGE_LVL);
+ /* Set MT6370_REG_DISCHARGE_EN bit and also the rest default value. */
+ mt6370_i2c_write8(port, MT6370_REG_BMC_CTRL,
+ MT6370_REG_DISCHARGE_EN |
+ MT6370_REG_BMC_CTRL_DEFAULT);
+
+ return EC_SUCCESS;
+}
+
/* MT6370 is a TCPCI compatible port controller */
const struct tcpm_drv mt6370_tcpm_drv = {
.init = &mt6370_init,
diff --git a/driver/tcpm/mt6370.h b/driver/tcpm/mt6370.h
index ff9ac569ee..5fdcffbdca 100644
--- a/driver/tcpm/mt6370.h
+++ b/driver/tcpm/mt6370.h
@@ -102,6 +102,16 @@
#define MT6370_REG_BMCIO_BG_EN (1 << 2)
#define MT6370_REG_VBUS_DET_EN (1 << 1)
#define MT6370_REG_BMCIO_OSC_EN (1 << 0)
+#define MT6370_REG_BMC_CTRL_DEFAULT \
+ (MT6370_REG_BMCIO_BG_EN | MT6370_REG_VBUS_DET_EN | \
+ MT6370_REG_BMCIO_OSC_EN)
+
+/*
+ * MT6370_REG_OVP_FLAG_SEL
+ */
+
+#define MT6370_MASK_DISCHARGE_LVL 0x03
+#define MT6370_REG_DISCHARGE_LVL (1 << 0)
/*
* MT6370_REG_RT_STATUS 0x97
@@ -176,4 +186,7 @@
extern const struct tcpm_drv mt6370_tcpm_drv;
+/* Enable VCONN discharge. */
+int mt6370_vconn_discharge(int port);
+
#endif /* __CROS_EC_USB_PD_TCPM_MT6370_H */