diff options
-rw-r--r-- | drivers/power/olpc_battery.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index 7385092f9bc8..1630add1a6de 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c | |||
@@ -267,6 +267,55 @@ static int olpc_bat_get_charge_now(union power_supply_propval *val) | |||
267 | return 0; | 267 | return 0; |
268 | } | 268 | } |
269 | 269 | ||
270 | static int olpc_bat_get_voltage_max_design(union power_supply_propval *val) | ||
271 | { | ||
272 | uint8_t ec_byte; | ||
273 | union power_supply_propval tech; | ||
274 | int mfr; | ||
275 | int ret; | ||
276 | |||
277 | ret = olpc_bat_get_tech(&tech); | ||
278 | if (ret) | ||
279 | return ret; | ||
280 | |||
281 | ec_byte = BAT_ADDR_MFR_TYPE; | ||
282 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1); | ||
283 | if (ret) | ||
284 | return ret; | ||
285 | |||
286 | mfr = ec_byte >> 4; | ||
287 | |||
288 | switch (tech.intval) { | ||
289 | case POWER_SUPPLY_TECHNOLOGY_NiMH: | ||
290 | switch (mfr) { | ||
291 | case 1: /* Gold Peak */ | ||
292 | val->intval = 6000000; | ||
293 | break; | ||
294 | default: | ||
295 | return -EIO; | ||
296 | } | ||
297 | break; | ||
298 | |||
299 | case POWER_SUPPLY_TECHNOLOGY_LiFe: | ||
300 | switch (mfr) { | ||
301 | case 1: /* Gold Peak */ | ||
302 | val->intval = 6400000; | ||
303 | break; | ||
304 | case 2: /* BYD */ | ||
305 | val->intval = 6500000; | ||
306 | break; | ||
307 | default: | ||
308 | return -EIO; | ||
309 | } | ||
310 | break; | ||
311 | |||
312 | default: | ||
313 | return -EIO; | ||
314 | } | ||
315 | |||
316 | return ret; | ||
317 | } | ||
318 | |||
270 | /********************************************************************* | 319 | /********************************************************************* |
271 | * Battery properties | 320 | * Battery properties |
272 | *********************************************************************/ | 321 | *********************************************************************/ |
@@ -401,6 +450,11 @@ static int olpc_bat_get_property(struct power_supply *psy, | |||
401 | sprintf(bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf)); | 450 | sprintf(bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf)); |
402 | val->strval = bat_serial; | 451 | val->strval = bat_serial; |
403 | break; | 452 | break; |
453 | case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN: | ||
454 | ret = olpc_bat_get_voltage_max_design(val); | ||
455 | if (ret) | ||
456 | return ret; | ||
457 | break; | ||
404 | default: | 458 | default: |
405 | ret = -EINVAL; | 459 | ret = -EINVAL; |
406 | break; | 460 | break; |
@@ -428,6 +482,7 @@ static enum power_supply_property olpc_xo1_bat_props[] = { | |||
428 | POWER_SUPPLY_PROP_MANUFACTURER, | 482 | POWER_SUPPLY_PROP_MANUFACTURER, |
429 | POWER_SUPPLY_PROP_SERIAL_NUMBER, | 483 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
430 | POWER_SUPPLY_PROP_CHARGE_COUNTER, | 484 | POWER_SUPPLY_PROP_CHARGE_COUNTER, |
485 | POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, | ||
431 | }; | 486 | }; |
432 | 487 | ||
433 | /* XO-1.5 does not have ambient temperature property */ | 488 | /* XO-1.5 does not have ambient temperature property */ |
@@ -449,6 +504,7 @@ static enum power_supply_property olpc_xo15_bat_props[] = { | |||
449 | POWER_SUPPLY_PROP_MANUFACTURER, | 504 | POWER_SUPPLY_PROP_MANUFACTURER, |
450 | POWER_SUPPLY_PROP_SERIAL_NUMBER, | 505 | POWER_SUPPLY_PROP_SERIAL_NUMBER, |
451 | POWER_SUPPLY_PROP_CHARGE_COUNTER, | 506 | POWER_SUPPLY_PROP_CHARGE_COUNTER, |
507 | POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN, | ||
452 | }; | 508 | }; |
453 | 509 | ||
454 | /* EEPROM reading goes completely around the power_supply API, sadly */ | 510 | /* EEPROM reading goes completely around the power_supply API, sadly */ |