Handle overtemp condition in discharging state

This change adds battery operating temperature check. Host and EC
will be turned off when overtemp. EC can be waked up by predefined
external signals like key press or AC_PRESENT gpio.

For safty reason, this change does not check battery temperature
after EC deep sleep.

Signed-off-by: Rong Chang <rongchang@chromium.org>
BUG=chrome-os-partner:8451,9108
TEST=none
  Mock battery_temperature() fucntion to test.

Change-Id: I3203515b3df86192f690f9b98901020209ce49b3
This commit is contained in:
Rong Chang
2012-04-25 11:45:16 +08:00
parent 470916fb0f
commit 5774ebbd78

View File

@@ -388,15 +388,19 @@ static enum power_state state_charge(struct power_state_context *ctx)
*/
static enum power_state state_discharge(struct power_state_context *ctx)
{
struct batt_params *batt = &ctx->curr.batt;
if (ctx->curr.ac)
return PWR_STATE_INIT;
if (ctx->curr.error)
return PWR_STATE_ERROR;
/* TODO(rong): crosbug.com/p/8451
* handle overtemp in discharge mode
/* Overtemp in discharging state
* - poweroff host and ec
*/
if (batt->temperature > ctx->battery->temp_discharge_max ||
batt->temperature < ctx->battery->temp_discharge_min)
poweroff_wait_ac();
return PWR_STATE_UNCHANGE;
}