summaryrefslogtreecommitdiff
path: root/board/kodama/battery.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/kodama/battery.c')
-rw-r--r--board/kodama/battery.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/board/kodama/battery.c b/board/kodama/battery.c
index 21e5672879..e64e0c167a 100644
--- a/board/kodama/battery.c
+++ b/board/kodama/battery.c
@@ -83,10 +83,37 @@ enum battery_present battery_hw_present(void)
int charger_profile_override(struct charge_state_data *curr)
{
+ const struct battery_info *batt_info = battery_get_info();
+ static int normal_charge_lock, over_discharge_lock;
/* battery temp in 0.1 deg C */
int bat_temp_c = curr->batt.temperature - 2731;
/*
+ * SMP battery uses HW pre-charge circuit and pre-charge current is
+ * limited to ~50mA. Once the charge current is lower than IEOC level
+ * within CHG_TEDG_EOC, and TE is enabled, the charging power path will
+ * be turned off. Disable EOC and TE when battery stays over discharge
+ * state, otherwise enable EOC and TE.
+ */
+ if (curr->batt.voltage < batt_info->voltage_min) {
+ normal_charge_lock = 0;
+
+ if (!over_discharge_lock && curr->state == ST_CHARGE) {
+ over_discharge_lock = 1;
+ rt946x_enable_charge_eoc(0);
+ rt946x_enable_charge_termination(0);
+ }
+ } else {
+ over_discharge_lock = 0;
+
+ if (!normal_charge_lock) {
+ normal_charge_lock = 1;
+ rt946x_enable_charge_eoc(1);
+ rt946x_enable_charge_termination(1);
+ }
+ }
+
+ /*
* When smart battery temperature is more than 45 deg C, the max
* charging voltage is 4100mV.
*/
@@ -107,9 +134,6 @@ int charger_profile_override(struct charge_state_data *curr)
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