In common/charge_state_v2.c, here is how charger_task sends host event EC_HOST_EVENT_BATTERY_LOW or EC_HOST_EVENT_BATTERY_CRITICAL:
if (curr.batt.state_of_charge <= BATTERY_LEVEL_LOW &&
prev_charge > BATTERY_LEVEL_LOW)
host_set_single_event(EC_HOST_EVENT_BATTERY_LOW);
if (curr.batt.state_of_charge <= BATTERY_LEVEL_CRITICAL &&
prev_charge > BATTERY_LEVEL_CRITICAL)
host_set_single_event(EC_HOST_EVENT_BATTERY_CRITICAL);
Note that prev_charge is initialized as -1.
So if we do a hard reset when SOC is already lower than BATTERY_LEVEL_CRITICAL, EC wouldn't send EC_HOST_EVENT_BATTERY_CRITICAL.
The case for BATTERY_LEVEL_LOW is similarly broken.
Well, I don't see any kernel code handles
EC_HOST_EVENT_BATTERY_LOW or EC_HOST_EVENT_BATTERY_CRITICAL anyway.
But it's still good to fix this.
Comment 1 by philipchen@chromium.org
, May 3 2018Owner: philipchen@chromium.org