summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Yung-Chieh Lo <yjlou@chromium.org>2014-01-03 15:53:55 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-01-07 04:53:20 +0000
commit5a4b239981a76aa9e98325bc082c67cbdfe487de (patch)
treeeda7b0278dff3eaf03a3cba4e4d7ac576edd1a67
parent4e27a42ff9d2b7bb566b6bc455404657a3250c91 (diff)
downloadchrome-ec-5a4b239981a76aa9e98325bc082c67cbdfe487de.tar.gz
rename power_state* to charge_state*
Those are actually charge state, not power state. Rename the misleading names. BUG=chrome-os-partner:24832 BRANCH=link,falco,samus,rambi,peppy,spring,pit,snow TEST=build only because no name conflicts. make clean BOARD=link && make -j32 BOARD=link && \ make clean BOARD=falco && make -j 32 BOARD=falco && \ make clean BOARD=samus && make -j 32 BOARD=samus && \ make clean BOARD=rambi && make -j 32 BOARD=rambi && \ make clean BOARD=peppy && make -j 32 BOARD=peppy && \ make clean BOARD=snow && make -j 32 BOARD=snow && \ make clean BOARD=spring && make -j 32 BOARD=spring && \ make clean BOARD=pit && make -j 32 BOARD=pit && \ make clean BOARD=nyan && make -j 32 BOARD=nyan && \ make runtests -j 32 && make tests -j 32 BOARD=link && \ make tests -j 32 BOARD=falco && make tests -j 32 BOARD=samus && \ make tests -j 32 BOARD=rambi && make tests -j 32 BOARD=peppy && \ make tests -j 32 BOARD=snow && make tests -j 32 BOARD=spring && \ make tests -j 32 BOARD=pit && make tests -j 32 BOARD=nyan Change-Id: Ie15052d5a7dbd97d519303d37260945346a27779 Signed-off-by: Louis Yung-Chieh Lo <yjlou@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/181505 Reviewed-by: Vic Yang <victoryang@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r--common/charge_state.c44
-rw-r--r--common/extpower_falco.c4
-rw-r--r--common/pmu_tps65090_charger.c2
-rw-r--r--include/charge_state.h23
-rw-r--r--include/extpower_falco.h2
-rw-r--r--include/pmu_tpschrome.h5
-rw-r--r--test/adapter.c2
-rw-r--r--test/adapter_externs.h2
-rw-r--r--test/led_spring.c2
-rw-r--r--test/sbs_charging.c4
10 files changed, 44 insertions, 46 deletions
diff --git a/common/charge_state.c b/common/charge_state.c
index d355017191..4539a88626 100644
--- a/common/charge_state.c
+++ b/common/charge_state.c
@@ -35,7 +35,7 @@
#define BATTERY_AP_OFF_LEVEL 0
#endif
-static const char * const state_name[] = POWER_STATE_NAME_TABLE;
+static const char * const state_name[] = CHARGE_STATE_NAME_TABLE;
static int state_machine_force_idle;
@@ -44,16 +44,16 @@ static unsigned user_current_limit = -1U;
static int fake_state_of_charge = -1;
/* Current power state context */
-static struct power_state_context task_ctx;
+static struct charge_state_context task_ctx;
static inline int is_charger_expired(
- struct power_state_context *ctx, timestamp_t now)
+ struct charge_state_context *ctx, timestamp_t now)
{
return now.val - ctx->charger_update_time.val > CHARGER_UPDATE_PERIOD;
}
static inline void update_charger_time(
- struct power_state_context *ctx, timestamp_t now)
+ struct charge_state_context *ctx, timestamp_t now)
{
ctx->charger_update_time.val = now.val;
}
@@ -106,7 +106,7 @@ static void update_battery_info(void)
/**
* Prevent battery from going into deep discharge state
*/
-static void low_battery_shutdown(struct power_state_context *ctx)
+static void low_battery_shutdown(struct charge_state_context *ctx)
{
if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
/* AP is off, so shut down the EC now */
@@ -199,12 +199,12 @@ static int charge_request(int voltage, int current)
* This handler gets battery charging parameters, charger state, ac state, and
* timestamp. It also fills memory map and issues power events on state change.
*/
-static int state_common(struct power_state_context *ctx)
+static int state_common(struct charge_state_context *ctx)
{
int rv, d;
- struct power_state_data *curr = &ctx->curr;
- struct power_state_data *prev = &ctx->prev;
+ struct charge_state_data *curr = &ctx->curr;
+ struct charge_state_data *prev = &ctx->prev;
struct batt_params *batt = &ctx->curr.batt;
uint8_t *batt_flags = ctx->memmap_batt_flags;
@@ -380,7 +380,7 @@ static int state_common(struct power_state_context *ctx)
* - initialize charger
* - new states: DISCHARGE, IDLE
*/
-static enum power_state state_init(struct power_state_context *ctx)
+static enum charge_state state_init(struct charge_state_context *ctx)
{
/* Stop charger, unconditionally */
charge_request(0, 0);
@@ -416,7 +416,7 @@ static enum power_state state_init(struct power_state_context *ctx)
* - detect charger and battery status change
* - new states: CHARGE, INIT
*/
-static enum power_state state_idle(struct power_state_context *ctx)
+static enum charge_state state_idle(struct charge_state_context *ctx)
{
struct batt_params *batt = &ctx->curr.batt;
@@ -466,9 +466,9 @@ static enum power_state state_idle(struct power_state_context *ctx)
* - detect battery status change
* - new state: INIT
*/
-static enum power_state state_charge(struct power_state_context *ctx)
+static enum charge_state state_charge(struct charge_state_context *ctx)
{
- struct power_state_data *curr = &ctx->curr;
+ struct charge_state_data *curr = &ctx->curr;
struct batt_params *batt = &ctx->curr.batt;
int debounce = 0;
int want_current;
@@ -552,7 +552,7 @@ static enum power_state state_charge(struct power_state_context *ctx)
* - detect ac status
* - new state: INIT
*/
-static enum power_state state_discharge(struct power_state_context *ctx)
+static enum charge_state state_discharge(struct charge_state_context *ctx)
{
struct batt_params *batt = &ctx->curr.batt;
int8_t bat_temp_c = DECI_KELVIN_TO_CELSIUS(batt->temperature);
@@ -580,7 +580,7 @@ static enum power_state state_discharge(struct power_state_context *ctx)
* - log error
* - new state: INIT
*/
-static enum power_state state_error(struct power_state_context *ctx)
+static enum charge_state state_error(struct charge_state_context *ctx)
{
static int logged_error;
@@ -608,7 +608,7 @@ static enum power_state state_error(struct power_state_context *ctx)
/**
* Print charging progress
*/
-static void charging_progress(struct power_state_context *ctx)
+static void charging_progress(struct charge_state_context *ctx)
{
int seconds, minutes;
@@ -641,7 +641,7 @@ static void charging_progress(struct power_state_context *ctx)
}
}
-enum power_state charge_get_state(void)
+enum charge_state charge_get_state(void)
{
return task_ctx.curr.state;
}
@@ -689,10 +689,10 @@ static int charge_force_idle(int enable)
*/
void charger_task(void)
{
- struct power_state_context *ctx = &task_ctx;
+ struct charge_state_context *ctx = &task_ctx;
timestamp_t ts;
int sleep_usec = POLL_PERIOD_SHORT, diff_usec, sleep_next;
- enum power_state new_state;
+ enum charge_state new_state;
uint8_t batt_flags;
while (1) {
@@ -700,7 +700,7 @@ void charger_task(void)
#ifdef CONFIG_CHARGER_TIMEOUT_HOURS
if (ctx->curr.state == PWR_STATE_CHARGE &&
- ctx->power_state_updated_time.val +
+ ctx->charge_state_updated_time.val +
CONFIG_CHARGER_TIMEOUT_HOURS * HOUR < ctx->curr.ts.val) {
CPRINTF("[%T Charge timed out after %d hours]\n",
CONFIG_CHARGER_TIMEOUT_HOURS);
@@ -767,8 +767,8 @@ void charger_task(void)
state_name[ctx->prev.state],
state_name[new_state],
ctx->curr.ts.val -
- ctx->power_state_updated_time.val);
- ctx->power_state_updated_time = ctx->curr.ts;
+ ctx->charge_state_updated_time.val);
+ ctx->charge_state_updated_time = ctx->curr.ts;
hook_notify(HOOK_CHARGE_STATE_CHANGE);
}
@@ -877,7 +877,7 @@ DECLARE_HOOK(HOOK_AC_CHANGE, charge_hook, HOOK_PRIO_DEFAULT);
static void charge_init(void)
{
- struct power_state_context *ctx = &task_ctx;
+ struct charge_state_context *ctx = &task_ctx;
ctx->prev.state = PWR_STATE_INIT;
ctx->curr.state = PWR_STATE_INIT;
diff --git a/common/extpower_falco.c b/common/extpower_falco.c
index 815d76edfb..664f2abe12 100644
--- a/common/extpower_falco.c
+++ b/common/extpower_falco.c
@@ -251,7 +251,7 @@ void check_threshold(int current, struct adapter_limits *lim, int whoami)
test_export_static
-void watch_battery_closely(struct power_state_context *ctx)
+void watch_battery_closely(struct charge_state_context *ctx)
{
int i;
int current = ctx->curr.batt.current;
@@ -275,7 +275,7 @@ void watch_battery_closely(struct power_state_context *ctx)
i + BATT_REASON_OFFSET);
}
-void watch_adapter_closely(struct power_state_context *ctx)
+void watch_adapter_closely(struct charge_state_context *ctx)
{
int current, i;
diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c
index d7d70c14c6..a55edfc426 100644
--- a/common/pmu_tps65090_charger.c
+++ b/common/pmu_tps65090_charger.c
@@ -44,7 +44,7 @@
#define BATTERY_AP_OFF_LEVEL 0
#endif
-static const char * const state_list[] = POWER_STATE_NAME_TABLE;
+static const char * const state_list[] = CHARGE_STATE_NAME_TABLE;
/* States for throttling PMU task */
static timestamp_t last_waken; /* Initialized to 0 */
diff --git a/include/charge_state.h b/include/charge_state.h
index 5a176c1b40..7aaf77b93d 100644
--- a/include/charge_state.h
+++ b/include/charge_state.h
@@ -41,7 +41,7 @@
F_CHARGER_INIT)
/* Power states */
-enum power_state {
+enum charge_state {
/* Meta-state; unchanged from previous time through task loop */
PWR_STATE_UNCHANGE = 0,
/* Initializing charge state machine at boot */
@@ -68,11 +68,10 @@ enum power_state {
/* External (AC) power is present */
#define CHARGE_FLAG_EXTERNAL_POWER (1 << 1)
-/* Debugging constants, in the same order as enum power_state. This string
+/* Debugging constants, in the same order as enum charge_state. This string
* table was moved here to sync with enum above.
*/
-#define POWER_STATE_NAME_TABLE \
- { \
+#define CHARGE_STATE_NAME_TABLE { \
"unchange", \
"init", \
"reinit", \
@@ -83,17 +82,17 @@ enum power_state {
"charge_near_full", \
"error" \
}
- /* End of POWER_STATE_NAME_TABLE macro */
+ /* End of CHARGE_STATE_NAME_TABLE macro */
/* Power state data
* Status collection of charging state machine.
*/
-struct power_state_data {
+struct charge_state_data {
int ac;
int charging_voltage;
int charging_current;
struct batt_params batt;
- enum power_state state;
+ enum charge_state state;
uint32_t error;
timestamp_t ts;
};
@@ -102,10 +101,10 @@ struct power_state_data {
* The shared context for state handler. The context contains current and
* previous state.
*/
-struct power_state_context {
- struct power_state_data curr;
- struct power_state_data prev;
- timestamp_t power_state_updated_time;
+struct charge_state_context {
+ struct charge_state_data curr;
+ struct charge_state_data prev;
+ timestamp_t charge_state_updated_time;
uint32_t *memmap_batt_volt;
uint32_t *memmap_batt_rate;
uint32_t *memmap_batt_cap;
@@ -124,7 +123,7 @@ struct power_state_context {
/**
* Return current charge state.
*/
-enum power_state charge_get_state(void);
+enum charge_state charge_get_state(void);
/**
* Return current charge state flags (CHARGE_FLAG_*)
diff --git a/include/extpower_falco.h b/include/extpower_falco.h
index 74d51f5acd..b5cbbcdc8d 100644
--- a/include/extpower_falco.h
+++ b/include/extpower_falco.h
@@ -41,6 +41,6 @@ struct adapter_limits {
#define NUM_BATT_THRESHOLDS 2
/* Change turbo mode or throttle the AP depending on the adapter state. */
-void watch_adapter_closely(struct power_state_context *ctx);
+void watch_adapter_closely(struct charge_state_context *ctx);
#endif /* __CROS_EC_EXTPOWER_FALCO_H */
diff --git a/include/pmu_tpschrome.h b/include/pmu_tpschrome.h
index 7c610a01b6..dc20aa8fd8 100644
--- a/include/pmu_tpschrome.h
+++ b/include/pmu_tpschrome.h
@@ -24,8 +24,7 @@ enum charging_state {
/* 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 \
- { \
+#define CHARGE_STATE_NAME_TABLE { \
"idle0", \
"idle", \
"bad cond", \
@@ -34,7 +33,7 @@ enum charging_state {
"charging error", \
"discharging" \
}
- /* End of POWER_STATE_NAME_TABLE macro */
+ /* End of CHARGE_STATE_NAME_TABLE macro */
/* JEITA temperature threshold */
enum TPS_TEMPERATURE {
diff --git a/test/adapter.c b/test/adapter.c
index f64197b387..2bfd570bd0 100644
--- a/test/adapter.c
+++ b/test/adapter.c
@@ -24,7 +24,7 @@
/* Local state */
static int mock_id;
static int mock_current;
-static struct power_state_context ctx;
+static struct charge_state_context ctx;
static void test_reset_mocks(void)
{
diff --git a/test/adapter_externs.h b/test/adapter_externs.h
index 9cb7c562b3..c866b23c1b 100644
--- a/test/adapter_externs.h
+++ b/test/adapter_externs.h
@@ -16,6 +16,6 @@ extern int ac_turbo;
extern int ap_is_throttled;
extern void check_threshold(int current, struct adapter_limits *lim);
extern struct adapter_limits batt_limits[NUM_BATT_THRESHOLDS];
-extern void watch_battery_closely(struct power_state_context *ctx);
+extern void watch_battery_closely(struct charge_state_context *ctx);
#endif /* __ADAPTER_EXTERNS_H */
diff --git a/test/led_spring.c b/test/led_spring.c
index e5778b4690..e1170a7992 100644
--- a/test/led_spring.c
+++ b/test/led_spring.c
@@ -26,7 +26,7 @@ static uint8_t lp5562_reg[LP5562_NUM_WATCH_REG];
static enum charging_state mock_charge_state = ST_IDLE;
static int lp5562_failed_i2c_reg = -1;
-static const char * const state_names[] = POWER_STATE_NAME_TABLE;
+static const char * const state_names[] = CHARGE_STATE_NAME_TABLE;
/*****************************************************************************/
/* Mock functions */
diff --git a/test/sbs_charging.c b/test/sbs_charging.c
index 77a6237394..1e068cd22a 100644
--- a/test/sbs_charging.c
+++ b/test/sbs_charging.c
@@ -67,7 +67,7 @@ static void test_setup(void)
static int wait_charging_state(void)
{
- enum power_state state;
+ enum charge_state state;
task_wake(TASK_ID_CHARGER);
msleep(WAIT_CHARGER_TASK);
state = charge_get_state();
@@ -85,7 +85,7 @@ static int charge_control(enum ec_charge_control_mode mode)
static int test_charge_state(void)
{
- enum power_state state;
+ enum charge_state state;
state = wait_charging_state();
/* Plug AC, charging at 1000mAh */