diff options
| -rw-r--r-- | drivers/power/olpc_battery.c | 24 |
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 | ||
| 252 | static 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, |
