diff options
author | Shawn Nematbakhsh <shawnn@chromium.org> | 2016-10-26 14:22:21 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-12-01 19:59:03 -0800 |
commit | 3a3834ab345b640af1a611566910d06e5faefb5d (patch) | |
tree | 81bced14d0b1eda63e3cb56c37a1184f91576cad /board/kevin | |
parent | 5602f4d5155a6ea0eefbd514871c069b381dbd0a (diff) | |
download | chrome-ec-3a3834ab345b640af1a611566910d06e5faefb5d.tar.gz |
kevin / gru: Add custom charge profile
- Stop charging when thermal limits are violated.
- Don't start charging if battery percent is above 95% (but continue to
charge if we're already charging).
- Don't allow battery voltage to get too close (10mA) to BD9995X VBAT
setting. If battery voltage exceeds VBAT then back boosting may occur.
BUG=chrome-os-partner:56255
BRANCH=gru
TEST=Manual on kevin, insert charger with battery at 97%, verify battery
doesn't charge and reported current is 0. Discharge down to 95% and
insert charger, verify battery charges. Charge to 100%, verify battery
stops requesting current.
Change-Id: Icc5641e88bfad7d9d8ad4b6840338541fe7ba9a8
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/403483
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/415494
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'board/kevin')
-rw-r--r-- | board/kevin/battery.c | 31 | ||||
-rw-r--r-- | board/kevin/board.h | 1 |
2 files changed, 21 insertions, 11 deletions
diff --git a/board/kevin/battery.c b/board/kevin/battery.c index 68150f6ce0..c1b2e09c67 100644 --- a/board/kevin/battery.c +++ b/board/kevin/battery.c @@ -18,7 +18,7 @@ #ifdef BOARD_KEVIN static const struct battery_info info = { - .voltage_max = 8700, + .voltage_max = 8688, /* 8700mA, round down for chg reg */ .voltage_normal = 7600, .voltage_min = 6000, .precharge_current = 200, @@ -31,7 +31,7 @@ static const struct battery_info info = { }; #elif defined(BOARD_GRU) static const struct battery_info info = { - .voltage_max = 8700, + .voltage_max = 8688, /* 8700mA, round down for chg reg */ .voltage_normal = 7600, .voltage_min = 5800, .precharge_current = 256, @@ -116,19 +116,28 @@ enum battery_disconnect_state battery_get_disconnect_state(void) int charger_profile_override(struct charge_state_data *curr) { - const struct battery_info *batt_info; + static int prev_state = ST_IDLE; + const struct battery_info *batt_info = battery_get_info(); + /* battery temp in 0.1 deg C */ int bat_temp_c = curr->batt.temperature - 2731; - batt_info = battery_get_info(); - /* Don't charge if outside of allowable temperature range */ - if (bat_temp_c >= batt_info->charging_max_c * 10 || - bat_temp_c < batt_info->charging_min_c * 10) { - curr->requested_current = 0; - curr->requested_voltage = 0; - curr->batt.flags &= ~BATT_FLAG_WANT_CHARGE; - curr->state = ST_IDLE; + if (curr->state == ST_CHARGE) { + /* Don't charge if outside of allowable temperature range */ + if (bat_temp_c >= batt_info->charging_max_c * 10 || + bat_temp_c < batt_info->charging_min_c * 10 || + /* Don't start charging if battery is nearly full */ + (prev_state != ST_CHARGE && + curr->batt.state_of_charge > 95) || + /* Don't charge if battery voltage is approaching max */ + curr->batt.voltage > batt_info->voltage_max - 10) { + curr->requested_current = curr->requested_voltage = 0; + curr->batt.flags &= ~BATT_FLAG_WANT_CHARGE; + curr->state = ST_IDLE; + } } + + prev_state = curr->state; return 0; } diff --git a/board/kevin/board.h b/board/kevin/board.h index 5fb35ea8f5..fa7cca42a1 100644 --- a/board/kevin/board.h +++ b/board/kevin/board.h @@ -66,6 +66,7 @@ #define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 2 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2 #define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000 +#define CONFIG_CHARGER_PROFILE_OVERRIDE #define CONFIG_USB_CHARGER #define CONFIG_USB_MUX_VIRTUAL |