summaryrefslogtreecommitdiff
path: root/include/linux/power_supply.h
diff options
context:
space:
mode:
authorLiam Breck <kernel@networkimprov.net>2017-06-07 11:37:51 -0700
committerSebastian Reichel <sebastian.reichel@collabora.co.uk>2017-06-08 16:29:28 +0200
commitc08b1f45d7d193b3e6dcbbf30d403cb49b667b8c (patch)
tree9f7389a87a3d8ff991f61d70d8224adee4f1e3f8 /include/linux/power_supply.h
parent230670479a6c54dcae6387119bb7d4441d7870b2 (diff)
power: supply: core: Add power_supply_battery_info and API
power_supply_get_battery_info() reads battery data from devicetree. struct power_supply_battery_info provides battery data to drivers. Its fields correspond to elements in enum power_supply_property. Drivers may surface battery data in sysfs via corresponding POWER_SUPPLY_PROP_* fields. Signed-off-by: Matt Ranostay <matt@ranostay.consulting> Signed-off-by: Liam Breck <kernel@networkimprov.net> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'include/linux/power_supply.h')
-rw-r--r--include/linux/power_supply.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 4bd34051995e..34345d716286 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -289,6 +289,25 @@ struct power_supply_info {
int use_for_apm;
};
+/*
+ * This is the recommended struct to manage static battery parameters,
+ * populated by power_supply_get_battery_info(). Most platform drivers should
+ * use these for consistency.
+ * Its field names must correspond to elements in enum power_supply_property.
+ * The default field value is -EINVAL.
+ * Power supply class itself doesn't use this.
+ */
+
+struct power_supply_battery_info {
+ int energy_full_design_uwh; /* microWatt-hours */
+ int charge_full_design_uah; /* microAmp-hours */
+ int voltage_min_design_uv; /* microVolts */
+ int precharge_current_ua; /* microAmps */
+ int charge_term_current_ua; /* microAmps */
+ int constant_charge_current_max_ua; /* microAmps */
+ int constant_charge_voltage_max_uv; /* microVolts */
+};
+
extern struct atomic_notifier_head power_supply_notifier;
extern int power_supply_reg_notifier(struct notifier_block *nb);
extern void power_supply_unreg_notifier(struct notifier_block *nb);
@@ -307,6 +326,9 @@ static inline struct power_supply *
devm_power_supply_get_by_phandle(struct device *dev, const char *property)
{ return NULL; }
#endif /* CONFIG_OF */
+
+extern int power_supply_get_battery_info(struct power_supply *psy,
+ struct power_supply_battery_info *info);
extern void power_supply_changed(struct power_supply *psy);
extern int power_supply_am_i_supplied(struct power_supply *psy);
extern int power_supply_set_battery_charged(struct power_supply *psy);