diff options
-rw-r--r-- | common/lp5562_battery_led.c | 2 | ||||
-rw-r--r-- | common/pmu_tps65090_charger.c | 40 | ||||
-rw-r--r-- | include/pmu_tpschrome.h | 17 |
3 files changed, 33 insertions, 26 deletions
diff --git a/common/lp5562_battery_led.c b/common/lp5562_battery_led.c index 6d038e3d0e..56f41709df 100644 --- a/common/lp5562_battery_led.c +++ b/common/lp5562_battery_led.c @@ -196,7 +196,7 @@ static void battery_led_update(void) /* Discharging with AC, must be battery assist */ state = LED_STATE_BREATHING; break; - case ST_REINIT: + case ST_IDLE0: case ST_BAD_COND: case ST_PRE_CHARGING: state = LED_STATE_SOLID_YELLOW; diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c index f85fe80de4..b5e0ca02cc 100644 --- a/common/pmu_tps65090_charger.c +++ b/common/pmu_tps65090_charger.c @@ -43,21 +43,13 @@ #define BATTERY_AP_OFF_LEVEL 0 #endif -static const char * const state_list[] = { - "idle", - "reinit", - "bad cond", - "pre-charging", - "charging", - "charging error", - "discharging" -}; +static const char * const state_list[] = POWER_STATE_NAME_TABLE; /* States for throttling PMU task */ static timestamp_t last_waken; /* Initialized to 0 */ static int has_pending_event; -static enum charging_state current_state = ST_REINIT; +static enum charging_state current_state = ST_IDLE0; static void enable_charging(int enable) { @@ -103,7 +95,7 @@ static int system_off(void) chipset_force_shutdown(); } - return ST_REINIT; + return ST_IDLE0; } /* @@ -188,7 +180,7 @@ static int calc_next_state(int state) int batt_temp, alarm, capacity, charge; switch (state) { - case ST_REINIT: + case ST_IDLE0: case ST_BAD_COND: case ST_IDLE: /* Check AC and chiset state */ @@ -234,18 +226,18 @@ static int calc_next_state(int state) case ST_PRE_CHARGING: if (!extpower_is_present()) - return ST_REINIT; + return ST_IDLE0; /* If the battery goes online after enable the charger, * go into charging state. */ if (battery_temperature(&batt_temp) == EC_SUCCESS) { if (!battery_start_charging_range(batt_temp)) - return ST_REINIT; + return ST_IDLE0; if (!battery_state_of_charge(&charge)) { config_low_current_charging(charge); if (charge >= 100) - return ST_REINIT; + return ST_IDLE0; } return ST_CHARGING; } @@ -255,7 +247,7 @@ static int calc_next_state(int state) case ST_CHARGING: /* Go back to idle state when AC is unplugged */ if (!extpower_is_present()) - return ST_REINIT; + return ST_IDLE0; /* * Disable charging on battery access error, or charging @@ -264,7 +256,7 @@ static int calc_next_state(int state) if (battery_temperature(&batt_temp)) { CPUTS("[pmu] charging: unable to get battery " "temperature\n"); - return ST_REINIT; + return ST_IDLE0; } else if (!battery_charging_range(batt_temp)) { CPRINTF("[pmu] charging: temperature out of range " "%dC\n", @@ -278,7 +270,7 @@ static int calc_next_state(int state) * - over current */ if (battery_status(&alarm)) - return ST_REINIT; + return ST_IDLE0; if (alarm & ALARM_OVER_TEMP) { CPUTS("[pmu] charging: battery over temp\n"); @@ -296,7 +288,7 @@ static int calc_next_state(int state) */ if (pmu_is_charger_alarm()) { CPUTS("[pmu] charging: charger alarm\n"); - return ST_REINIT; + return ST_IDLE0; } return ST_CHARGING; @@ -325,17 +317,17 @@ static int calc_next_state(int state) return ST_CHARGING; } - return ST_REINIT; + return ST_IDLE0; case ST_DISCHARGING: /* Go back to idle state when AC is plugged */ if (extpower_is_present()) - return ST_REINIT; + return ST_IDLE0; /* Prepare EC sleep after system stopped discharging */ if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) - return ST_REINIT; + return ST_IDLE0; /* Check battery discharging temperature range */ if (battery_temperature(&batt_temp) == 0) { @@ -368,7 +360,7 @@ static int calc_next_state(int state) return ST_DISCHARGING; } - return ST_REINIT; + return ST_IDLE0; } /* TODO: Merge charge_state.h and unify charge interface */ @@ -469,7 +461,7 @@ void charger_task(void) enable_charging(1); break; case ST_IDLE: - case ST_REINIT: + case ST_IDLE0: case ST_BAD_COND: case ST_DISCHARGING: enable_charging(0); diff --git a/include/pmu_tpschrome.h b/include/pmu_tpschrome.h index 744e15c634..58e2288ee6 100644 --- a/include/pmu_tpschrome.h +++ b/include/pmu_tpschrome.h @@ -12,8 +12,8 @@ /* Non-SBS charging states */ enum charging_state { + ST_IDLE0, ST_IDLE, - ST_REINIT, ST_BAD_COND, ST_PRE_CHARGING, ST_CHARGING, @@ -21,6 +21,21 @@ enum charging_state { ST_DISCHARGING, }; +/* Debugging constants, in the same order as enum power_state. This string + * table was moved here to sync with enum above. + */ +#define POWER_STATE_NAME_TABLE \ + { \ + "idle0", \ + "idle", \ + "bad cond", \ + "pre-charging", \ + "charging", \ + "charging error", \ + "discharging" \ + } + /* End of POWER_STATE_NAME_TABLE macro */ + /* JEITA temperature threshold */ enum TPS_TEMPERATURE { TSET_T1, |