diff options
author | David Huang <david.huang@quanta.corp-partner.google.com> | 2020-02-26 16:04:14 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-17 10:35:16 +0000 |
commit | e54818593e239ea60cde55736c4dc55864508994 (patch) | |
tree | 21f56cce6d5d456f443b7a9082c176648c523fcc /board/jacuzzi | |
parent | 57d7636cb077c4b5d1fbcf2dd0f0a912203b2867 (diff) | |
download | chrome-ec-e54818593e239ea60cde55736c4dc55864508994.tar.gz |
Juniper: Return BP_NOT_SURE when DFET status is off
Make battery_is_present and battery_check_present_status overridable
for customize by device.
Do not return BP_NO when DFET status is off.
Battery might need more charge time to wake up from shutdown.
Return BP_NOT_SURE to keep charge battery.
BUG=b:149971271
BRANCH=jacuzzi
TEST=Insert UVP/shutdown battery and check battery resume normally.
Change-Id: I68841e4e6e0457711fc4f43e6346b54805b7217c
Signed-off-by: David Huang <david.huang@quanta.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2091131
Reviewed-by: Eric Yilun Lin <yllin@chromium.org>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'board/jacuzzi')
-rw-r--r-- | board/jacuzzi/battery.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/board/jacuzzi/battery.c b/board/jacuzzi/battery.c index 7fd56ea7a3..4f8ae97451 100644 --- a/board/jacuzzi/battery.c +++ b/board/jacuzzi/battery.c @@ -3,6 +3,7 @@ * found in the LICENSE file. */ +#include "baseboard/kukui/battery_smart.h" #include "battery.h" #include "battery_fuel_gauge.h" #include "gpio.h" @@ -99,3 +100,51 @@ enum battery_present battery_hw_present(void) { return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES; } + +/* + * Physical detection of battery. + */ +__override enum battery_present battery_check_present_status(void) +{ + enum battery_present batt_pres = BP_NOT_SURE; + +#ifdef CONFIG_BATTERY_HW_PRESENT_CUSTOM + /* Get the physical hardware status */ + batt_pres = battery_hw_present(); +#endif + + /* + * If the battery is not physically connected, then no need to perform + * any more checks. + */ + if (batt_pres == BP_NO) + return batt_pres; + + /* + * If the battery is present now and was present last time we checked, + * return early. + */ + if (batt_pres == batt_pres_prev) + return batt_pres; + + /* + * Check battery disconnect status. If we are unable to read battery + * disconnect status or DFET is off, then return BP_NOT_SURE. Battery + * could be in ship mode and might require pre-charge current to wake + * it up. BP_NO is not returned here because charger state machine + * will not provide pre-charge current assuming that battery is not + * present. + */ + if (battery_get_disconnect_state() != BATTERY_NOT_DISCONNECTED) + return BP_NOT_SURE; + + /* + * Ensure that battery is: + * 1. Not in cutoff + */ + if (battery_is_cut_off() != BATTERY_CUTOFF_STATE_NORMAL) + return BP_NO; + + return batt_pres; +} + |