diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/battery.h | 94 | ||||
-rw-r--r-- | include/charge_state.h | 15 |
2 files changed, 32 insertions, 77 deletions
diff --git a/include/battery.h b/include/battery.h index b5056cf9d4..cb2a5c32ef 100644 --- a/include/battery.h +++ b/include/battery.h @@ -38,11 +38,27 @@ struct batt_params { int temperature; /* Temperature in 0.1 K */ int state_of_charge; /* State of charge (percent, 0-100) */ int voltage; /* Battery voltage (mV) */ - int current; /* Battery current (mA) */ + int current; /* Battery current (mA); negative=discharging */ int desired_voltage; /* Charging voltage desired by battery (mV) */ int desired_current; /* Charging current desired by battery (mA) */ + int flags; /* Flags */ }; +/* Flags for batt_params */ + +/* Battery wants to be charged */ +#define BATT_FLAG_WANT_CHARGE (1 << 0) + +/* Battery is responsive (talking to us via I2C) */ +#define BATT_FLAG_RESPONSIVE (1 << 1) + +/* Able to talk to battery, but it won't tell us voltage or charge percent */ +#define BATT_FLAG_BAD_VOLTAGE (1 << 2) +#define BATT_FLAG_BAD_CHARGE_PERCENT (1 << 3) + +/* Battery couldn't tell us every params we want */ +#define BATT_FLAG_BAD_ANY (1 << 4) + /* Working temperature ranges in degrees C */ struct battery_temperature_ranges { int8_t start_charging_min_c; @@ -70,6 +86,15 @@ struct battery_info { const struct battery_info *battery_get_info(void); /** + * Get current battery parameters. + * + * Error conditions are reported via batt.flags. + * + * @param batt Destination for battery data + */ +void battery_get_params(struct batt_params *batt); + +/** * Modify battery parameters to match vendor charging profile. * * @param batt Battery parameters to modify @@ -121,22 +146,6 @@ int battery_is_in_10mw_mode(int *val); int battery_set_10mw_mode(int enabled); /** - * Read battery temperature. - * - * @param deci_kelvin Destination for battery temperature in units of 0.1 K - * @return non-zero if error. - */ -int battery_temperature(int *deci_kelvin); - -/** - * Read battery voltage. - * - * @param voltage Destination for voltage in mW - * @return non-zero if error. - */ -int battery_voltage(int *voltage); - -/** * Read nominal voltage battery is designed to supply. * * @param voltage Destination for voltage in mW @@ -145,48 +154,6 @@ int battery_voltage(int *voltage); int battery_design_voltage(int *voltage); /** - * Read charging voltage desired by battery. - * - * @param voltage Destination for voltage in mV. - * @return non-zero if error. - */ -int battery_desired_voltage(int *voltage); - -/** - * Read battery discharging current. - * - * @param current Destination for discharge current in mA; negative - * value indicates charging. - * @return non-zero if error. - */ -int battery_current(int *current); - -/** - * Read averaged battery discharging current. - * - * @param current Destination for discharge current in mA; negative - * value indicates charging. - * @return non-zero if error. - */ -int battery_average_current(int *current); - -/** - * Read charging current desired by battery. - * - * @param current Destination for current in mA. - * @return non-zero if error. - */ -int battery_desired_current(int *current); - -/** - * Read battery relative state of charge. - * - * @param percent Destination for charge in percent - * @return non-zero if error. - */ -int battery_state_of_charge(int *percent); - -/** * Read absolute state of charge. * * @param percent Destination for charge in percent @@ -257,14 +224,6 @@ int battery_time_to_full(int *minutes); int battery_time_at_rate(int rate, int *minutes); /** - * Check if battery allows charging. - * - * @param allowed Non-zero if charging allowed; zero if not allowed. - * @return non-zero if error. - */ -int battery_charging_allowed(int *allowed); - -/** * Read battery status. * * @param status Destination for status; see STATUS_* in battery_smart.h. @@ -326,4 +285,3 @@ int battery_device_chemistry(char *dest, int size); int battery_manufacturer_date(int *year, int *month, int *day); #endif /* __CROS_EC_BATTERY_H */ - diff --git a/include/charge_state.h b/include/charge_state.h index bd8e5d05e6..5a176c1b40 100644 --- a/include/charge_state.h +++ b/include/charge_state.h @@ -22,24 +22,21 @@ /* Power state error flags */ #define F_CHARGER_INIT (1 << 0) /* Charger initialization */ -#define F_CHARGER_VOLTAGE (1 << 1) /* Charger maximun output voltage */ +#define F_CHARGER_VOLTAGE (1 << 1) /* Charger maximum output voltage */ #define F_CHARGER_CURRENT (1 << 2) /* Charger maximum output current */ #define F_BATTERY_VOLTAGE (1 << 3) /* Battery voltage */ -#define F_BATTERY_CURRENT (1 << 4) /* Battery charging current */ -#define F_DESIRED_VOLTAGE (1 << 5) /* Battery desired voltage */ -#define F_DESIRED_CURRENT (1 << 6) /* Battery desired current */ -#define F_BATTERY_TEMPERATURE (1 << 7) /* Battery temperature */ #define F_BATTERY_MODE (1 << 8) /* Battery mode */ #define F_BATTERY_CAPACITY (1 << 9) /* Battery capacity */ #define F_BATTERY_STATE_OF_CHARGE (1 << 10) /* State of charge, percentage */ #define F_BATTERY_UNRESPONSIVE (1 << 11) /* Battery not responding */ #define F_BATTERY_NOT_CONNECTED (1 << 12) /* Battery not connected */ +#define F_BATTERY_GET_PARAMS (1 << 13) /* Any battery parameter bad */ -#define F_BATTERY_MASK (F_BATTERY_VOLTAGE | F_BATTERY_CURRENT | \ - F_DESIRED_VOLTAGE | F_DESIRED_CURRENT | \ - F_BATTERY_TEMPERATURE | F_BATTERY_MODE | \ +#define F_BATTERY_MASK (F_BATTERY_VOLTAGE | \ + F_BATTERY_MODE | \ F_BATTERY_CAPACITY | F_BATTERY_STATE_OF_CHARGE | \ - F_BATTERY_UNRESPONSIVE | F_BATTERY_NOT_CONNECTED) + F_BATTERY_UNRESPONSIVE | F_BATTERY_NOT_CONNECTED | \ + F_BATTERY_GET_PARAMS) #define F_CHARGER_MASK (F_CHARGER_VOLTAGE | F_CHARGER_CURRENT | \ F_CHARGER_INIT) |