diff mbox series

[RFC,v3,5/9] power: supply: Add constant battery aging degradation to batinfo

Message ID bb0b356c62c6f3460ce77b29ada02443c73c7545.1637061794.git.matti.vaittinen@fi.rohmeurope.com (mailing list archive)
State Not Applicable, archived
Headers show
Series power: supply: Add some fuel-gauge logic | expand

Commit Message

Vaittinen, Matti Nov. 16, 2021, 12:27 p.m. UTC
Few batteries can be modelled to degrade at constant rate for each
increased cycle. Add degradation constant for such simple model to
batinfo.

Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
---
RFCv3: New patch
---
 drivers/power/supply/power_supply_core.c | 3 +++
 include/linux/power_supply.h             | 1 +
 2 files changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c
index 47176ed2570b..ebc961b5aa45 100644
--- a/drivers/power/supply/power_supply_core.c
+++ b/drivers/power/supply/power_supply_core.c
@@ -639,6 +639,7 @@  int power_supply_dev_get_battery_info(struct device *dev,
 	info->resist_table = NULL;
 	info->temp_dgrd_values = 0;
 	info->temp_dgrd = NULL;
+	info->degrade_cycle_uah = 0;
 
 	for (index = 0; index < POWER_SUPPLY_OCV_TEMP_MAX; index++) {
 		info->ocv_table[index]       = NULL;
@@ -689,6 +690,8 @@  int power_supply_dev_get_battery_info(struct device *dev,
 			dev_warn(dev, "%s unknown battery type\n", value);
 	}
 
+	fwnode_property_read_u32(battery_node, "degrade-cycle-microamp-hours",
+			     &info->degrade_cycle_uah);
 	fwnode_property_read_u32(battery_node, "energy-full-design-microwatt-hours",
 			     &info->energy_full_design_uwh);
 	fwnode_property_read_u32(battery_node, "charge-full-design-microamp-hours",
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index ef7db73a5bd1..c5118265b3ab 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -403,6 +403,7 @@  struct power_supply_battery_info {
 	int resist_table_size;
 	int temp_dgrd_values;
 	struct power_supply_temp_degr *temp_dgrd;
+	int degrade_cycle_uah;
 };
 
 extern struct atomic_notifier_head power_supply_notifier;