summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin Lu <Devin.Lu@quantatw.com>2021-03-29 13:58:11 +0800
committerCommit Bot <commit-bot@chromium.org>2021-04-09 03:04:57 +0000
commit393c3c20dfd15d666c84b88a23cadac1c6dadb3f (patch)
treef9ca4c1da3cde900702a7ce9d16329c84a7e7029
parent99e2e5148ec6739c1feb600cd8b41be329069fc8 (diff)
downloadchrome-ec-393c3c20dfd15d666c84b88a23cadac1c6dadb3f.tar.gz
isl9241: Toggle learning mode when fully charged
In low-power states, the ISL9241 may become stuck in CCM, consuming excess power. Toggle learning mode to enter DCM and save power. This is a workaround recommended by Renasas. BUG=b:183771327 BRANCH=firmware-volteer-13672.B-main TEST=Verifed charger doesn't stuck in CCM mode. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I70bf088b9214fd4b3cee137da561ba84e854106a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2789811 Reviewed-by: Abe Levkoy <alevkoy@chromium.org> Commit-Queue: Abe Levkoy <alevkoy@chromium.org>
-rw-r--r--driver/charger/isl9241.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c
index ab92ef70ad..4a53c2440a 100644
--- a/driver/charger/isl9241.c
+++ b/driver/charger/isl9241.c
@@ -12,6 +12,7 @@
#include "battery.h"
#include "battery_smart.h"
#include "charger.h"
+#include "charge_state.h"
#include "console.h"
#include "common.h"
#include "hooks.h"
@@ -498,6 +499,30 @@ static int isl9241_ramp_get_current_limit(int chgnum)
}
#endif /* CONFIG_CHARGE_RAMP_HW */
+/*
+ * When fully charged in a low-power state, the ISL9241 may get stuck
+ * in CCM. Toggle learning mode for 50 ms to enter DCM and save power.
+ * This is a workaround provided by Renesas. See b/183771327.
+ */
+static void isl9241_restart_charge_voltage_when_full(void)
+{
+ if (!chipset_in_or_transitioning_to_state(CHIPSET_STATE_ON)
+ && charge_get_state() == PWR_STATE_CHARGE_NEAR_FULL) {
+ charger_discharge_on_ac(1);
+ msleep(50);
+ charger_discharge_on_ac(0);
+ }
+}
+DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE,
+ isl9241_restart_charge_voltage_when_full,
+ HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND,
+ isl9241_restart_charge_voltage_when_full,
+ HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN,
+ isl9241_restart_charge_voltage_when_full,
+ HOOK_PRIO_DEFAULT);
+
/*****************************************************************************/
#ifdef CONFIG_CMD_CHARGER_DUMP
static void dump_reg_range(int chgnum, int low, int high)