summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/kodama/battery.c30
-rw-r--r--board/kodama/board.h1
2 files changed, 29 insertions, 2 deletions
diff --git a/board/kodama/battery.c b/board/kodama/battery.c
index 28086d317b..62b0c85610 100644
--- a/board/kodama/battery.c
+++ b/board/kodama/battery.c
@@ -16,8 +16,6 @@
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
-#define BAT_LEVEL_PD_LIMIT 85
-
const struct board_batt_params board_battery_info[] = {
[BATTERY_SIMPLO] = {
.fuel_gauge = {
@@ -89,6 +87,34 @@ int charger_profile_override(struct charge_state_data *curr)
mt6370_charger_profile_override(curr);
#endif /* CONFIG_CHARGER_MT6370 */
+ if (IS_ENABLED(CONFIG_CHARGER_MAINTAIN_VBAT)) {
+ /* Turn charger off if it's not needed */
+ if (curr->state == ST_IDLE || curr->state == ST_DISCHARGE) {
+ curr->requested_voltage = 0;
+ curr->requested_current = 0;
+ }
+
+ if (!curr->batt.is_present &&
+ curr->requested_voltage == 0 &&
+ curr->requested_current == 0) {
+ const struct battery_info *batt_info =
+ battery_get_info();
+
+ /*
+ * b/138978212: With adapter plugged in S0, the system
+ * will set charging current and voltage as 0V/0A once
+ * removing battery. Vsys drop to lower voltage
+ * (Vsys < 2.5V) since Vsys's loading, then system will
+ * shutdown. Keep max charging voltage as 4.4V when
+ * remove battery in S0 to not let the system to trigger
+ * under voltage (Vsys < 2.5V).
+ */
+ CPRINTS("battery disconnected");
+ curr->requested_voltage = batt_info->voltage_max;
+ curr->requested_current = 500;
+ }
+ }
+
return 0;
}
diff --git a/board/kodama/board.h b/board/kodama/board.h
index 771bf5f81e..ff71117cb9 100644
--- a/board/kodama/board.h
+++ b/board/kodama/board.h
@@ -35,6 +35,7 @@
#endif /* BOARD_KRANE */
#define CONFIG_CHARGER_MT6370_BACKLIGHT
+#define CONFIG_CHARGER_MAINTAIN_VBAT
/* Motion Sensors */
#ifdef SECTION_IS_RW