From 2ce3beec20501d1975acb69053d724c6b391f849 Mon Sep 17 00:00:00 2001 From: johnwc_yeh Date: Wed, 9 Jun 2021 18:18:52 +0800 Subject: cret/raa489000: Control ASGATE state There is 0.1V leakage from Charger to Vbus when a charger is removed in S5. Control ASGATE state to prevent the leakage. This commit uses the charger side registers to control the ASGATE when selecting our active charge port. This is done in addition to the existing implementation which uses the TCPCI registers to control ASGATE. BUG=b:189299803 BRANCH=dedede TEST=Build and flash Cret, the leakage has been improved from 0.1V to 0.001V Signed-off-by: johnwc_yeh Change-Id: Ib81ca651b0708149fae7b4df27f66107b47f8490 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2948604 Reviewed-by: Elthan Huang Reviewed-by: Aseda Aboagye Tested-by: Elthan Huang Commit-Queue: Aseda Aboagye --- board/cret/board.c | 9 ++++++--- board/cret/usb_pd_policy.c | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/board/cret/board.c b/board/cret/board.c index f8d0d566fa..56e80bc388 100644 --- a/board/cret/board.c +++ b/board/cret/board.c @@ -258,10 +258,11 @@ int board_set_active_charge_port(int port) /* Disable all ports. */ if (port == CHARGE_PORT_NONE) { - for (i = 0; i < board_get_usb_pd_port_count(); i++) + for (i = 0; i < board_get_usb_pd_port_count(); i++) { tcpc_write(i, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW); - + raa489000_enable_asgate(i, false); + } return EC_SUCCESS; } @@ -282,6 +283,7 @@ int board_set_active_charge_port(int port) if (tcpc_write(i, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW)) CPRINTS("p%d: sink path disable failed.", i); + raa489000_enable_asgate(i, false); } /* @@ -292,7 +294,8 @@ int board_set_active_charge_port(int port) charger_discharge_on_ac(1); /* Enable requested charge port. */ - if (tcpc_write(port, TCPC_REG_COMMAND, + if (raa489000_enable_asgate(port, true) || + tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_HIGH)) { CPRINTS("p%d: sink path enable failed.", port); charger_discharge_on_ac(0); diff --git a/board/cret/usb_pd_policy.c b/board/cret/usb_pd_policy.c index f00fb3aa95..15faf41ffc 100644 --- a/board/cret/usb_pd_policy.c +++ b/board/cret/usb_pd_policy.c @@ -7,6 +7,7 @@ #include "chipset.h" #include "common.h" #include "console.h" +#include "driver/charger/isl923x_public.h" #include "driver/tcpm/tcpci.h" #include "usb_pd.h" @@ -49,6 +50,10 @@ int pd_set_power_supply_ready(int port) if (rv) return rv; + rv = raa489000_enable_asgate(port, true); + if (rv) + return rv; + /* Notify host of power info change. */ pd_send_host_event(PD_EVENT_POWER_CHANGE); -- cgit v1.2.1