From 37168486d3f5543b5dd7a8e5d819c68c4c68c5b0 Mon Sep 17 00:00:00 2001 From: Philip Chen Date: Wed, 23 May 2018 20:18:59 -0700 Subject: scarlet: Disable idle mode in a special case When AC is plugged, battery is full and AP is off, there is a small chance that rt946x would be damaged. I'm told that consuming more current in this case would mitigate the issue. So let's disable idle mode in this case. BUG=b:78792296 BRANCH=scarlet TEST=manually test on scarlet and confirm idle mode is disabled in the described special case Change-Id: Idc3a3165ebaa2f99bdd5df56675c3945eaeae9fa Signed-off-by: Philip Chen Reviewed-on: https://chromium-review.googlesource.com/1071124 Reviewed-by: Randall Spangler Commit-Queue: Philip Chen Tested-by: Philip Chen --- board/scarlet/battery.c | 20 +++++++++++++++++++- board/scarlet/board.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/board/scarlet/battery.c b/board/scarlet/battery.c index 25b161dee2..62a733e463 100644 --- a/board/scarlet/battery.c +++ b/board/scarlet/battery.c @@ -8,6 +8,7 @@ #include "battery.h" #include "battery_smart.h" #include "charge_state.h" +#include "chipset.h" #include "console.h" #include "driver/battery/max17055.h" #include "driver/charger/rt946x.h" @@ -15,6 +16,7 @@ #include "extpower.h" #include "gpio.h" #include "hooks.h" +#include "system.h" #include "util.h" /* @@ -248,13 +250,29 @@ int charger_profile_override(struct charge_state_data *curr) * BATTERY_LEVEL_NEAR_FULL. So we can ensure both Chrome OS UI * and battery LED indicate full charge. */ - if (rt946x_is_charge_done()) + if (rt946x_is_charge_done()) { curr->batt.state_of_charge = MAX(BATTERY_LEVEL_NEAR_FULL, curr->batt.state_of_charge); + /* + * This is a workaround for b:78792296. When AP is off and + * charge termination is detected, we disable idle mode. + */ + if (chipset_in_state(CHIPSET_STATE_ANY_OFF | + CHIPSET_STATE_ANY_SUSPEND)) + disable_idle(); + else + enable_idle(); + } return 0; } +static void board_enable_idle(void) +{ + enable_idle(); +} +DECLARE_HOOK(HOOK_AC_CHANGE, board_enable_idle, HOOK_PRIO_DEFAULT); + static void board_charge_termination(void) { static uint8_t te; diff --git a/board/scarlet/board.h b/board/scarlet/board.h index eb4ba03d97..278f3cb016 100644 --- a/board/scarlet/board.h +++ b/board/scarlet/board.h @@ -23,6 +23,7 @@ #define CONFIG_I2C_PASSTHRU_RESTRICTED #define CONFIG_LED_COMMON #define CONFIG_LOW_POWER_IDLE +#define CONFIG_LOW_POWER_IDLE_LIMITED #define CONFIG_POWER_COMMON #define CONFIG_SPI #define CONFIG_SPI_MASTER -- cgit v1.2.1