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")
Showing the changes to include/linux/platform_data (1 of 1 file). Show all
Unified · Split
| @@ -3843,16 +3843,61 @@ struct ec_params_i2c_write { · 3842 unmodified lines | |||
| 3843 | * discharge the battery. | 3843 | * discharge the battery. |
| 3844 | */ | 3844 | */ |
| 3845 | #define EC_CMD_CHARGE_CONTROL 0x0096 | 3845 | #define EC_CMD_CHARGE_CONTROL 0x0096 |
| 3846 | #define EC_VER_CHARGE_CONTROL 1 | 3846 | #define EC_VER_CHARGE_CONTROL 3 |
| 3847 | 3847 | ||
| 3848 | enum ec_charge_control_mode { | 3848 | enum ec_charge_control_mode { |
| 3849 | CHARGE_CONTROL_NORMAL = 0, | 3849 | CHARGE_CONTROL_NORMAL = 0, |
| 3850 | CHARGE_CONTROL_IDLE, | 3850 | CHARGE_CONTROL_IDLE, |
| 3851 | CHARGE_CONTROL_DISCHARGE, | 3851 | 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), | ||
| 3852 | }; | 3870 | }; |
| 3853 | 3871 | ||
| 3854 | struct ec_params_charge_control { | 3872 | 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; | ||
| 3856 | } __ec_align4; | 3901 | } __ec_align4; |
| 3857 | 3902 | ||
| 3858 | /*****************************************************************************/ | 3903 | /*****************************************************************************/ |