aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2010-12-10 17:05:20 -0500
committerAnton Vorontsov <cbouatmailru@gmail.com>2011-01-12 12:29:00 -0500
commit20fd9830ccc685adce65ba89ffc3ca5426a2b064 (patch)
treeedd1222e5b18717bea107fa1f39c27d7a9d3b822 /drivers/power
parentb202a5e6c94d8c43ade5adb97e87734cc4f4f228 (diff)
olpc_battery: Add support for CHARGE_NOW
CHARGE_NOW is needed by some user space software (read: UPower) for internal calculations. This patch violates the power supply class definition (as we already do for CAPACITY though it isn't as obvious there), but this is the best we can do without adding rather sophisticated algorithms to either the EC or UPower. Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org> Signed-off-by: Paul Fox <pgf@laptop.org> Signed-off-by: Anton Vorontsov <cbouatmailru@gmail.com>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/olpc_battery.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c
index 663b73023eaf..0f7a7b11bda3 100644
--- a/drivers/power/olpc_battery.c
+++ b/drivers/power/olpc_battery.c
@@ -249,6 +249,24 @@ static int olpc_bat_get_charge_full_design(union power_supply_propval *val)
249 return ret; 249 return ret;
250} 250}
251 251
252static int olpc_bat_get_charge_now(union power_supply_propval *val)
253{
254 uint8_t soc;
255 union power_supply_propval full;
256 int ret;
257
258 ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &soc, 1);
259 if (ret)
260 return ret;
261
262 ret = olpc_bat_get_charge_full_design(&full);
263 if (ret)
264 return ret;
265
266 val->intval = soc * (full.intval / 100);
267 return 0;
268}
269
252/********************************************************************* 270/*********************************************************************
253 * Battery properties 271 * Battery properties
254 *********************************************************************/ 272 *********************************************************************/
@@ -347,6 +365,11 @@ static int olpc_bat_get_property(struct power_supply *psy,
347 if (ret) 365 if (ret)
348 return ret; 366 return ret;
349 break; 367 break;
368 case POWER_SUPPLY_PROP_CHARGE_NOW:
369 ret = olpc_bat_get_charge_now(val);
370 if (ret)
371 return ret;
372 break;
350 case POWER_SUPPLY_PROP_TEMP: 373 case POWER_SUPPLY_PROP_TEMP:
351 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); 374 ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2);
352 if (ret) 375 if (ret)
@@ -395,6 +418,7 @@ static enum power_supply_property olpc_xo1_bat_props[] = {
395 POWER_SUPPLY_PROP_CAPACITY, 418 POWER_SUPPLY_PROP_CAPACITY,
396 POWER_SUPPLY_PROP_CAPACITY_LEVEL, 419 POWER_SUPPLY_PROP_CAPACITY_LEVEL,
397 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, 420 POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
421 POWER_SUPPLY_PROP_CHARGE_NOW,
398 POWER_SUPPLY_PROP_TEMP, 422 POWER_SUPPLY_PROP_TEMP,
399 POWER_SUPPLY_PROP_TEMP_AMBIENT, 423 POWER_SUPPLY_PROP_TEMP_AMBIENT,
400 POWER_SUPPLY_PROP_MANUFACTURER, 424 POWER_SUPPLY_PROP_MANUFACTURER,