diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-12-02 13:12:31 -0800 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2013-12-03 07:28:50 +0000 |
commit | 3b0a4055d17c17e4ee8df474858b40ffda518c31 (patch) | |
tree | 11f34c41666d8532ad012affea817402d6a75696 | |
parent | a35f1b78417edab1150f1eb68b5d4dee7708dfc8 (diff) | |
download | chrome-ec-3b0a4055d17c17e4ee8df474858b40ffda518c31.tar.gz |
Move battery temp ranges to battery_info struct
This allows boards to detect the battery and return the correct temp
ranges, which will be needed for upcoming boards.
In the board-specific implementations, it's pretty much just moving
the fields from one const struct to another, so the impact is minor.
BUG=chrome-os-partner:24310
BRANCH=none
TEST=build all platforms; verify pit and rambi still charge
Change-Id: I7be075b3abb4039577f6362316adc1860c121d5c
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/178424
Reviewed-by: Yung-chieh Lo <yjlou@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
-rw-r--r-- | board/falco/battery.c | 16 | ||||
-rw-r--r-- | board/host/battery.c | 27 | ||||
-rw-r--r-- | board/nyan/battery.c | 30 | ||||
-rw-r--r-- | board/peppy/battery.c | 16 | ||||
-rw-r--r-- | board/pit/board.c | 7 | ||||
-rw-r--r-- | board/rambi/battery.c | 13 | ||||
-rw-r--r-- | board/snow/board.c | 7 | ||||
-rw-r--r-- | board/spring/battery.c | 7 | ||||
-rw-r--r-- | common/charge_state.c | 4 | ||||
-rw-r--r-- | common/pmu_tps65090_charger.c | 18 | ||||
-rw-r--r-- | driver/battery/link.c | 15 | ||||
-rw-r--r-- | include/battery.h | 18 |
12 files changed, 90 insertions, 88 deletions
diff --git a/board/falco/battery.c b/board/falco/battery.c index ea8e718110..b2dd7fc00d 100644 --- a/board/falco/battery.c +++ b/board/falco/battery.c @@ -11,15 +11,6 @@ #define SB_SHIP_MODE_DATA 0x0010 -const struct battery_temperature_ranges bat_temp_ranges = { - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 45, - .discharging_min_c = -10, - .discharging_max_c = 60, -}; - static const struct battery_info info = { .voltage_max = 8400, @@ -28,6 +19,13 @@ static const struct battery_info info = { /* Pre-charge values. */ .precharge_current = 256, /* mA */ + + .start_charging_min_c = 0, + .start_charging_max_c = 45, + .charging_min_c = 0, + .charging_max_c = 45, + .discharging_min_c = -10, + .discharging_max_c = 60, }; const struct battery_info *battery_get_info(void) diff --git a/board/host/battery.c b/board/host/battery.c index 02fc263fc1..85173f8378 100644 --- a/board/host/battery.c +++ b/board/host/battery.c @@ -51,21 +51,6 @@ int battery_time_at_rate(int rate, int *minutes) return EC_SUCCESS; } -/* Fake battery */ -const struct battery_temperature_ranges bat_temp_ranges = { - /* - * Operational temperature range - * 0 <= T_charge <= 50 deg C - * -20 <= T_discharge <= 60 deg C - */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 50, - .discharging_min_c = -20, - .discharging_max_c = 60, -}; - static const struct battery_info bat_info = { /* * Design voltage @@ -79,6 +64,18 @@ static const struct battery_info bat_info = { /* Pre-charge current: I <= 0.01C */ .precharge_current = 64, /* mA */ + + /* + * Operational temperature range + * 0 <= T_charge <= 50 deg C + * -20 <= T_discharge <= 60 deg C + */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 50, + .discharging_min_c = -20, + .discharging_max_c = 60, }; const struct battery_info *battery_get_info(void) diff --git a/board/nyan/battery.c b/board/nyan/battery.c index 12911de286..8e46df4e59 100644 --- a/board/nyan/battery.c +++ b/board/nyan/battery.c @@ -47,20 +47,6 @@ static const int const current_limit[TEMP_RANGE_MAX][VOLT_RANGE_MAX] = { { 800, 1600, 800}, }; -const struct battery_temperature_ranges bat_temp_ranges = { - /* - * Operational temperature range - * 0 <= T_charge <= 50 deg C - * -20 <= T_discharge <= 60 deg C - */ - .start_charging_min_c = 0, - .start_charging_max_c = 50, - .charging_min_c = 0, - .charging_max_c = 50, - .discharging_min_c = -20, - .discharging_max_c = 60, -}; - static const struct battery_info info = { /* * Design voltage @@ -74,6 +60,18 @@ static const struct battery_info info = { /* Pre-charge current: I <= 0.01C */ .precharge_current = 64, /* mA */ + + /* + * Operational temperature range + * 0 <= T_charge <= 50 deg C + * -20 <= T_discharge <= 60 deg C + */ + .start_charging_min_c = 0, + .start_charging_max_c = 50, + .charging_min_c = 0, + .charging_max_c = 50, + .discharging_min_c = -20, + .discharging_max_c = 60, }; static inline void limit_value(int *val, int limit) @@ -98,8 +96,8 @@ void battery_vendor_params(struct batt_params *batt) batt->desired_voltage = info.voltage_max; /* Don't charge if outside of allowable temperature range */ - if (bat_temp_c >= bat_temp_ranges.charging_max_c || - bat_temp_c < bat_temp_ranges.charging_min_c) { + if (bat_temp_c >= info.charging_max_c || + bat_temp_c < info.charging_min_c) { batt->desired_voltage = 0; batt->desired_current = 0; batt->flags &= ~BATT_FLAG_WANT_CHARGE; diff --git a/board/peppy/battery.c b/board/peppy/battery.c index 2fd90823fb..3d5856ef30 100644 --- a/board/peppy/battery.c +++ b/board/peppy/battery.c @@ -14,15 +14,6 @@ #define SB_SHIP_MODE_DATA 0xc574 /* Values for 54Wh 3UPF656790-1-T1001 battery */ -const struct battery_temperature_ranges bat_temp_ranges = { - .start_charging_min_c = 0, - .start_charging_max_c = 60, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 50, -}; - static const struct battery_info info = { .voltage_max = 12600, @@ -31,6 +22,13 @@ static const struct battery_info info = { /* Pre-charge values. */ .precharge_current = 392, /* mA */ + + .start_charging_min_c = 0, + .start_charging_max_c = 60, + .charging_min_c = 0, + .charging_max_c = 60, + .discharging_min_c = 0, + .discharging_max_c = 50, }; const struct battery_info *battery_get_info(void) diff --git a/board/pit/board.c b/board/pit/board.c index c548ee4040..de0730967f 100644 --- a/board/pit/board.c +++ b/board/pit/board.c @@ -96,7 +96,7 @@ const struct gpio_alt_func gpio_alt_funcs[] = { const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); /* Battery temperature ranges in degrees C */ -const struct battery_temperature_ranges bat_temp_ranges = { +static const struct battery_info info = { .start_charging_min_c = 0, .start_charging_max_c = 45, .charging_min_c = 0, @@ -105,6 +105,11 @@ const struct battery_temperature_ranges bat_temp_ranges = { .discharging_max_c = 100, }; +const struct battery_info *battery_get_info(void) +{ + return &info; +} + /* I2C ports */ const struct i2c_port_t i2c_ports[] = { {"master", I2C_PORT_MASTER, 100}, diff --git a/board/rambi/battery.c b/board/rambi/battery.c index 6edd535354..622d903d22 100644 --- a/board/rambi/battery.c +++ b/board/rambi/battery.c @@ -15,7 +15,11 @@ /* Shutdown mode parameter to write to manufacturer access register */ #define SB_SHUTDOWN_DATA 0x0010 -const struct battery_temperature_ranges bat_temp_ranges = { +static const struct battery_info info = { + .voltage_max = 8400, /* mV */ + .voltage_normal = 7400, + .voltage_min = 6000, + .precharge_current = 256, /* mA */ .start_charging_min_c = 0, .start_charging_max_c = 45, .charging_min_c = 0, @@ -24,13 +28,6 @@ const struct battery_temperature_ranges bat_temp_ranges = { .discharging_max_c = 60, }; -static const struct battery_info info = { - .voltage_max = 8400, /* mV */ - .voltage_normal = 7400, - .voltage_min = 6000, - .precharge_current = 256, /* mA */ -}; - const struct battery_info *battery_get_info(void) { return &info; diff --git a/board/snow/board.c b/board/snow/board.c index 1540612252..7f2b6a44a1 100644 --- a/board/snow/board.c +++ b/board/snow/board.c @@ -106,7 +106,7 @@ const struct gpio_alt_func gpio_alt_funcs[] = { const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs); /* Battery temperature ranges in degrees C */ -const struct battery_temperature_ranges bat_temp_ranges = { +static const struct battery_info info = { .start_charging_min_c = 0, .start_charging_max_c = 45, .charging_min_c = 0, @@ -115,6 +115,11 @@ const struct battery_temperature_ranges bat_temp_ranges = { .discharging_max_c = 100, }; +const struct battery_info *battery_get_info(void) +{ + return &info; +} + /* I2C ports */ const struct i2c_port_t i2c_ports[] = { {"master", I2C_PORT_MASTER, 100}, diff --git a/board/spring/battery.c b/board/spring/battery.c index c5a9393b01..f8d88a84d2 100644 --- a/board/spring/battery.c +++ b/board/spring/battery.c @@ -15,7 +15,7 @@ #define PARAM_CUT_OFF_HIGH 0x00 /* Battery temperature ranges in degrees C */ -const struct battery_temperature_ranges bat_temp_ranges = { +static const struct battery_info info = { .start_charging_min_c = 5, .start_charging_max_c = 45, .charging_min_c = 5, @@ -24,6 +24,11 @@ const struct battery_temperature_ranges bat_temp_ranges = { .discharging_max_c = 100, }; +const struct battery_info *battery_get_info(void) +{ + return &info; +} + int battery_command_cut_off(struct host_cmd_handler_args *args) { int rv; diff --git a/common/charge_state.c b/common/charge_state.c index be07113a0d..83efbd8d14 100644 --- a/common/charge_state.c +++ b/common/charge_state.c @@ -559,8 +559,8 @@ static enum power_state state_discharge(struct power_state_context *ctx) return PWR_STATE_ERROR; /* Handle overtemp in discharging state by powering off host */ - if ((bat_temp_c >= bat_temp_ranges.discharging_max_c || - bat_temp_c < bat_temp_ranges.discharging_min_c) && + if ((bat_temp_c >= ctx->battery->discharging_max_c || + bat_temp_c < ctx->battery->discharging_min_c) && chipset_in_state(CHIPSET_STATE_ON)) { CPRINTF("[%T charge force shutdown due to battery temp]\n"); chipset_force_shutdown(); diff --git a/common/pmu_tps65090_charger.c b/common/pmu_tps65090_charger.c index 974d0b4b0f..2a51d32d0c 100644 --- a/common/pmu_tps65090_charger.c +++ b/common/pmu_tps65090_charger.c @@ -62,22 +62,28 @@ static void enable_charging(int enable) static int battery_start_charging_range(int deci_k) { int8_t temp_c = DECI_KELVIN_TO_CELSIUS(deci_k); - return (temp_c >= bat_temp_ranges.start_charging_min_c && - temp_c < bat_temp_ranges.start_charging_max_c); + const struct battery_info *info = battery_get_info(); + + return (temp_c >= info->start_charging_min_c && + temp_c < info->start_charging_max_c); } static int battery_charging_range(int deci_k) { int8_t temp_c = DECI_KELVIN_TO_CELSIUS(deci_k); - return (temp_c >= bat_temp_ranges.charging_min_c && - temp_c < bat_temp_ranges.charging_max_c); + const struct battery_info *info = battery_get_info(); + + return (temp_c >= info->charging_min_c && + temp_c < info->charging_max_c); } static int battery_discharging_range(int deci_k) { int8_t temp_c = DECI_KELVIN_TO_CELSIUS(deci_k); - return (temp_c >= bat_temp_ranges.discharging_min_c && - temp_c < bat_temp_ranges.discharging_max_c); + const struct battery_info *info = battery_get_info(); + + return (temp_c >= info->discharging_min_c && + temp_c < info->discharging_max_c); } /** diff --git a/driver/battery/link.c b/driver/battery/link.c index 891e555922..f870342f9a 100644 --- a/driver/battery/link.c +++ b/driver/battery/link.c @@ -20,14 +20,7 @@ static const struct battery_info info = { /* Pre-charge current: I <= 0.01C */ .precharge_current = 64, /* mA */ -}; - -const struct battery_info *battery_get_info(void) -{ - return &info; -} -const struct battery_temperature_ranges bat_temp_ranges = { /* * Operational temperature range * 0 <= T_charge <= 50 deg C @@ -41,6 +34,10 @@ const struct battery_temperature_ranges bat_temp_ranges = { .discharging_max_c = 60, }; +const struct battery_info *battery_get_info(void) +{ + return &info; +} #ifdef CONFIG_BATTERY_VENDOR_PARAMS @@ -107,8 +104,8 @@ void battery_vendor_params(struct batt_params *batt) batt->desired_voltage = info.voltage_max; /* Don't charge if outside of allowable temperature range */ - if (bat_temp_c >= bat_temp_ranges.charging_max_c || - bat_temp_c < bat_temp_ranges.charging_min_c) { + if (bat_temp_c >= info.charging_max_c || + bat_temp_c < info.charging_min_c) { batt->flags &= ~BATT_FLAG_WANT_CHARGE; batt->desired_voltage = 0; batt->desired_current = 0; diff --git a/include/battery.h b/include/battery.h index 522f3aa80a..b10f8904c4 100644 --- a/include/battery.h +++ b/include/battery.h @@ -59,17 +59,6 @@ struct batt_params { /* Battery couldn't tell us every params we want */ #define BATT_FLAG_BAD_ANY (1 << 4) -/* Working temperature ranges in degrees C */ -struct battery_temperature_ranges { - int8_t start_charging_min_c; - int8_t start_charging_max_c; - int8_t charging_min_c; - int8_t charging_max_c; - int8_t discharging_min_c; - int8_t discharging_max_c; -}; -extern const struct battery_temperature_ranges bat_temp_ranges; - /* Battery constants */ struct battery_info { /* Design voltage in mV */ @@ -78,6 +67,13 @@ struct battery_info { int voltage_min; /* Pre-charge current in mA */ int precharge_current; + /* Working temperature ranges in degrees C */ + int8_t start_charging_min_c; + int8_t start_charging_max_c; + int8_t charging_min_c; + int8_t charging_max_c; + int8_t discharging_min_c; + int8_t discharging_max_c; }; /** |