From 5f068e277ba6de108615aa3190ccb14b316b67f0 Mon Sep 17 00:00:00 2001 From: Yilun Lin Date: Tue, 23 Oct 2018 18:17:52 +0800 Subject: tcpm/mt6370: Support low power mode. TEST=make BOARD=kukui -j TEST=Test plug/unplug pd charger that can do pd negiotiate. TEST=Test plug/unplug peripheral that can sink power. BUG=b:113641776, b:80160923 BRANCH=None Change-Id: I4dd1ee5cfe2111af0abb47f62f34cf34e3fd81ad Signed-off-by: Yilun Lin Reviewed-on: https://chromium-review.googlesource.com/1297096 Commit-Ready: Yilun Lin Tested-by: Yilun Lin Reviewed-by: Jett Rink --- driver/tcpm/mt6370.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'driver') diff --git a/driver/tcpm/mt6370.c b/driver/tcpm/mt6370.c index d79ef0b691..a77dd96b57 100644 --- a/driver/tcpm/mt6370.c +++ b/driver/tcpm/mt6370.c @@ -102,6 +102,22 @@ static int mt6370_get_cc(int port, int *cc1, int *cc2) return rv; } +#ifdef CONFIG_USB_PD_TCPC_LOW_POWER +static int mt6370_enter_low_power_mode(int port) +{ + int rv; + + /* VBUS_DET_EN for detecting charger plug. */ + rv = tcpc_write(port, MT6370_REG_BMC_CTRL, + MT6370_REG_BMCIO_LPEN | MT6370_REG_VBUS_DET_EN); + + if (rv) + return rv; + + return tcpci_enter_low_power_mode(port); +} +#endif + /* MT6370 is a TCPCI compatible port controller */ const struct tcpm_drv mt6370_tcpm_drv = { .init = &mt6370_init, @@ -130,4 +146,7 @@ const struct tcpm_drv mt6370_tcpm_drv = { .set_snk_ctrl = &tcpci_tcpm_set_snk_ctrl, .set_src_ctrl = &tcpci_tcpm_set_src_ctrl, #endif +#ifdef CONFIG_USB_PD_TCPC_LOW_POWER + .enter_low_power_mode = &mt6370_enter_low_power_mode, +#endif }; -- cgit v1.2.1