summaryrefslogtreecommitdiff
path: root/common/charge_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/charge_state.c')
-rw-r--r--common/charge_state.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/common/charge_state.c b/common/charge_state.c
index 8d605ec03e..49630ff7be 100644
--- a/common/charge_state.c
+++ b/common/charge_state.c
@@ -34,6 +34,13 @@
/* Timeout after AP battery shutdown warning before we kill the AP */
#define LOW_BATTERY_SHUTDOWN_TIMEOUT_US (30 * SECOND)
+#ifndef TASK_ID_CHARGER
+#define TASK_ID_CHARGER TASK_ID_INVALID
+#endif
+#ifndef TASK_ID_SWITCH
+#define TASK_ID_SWITCH TASK_ID_INVALID
+#endif
+
static const char * const state_name[] = POWER_STATE_NAME_TABLE;
static int state_machine_force_idle = 0;
@@ -483,6 +490,7 @@ 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;
+ int8_t bat_temp_c = DECI_KELVIN_TO_CELSIUS(batt->temperature);
if (ctx->curr.ac)
return PWR_STATE_REINIT;
@@ -490,8 +498,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 ((batt->temperature > ctx->battery->temp_discharge_max ||
- batt->temperature < ctx->battery->temp_discharge_min) &&
+ if ((bat_temp_c >= bat_temp_ranges.discharging_max_c ||
+ bat_temp_c < bat_temp_ranges.discharging_min_c) &&
chipset_in_state(CHIPSET_STATE_ON)) {
CPRINTF("[%T charge force shutdown due to battery temp]\n");
chipset_force_shutdown();