Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 320503
b: refs/heads/master
c: 5619d0b
h: refs/heads/master
i:
  320501: e6f5b2c
  320499: ac1cb88
  320495: 65c5e0f
v: v3
  • Loading branch information
Richard A. Smith authored and Anton Vorontsov committed Jul 16, 2012
1 parent e3853cf commit 7fe240f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: c4727555d0bb2242047395dbcec253ea9d08a3b7
refs/heads/master: 5619d0ba97cd336a100121cf8f2968c4b1f6c848
56 changes: 56 additions & 0 deletions trunk/drivers/power/olpc_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,55 @@ static int olpc_bat_get_charge_now(union power_supply_propval *val)
return 0;
}

static int olpc_bat_get_voltage_max_design(union power_supply_propval *val)
{
uint8_t ec_byte;
union power_supply_propval tech;
int mfr;
int ret;

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 = 6000000;
break;
default:
return -EIO;
}
break;

case POWER_SUPPLY_TECHNOLOGY_LiFe:
switch (mfr) {
case 1: /* Gold Peak */
val->intval = 6400000;
break;
case 2: /* BYD */
val->intval = 6500000;
break;
default:
return -EIO;
}
break;

default:
return -EIO;
}

return ret;
}

/*********************************************************************
* Battery properties
*********************************************************************/
Expand Down Expand Up @@ -401,6 +450,11 @@ static int olpc_bat_get_property(struct power_supply *psy,
sprintf(bat_serial, "%016llx", (long long)be64_to_cpu(ser_buf));
val->strval = bat_serial;
break;
case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
ret = olpc_bat_get_voltage_max_design(val);
if (ret)
return ret;
break;
default:
ret = -EINVAL;
break;
Expand Down Expand Up @@ -428,6 +482,7 @@ static enum power_supply_property olpc_xo1_bat_props[] = {
POWER_SUPPLY_PROP_MANUFACTURER,
POWER_SUPPLY_PROP_SERIAL_NUMBER,
POWER_SUPPLY_PROP_CHARGE_COUNTER,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
};

/* XO-1.5 does not have ambient temperature property */
Expand All @@ -449,6 +504,7 @@ static enum power_supply_property olpc_xo15_bat_props[] = {
POWER_SUPPLY_PROP_MANUFACTURER,
POWER_SUPPLY_PROP_SERIAL_NUMBER,
POWER_SUPPLY_PROP_CHARGE_COUNTER,
POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN,
};

/* EEPROM reading goes completely around the power_supply API, sadly */
Expand Down

0 comments on commit 7fe240f

Please sign in to comment.