summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2021-06-22 21:24:06 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-23 20:47:18 +0000
commit3aa4dd2c4a695152dd17aaec601d3a79bc5ab1c4 (patch)
tree0f08d695a03d2ca88092b7ae82429cd38143928e
parent87f59b57817d5800fd929938b2dca914bad14d2c (diff)
downloadchrome-ec-3aa4dd2c4a695152dd17aaec601d3a79bc5ab1c4.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>
-rw-r--r--baseboard/asurada/baseboard.h1
-rw-r--r--baseboard/brya/baseboard.h2
-rw-r--r--baseboard/dedede/baseboard.h1
-rw-r--r--baseboard/dragonegg/baseboard.h1
-rw-r--r--baseboard/grunt/baseboard.h7
-rw-r--r--baseboard/guybrush/baseboard.h3
-rw-r--r--baseboard/hatch/baseboard.h2
-rw-r--r--baseboard/intelrvp/baseboard.h2
-rw-r--r--baseboard/kukui/baseboard.h1
-rw-r--r--baseboard/octopus/baseboard.h1
-rw-r--r--baseboard/trogdor/baseboard.h1
-rw-r--r--baseboard/volteer/baseboard.h2
-rw-r--r--baseboard/zork/baseboard.h1
-rw-r--r--board/atlas/board.h1
-rw-r--r--board/casta/board.h1
-rw-r--r--board/coral/board.h1
-rw-r--r--board/eve/board.h1
-rw-r--r--board/flapjack/board.h1
-rw-r--r--board/homestar/board.h3
-rw-r--r--board/mchpevb1/board.h5
-rw-r--r--board/nami/board.h3
-rw-r--r--board/nautilus/board.h1
-rw-r--r--board/nocturne/board.h1
-rw-r--r--board/poppy/board.h1
-rw-r--r--board/rammus/board.h1
-rw-r--r--board/reef/board.h1
-rw-r--r--board/reef_it8320/board.h1
-rw-r--r--board/reef_mchp/board.h1
-rw-r--r--board/samus/board.h1
-rw-r--r--board/scarlet/board.h1
-rw-r--r--board/storo/board.h3
-rw-r--r--common/battery.c6
-rw-r--r--common/led_onoff_states.c5
-rw-r--r--include/config.h63
34 files changed, 33 insertions, 94 deletions
diff --git a/baseboard/asurada/baseboard.h b/baseboard/asurada/baseboard.h
index 52461d8822..97576a32ef 100644
--- a/baseboard/asurada/baseboard.h
+++ b/baseboard/asurada/baseboard.h
@@ -64,7 +64,6 @@
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_ISL9238C
#define CONFIG_CHARGER_MAINTAIN_VBAT
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGER_OTG
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_PSYS_READ
diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h
index 6ebc5b06e7..547349469d 100644
--- a/baseboard/brya/baseboard.h
+++ b/baseboard/brya/baseboard.h
@@ -73,8 +73,6 @@
* communicate on locked systems (which haven't PD negotiated)
*/
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15001
/* Common battery defines */
diff --git a/baseboard/dedede/baseboard.h b/baseboard/dedede/baseboard.h
index 933512548b..1b16e5dd35 100644
--- a/baseboard/dedede/baseboard.h
+++ b/baseboard/dedede/baseboard.h
@@ -149,7 +149,6 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 256
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_USB_CHARGER
#define CONFIG_TRICKLE_CHARGING
diff --git a/baseboard/dragonegg/baseboard.h b/baseboard/dragonegg/baseboard.h
index 60b2d07241..a22ad924e9 100644
--- a/baseboard/dragonegg/baseboard.h
+++ b/baseboard/dragonegg/baseboard.h
@@ -56,7 +56,6 @@
#define CONFIG_CHARGER_BQ25710
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h
index 2621bcdbdb..7f22d92d17 100644
--- a/baseboard/grunt/baseboard.h
+++ b/baseboard/grunt/baseboard.h
@@ -149,13 +149,6 @@
#define PD_MAX_VOLTAGE_MV 20000
/*
- * Minimum conditions to start AP and perform swsync. Note that when the
- * charger is connected via USB-PD analog signaling, the boot will proceed
- * regardless.
- */
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
-
-/*
* Require PD negotiation to be complete when we are in a low-battery condition
* prior to releasing depthcharge to the kernel.
*/
diff --git a/baseboard/guybrush/baseboard.h b/baseboard/guybrush/baseboard.h
index 016d36b503..77e22c433b 100644
--- a/baseboard/guybrush/baseboard.h
+++ b/baseboard/guybrush/baseboard.h
@@ -135,11 +135,10 @@
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
/*
- * EC will boot AP to depthcharge if: (BAT >= 4%) || (AC >= 50W)
+ * EC will boot AP to depthcharge if: (BAT >= 2%) || (AC >= 50W)
* CONFIG_CHARGER_LIMIT_* is not set, so there is no additional restriction on
* Depthcharge to boot OS.
*/
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 4
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 50000
/*
diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h
index 2cbe91221f..bf9140b33f 100644
--- a/baseboard/hatch/baseboard.h
+++ b/baseboard/hatch/baseboard.h
@@ -97,6 +97,7 @@
#define CONFIG_CHARGER_BQ25710
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */
+#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_SENSE_RESISTOR 10
@@ -106,7 +107,6 @@
* communicate on locked systems (which haven't PD negotiated)
*/
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15001
/* Common battery defines */
diff --git a/baseboard/intelrvp/baseboard.h b/baseboard/intelrvp/baseboard.h
index 563be4199f..d57de6e3cd 100644
--- a/baseboard/intelrvp/baseboard.h
+++ b/baseboard/intelrvp/baseboard.h
@@ -73,8 +73,6 @@
* communicate on locked systems (which haven't PD negotiated)
*/
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15001
/* Keyboard */
diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h
index 9b16c9d5e6..9ba11111e8 100644
--- a/baseboard/kukui/baseboard.h
+++ b/baseboard/kukui/baseboard.h
@@ -181,7 +181,6 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000
#define CONFIG_CHARGER_DISCHARGE_ON_AC
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h
index e07fa9166e..059dec29d9 100644
--- a/baseboard/octopus/baseboard.h
+++ b/baseboard/octopus/baseboard.h
@@ -142,7 +142,6 @@
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER
#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_USB_CHARGER
diff --git a/baseboard/trogdor/baseboard.h b/baseboard/trogdor/baseboard.h
index 570bf16f83..398c9cf912 100644
--- a/baseboard/trogdor/baseboard.h
+++ b/baseboard/trogdor/baseboard.h
@@ -86,7 +86,6 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index b3bb89f91d..4ea3d81676 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -122,8 +122,6 @@
* communicate on locked systems (which haven't PD negotiated)
*/
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15001
/* Common battery defines */
diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h
index ea1e19945d..60db6e1cb2 100644
--- a/baseboard/zork/baseboard.h
+++ b/baseboard/zork/baseboard.h
@@ -225,7 +225,6 @@
* CONFIG_CHARGER_LIMIT_* is not set, so there is no additional restriction on
* Depthcharge to boot OS.
*/
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 4
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 50000
/* Increase length of history buffer for port80 messages. */
diff --git a/board/atlas/board.h b/board/atlas/board.h
index 4d0795f8d3..95c9b2d1f8 100644
--- a/board/atlas/board.h
+++ b/board/atlas/board.h
@@ -80,7 +80,6 @@
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_PSYS_READ
diff --git a/board/casta/board.h b/board/casta/board.h
index e931cbd407..934063c548 100644
--- a/board/casta/board.h
+++ b/board/casta/board.h
@@ -33,7 +33,6 @@
* communicate on locked systems (which haven't PD negotiated).
*/
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15001
diff --git a/board/coral/board.h b/board/coral/board.h
index 1fec0ed36c..7f9937af1d 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -60,6 +60,7 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_MAINTAIN_VBAT
+#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_USB_CHARGER
#define CONFIG_CHARGER_PROFILE_OVERRIDE
diff --git a/board/eve/board.h b/board/eve/board.h
index f342af8f55..9f44e8862d 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -103,7 +103,6 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
#define CONFIG_CHARGER_MAINTAIN_VBAT
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PSYS_READ
#define CONFIG_CHARGER_SENSE_RESISTOR 10
diff --git a/board/flapjack/board.h b/board/flapjack/board.h
index 9c47f72d06..527c911cb0 100644
--- a/board/flapjack/board.h
+++ b/board/flapjack/board.h
@@ -69,7 +69,6 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_MT6370
#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000
#define CONFIG_CHARGER_PROFILE_OVERRIDE
diff --git a/board/homestar/board.h b/board/homestar/board.h
index 63cf7a3ad5..1c3a114a71 100644
--- a/board/homestar/board.h
+++ b/board/homestar/board.h
@@ -40,9 +40,6 @@
#define CONFIG_BATTERY_REVIVE_DISCONNECT
#define CONFIG_BATTERY_FUEL_GAUGE
#define CONFIG_BATTERY_VENDOR_PARAM
-#define CONFIG_BATTERY_EXPORT_DISPLAY_SOC
-#undef CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE
-#define CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE 2
/* Enable PD3.0 */
#define CONFIG_USB_PD_REV30
diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h
index 07e85935fc..98ab333b67 100644
--- a/board/mchpevb1/board.h
+++ b/board/mchpevb1/board.h
@@ -154,11 +154,6 @@
/* #define CONFIG_CHARGER_ILIM_PIN_DISABLED */
/* #define CONFIG_CHARGER_INPUT_CURRENT 512 */
-/*
- * MCHP disable this for Kabylake eSPI bring up
- * #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
- */
-
/* #define CONFIG_CHARGER_NARROW_VDC */
/* #define CONFIG_CHARGER_PROFILE_OVERRIDE */
/* #define CONFIG_CHARGER_SENSE_RESISTOR 10 */
diff --git a/board/nami/board.h b/board/nami/board.h
index 40229fe18a..b2bb4c5dae 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -97,9 +97,6 @@
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
-/* EC's thresholds. 3%: boot, 2%: no boot. Required for soft sync. */
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 27000
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
/* AP's thresholds. */
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index 4e79519ee0..858d9b91a2 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -81,7 +81,6 @@
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_SENSE_RESISTOR 10
diff --git a/board/nocturne/board.h b/board/nocturne/board.h
index a686a55e8b..a025f310ae 100644
--- a/board/nocturne/board.h
+++ b/board/nocturne/board.h
@@ -70,6 +70,7 @@
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 128
#define CONFIG_CHARGER_ISL9238
+#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_SENSE_RESISTOR 10
diff --git a/board/poppy/board.h b/board/poppy/board.h
index 7f0b3eb95a..ae134e8b66 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -91,7 +91,6 @@
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/board/rammus/board.h b/board/rammus/board.h
index 9d3662d80c..d2d61e9df9 100644
--- a/board/rammus/board.h
+++ b/board/rammus/board.h
@@ -78,7 +78,6 @@
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/board/reef/board.h b/board/reef/board.h
index ef2957c577..1a003d698b 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -55,6 +55,7 @@
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000
#define CONFIG_CHARGER_MAINTAIN_VBAT
+#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_USB_CHARGER
#define CONFIG_CHARGER_PROFILE_OVERRIDE
diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h
index 9bc9d2249a..3a2668e609 100644
--- a/board/reef_it8320/board.h
+++ b/board/reef_it8320/board.h
@@ -52,6 +52,7 @@
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000
#define CONFIG_CHARGER_MAINTAIN_VBAT
+#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_USB_CHARGER
#define CONFIG_CHARGER_PROFILE_OVERRIDE
diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h
index fedfc82edd..a512f8551d 100644
--- a/board/reef_mchp/board.h
+++ b/board/reef_mchp/board.h
@@ -57,6 +57,7 @@
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000
#define CONFIG_CHARGER_MAINTAIN_VBAT
+#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_USB_CHARGER
#define CONFIG_CHARGER_PROFILE_OVERRIDE
diff --git a/board/samus/board.h b/board/samus/board.h
index 13bedb3ab7..dc72ea9944 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -54,6 +54,7 @@
#define CONFIG_CHARGER_INPUT_CURRENT 320
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM
+#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_FANS 2
#define CONFIG_FAN_UPDATE_PERIOD 10
diff --git a/board/scarlet/board.h b/board/scarlet/board.h
index a39570b817..6d179dfa7c 100644
--- a/board/scarlet/board.h
+++ b/board/scarlet/board.h
@@ -72,7 +72,6 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_RT9467
#define CONFIG_CHARGER_INPUT_CURRENT 512
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000
#define CONFIG_CHARGER_PROFILE_OVERRIDE
diff --git a/board/storo/board.h b/board/storo/board.h
index 48d4882eb4..87525dd071 100644
--- a/board/storo/board.h
+++ b/board/storo/board.h
@@ -18,9 +18,6 @@
/* Battery */
#define CONFIG_BATTERY_FUEL_GAUGE
-#define CONFIG_BATTERY_EXPORT_DISPLAY_SOC
-#undef CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE
-#define CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE 3
/* BC 1.2 */
#define CONFIG_BC12_DETECT_PI3USB9201
diff --git a/common/battery.c b/common/battery.c
index 80a8d4ef89..cff2613668 100644
--- a/common/battery.c
+++ b/common/battery.c
@@ -25,7 +25,6 @@
#define CUTOFFPRINTS(info) CPRINTS("%s %s", "Battery cut off", info)
/* 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;
@@ -627,9 +626,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;
@@ -664,7 +660,7 @@ void battery_compensate_params(struct batt_params *batt)
batt->display_charge = 1000;
}
-#ifdef CONFIG_BATTERY_EXPORT_DISPLAY_SOC
+#ifdef CONFIG_CHARGER
static enum ec_status battery_display_soc(struct host_cmd_handler_args *args)
{
struct ec_response_display_soc *r = args->response;
diff --git a/common/led_onoff_states.c b/common/led_onoff_states.c
index f5db121de0..8d1dce8971 100644
--- a/common/led_onoff_states.c
+++ b/common/led_onoff_states.c
@@ -38,10 +38,7 @@ int charge_get_percent(void);
static int led_get_charge_percent(void)
{
- if (IS_ENABLED(CONFIG_BATTERY_EXPORT_DISPLAY_SOC))
- return DIV_ROUND_NEAREST(charge_get_display_charge(), 10);
- else
- return charge_get_percent();
+ return DIV_ROUND_NEAREST(charge_get_display_charge(), 10);
}
static enum led_states led_get_state(void)
diff --git a/include/config.h b/include/config.h
index 175d64a0bb..661e1de680 100644
--- a/include/config.h
+++ b/include/config.h
@@ -634,61 +634,44 @@
#undef CONFIG_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
/*
- * If remaining capacity is x% of full capacity, remaining capacity is set
- * equal to full capacity.
- *
* Some batteries don't update full capacity timely or don't update it at all.
* On such systems, compensation is required to guarantee remaining_capacity
* will be equal to full_capacity eventually. This used to be done in ACPI.
*
- * When CONFIG_BATTERY_EXPORT_DISPLAY_SOC is enabled, CONFIG_BATT_FULL_FACTOR
- * has no effect. Also CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE is used by Powerd
- * as the threshold for low battery shutdown. For example, if we have:
+ * Powerd uses CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE as the threshold for low
+ * battery shutdown.
+ *
+ * We want to show the low battery alert whenever we can. Thus, we make EC not
+ * inhibit power-on even if it knows the host would immediately shut down. To
+ * get that behavior, we need:
+ *
+ * MIN_BAT_PCT_FOR_POWER_ON < HOST_SHUTDOWN_PER = BATTERY_LEVEL_SHUTDOWN
*
- * CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON = 3
- * CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE = 2,
- * BATTERY_LEVEL_SHUTDOWN = 1
+ * Thus, we set them as follows by default:
*
- * the battery range is divided as follows (assuming system is powered only by
- * internal battery):
+ * 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%)
*
- * 0% ------------------- 1% ------------------- 2% ------------------- 3%
- * EC refuses to boot ->
- * Powerd shuts down system ->
- * EC shuts down system ->
+ * This produces the following behavior:
+ *
+ * - If soc = 1%, system doesn't boot. User wouldn't know why.
+ * - If soc = 2%, system boots. Alert is shown. System immediately shuts down.
+ * - If battery discharges to 2% while the system is running, system shuts down.
+ * If that happens while a user is away, they can press the power button to
+ * learn what happened.
*/
-#define CONFIG_BATT_FULL_FACTOR 98
-#define CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE 4
+#define CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE 2 /* shutdown if soc <= 2% */
/*
* Powerd's full_factor. The value comes from:
* src/platform2/power_manager/default_prefs/power_supply_full_factor
*
- * When CONFIG_BATTERY_EXPORT_DISPLAY_SOC is enabled, this value is exported
- * to the host (i.e. Powerd). It's used to calculate the ETA for full charge.
+ * This value is used by the host to calculate the ETA for full charge.
*/
#define CONFIG_BATT_HOST_FULL_FACTOR 97
/*
- * This option enables EC to be the origin of the display SoC and allows the
- * host (i.e. Powerd) to retrieve it through EC_CMD_DISPLAY_SOC.
- *
- * The display SoC is computed from the remaining capacity, the last full
- * charge, CONFIG_BATT_FULL_FACTOR, CONFIG_BATT_HOST_FULL_FACTOR, and
- * CONFIG_BATT_HOST_SHUTDOWN_PERCENTAGE.
- *
- * If this option is disabled, the EC and the host will individually compute
- * the display SoC, which may result in inconsistent behaviors since the numbers
- * do not necessarily match. As such, this option is going to be enabled by
- * default and the old behavior (#undef CONFIG_BATTERY_EXPORT_DISPLAY_SOC) will
- * be deprecated.
- *
- * TODO: Define CONFIG_BATTERY_EXPORT_DISPLAY_SOC by default and remove
- * CONFIG_BATTERY_EXPORT_DISPLAY_SOC and CONFIG_BATT_FULL_FACTOR.
- */
-#undef CONFIG_BATTERY_EXPORT_DISPLAY_SOC
-
-/*
* Smart battery pass-through host commands.
*/
#undef CONFIG_SB_PASSTHROUGH
@@ -1070,8 +1053,8 @@
* analog signaling. If the AP requires greater than 15W to boot, then see
* CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW.
*/
-#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
-#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
+#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2 /* Don't boot if soc < 2% */
+#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
/* Default: 15000 */
#undef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
/* Default: Disabled */