diff options
-rw-r--r-- | Documentation/power/power_supply_class.txt | 5 | ||||
-rw-r--r-- | drivers/power/olpc_battery.c | 9 | ||||
-rw-r--r-- | drivers/power/power_supply_sysfs.c | 6 | ||||
-rw-r--r-- | include/linux/power_supply.h | 8 |
4 files changed, 28 insertions, 0 deletions
diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt index 709d95571d7b..9f16c5178b66 100644 --- a/Documentation/power/power_supply_class.txt +++ b/Documentation/power/power_supply_class.txt | |||
@@ -76,6 +76,11 @@ STATUS - this attribute represents operating status (charging, full, | |||
76 | discharging (i.e. powering a load), etc.). This corresponds to | 76 | discharging (i.e. powering a load), etc.). This corresponds to |
77 | BATTERY_STATUS_* values, as defined in battery.h. | 77 | BATTERY_STATUS_* values, as defined in battery.h. |
78 | 78 | ||
79 | CHARGE_TYPE - batteries can typically charge at different rates. | ||
80 | This defines trickle and fast charges. For batteries that | ||
81 | are already charged or discharging, 'n/a' can be displayed (or | ||
82 | 'unknown', if the status is not known). | ||
83 | |||
79 | HEALTH - represents health of the battery, values corresponds to | 84 | HEALTH - represents health of the battery, values corresponds to |
80 | POWER_SUPPLY_HEALTH_*, defined in battery.h. | 85 | POWER_SUPPLY_HEALTH_*, defined in battery.h. |
81 | 86 | ||
diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index 602bbd008f78..8fefe5a73558 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c | |||
@@ -233,6 +233,14 @@ static int olpc_bat_get_property(struct power_supply *psy, | |||
233 | if (ret) | 233 | if (ret) |
234 | return ret; | 234 | return ret; |
235 | break; | 235 | break; |
236 | case POWER_SUPPLY_PROP_CHARGE_TYPE: | ||
237 | if (ec_byte & BAT_STAT_TRICKLE) | ||
238 | val->intval = POWER_SUPPLY_CHARGE_TYPE_TRICKLE; | ||
239 | else if (ec_byte & BAT_STAT_CHARGING) | ||
240 | val->intval = POWER_SUPPLY_CHARGE_TYPE_FAST; | ||
241 | else | ||
242 | val->intval = POWER_SUPPLY_CHARGE_TYPE_NONE; | ||
243 | break; | ||
236 | case POWER_SUPPLY_PROP_PRESENT: | 244 | case POWER_SUPPLY_PROP_PRESENT: |
237 | val->intval = !!(ec_byte & (BAT_STAT_PRESENT | | 245 | val->intval = !!(ec_byte & (BAT_STAT_PRESENT | |
238 | BAT_STAT_TRICKLE)); | 246 | BAT_STAT_TRICKLE)); |
@@ -325,6 +333,7 @@ static int olpc_bat_get_property(struct power_supply *psy, | |||
325 | 333 | ||
326 | static enum power_supply_property olpc_bat_props[] = { | 334 | static enum power_supply_property olpc_bat_props[] = { |
327 | POWER_SUPPLY_PROP_STATUS, | 335 | POWER_SUPPLY_PROP_STATUS, |
336 | POWER_SUPPLY_PROP_CHARGE_TYPE, | ||
328 | POWER_SUPPLY_PROP_PRESENT, | 337 | POWER_SUPPLY_PROP_PRESENT, |
329 | POWER_SUPPLY_PROP_HEALTH, | 338 | POWER_SUPPLY_PROP_HEALTH, |
330 | POWER_SUPPLY_PROP_TECHNOLOGY, | 339 | POWER_SUPPLY_PROP_TECHNOLOGY, |
diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index 9deabbde6fd6..08144393d64b 100644 --- a/drivers/power/power_supply_sysfs.c +++ b/drivers/power/power_supply_sysfs.c | |||
@@ -43,6 +43,9 @@ static ssize_t power_supply_show_property(struct device *dev, | |||
43 | static char *status_text[] = { | 43 | static char *status_text[] = { |
44 | "Unknown", "Charging", "Discharging", "Not charging", "Full" | 44 | "Unknown", "Charging", "Discharging", "Not charging", "Full" |
45 | }; | 45 | }; |
46 | static char *charge_type[] = { | ||
47 | "Unknown", "N/A", "Trickle", "Fast" | ||
48 | }; | ||
46 | static char *health_text[] = { | 49 | static char *health_text[] = { |
47 | "Unknown", "Good", "Overheat", "Dead", "Over voltage", | 50 | "Unknown", "Good", "Overheat", "Dead", "Over voltage", |
48 | "Unspecified failure", "Cold", | 51 | "Unspecified failure", "Cold", |
@@ -70,6 +73,8 @@ static ssize_t power_supply_show_property(struct device *dev, | |||
70 | 73 | ||
71 | if (off == POWER_SUPPLY_PROP_STATUS) | 74 | if (off == POWER_SUPPLY_PROP_STATUS) |
72 | return sprintf(buf, "%s\n", status_text[value.intval]); | 75 | return sprintf(buf, "%s\n", status_text[value.intval]); |
76 | else if (off == POWER_SUPPLY_PROP_CHARGE_TYPE) | ||
77 | return sprintf(buf, "%s\n", charge_type[value.intval]); | ||
73 | else if (off == POWER_SUPPLY_PROP_HEALTH) | 78 | else if (off == POWER_SUPPLY_PROP_HEALTH) |
74 | return sprintf(buf, "%s\n", health_text[value.intval]); | 79 | return sprintf(buf, "%s\n", health_text[value.intval]); |
75 | else if (off == POWER_SUPPLY_PROP_TECHNOLOGY) | 80 | else if (off == POWER_SUPPLY_PROP_TECHNOLOGY) |
@@ -86,6 +91,7 @@ static ssize_t power_supply_show_property(struct device *dev, | |||
86 | static struct device_attribute power_supply_attrs[] = { | 91 | static struct device_attribute power_supply_attrs[] = { |
87 | /* Properties of type `int' */ | 92 | /* Properties of type `int' */ |
88 | POWER_SUPPLY_ATTR(status), | 93 | POWER_SUPPLY_ATTR(status), |
94 | POWER_SUPPLY_ATTR(charge_type), | ||
89 | POWER_SUPPLY_ATTR(health), | 95 | POWER_SUPPLY_ATTR(health), |
90 | POWER_SUPPLY_ATTR(present), | 96 | POWER_SUPPLY_ATTR(present), |
91 | POWER_SUPPLY_ATTR(online), | 97 | POWER_SUPPLY_ATTR(online), |
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 0ab6aa171241..4c7c6fc35487 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h | |||
@@ -39,6 +39,13 @@ enum { | |||
39 | }; | 39 | }; |
40 | 40 | ||
41 | enum { | 41 | enum { |
42 | POWER_SUPPLY_CHARGE_TYPE_UNKNOWN = 0, | ||
43 | POWER_SUPPLY_CHARGE_TYPE_NONE, | ||
44 | POWER_SUPPLY_CHARGE_TYPE_TRICKLE, | ||
45 | POWER_SUPPLY_CHARGE_TYPE_FAST, | ||
46 | }; | ||
47 | |||
48 | enum { | ||
42 | POWER_SUPPLY_HEALTH_UNKNOWN = 0, | 49 | POWER_SUPPLY_HEALTH_UNKNOWN = 0, |
43 | POWER_SUPPLY_HEALTH_GOOD, | 50 | POWER_SUPPLY_HEALTH_GOOD, |
44 | POWER_SUPPLY_HEALTH_OVERHEAT, | 51 | POWER_SUPPLY_HEALTH_OVERHEAT, |
@@ -70,6 +77,7 @@ enum { | |||
70 | enum power_supply_property { | 77 | enum power_supply_property { |
71 | /* Properties of type `int' */ | 78 | /* Properties of type `int' */ |
72 | POWER_SUPPLY_PROP_STATUS = 0, | 79 | POWER_SUPPLY_PROP_STATUS = 0, |
80 | POWER_SUPPLY_PROP_CHARGE_TYPE, | ||
73 | POWER_SUPPLY_PROP_HEALTH, | 81 | POWER_SUPPLY_PROP_HEALTH, |
74 | POWER_SUPPLY_PROP_PRESENT, | 82 | POWER_SUPPLY_PROP_PRESENT, |
75 | POWER_SUPPLY_PROP_ONLINE, | 83 | POWER_SUPPLY_PROP_ONLINE, |