summaryrefslogtreecommitdiff
path: root/driver/tcpm/mt6370.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver/tcpm/mt6370.c')
-rw-r--r--driver/tcpm/mt6370.c23
1 files changed, 23 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,