Commit b202a5e6 authored by Sascha Silbe's avatar Sascha Silbe Committed by Anton Vorontsov

olpc_battery: Add support for CHARGE_FULL_DESIGN

Some user space software (read: UPower) uses CHARGE_FULL_DESIGN for internal
calculations. The design capacity of the OLPC batteries is effectively fixed
and only needs to be exported.
Signed-off-by: default avatarSascha Silbe <sascha-pgp@silbe.org>
Signed-off-by: default avatarPaul Fox <pgf@laptop.org>
Signed-off-by: default avatarAnton Vorontsov <cbouatmailru@gmail.com>
parent c566d299
...@@ -201,6 +201,54 @@ static int olpc_bat_get_tech(union power_supply_propval *val) ...@@ -201,6 +201,54 @@ static int olpc_bat_get_tech(union power_supply_propval *val)
return ret; return ret;
} }
static int olpc_bat_get_charge_full_design(union power_supply_propval *val)
{
uint8_t ec_byte;
union power_supply_propval tech;
int ret, mfr;
ret = olpc_bat_get_tech(&tech);
if (ret)
return ret;
ec_byte = BAT_ADDR_MFR_TYPE;
ret = olpc_ec_cmd(EC_BAT_EEPROM, &ec_byte, 1, &ec_byte, 1);
if (ret)
return ret;
mfr = ec_byte >> 4;
switch (tech.intval) {
case POWER_SUPPLY_TECHNOLOGY_NiMH:
switch (mfr) {
case 1: /* Gold Peak */
val->intval = 3000000*.8;
break;
default:
return -EIO;
}
break;
case POWER_SUPPLY_TECHNOLOGY_LiFe:
switch (mfr) {
case 1: /* Gold Peak */
val->intval = 2800000;
break;
case 2: /* BYD */
val->intval = 3100000;
break;
default:
return -EIO;
}
break;
default:
return -EIO;
}
return ret;
}
/********************************************************************* /*********************************************************************
* Battery properties * Battery properties
*********************************************************************/ *********************************************************************/
...@@ -294,6 +342,11 @@ static int olpc_bat_get_property(struct power_supply *psy, ...@@ -294,6 +342,11 @@ static int olpc_bat_get_property(struct power_supply *psy,
else else
val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL; val->intval = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
break; break;
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
ret = olpc_bat_get_charge_full_design(val);
if (ret)
return ret;
break;
case POWER_SUPPLY_PROP_TEMP: case POWER_SUPPLY_PROP_TEMP:
ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2); ret = olpc_ec_cmd(EC_BAT_TEMP, NULL, 0, (void *)&ec_word, 2);
if (ret) if (ret)
...@@ -341,6 +394,7 @@ static enum power_supply_property olpc_xo1_bat_props[] = { ...@@ -341,6 +394,7 @@ static enum power_supply_property olpc_xo1_bat_props[] = {
POWER_SUPPLY_PROP_CURRENT_AVG, POWER_SUPPLY_PROP_CURRENT_AVG,
POWER_SUPPLY_PROP_CAPACITY, POWER_SUPPLY_PROP_CAPACITY,
POWER_SUPPLY_PROP_CAPACITY_LEVEL, POWER_SUPPLY_PROP_CAPACITY_LEVEL,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TEMP,
POWER_SUPPLY_PROP_TEMP_AMBIENT, POWER_SUPPLY_PROP_TEMP_AMBIENT,
POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_MANUFACTURER,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment