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>
This commit is contained in:
Shawn Nematbakhsh
2016-10-26 14:22:21 -07:00
committed by chrome-bot
parent 5602f4d515
commit 3a3834ab34
2 changed files with 21 additions and 11 deletions

View File

@@ -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;
}

View File

@@ -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