mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
power_supply: Add a charge_type property, and use it for olpc driver
This adds a new sysfs file called 'charge_type' which displays the type of charging (unknown, n/a, trickle charge, or fast charging). This allows things like battery diagnostics to determine what the battery/EC is doing without resorting to changing the 'status' sysfs output. Signed-off-by: Andres Salomon <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Anton Vorontsov <[email protected]>
This commit is contained in:
parent
144bbeaedc
commit
ee8076ed3e
4 changed files with 28 additions and 0 deletions
|
|
@ -233,6 +233,14 @@ static int olpc_bat_get_property(struct power_supply *psy,
|
|||
if (ret)
|
||||
return ret;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_TYPE:
|
||||
if (ec_byte & BAT_STAT_TRICKLE)
|
||||
val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
|
||||
else if (ec_byte & BAT_STAT_CHARGING)
|
||||
val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST;
|
||||
else
|
||||
val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_PRESENT:
|
||||
val->intval = !!(ec_byte & (BAT_STAT_PRESENT |
|
||||
BAT_STAT_TRICKLE));
|
||||
|
|
@ -325,6 +333,7 @@ static int olpc_bat_get_property(struct power_supply *psy,
|
|||
|
||||
static enum power_supply_property olpc_bat_props[] = {
|
||||
POWER_SUPPLY_PROP_STATUS,
|
||||
POWER_SUPPLY_PROP_CHARGE_TYPE,
|
||||
POWER_SUPPLY_PROP_PRESENT,
|
||||
POWER_SUPPLY_PROP_HEALTH,
|
||||
POWER_SUPPLY_PROP_TECHNOLOGY,
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ static ssize_t power_supply_show_property(struct device *dev,
|
|||
static char *status_text[] = {
|
||||
"Unknown", "Charging", "Discharging", "Not charging", "Full"
|
||||
};
|
||||
static char *charge_type[] = {
|
||||
"Unknown", "N/A", "Trickle", "Fast"
|
||||
};
|
||||
static char *health_text[] = {
|
||||
"Unknown", "Good", "Overheat", "Dead", "Over voltage",
|
||||
"Unspecified failure", "Cold",
|
||||
|
|
@ -70,6 +73,8 @@ static ssize_t power_supply_show_property(struct device *dev,
|
|||
|
||||
if (off == POWER_SUPPLY_PROP_STATUS)
|
||||
return sprintf(buf, "%s\n", status_text[value.intval]);
|
||||
else if (off == POWER_SUPPLY_PROP_CHARGE_TYPE)
|
||||
return sprintf(buf, "%s\n", charge_type[value.intval]);
|
||||
else if (off == POWER_SUPPLY_PROP_HEALTH)
|
||||
return sprintf(buf, "%s\n", health_text[value.intval]);
|
||||
else if (off == POWER_SUPPLY_PROP_TECHNOLOGY)
|
||||
|
|
@ -86,6 +91,7 @@ static ssize_t power_supply_show_property(struct device *dev,
|
|||
static struct device_attribute power_supply_attrs[] = {
|
||||
/* Properties of type `int' */
|
||||
POWER_SUPPLY_ATTR(status),
|
||||
POWER_SUPPLY_ATTR(charge_type),
|
||||
POWER_SUPPLY_ATTR(health),
|
||||
POWER_SUPPLY_ATTR(present),
|
||||
POWER_SUPPLY_ATTR(online),
|
||||
|
|
|
|||
Loading…
Reference in a new issue