diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2020-05-11 14:58:01 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-06-20 02:17:16 +0000 |
commit | 6218ae98872846970d52024b04f01874534889dd (patch) | |
tree | 8526840700425d10748249c094fe4315c0ce5fba /include | |
parent | f4a6e87bd1fcc7932fc4cba148b171c514b21a1c (diff) | |
download | chrome-ec-6218ae98872846970d52024b04f01874534889dd.tar.gz |
Battery: Implement smart discharge system
Currently, CrOS EC chooses only one of the two powre-saving states
when the system is left idle. One is to hibernate and the other is
to cut off the battery. And these are determined at compile time.
If the system hibernates, EC will not have a chance to cut off the
battery before the state of charge reaches critical low. If the
system is in cutoff, it requires an AC adapter to wake up. So, neither
behavior is ideal.
This patch introduces the smart discharge system. Given the number
of hours to zero capacity as a target, it tries to choose the better
state for idling.
For example, if the state of charge is high, it will hibernate the
system because the target can be met before the battery completely
drains. If the state of charge is low, it will keep the EC up so
that it can cutoff the battery.
Tests are done on Bloog as follows:
Verify EC selects not to hibernate when the remaining capacity is
below the stay-up threshold.
The ectool smartdischarge command is tested as follows:
localhost ~ # ectool smartdischarge
Hours to zero capacity: 0 h
Stay-up threshold: 0 mAh
Cutoff threshold: 0 mAh
Hibernate discharge rate: 0 uA
Cutoff discharge rate: 0 uA
localhost ~ # ectool smartdischarge 2160
Hours to zero capacity: 2160 h
Stay-up threshold: 0 mAh
Cutoff threshold: 0 mAh
Hibernate discharge rate: 0 uA
Cutoff discharge rate: 0 uA
localhost ~ # ectool smartdischarge 2160 200 1500
EC result 3 (INVALID_PARAM)
localhost ~ # ectool smartdischarge 2160 1500 200
Hours to zero capacity: 2160 h
Stay-up threshold: 3240 mAh
Cutoff threshold: 432 mAh
Hibernate discharge rate: 1500 uA
Cutoff discharge rate: 200 uA
localhost ~ # ectool smartdischarge 2160 1500 0
EC result 3 (INVALID_PARAM)
localhost ~ # ectool smartdischarge 0
Hours to zero capacity: 0 h
Stay-up threshold: 0 mAh
Cutoff threshold: 0 mAh
Hibernate discharge rate: 1500 uA
Cutoff discharge rate: 200 uA
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
BUG=b:152431365, b:157602162
BRANCH=none
TEST=See above
Change-Id: I1470b13203f3653ae0e495cd5ec8ed05f3c5102f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2216392
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Commit-Queue: Daisuke Nojiri <dnojiri@chromium.org>
Tested-by: Daisuke Nojiri <dnojiri@chromium.org>
Auto-Submit: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/ec_commands.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h index 877ce3476b..c239de8b66 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -6140,6 +6140,44 @@ struct ec_response_keybd_config { } __ec_align1; +/* + * Configure smart discharge + */ +#define EC_CMD_SMART_DISCHARGE 0x012B + +#define EC_SMART_DISCHARGE_FLAGS_SET BIT(0) + +/* Discharge rates when the system is in cutoff or hibernation. */ +struct discharge_rate { + uint16_t cutoff; /* Discharge rate (uA) in cutoff */ + uint16_t hibern; /* Discharge rate (uA) in hibernation */ +}; + +struct smart_discharge_zone { + /* When the capacity (mAh) goes below this, EC cuts off the battery. */ + int cutoff; + /* When the capacity (mAh) is below this, EC stays up. */ + int stayup; +}; + +struct ec_params_smart_discharge { + uint8_t flags; /* EC_SMART_DISCHARGE_FLAGS_* */ + /* + * Desired hours for the battery to survive before reaching 0%. Set to + * zero to disable smart discharging. That is, the system hibernates as + * soon as the G3 idle timer expires. + */ + uint16_t hours_to_zero; + /* Set both to zero to keep the current rates. */ + struct discharge_rate drate; +}; + +struct ec_response_smart_discharge { + uint16_t hours_to_zero; + struct discharge_rate drate; + struct smart_discharge_zone dzone; +}; + /*****************************************************************************/ /* The command range 0x200-0x2FF is reserved for Rotor. */ |