summaryrefslogtreecommitdiff
path: root/common/battery.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-06-22 21:24:06 -0700
committerCommit Bot <commit-bot@chromium.org>2021-12-15 06:15:22 +0000
commitbfb2075a30c4488e7ce8025f91eb4413c010e4c5 (patch)
tree9bd839bdaa30ababd5e7ee08992c2418e2f72020 /common/battery.c
parentf319cf9bce20170273ca36c23555503a56c9de6a (diff)
downloadchrome-ec-bfb2075a30c4488e7ce8025f91eb4413c010e4c5.tar.gz
chgstv2: Unify power-on and shutdown battery thresholds
Currently, power-on battery SoC and shutdown battery SoC are independently configured by each board. This patch will unify the setting as follows: CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON = 2 (don't boot if soc < 2%) CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE = 2 (shutdown if soc <= 2%) BATTERY_LEVEL_SHUTDOWN = 3 (shutdown if soc < 3%) CONFIG_BATTERY_EXPORT_DISPLAY_SOC = Y (removed) CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC = 1 This allows us to show the low battery alert whenever we can because EC doesn't inhibit power-on even if it knows the host would immediately shut down. With CONFIG_BATTERY_EXPORT_DISPLAY_SOC, boards will start using the CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE = 2% as the low battery threshold (and the SoC will be agreed between the EC and Powerd). Boards with CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON = 1 will keep the same threshold. This is for avoiding degrading the UX by increasing the power-on threshold (even though a question that 1% may not be enough for soft sync to finish consistently remains to be answered). Boards with CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON > 2 will have a lower threshold but we think 2% is enough to finish the software sync. A lower threshold also improves the UX by showing the low battery alert in the situation where otherwise the system would leave the user uninformed by not responding to a power button press. BUG=b:191837893 BRANCH=None TEST=buildall Change-Id: If6ff733bc181f929561a3fffb8a84e760668ce37 Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2981468 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3336671
Diffstat (limited to 'common/battery.c')
-rw-r--r--common/battery.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/common/battery.c b/common/battery.c
index f048a1db91..50d689f0d1 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -22,7 +22,6 @@
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
/* See config.h for details */
-const static int batt_full_factor = CONFIG_BATT_FULL_FACTOR;
const static int batt_host_full_factor = CONFIG_BATT_HOST_FULL_FACTOR;
const static int batt_host_shutdown_pct = CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE;
@@ -588,9 +587,6 @@ void battery_compensate_params(struct batt_params *batt)
return;
/* Some batteries don't update full capacity as often. */
- if (!IS_ENABLED(CONFIG_BATTERY_EXPORT_DISPLAY_SOC))
- /* full_factor is effectively disabled in powerd. */
- *full = *full * batt_full_factor / 100;
if (*remain > *full)
*remain = *full;
@@ -625,7 +621,7 @@ void battery_compensate_params(struct batt_params *batt)
batt->display_charge = 1000;
}
-#ifdef CONFIG_BATTERY_EXPORT_DISPLAY_SOC
+#ifdef CONFIG_CHARGER
static int battery_display_soc(struct host_cmd_handler_args *args)
{
struct ec_response_display_soc *r = args->response;