diff options
Diffstat (limited to 'drivers/power/olpc_battery.c')
-rw-r--r-- | drivers/power/olpc_battery.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index 0cd4f15e3013..663b73023eaf 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c | |||
@@ -201,6 +201,54 @@ static int olpc_bat_get_tech(union power_supply_propval *val) | |||
201 | return ret; | 201 | return ret; |
202 | } | 202 | } |
203 | 203 | ||
204 | static int olpc_bat_get_charge_full_design(union power_supply_propval *val) | ||
205 | { | ||
206 | uint8_t ec_byte; | ||
207 | union power_supply_propval tech; | ||
208 | int ret, mfr; | ||
209 | |||
210 | ret = olpc_bat_get_tech(&tech); | ||
211 | if (ret) | ||
212 | return ret; | ||
213 | |||
214 | ec_byte = BAT_ADDR_MFR_TYPE; | ||
215 | ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1); | ||
216 | if (ret) | ||
217 | return ret; | ||
218 | |||
219 | mfr = ec_byte >> 4; | ||
220 | |||
221 | switch (tech.intval) { | ||
222 | case POWER_SUPPLY_TECHNOLOGY_NiMH: | ||
223 | switch (mfr) { | ||
224 | case 1: /* Gold Peak */ | ||
225 | val->intval = 3000000*.8; | ||
226 | break; | ||
227 | default: | ||
228 | return -EIO; | ||
229 | } | ||
230 | break; | ||
231 | |||
232 | case POWER_SUPPLY_TECHNOLOGY_LiFe: | ||
233 | switch (mfr) { | ||
234 | case 1: /* Gold Peak */ | ||
235 | val->intval = 2800000; | ||
236 | break; | ||
237 | case 2: /* BYD */ | ||
238 | val->intval = 3100000; | ||
239 | break; | ||
240 | default: | ||
241 | return -EIO; | ||
242 | } | ||
243 | break; | ||
244 | |||
245 | default: | ||
246 | return -EIO; | ||
247 | } | ||
248 | |||
249 | return ret; | ||
250 | } | ||
251 | |||
204 | /********************************************************************* | 252 | /********************************************************************* |
205 | * Battery properties | 253 | * Battery properties |
206 | *********************************************************************/ | 254 | *********************************************************************/ |
@@ -294,6 +342,11 @@ static int olpc_bat_get_property(struct power_supply *psy, | |||
294 | else | 342 | else |
295 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; | 343 | val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; |
296 | break; | 344 | break; |
345 | case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN: | ||
346 | ret = olpc_bat_get_charge_full_design(val); | ||
347 | if (ret) | ||
348 | return ret; | ||
349 | break; | ||
297 | case POWER_SUPPLY_PROP_TEMP: | 350 | case POWER_SUPPLY_PROP_TEMP: |
298 | ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); | 351 | ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); |
299 | if (ret) | 352 | if (ret) |
@@ -341,6 +394,7 @@ static enum power_supply_property olpc_xo1_bat_props[] = { | |||
341 | POWER_SUPPLY_PROP_CURRENT_AVG, | 394 | POWER_SUPPLY_PROP_CURRENT_AVG, |
342 | POWER_SUPPLY_PROP_CAPACITY, | 395 | POWER_SUPPLY_PROP_CAPACITY, |
343 | POWER_SUPPLY_PROP_CAPACITY_LEVEL, | 396 | POWER_SUPPLY_PROP_CAPACITY_LEVEL, |
397 | POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN, | ||
344 | POWER_SUPPLY_PROP_TEMP, | 398 | POWER_SUPPLY_PROP_TEMP, |
345 | POWER_SUPPLY_PROP_TEMP_AMBIENT, | 399 | POWER_SUPPLY_PROP_TEMP_AMBIENT, |
346 | POWER_SUPPLY_PROP_MANUFACTURER, | 400 | POWER_SUPPLY_PROP_MANUFACTURER, |