diff options
author | Daisuke Nojiri <dnojiri@chromium.org> | 2021-05-28 10:48:14 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-06-25 16:36:48 +0000 |
commit | 4f2e6792dd09c24805a0926c6239909b63acf1c5 (patch) | |
tree | a27d2f37f82c7bb08ca2eaec3fb649a5035f809b /include | |
parent | 594cd10300325d2ef983444218843098316acbeb (diff) | |
download | chrome-ec-4f2e6792dd09c24805a0926c6239909b63acf1c5.tar.gz |
Update EC_CMD_CHARGE_CONTROL to version 2
Version 2 of EC_CMD_CHARGE_CONTROL can control battery sustainer.
It allows the host to set the upper and lower thresholds between
which the EC tries to keep the battery state of charge.
Version 2 of EC_CMD_CHARGE_CONTROL also supports 'GET' request.
It allows the host to query the current charge control settings.
localhost ~ # ectool chargecontrol
Charge mode = NORMAL (0)
Battery sustainer = off (-1% ~ -1%)
localhost ~ # ectool chargecontrol normal 66 66
Charge state machine is in normal mode with sustainer enabled.
localhost ~ # ectool chargecontrol
Charge mode = NORMAL (0)
Battery sustainer = on (66% ~ 66%)
localhost ~ # ectool chargecontrol normal
Charge state machine is in normal mode.
BUG=b:188457962
BRANCH=none
TEST=Atlas. See above.
Change-Id: I81ec62172b4f159c46334fc0f940a2adae3f2b8a
Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2929340
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/charge_state_v2.h | 5 | ||||
-rw-r--r-- | include/ec_commands.h | 39 |
2 files changed, 43 insertions, 1 deletions
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h index df2d51cdb1..1bd64dec88 100644 --- a/include/charge_state_v2.h +++ b/include/charge_state_v2.h @@ -51,6 +51,11 @@ struct charge_state_data { #endif }; +struct sustain_soc { + int8_t lower; + int8_t upper; +}; + /** * Set the output current limit and voltage. This is used to provide power from * the charger chip ("OTG" mode). diff --git a/include/ec_commands.h b/include/ec_commands.h index e252e1165e..f38e23c021 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -4249,7 +4249,7 @@ struct ec_params_i2c_write { * discharge the battery. */ #define EC_CMD_CHARGE_CONTROL 0x0096 -#define EC_VER_CHARGE_CONTROL 1 +#define EC_VER_CHARGE_CONTROL 2 enum ec_charge_control_mode { CHARGE_CONTROL_NORMAL = 0, @@ -4257,8 +4257,45 @@ enum ec_charge_control_mode { CHARGE_CONTROL_DISCHARGE, }; +#define EC_CHARGE_MODE_TEXT { \ + [CHARGE_CONTROL_NORMAL] = "NORMAL", \ + [CHARGE_CONTROL_IDLE] = "IDLE", \ + [CHARGE_CONTROL_DISCHARGE] = "DISCHARGE", \ + } + +enum ec_charge_control_cmd { + EC_CHARGE_CONTROL_CMD_SET = 0, + EC_CHARGE_CONTROL_CMD_GET, +}; + struct ec_params_charge_control { uint32_t mode; /* enum charge_control_mode */ + + /* Below are the fields added in V2. */ + uint8_t cmd; /* enum ec_charge_control_cmd. */ + uint8_t reserved; + /* + * Lower and upper thresholds for battery sustainer. This struct isn't + * named to avoid tainting foreign projects' name spaces. + * + * If charge mode is explicitly set (e.g. DISCHARGE), battery sustainer + * will be disabled. To disable battery sustainer, set mode=NORMAL, + * lower=-1, upper=-1. + */ + struct { + int8_t lower; /* Display SoC in percentage. */ + int8_t upper; /* Display SoC in percentage. */ + } sustain_soc; +} __ec_align4; + +/* Added in v2 */ +struct ec_response_charge_control { + uint32_t mode; /* enum charge_control_mode */ + struct { /* Battery sustainer thresholds */ + int8_t lower; + int8_t upper; + } sustain_soc; + uint16_t reserved; } __ec_align4; /*****************************************************************************/ |