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

power_supply: Add boot and calibration attributes

Usually PMIC's come with coulomb counting mechanism which can be
used to implement a Fuel Gauginig solution in Software itself.
One of key input to these SW Fuel Gauge solutioons is the boot up
parameters like boot voltage and boot current.

This patch adds the VOLTAGE_BOOT and CURRENT_BOOT power supply attributes
to report bootup voltage and current.

This patch also adds CALIBRATE power supply attribute which useful is
for calibrating the battery/coulomb counter.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>

authored by

Ramakrishna Pallala and committed by
Sebastian Reichel
a8adcc90 b1022e24

+14
+6
Documentation/power/power_supply_class.txt
··· 101 101 these ones should be used if hardware could only guess (measure and 102 102 retain) the thresholds of a given power supply. 103 103 104 + VOLTAGE_BOOT - Reports the voltage measured during boot 105 + 106 + CURRENT_BOOT - Reports the current measured during boot 107 + 104 108 CHARGE_FULL_DESIGN, CHARGE_EMPTY_DESIGN - design charge values, when 105 109 battery considered full/empty. 106 110 ··· 126 122 the current drawn from a charging source. 127 123 CHARGE_TERM_CURRENT - Charge termination current used to detect the end of charge 128 124 condition. 125 + 126 + CALIBRATE - battery or coulomb counter calibration status 129 127 130 128 CONSTANT_CHARGE_VOLTAGE - constant charge voltage programmed by charger. 131 129 CONSTANT_CHARGE_VOLTAGE_MAX - maximum charge voltage supported by the
+3
drivers/power/power_supply_sysfs.c
··· 149 149 POWER_SUPPLY_ATTR(voltage_now), 150 150 POWER_SUPPLY_ATTR(voltage_avg), 151 151 POWER_SUPPLY_ATTR(voltage_ocv), 152 + POWER_SUPPLY_ATTR(voltage_boot), 152 153 POWER_SUPPLY_ATTR(current_max), 153 154 POWER_SUPPLY_ATTR(current_now), 154 155 POWER_SUPPLY_ATTR(current_avg), 156 + POWER_SUPPLY_ATTR(current_boot), 155 157 POWER_SUPPLY_ATTR(power_now), 156 158 POWER_SUPPLY_ATTR(power_avg), 157 159 POWER_SUPPLY_ATTR(charge_full_design), ··· 195 193 POWER_SUPPLY_ATTR(type), 196 194 POWER_SUPPLY_ATTR(scope), 197 195 POWER_SUPPLY_ATTR(charge_term_current), 196 + POWER_SUPPLY_ATTR(calibrate), 198 197 /* Properties of type `const char *' */ 199 198 POWER_SUPPLY_ATTR(model_name), 200 199 POWER_SUPPLY_ATTR(manufacturer),
+5
include/linux/power_supply.h
··· 102 102 POWER_SUPPLY_PROP_VOLTAGE_NOW, 103 103 POWER_SUPPLY_PROP_VOLTAGE_AVG, 104 104 POWER_SUPPLY_PROP_VOLTAGE_OCV, 105 + POWER_SUPPLY_PROP_VOLTAGE_BOOT, 105 106 POWER_SUPPLY_PROP_CURRENT_MAX, 106 107 POWER_SUPPLY_PROP_CURRENT_NOW, 107 108 POWER_SUPPLY_PROP_CURRENT_AVG, 109 + POWER_SUPPLY_PROP_CURRENT_BOOT, 108 110 POWER_SUPPLY_PROP_POWER_NOW, 109 111 POWER_SUPPLY_PROP_POWER_AVG, 110 112 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, ··· 148 146 POWER_SUPPLY_PROP_TYPE, /* use power_supply.type instead */ 149 147 POWER_SUPPLY_PROP_SCOPE, 150 148 POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT, 149 + POWER_SUPPLY_PROP_CALIBRATE, 151 150 /* Properties of type `const char *' */ 152 151 POWER_SUPPLY_PROP_MODEL_NAME, 153 152 POWER_SUPPLY_PROP_MANUFACTURER, ··· 294 291 case POWER_SUPPLY_PROP_CURRENT_MAX: 295 292 case POWER_SUPPLY_PROP_CURRENT_NOW: 296 293 case POWER_SUPPLY_PROP_CURRENT_AVG: 294 + case POWER_SUPPLY_PROP_CURRENT_BOOT: 297 295 return 1; 298 296 default: 299 297 break; ··· 319 315 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 320 316 case POWER_SUPPLY_PROP_VOLTAGE_AVG: 321 317 case POWER_SUPPLY_PROP_VOLTAGE_OCV: 318 + case POWER_SUPPLY_PROP_VOLTAGE_BOOT: 322 319 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE: 323 320 case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX: 324 321 case POWER_SUPPLY_PROP_POWER_NOW: