summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-05-02 01:43:39 +0800
committerChromeBot <chrome-bot@google.com>2013-05-01 13:19:20 -0700
commit73194806034d24594a0ca86fb10867050eba02cc (patch)
treed7345c2a94d294f87d065efee472311f8ff0b2fd
parent7de52688be2f1b06a2cbd61da0f86b5b0c489b7e (diff)
downloadchrome-ec-73194806034d24594a0ca86fb10867050eba02cc.tar.gz
Rename REINIT to IDLE0 in TPS65090 charge state machine
The state REINIT in TPS65090 charge state machine is more like IDLE0 state in charge_state.h. Rename it so that it's less confusing and easier to merge the two state machines in the future. Also move the state name definition to the header file. BUG=chrome-os-partner:18914 TEST=Boot Spring BRANCH=None Change-Id: I116438fedc46ff188dfb6a3964795715b5af4d1f Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/49732 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/lp5562_battery_led.c2
-rw-r--r--common/pmu_tps65090_charger.c40
-rw-r--r--include/pmu_tpschrome.h17
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,