summaryrefslogtreecommitdiff
path: root/baseboard/brya
diff options
context:
space:
mode:
authorCaveh Jalali <caveh@chromium.org>2021-03-16 22:34:35 -0700
committerCommit Bot <commit-bot@chromium.org>2021-03-18 01:28:56 +0000
commitd0f0fd2d6f165c4a4147ca82d4d96d16bbd8a6d7 (patch)
tree6a1116f50a57acca23ce67ac25d90a841dd11b8a /baseboard/brya
parent74e10b1d5d6f7b346cd61a408a6d699b2572b95c (diff)
downloadchrome-ec-d0f0fd2d6f165c4a4147ca82d4d96d16bbd8a6d7.tar.gz
brya: Fix battery wake-up logic
This fixes a circular dependency in waking up a battery after cut-off (ship mode). Previously, we would report the battery as not present when we failed to talk to the battery. This would prevent the charger task from attempting to wake up the battery (i.e. enable pre-charge current). Without pre-charge current, we can not talk to a cut-off battery and would never be able to satisfy the conditions required to turn on the battery. The solution is to report BP_NOT_SURE back to the charger state machine so that it enters the pre-charge state when we can not talk to the battery. BRANCH=none BUG=b:180784200,b:181842699 TEST=cutoff battery from EC and reboot, observe battery wakes up. Change-Id: Ib63167626dd7def685379fe718b3fadd043a341b Signed-off-by: Caveh Jalali <caveh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2766484
Diffstat (limited to 'baseboard/brya')
-rw-r--r--baseboard/brya/battery_presence.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/baseboard/brya/battery_presence.c b/baseboard/brya/battery_presence.c
index 1bd8f7cabd..4fc8060de6 100644
--- a/baseboard/brya/battery_presence.c
+++ b/baseboard/brya/battery_presence.c
@@ -20,29 +20,23 @@ enum battery_present battery_hw_present(void)
return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES;
}
-static bool battery_init(void)
+__overridable bool board_battery_is_initialized(void)
{
int batt_status;
- return battery_status(&batt_status) ? 0 :
+ return battery_status(&batt_status) != EC_SUCCESS ? false :
!!(batt_status & STATUS_INITIALIZED);
}
-__overridable bool board_battery_is_initialized(void)
-{
- /*
- * Set default to return true
- */
- return true;
-}
-
/*
* Physical detection of battery.
*/
static enum battery_present battery_check_present_status(void)
{
enum battery_present batt_pres;
- bool batt_initialization_state;
+
+ if (battery_is_cut_off())
+ return BP_NO;
/* Get the physical hardware status */
batt_pres = battery_hw_present();
@@ -51,15 +45,15 @@ static enum battery_present battery_check_present_status(void)
* If the battery is not physically connected, then no need to perform
* any more checks.
*/
- if (batt_pres != BP_YES)
- return batt_pres;
+ if (batt_pres == BP_NO)
+ return BP_NO;
/*
* If the battery is present now and was present last time we checked,
* return early.
*/
- if (batt_pres == batt_pres_prev)
- return batt_pres;
+ if ((batt_pres == BP_YES) && (batt_pres == batt_pres_prev))
+ return BP_YES;
/*
* Check battery initialization. If the battery is not initialized,
@@ -68,18 +62,10 @@ static enum battery_present battery_check_present_status(void)
* returned here because charger state machine will not provide
* pre-charge current assuming that battery is not present.
*/
- batt_initialization_state = board_battery_is_initialized();
- if (!batt_initialization_state)
+ if (!board_battery_is_initialized())
return BP_NOT_SURE;
- /*
- * Ensure that battery is:
- * 1. Not in cutoff
- * 2. Initialized
- */
- if (battery_is_cut_off() || !battery_init())
- batt_pres = BP_NO;
- return batt_pres;
+ return BP_YES;
}
enum battery_present battery_is_present(void)