summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2018-05-09 10:54:04 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-05-14 18:56:51 -0700
commitcbe7c128d054dd3c1ff758f84a44fc66a4ab29d5 (patch)
treed9da7a4c292fbce2a92cdd3baa538ddae722b4ec
parent82133f4b1c36f8e890d9ad503c4d75278becced2 (diff)
downloadchrome-ec-cbe7c128d054dd3c1ff758f84a44fc66a4ab29d5.tar.gz
charge_state_v2: Add explicit check for battery disconnect state
The charge_prevent_power_on() function checks for battery presence and its charge level as a condition to prevent AP power on. In order to deal with the short (up to a few seconds) time window where the fuel gauge can be read but the discharge FET is not yet enabled, the status of battery_get_disconnect_state() has been added as a condition to many board's battery_is_present() function. The problem with this approach is that the return value of battery_is_present() is also used by charge_state_v2 as a condition to force the charge state to ST_IDLE. Then, if the config option CONFIG_CHARGER_MAINTAIN_VBAT is not defined, the value of requested current and voltage will be forced to 0 as long as the state remains in ST_IDLE. When the battery is dead or has been cutoff its discharge FET will be disabled. In order to for the discharge FET to be enabled the charger must provide at least a precharge level of current to the battery. But, if the FET status is used as a condition for battery_is_present which in turn forces the charge state to ST_IDLE which can lead to requested_current being forced to 0. This CL enables a way to remove battery_get_disconnect_state() as a condition from battery_is_present and instead call battery_get_disconnect_state() directly in the function charge_prevent_power_on. Therefore AP power can still be gated by the battery FET status, but the charge state will not be stuck in ST_IDLE. This new check is guarded by CONFIG_BATTERY_REVIVE_DISCONNECT. Boards which currently condition battery_is_present on the value of battery_get_disconnect_state() don't change at all, but a board which needs to remove that condition on battery_is_present can still use the FET check to prevent AP power on. BUG=b:79133101 BRANCH=none TEST=Tested on Yorp and verifed that when using either a dead battery or a battery that had been cutoff, prevent_power_on was set to 1 until the FET status was correct for the battery to provide power. Change-Id: Ic27f42610a7b751394b29a013c4dd17030a3df31 Signed-off-by: Scott Collyer <scollyer@google.com> Reviewed-on: https://chromium-review.googlesource.com/1053095 Commit-Ready: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--common/charge_state_v2.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index f5da9b8873..d0f5d30512 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -1866,8 +1866,14 @@ int charge_prevent_power_on(int power_button_pressed)
current_batt_params = &params;
}
- /* Require a minimum battery level to power on */
+ /*
+ * Require a minimum battery level to power on and ensure that the
+ * battery can prvoide power to the system.
+ */
if (current_batt_params->is_present != BP_YES ||
+#ifdef CONFIG_BATTERY_REVIVE_DISCONNECT
+ battery_get_disconnect_state() != BATTERY_NOT_DISCONNECTED ||
+#endif
current_batt_params->state_of_charge <
CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON)
prevent_power_on = 1;