link: If discharging and system is off, only poll battery once a minute

This reduces power consumption in S3/S5 because the EC doesn't need to
poll the battery every 500ms.

BUG=chrome-os-partner:9676
BRANCH=link
TEST=manual

As much as can be tested with the current debug information:

- Boot system with AC adapter in.  Charge state machine should go to
  charging state.
- Remove AC adapter.  Charge state -> discharging.
- Shut system down.
- Plug AC adapter in.  Charge state -> init -> charging over the course of
  a few seconds (NOT a minute).
- Remove AC adapter.  Charge state -> discharging.

Really good testing requires a source-level change.  Hack in a line of
debug output above task_wait_event(sleep_next) in
charge_state_machine_task() which prints how long the charge state
machine is sleeping.  It should sleep for ~250ms when charging, ~500ms
when discharging and the system is on, or ~60000ms when discharging
and the system is off.  (I did this when writing this change, but
removed it because it clutters up the debug console output.)

Change-Id: I7d3e291fbc40bfcc67d1fb4982d91f0e6bf2e785
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/33921
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-by: Rong Chang <rongchang@chromium.org>
2 files changed