summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/samus/board.h2
-rw-r--r--common/charge_state_v2.c15
-rw-r--r--driver/battery/smart.c13
-rw-r--r--include/config.h7
4 files changed, 37 insertions, 0 deletions
diff --git a/board/samus/board.h b/board/samus/board.h
index 36e83f68c7..b914964e78 100644
--- a/board/samus/board.h
+++ b/board/samus/board.h
@@ -29,6 +29,8 @@
/* Note: not CONFIG_BACKLIGHT_LID. It's handled specially for Samus. */
#define CONFIG_BACKLIGHT_REQ_GPIO GPIO_PCH_BL_EN
#define CONFIG_BATTERY_SAMUS
+/* TODO(crosbug.com/p/29467): remove this workaround when possible. */
+#define CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_BATTERY_SMART
#define CONFIG_CHARGER
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 4a58aae54f..87ad28561b 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -570,6 +570,21 @@ void charger_task(void)
goto wait_for_it;
} else {
/* The battery is responding. Yay. Try to use it. */
+#ifdef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
+ /*
+ * TODO (crosbug.com/p/29467): remove this workaround
+ * for dead battery that requests no voltage/current
+ */
+ if (curr.requested_voltage == 0 &&
+ curr.requested_current == 0 &&
+ curr.batt.state_of_charge == 0) {
+ /* Battery is dead, give precharge current */
+ curr.requested_voltage =
+ batt_info->voltage_max;
+ curr.requested_current =
+ batt_info->precharge_current;
+ } else
+#endif
if (curr.state == ST_PRECHARGE ||
battery_seems_to_be_dead) {
CPRINTS("battery woke up");
diff --git a/driver/battery/smart.c b/driver/battery/smart.c
index 52e61a8699..6dcedfd81f 100644
--- a/driver/battery/smart.c
+++ b/driver/battery/smart.c
@@ -300,9 +300,22 @@ void battery_get_params(struct batt_params *batt)
if (!(batt_new.flags & (BATT_FLAG_BAD_DESIRED_VOLTAGE |
BATT_FLAG_BAD_DESIRED_CURRENT |
BATT_FLAG_BAD_STATE_OF_CHARGE)) &&
+#ifdef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
+ /*
+ * TODO (crosbug.com/p/29467): remove this workaround
+ * for dead battery that requests no voltage/current
+ */
+ ((batt_new.desired_voltage &&
+ batt_new.desired_current &&
+ batt_new.state_of_charge < BATTERY_LEVEL_FULL) ||
+ (batt_new.desired_voltage == 0 &&
+ batt_new.desired_current == 0 &&
+ batt_new.state_of_charge == 0)))
+#else
batt_new.desired_voltage &&
batt_new.desired_current &&
batt_new.state_of_charge < BATTERY_LEVEL_FULL)
+#endif
batt_new.flags |= BATT_FLAG_WANT_CHARGE;
else
/* Force both to zero */
diff --git a/include/config.h b/include/config.h
index 86b43d2509..464ad50953 100644
--- a/include/config.h
+++ b/include/config.h
@@ -143,6 +143,13 @@
*/
#undef CONFIG_BATTERY_VENDOR_PARAM
+/*
+ * TODO(crosbug.com/p/29467): allows charging of a dead battery that
+ * requests nil for current and voltage. Remove this workaround when
+ * possible.
+ */
+#undef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
+
/*****************************************************************************/
/*