Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power_supply: Add voltage_ocv property and use it for max17042 driver

This adds a new sysfs file called 'voltage_ocv' which gives the
Open Circuit Voltage of the battery.

This property can be used for platform shutdown policies and
can be useful for initial capacity estimations.

Note: This patch is generated against linux-next branch.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>

authored by

Ramakrishna Pallala and committed by
Anton Vorontsov
a2ebfe2f 48e41c70

+13
+2
Documentation/power/power_supply_class.txt
··· 84 84 HEALTH - represents health of the battery, values corresponds to 85 85 POWER_SUPPLY_HEALTH_*, defined in battery.h. 86 86 87 + VOLTAGE_OCV - open circuit voltage of the battery. 88 + 87 89 VOLTAGE_MAX_DESIGN, VOLTAGE_MIN_DESIGN - design values for maximal and 88 90 minimal power supply voltages. Maximal/minimal means values of voltages 89 91 when battery considered "full"/"empty" at normal conditions. Yes, there is
+8
drivers/power/max17042_battery.c
··· 106 106 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 107 107 POWER_SUPPLY_PROP_VOLTAGE_NOW, 108 108 POWER_SUPPLY_PROP_VOLTAGE_AVG, 109 + POWER_SUPPLY_PROP_VOLTAGE_OCV, 109 110 POWER_SUPPLY_PROP_CAPACITY, 110 111 POWER_SUPPLY_PROP_CHARGE_FULL, 111 112 POWER_SUPPLY_PROP_TEMP, ··· 168 167 break; 169 168 case POWER_SUPPLY_PROP_VOLTAGE_AVG: 170 169 ret = max17042_read_reg(chip->client, MAX17042_AvgVCELL); 170 + if (ret < 0) 171 + return ret; 172 + 173 + val->intval = ret * 625 / 8; 174 + break; 175 + case POWER_SUPPLY_PROP_VOLTAGE_OCV: 176 + ret = max17042_read_reg(chip->client, MAX17042_OCVInternal); 171 177 if (ret < 0) 172 178 return ret; 173 179
+1
drivers/power/power_supply_sysfs.c
··· 146 146 POWER_SUPPLY_ATTR(voltage_min_design), 147 147 POWER_SUPPLY_ATTR(voltage_now), 148 148 POWER_SUPPLY_ATTR(voltage_avg), 149 + POWER_SUPPLY_ATTR(voltage_ocv), 149 150 POWER_SUPPLY_ATTR(current_max), 150 151 POWER_SUPPLY_ATTR(current_now), 151 152 POWER_SUPPLY_ATTR(current_avg),
+2
include/linux/power_supply.h
··· 96 96 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 97 97 POWER_SUPPLY_PROP_VOLTAGE_NOW, 98 98 POWER_SUPPLY_PROP_VOLTAGE_AVG, 99 + POWER_SUPPLY_PROP_VOLTAGE_OCV, 99 100 POWER_SUPPLY_PROP_CURRENT_MAX, 100 101 POWER_SUPPLY_PROP_CURRENT_NOW, 101 102 POWER_SUPPLY_PROP_CURRENT_AVG, ··· 262 261 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 263 262 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 264 263 case POWER_SUPPLY_PROP_VOLTAGE_AVG: 264 + case POWER_SUPPLY_PROP_VOLTAGE_OCV: 265 265 case POWER_SUPPLY_PROP_POWER_NOW: 266 266 return 1; 267 267 default: