diff options
author | Devin Lu <Devin.Lu@quantatw.com> | 2022-05-05 11:17:30 +0800 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-09 09:53:24 +0000 |
commit | 1ada55a5a0cd164621d387741df87735d8f571ce (patch) | |
tree | 7eadbfeada9247c76a37a970fd6d2c9e584e4031 | |
parent | 17d653cda8c3c38066ff3dd34f369505b8ee3cd5 (diff) | |
download | chrome-ec-1ada55a5a0cd164621d387741df87735d8f571ce.tar.gz |
dojo: Add CONFIG_BATTERY_PRESENT_CUSTOM
This patch fixes the battery cannot resume from battery cut
off. Dojo battery is not responding at resuming from cut off.
Report battery status to BP_NOT_SURE instead of BP_YES at initial.
BUG=b:230411929
BRANCH=firmware-cherry-14454.B-main
TEST=On Dojo. Verified system is able to resume after the battery
is cut off.
Signed-off-by: Devin Lu <Devin.Lu@quantatw.com>
Change-Id: Ia5b1d559025629e05c5e5d94e8e86d819dc85ee7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3627093
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Reviewed-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com>
Tested-by: Tommy Chung <tommy.chung@quanta.corp-partner.google.com>
-rw-r--r-- | board/dojo/battery.c | 55 | ||||
-rw-r--r-- | board/dojo/board.h | 2 |
2 files changed, 57 insertions, 0 deletions
diff --git a/board/dojo/battery.c b/board/dojo/battery.c index 12e6b6aba0..290bf6067c 100644 --- a/board/dojo/battery.c +++ b/board/dojo/battery.c @@ -8,6 +8,7 @@ #include "battery_smart.h" #include "charge_state.h" #include "console.h" +#include "gpio.h" #include "temp_sensor.h" #include "util.h" @@ -206,3 +207,57 @@ enum ec_status charger_profile_override_set_param(uint32_t param, { return EC_RES_INVALID_PARAM; } + +enum battery_present batt_pres_prev = BP_NOT_SURE; + +/* + * Physical detection of battery. + */ +static enum battery_present battery_check_present_status(void) +{ + enum battery_present batt_pres = BP_NOT_SURE; + + /* Get the physical hardware status */ + batt_pres = battery_hw_present(); + + /* + * 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, 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_DISCONNECT_ERROR) + return BP_NOT_SURE; + + /* Ensure the battery is not in cutoff state */ + if (battery_is_cut_off() != BATTERY_CUTOFF_STATE_NORMAL) + return BP_NO; + + return batt_pres; +} + +enum battery_present battery_is_present(void) +{ + batt_pres_prev = battery_check_present_status(); + return batt_pres_prev; +} + +enum battery_present battery_hw_present(void) +{ + return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES; +} diff --git a/board/dojo/board.h b/board/dojo/board.h index e07ec79dd7..734b73bac7 100644 --- a/board/dojo/board.h +++ b/board/dojo/board.h @@ -20,9 +20,11 @@ #define CONFIG_IT83XX_RESET_PD_CONTRACT_IN_BRAM /* Battery */ +#undef CONFIG_BATTERY_PRESENT_GPIO #define CONFIG_BATTERY_V2 #define CONFIG_BATTERY_COUNT 1 #define CONFIG_HOSTCMD_BATTERY_V2 +#define CONFIG_BATTERY_PRESENT_CUSTOM #define CONFIG_BATTERY_VENDOR_PARAM /* BC12 */ |