diff options
author | Ting Shen <phoenixshen@google.com> | 2019-04-03 17:38:22 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-06-20 09:38:52 +0000 |
commit | 472a26a4bbb7fa67b782e9663a06b01a29468a79 (patch) | |
tree | ddcd0a02d967a310d1c61e5e1e28124456940f04 /board/kukui | |
parent | 8b6200d6c6caaf1dc1b65db5dac85ba1bb9ccd49 (diff) | |
download | chrome-ec-472a26a4bbb7fa67b782e9663a06b01a29468a79.tar.gz |
kukui: implement pogo discharge and extpower_present
- checks pogo present in extpower_present()
- implemented customized discharge_on_ac, we can't really discharge on
pogo, so only set charge to NONE when force discharging.
BUG=b:127767432,b:128386458
TEST=None
BRANCH=None
Change-Id: I2ffb6a69f102b9e10eff0a7794e04516055fac9d
Signed-off-by: Ting Shen <phoenixshen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1549811
Tested-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Auto-Submit: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Yilun Lin <yllin@chromium.org>
Diffstat (limited to 'board/kukui')
-rw-r--r-- | board/kukui/board.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/board/kukui/board.c b/board/kukui/board.c index 285372e089..40a18c9729 100644 --- a/board/kukui/board.c +++ b/board/kukui/board.c @@ -197,10 +197,16 @@ static void board_pogo_charge_init(void) DECLARE_HOOK(HOOK_INIT, board_pogo_charge_init, HOOK_PRIO_CHARGE_MANAGER_INIT + 1); +static int force_discharge; + int board_set_active_charge_port(int charge_port) { CPRINTS("New chg p%d", charge_port); + /* ignore all request when discharge mode is on */ + if (force_discharge) + return EC_SUCCESS; + switch (charge_port) { case CHARGE_PORT_USB_C: /* Don't charge from a source port */ @@ -240,7 +246,22 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int board_discharge_on_ac(int enable) { - /* TODO(b:123268580): Implement POGO discharge logic. */ + int ret, port; + + if (enable) { + port = CHARGE_PORT_NONE; + } else { + /* restore the charge port state */ + port = charge_manager_get_override(); + if (port == OVERRIDE_OFF) + port = charge_manager_get_active_charge_port(); + } + + ret = board_set_active_charge_port(port); + if (ret) + return ret; + force_discharge = enable; + return charger_discharge_on_ac(enable); } @@ -250,11 +271,14 @@ int extpower_is_present(void) * The charger will indicate VBUS presence if we're sourcing 5V, * so exclude such ports. */ - /* TODO(b:127767432): Also need to check pogo_vbus_present. */ + int usb_c_extpower_present; + if (board_vbus_source_enabled(CHARGE_PORT_USB_C)) - return 0; + usb_c_extpower_present = 0; else - return tcpm_get_vbus_level(CHARGE_PORT_USB_C); + usb_c_extpower_present = tcpm_get_vbus_level(CHARGE_PORT_USB_C); + + return usb_c_extpower_present || gpio_get_level(GPIO_POGO_VBUS_PRESENT); } int pd_snk_is_vbus_provided(int port) |