summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Chao <scott_chao@wistron.corp-partner.google.com>2020-09-14 17:24:41 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-21 19:13:57 +0000
commitc6e2ac5ba87352505985c6f374c142fa6189b5ac (patch)
treeddbcfe88825a600ac79af706033c64de532dbbe5
parentdb78abe0160364bf075e1595850407dfdd182297 (diff)
downloadchrome-ec-c6e2ac5ba87352505985c6f374c142fa6189b5ac.tar.gz
eldrid: fix battery cutoff
Eldrid's battery need to apply charging voltage input>3V and aleast 2 sec to let C/D FET will turn on. So add board_battery_is_initialized to check battery initialization. And try to provide pre-charge current to battery when battery have no response. BUG=b:165780074 BRANCH=none TEST=make -j BOARD=eldrid TEST=make buildall Signed-off-by: Scott Chao <scott_chao@wistron.corp-partner.google.com> Change-Id: I4265538b5a789b76a85d21a1459d19142a86106e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2409712 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--baseboard/volteer/baseboard.h9
-rw-r--r--baseboard/volteer/battery_presence.c19
-rw-r--r--board/eldrid/battery.c12
3 files changed, 40 insertions, 0 deletions
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index b4d0645e3b..004e85bcae 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_BASEBOARD_H
#define __CROS_EC_BASEBOARD_H
+#include <stdbool.h>
+
/*
* By default, enable all console messages excepted HC
*/
@@ -266,6 +268,13 @@ unsigned char get_board_id(void);
*/
__override_proto void board_cbi_init(void);
+/*
+ * Check battery disconnect state.
+ * This function will return if battery is initialized or not.
+ * @return true - initialized. false - not.
+ */
+__override_proto bool board_battery_is_initialized(void);
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BASEBOARD_H */
diff --git a/baseboard/volteer/battery_presence.c b/baseboard/volteer/battery_presence.c
index 0d6590011f..4953d7a49e 100644
--- a/baseboard/volteer/battery_presence.c
+++ b/baseboard/volteer/battery_presence.c
@@ -28,12 +28,21 @@ static bool battery_init(void)
!!(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;
/* Get the physical hardware status */
batt_pres = battery_hw_present();
@@ -53,6 +62,16 @@ static enum battery_present battery_check_present_status(void)
return batt_pres;
/*
+ * Check battery initialization. If the battery is not initialized,
+ * 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.
+ */
+ batt_initialization_state = board_battery_is_initialized();
+ if (!batt_initialization_state)
+ return BP_NOT_SURE;
+ /*
* Ensure that battery is:
* 1. Not in cutoff
* 2. Initialized
diff --git a/board/eldrid/battery.c b/board/eldrid/battery.c
index 01c2937fe0..3c9f2b0c21 100644
--- a/board/eldrid/battery.c
+++ b/board/eldrid/battery.c
@@ -5,7 +5,9 @@
* Battery pack vendor provided charging profile
*/
+#include "battery.h"
#include "battery_fuel_gauge.h"
+#include "battery_smart.h"
#include "common.h"
#include "util.h"
@@ -92,3 +94,13 @@ const struct board_batt_params board_battery_info[] = {
BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_SIMPLO_HIGHPOWER;
+
+__override bool board_battery_is_initialized(void)
+{
+ bool batt_initialization_state;
+ int batt_status;
+
+ batt_initialization_state = (battery_status(&batt_status) ? false :
+ !!(batt_status & STATUS_INITIALIZED));
+ return batt_initialization_state;
+}