aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2010-12-10 23:05:20 +0100
committerAnton Vorontsov <cbouatmailru@gmail.com>2011-01-12 20:29:00 +0300
commit20fd9830ccc685adce65ba89ffc3ca5426a2b064 (patch)
treeedd1222e5b18717bea107fa1f39c27d7a9d3b822 /drivers/power
parentolpc_battery: Add support for CHARGE_FULL_DESIGN (diff)
downloadlinux-dev-20fd9830ccc685adce65ba89ffc3ca5426a2b064.tar.xz
linux-dev-20fd9830ccc685adce65ba89ffc3ca5426a2b064.zip
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)
return ret;
}
+static int olpc_bat_get_charge_now(union power_supply_propval *val)
+{
+ uint8_t soc;
+ union power_supply_propval full;
+ int ret;
+
+ ret = olpc_ec_cmd(EC_BAT_SOC, NULL, 0, &soc, 1);
+ if (ret)
+ return ret;
+
+ ret = olpc_bat_get_charge_full_design(&full);
+ if (ret)
+ return ret;
+
+ val->intval = soc * (full.intval / 100);
+ return 0;
+}
+
/*********************************************************************
* Battery properties
*********************************************************************/
@@ -347,6 +365,11 @@ static int olpc_bat_get_property(struct power_supply *psy,
if (ret)
return ret;
break;
+ case POWER_SUPPLY_PROP_CHARGE_NOW:
+ ret = olpc_bat_get_charge_now(val);
+ if (ret)
+ return ret;
+ break;
case POWER_SUPPLY_PROP_TEMP:
ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2);
if (ret)
@@ -395,6 +418,7 @@ static enum power_supply_property olpc_xo1_bat_props[] = {
POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_CAPACITY_LEVEL,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
+ POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TEMP_AMBIENT,
POWER_SUPPLY_PROP_MANUFACTURER,