aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamakrishna Pallala <ramakrishna.pallala@intel.com>2012-04-10 06:51:20 -0400
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-05-04 23:44:29 -0400
commita2ebfe2fc6e088a70d06cd15a5bc9bcb621cc195 (patch)
treee9c03e1cbcb7b98f6049c17bb6000ae5218ae754
parent48e41c70c10f10541d922fc67e7952f06ad59d9a (diff)
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>
-rw-r--r--Documentation/power/power_supply_class.txt2
-rw-r--r--drivers/power/max17042_battery.c8
-rw-r--r--drivers/power/power_supply_sysfs.c1
-rw-r--r--include/linux/power_supply.h2
4 files changed, 13 insertions, 0 deletions
diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt
index 9f16c5178b66..211831d4095f 100644
--- a/Documentation/power/power_supply_class.txt
+++ b/Documentation/power/power_supply_class.txt
@@ -84,6 +84,8 @@ are already charged or discharging, 'n/a' can be displayed (or
84HEALTH - represents health of the battery, values corresponds to 84HEALTH - represents health of the battery, values corresponds to
85POWER_SUPPLY_HEALTH_*, defined in battery.h. 85POWER_SUPPLY_HEALTH_*, defined in battery.h.
86 86
87VOLTAGE_OCV - open circuit voltage of the battery.
88
87VOLTAGE_MAX_DESIGN, VOLTAGE_MIN_DESIGN - design values for maximal and 89VOLTAGE_MAX_DESIGN, VOLTAGE_MIN_DESIGN - design values for maximal and
88minimal power supply voltages. Maximal/minimal means values of voltages 90minimal power supply voltages. Maximal/minimal means values of voltages
89when battery considered "full"/"empty" at normal conditions. Yes, there is 91when battery considered "full"/"empty" at normal conditions. Yes, there is
diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
index 738648d1d9fc..42c4be9a664b 100644
--- a/drivers/power/max17042_battery.c
+++ b/drivers/power/max17042_battery.c
@@ -106,6 +106,7 @@ static enum power_supply_property max17042_battery_props[] = {
106 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 106 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
107 POWER_SUPPLY_PROP_VOLTAGE_NOW, 107 POWER_SUPPLY_PROP_VOLTAGE_NOW,
108 POWER_SUPPLY_PROP_VOLTAGE_AVG, 108 POWER_SUPPLY_PROP_VOLTAGE_AVG,
109 POWER_SUPPLY_PROP_VOLTAGE_OCV,
109 POWER_SUPPLY_PROP_CAPACITY, 110 POWER_SUPPLY_PROP_CAPACITY,
110 POWER_SUPPLY_PROP_CHARGE_FULL, 111 POWER_SUPPLY_PROP_CHARGE_FULL,
111 POWER_SUPPLY_PROP_TEMP, 112 POWER_SUPPLY_PROP_TEMP,
@@ -172,6 +173,13 @@ static int max17042_get_property(struct power_supply *psy,
172 173
173 val->intval = ret * 625 / 8; 174 val->intval = ret * 625 / 8;
174 break; 175 break;
176 case POWER_SUPPLY_PROP_VOLTAGE_OCV:
177 ret = max17042_read_reg(chip->client, MAX17042_OCVInternal);
178 if (ret < 0)
179 return ret;
180
181 val->intval = ret * 625 / 8;
182 break;
175 case POWER_SUPPLY_PROP_CAPACITY: 183 case POWER_SUPPLY_PROP_CAPACITY:
176 ret = max17042_read_reg(chip->client, MAX17042_RepSOC); 184 ret = max17042_read_reg(chip->client, MAX17042_RepSOC);
177 if (ret < 0) 185 if (ret < 0)
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
index 4368e7d61316..4150747f9186 100644
--- a/drivers/power/power_supply_sysfs.c
+++ b/drivers/power/power_supply_sysfs.c
@@ -146,6 +146,7 @@ static struct device_attribute power_supply_attrs[] = {
146 POWER_SUPPLY_ATTR(voltage_min_design), 146 POWER_SUPPLY_ATTR(voltage_min_design),
147 POWER_SUPPLY_ATTR(voltage_now), 147 POWER_SUPPLY_ATTR(voltage_now),
148 POWER_SUPPLY_ATTR(voltage_avg), 148 POWER_SUPPLY_ATTR(voltage_avg),
149 POWER_SUPPLY_ATTR(voltage_ocv),
149 POWER_SUPPLY_ATTR(current_max), 150 POWER_SUPPLY_ATTR(current_max),
150 POWER_SUPPLY_ATTR(current_now), 151 POWER_SUPPLY_ATTR(current_now),
151 POWER_SUPPLY_ATTR(current_avg), 152 POWER_SUPPLY_ATTR(current_avg),
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index c38c13db8832..fd17ae0f9c20 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -96,6 +96,7 @@ enum power_supply_property {
96 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN, 96 POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN,
97 POWER_SUPPLY_PROP_VOLTAGE_NOW, 97 POWER_SUPPLY_PROP_VOLTAGE_NOW,
98 POWER_SUPPLY_PROP_VOLTAGE_AVG, 98 POWER_SUPPLY_PROP_VOLTAGE_AVG,
99 POWER_SUPPLY_PROP_VOLTAGE_OCV,
99 POWER_SUPPLY_PROP_CURRENT_MAX, 100 POWER_SUPPLY_PROP_CURRENT_MAX,
100 POWER_SUPPLY_PROP_CURRENT_NOW, 101 POWER_SUPPLY_PROP_CURRENT_NOW,
101 POWER_SUPPLY_PROP_CURRENT_AVG, 102 POWER_SUPPLY_PROP_CURRENT_AVG,
@@ -261,6 +262,7 @@ static inline bool power_supply_is_watt_property(enum power_supply_property psp)
261 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN: 262 case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
262 case POWER_SUPPLY_PROP_VOLTAGE_NOW: 263 case POWER_SUPPLY_PROP_VOLTAGE_NOW:
263 case POWER_SUPPLY_PROP_VOLTAGE_AVG: 264 case POWER_SUPPLY_PROP_VOLTAGE_AVG:
265 case POWER_SUPPLY_PROP_VOLTAGE_OCV:
264 case POWER_SUPPLY_PROP_POWER_NOW: 266 case POWER_SUPPLY_PROP_POWER_NOW:
265 return 1; 267 return 1;
266 default: 268 default: