History

platform/chrome: Update binary interface for EC-based charge control

The charge-control command v2/v3 is more featureful than v1, it additionally supports charge thresholds. The definitions were imported from ChromeOS EC commit 32870d602317 ("squirtle: modify motionsense rotation matrix")

Thomas Weißschuh committed 2 years ago

Commit c05cb5b1 parent 2681bba1 file · +47 −2Browse files

Showing the changes to include/linux/platform_data (1 of 1 file). Show all

Unified · Split

include/linux/platform_data/cros_ec_commands.h+47−2
@@ -3843,16 +3843,61 @@ struct ec_params_i2c_write { · 3842 unmodified lines
38433843 * discharge the battery.
38443844 */
38453845 #define EC_CMD_CHARGE_CONTROL 0x0096
3846−#define EC_VER_CHARGE_CONTROL 1
3846+#define EC_VER_CHARGE_CONTROL 3
38473847
38483848 enum ec_charge_control_mode {
38493849 CHARGE_CONTROL_NORMAL = 0,
38503850 CHARGE_CONTROL_IDLE,
38513851 CHARGE_CONTROL_DISCHARGE,
3852+ /* Add no more entry below. */
3853+ CHARGE_CONTROL_COUNT,
3854+};
3855+
3856+#define EC_CHARGE_MODE_TEXT \
3857+ { \
3858+ [CHARGE_CONTROL_NORMAL] = "NORMAL", \
3859+ [CHARGE_CONTROL_IDLE] = "IDLE", \
3860+ [CHARGE_CONTROL_DISCHARGE] = "DISCHARGE", \
3861+ }
3862+
3863+enum ec_charge_control_cmd {
3864+ EC_CHARGE_CONTROL_CMD_SET = 0,
3865+ EC_CHARGE_CONTROL_CMD_GET,
3866+};
3867+
3868+enum ec_charge_control_flag {
3869+ EC_CHARGE_CONTROL_FLAG_NO_IDLE = BIT(0),
38523870 };
38533871
38543872 struct ec_params_charge_control {
3855− uint32_t mode; /* enum charge_control_mode */
3873+ uint32_t mode; /* enum charge_control_mode */
3874+
3875+ /* Below are the fields added in V2. */
3876+ uint8_t cmd; /* enum ec_charge_control_cmd. */
3877+ uint8_t flags; /* enum ec_charge_control_flag (v3+) */
3878+ /*
3879+ * Lower and upper thresholds for battery sustainer. This struct isn't
3880+ * named to avoid tainting foreign projects' name spaces.
3881+ *
3882+ * If charge mode is explicitly set (e.g. DISCHARGE), battery sustainer
3883+ * will be disabled. To disable battery sustainer, set mode=NORMAL,
3884+ * lower=-1, upper=-1.
3885+ */
3886+ struct {
3887+ int8_t lower; /* Display SoC in percentage. */
3888+ int8_t upper; /* Display SoC in percentage. */
3889+ } sustain_soc;
3890+} __ec_align4;
3891+
3892+/* Added in v2 */
3893+struct ec_response_charge_control {
3894+ uint32_t mode; /* enum charge_control_mode */
3895+ struct { /* Battery sustainer thresholds */
3896+ int8_t lower;
3897+ int8_t upper;
3898+ } sustain_soc;
3899+ uint8_t flags; /* enum ec_charge_control_flag (v3+) */
3900+ uint8_t reserved;
38563901 } __ec_align4;
38573902
38583903 /*****************************************************************************/

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t