pyro/snappy: Do not discharge on AC when battery is still waking up

Follow reef setting.

discharges on AC till the charger is detected and settled but
when booting from the cut-off mode this will kill the power hence
do not discharge on AC when battery is still waking up and settled.

BUG=none
BRANCH=reef
TEST=make buildall

Change-Id: I09d8f5a363d20bb3d0df80694de52ae3a37a0ed9
Signed-off-by: Bruce.Wan <Bruce.Wan@quantatw.com>
Reviewed-on: https://chromium-review.googlesource.com/422621
Commit-Ready: Keith Tzeng <keith.tzeng@quantatw.com>
Tested-by: Keith Tzeng <keith.tzeng@quantatw.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Bruce
2016-12-30 14:54:21 +08:00
committed by chrome-bot
parent bcffec7fdc
commit a80a815ea2
2 changed files with 82 additions and 50 deletions

View File

@@ -193,6 +193,46 @@ enum battery_disconnect_state battery_get_disconnect_state(void)
static int fast_charging_allowed = 1;
static int charger_should_discharge_on_ac(struct charge_state_data *curr)
{
/* can not discharge on AC without battery */
if (curr->batt.is_present != BP_YES)
return 0;
/* Do not discharge on AC if the battery is still waking up */
if (!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
!(curr->batt.status & STATUS_FULLY_CHARGED))
return 0;
/*
* In light load (<450mA being withdrawn from VSYS) the DCDC of the
* charger operates intermittently i.e. DCDC switches continuously
* and then stops to regulate the output voltage and current, and
* sometimes to prevent reverse current from flowing to the input.
* This causes a slight voltage ripple on VSYS that falls in the
* audible noise frequency (single digit kHz range). This small
* ripple generates audible noise in the output ceramic capacitors
* (caps on VSYS and any input of DCDC under VSYS).
*
* To overcome this issue enable the battery learning operation
* and suspend USB charging and DC/DC converter.
*/
if (!battery_is_cut_off() &&
!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
(curr->batt.status & STATUS_FULLY_CHARGED))
return 1;
/*
* To avoid inrush current from the external charger, enable
* discharge on AC till the new charger is detected and charge
* detect delay has passed.
*/
if (!chg_ramp_is_detected() && curr->batt.state_of_charge > 2)
return 1;
return 0;
}
/*
* This can override the smart battery's charging profile. To make a change,
* modify one or more of requested_voltage, requested_current, or state.
@@ -223,31 +263,7 @@ int charger_profile_override(struct charge_state_data *curr)
/* Current and previous battery voltage */
int batt_voltage;
static int prev_batt_voltage;
int disch_on_ac;
/*
* In light load (<450mA being withdrawn from VSYS) the DCDC of the
* charger operates intermittently i.e. DCDC switches continuously
* and then stops to regulate the output voltage and current, and
* sometimes to prevent reverse current from flowing to the input.
* This causes a slight voltage ripple on VSYS that falls in the
* audible noise frequency (single digit kHz range). This small
* ripple generates audible noise in the output ceramic capacitors
* (caps on VSYS and any input of DCDC under VSYS).
*
* To overcome this issue enable the battery learning operation
* and suspend USB charging and DC/DC converter.
*
* And also to avoid inrush current from the external charger, enable
* discharge on AC till the new charger is detected and charge detect
* delay has passed.
*/
disch_on_ac = (curr->batt.is_present == BP_YES &&
!battery_is_cut_off() &&
!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
curr->batt.status & STATUS_FULLY_CHARGED;
(!chg_ramp_is_detected() &&
curr->batt.state_of_charge > 2);
int disch_on_ac = charger_should_discharge_on_ac(curr);
charger_discharge_on_ac(disch_on_ac);

View File

@@ -121,6 +121,46 @@ enum battery_disconnect_state battery_get_disconnect_state(void)
static int fast_charging_allowed = 1;
static int charger_should_discharge_on_ac(struct charge_state_data *curr)
{
/* can not discharge on AC without battery */
if (curr->batt.is_present != BP_YES)
return 0;
/* Do not discharge on AC if the battery is still waking up */
if (!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
!(curr->batt.status & STATUS_FULLY_CHARGED))
return 0;
/*
* In light load (<450mA being withdrawn from VSYS) the DCDC of the
* charger operates intermittently i.e. DCDC switches continuously
* and then stops to regulate the output voltage and current, and
* sometimes to prevent reverse current from flowing to the input.
* This causes a slight voltage ripple on VSYS that falls in the
* audible noise frequency (single digit kHz range). This small
* ripple generates audible noise in the output ceramic capacitors
* (caps on VSYS and any input of DCDC under VSYS).
*
* To overcome this issue enable the battery learning operation
* and suspend USB charging and DC/DC converter.
*/
if (!battery_is_cut_off() &&
!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
(curr->batt.status & STATUS_FULLY_CHARGED))
return 1;
/*
* To avoid inrush current from the external charger, enable
* discharge on AC till the new charger is detected and charge
* detect delay has passed.
*/
if (!chg_ramp_is_detected() && curr->batt.state_of_charge > 2)
return 1;
return 0;
}
/*
* This can override the smart battery's charging profile. To make a change,
* modify one or more of requested_voltage, requested_current, or state.
@@ -151,31 +191,7 @@ int charger_profile_override(struct charge_state_data *curr)
/* Current and previous battery voltage */
int batt_voltage;
static int prev_batt_voltage;
int disch_on_ac;
/*
* In light load (<450mA being withdrawn from VSYS) the DCDC of the
* charger operates intermittently i.e. DCDC switches continuously
* and then stops to regulate the output voltage and current, and
* sometimes to prevent reverse current from flowing to the input.
* This causes a slight voltage ripple on VSYS that falls in the
* audible noise frequency (single digit kHz range). This small
* ripple generates audible noise in the output ceramic capacitors
* (caps on VSYS and any input of DCDC under VSYS).
*
* To overcome this issue enable the battery learning operation
* and suspend USB charging and DC/DC converter.
*
* And also to avoid inrush current from the external charger, enable
* discharge on AC till the new charger is detected and charge detect
* delay has passed.
*/
disch_on_ac = (curr->batt.is_present == BP_YES &&
!battery_is_cut_off() &&
!(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
curr->batt.status & STATUS_FULLY_CHARGED;
(!chg_ramp_is_detected() &&
curr->batt.state_of_charge > 2);
int disch_on_ac = charger_should_discharge_on_ac(curr);
charger_discharge_on_ac(disch_on_ac);