mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-08 16:41:55 +00:00
Handle battery charged alarm
When battery flags TERMINATE_CHARGE or OVER_CHARGED alarm, we should
treat them as a signal of battery fully charged.
BUG=chrome-os-partner:18914
TEST=On Spring:
1. Plug in adapter when battery if full, see green LED.
2. Plug in adapter when battery is not full, see yellow LED.
BRANCH=spring
Change-Id: Ica414a0e1667b8f30a0cc9a5d66dba1b119a59ba
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49456
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
@@ -24,9 +24,7 @@
|
||||
|
||||
/* Charging and discharging alarms */
|
||||
#define ALARM_DISCHARGING (ALARM_TERMINATE_DISCHARGE | ALARM_OVER_TEMP)
|
||||
#define ALARM_CHARGING (ALARM_TERMINATE_CHARGE | \
|
||||
ALARM_OVER_CHARGED | \
|
||||
ALARM_OVER_TEMP)
|
||||
#define ALARM_CHARGED (ALARM_OVER_CHARGED | ALARM_TERMINATE_CHARGE)
|
||||
|
||||
/* Maximum time allowed to revive a extremely low charge battery */
|
||||
#define PRE_CHARGING_TIMEOUT (15 * SECOND)
|
||||
@@ -217,10 +215,14 @@ static int calc_next_state(int state)
|
||||
if (!battery_start_charging_range(batt_temp))
|
||||
return ST_BAD_COND;
|
||||
|
||||
/* Turn off charger on battery charging alarm */
|
||||
if (battery_status(&alarm) || (alarm & ALARM_CHARGING))
|
||||
/* Turn off charger on battery over temperature alarm */
|
||||
if (battery_status(&alarm) || (alarm & ALARM_OVER_TEMP))
|
||||
return ST_BAD_COND;
|
||||
|
||||
/* Stop charging if the battery says it's charged */
|
||||
if (alarm & ALARM_CHARGED)
|
||||
return ST_IDLE;
|
||||
|
||||
/* Start charging only when battery charge lower than 100% */
|
||||
if (!battery_state_of_charge(&charge)) {
|
||||
config_low_current_charging(charge);
|
||||
@@ -278,13 +280,15 @@ static int calc_next_state(int state)
|
||||
if (battery_status(&alarm))
|
||||
return ST_REINIT;
|
||||
|
||||
if (alarm & ALARM_CHARGING) {
|
||||
CPUTS("[pmu] charging: battery alarm\n");
|
||||
if (alarm & ALARM_OVER_TEMP)
|
||||
return ST_CHARGING_ERROR;
|
||||
return ST_REINIT;
|
||||
if (alarm & ALARM_OVER_TEMP) {
|
||||
CPUTS("[pmu] charging: battery over temp\n");
|
||||
return ST_CHARGING_ERROR;
|
||||
}
|
||||
|
||||
/* Go to idle state if battery is fully charged */
|
||||
if (alarm & ALARM_CHARGED)
|
||||
return ST_IDLE;
|
||||
|
||||
/*
|
||||
* Disable charging on charger alarm events:
|
||||
* - charger over current
|
||||
|
||||
Reference in New Issue
Block a user