* [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver @ 2009-06-30 6:17 Andres Salomon 2009-06-30 11:31 ` Mark Brown 2009-06-30 23:14 ` Anton Vorontsov 0 siblings, 2 replies; 11+ messages in thread From: Andres Salomon @ 2009-06-30 6:17 UTC (permalink / raw) To: cbou; +Cc: dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena This adds a new sysfs file called 'charge_type' which displays the type of charging (n/a, trickle charge, slow 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 <dilinger@collabora.co.uk> --- Documentation/power/power_supply_class.txt | 4 ++++ drivers/power/olpc_battery.c | 9 +++++++++ drivers/power/power_supply_sysfs.c | 6 ++++++ include/linux/power_supply.h | 8 ++++++++ 4 files changed, 27 insertions(+), 0 deletions(-) diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt index 709d955..bd53ebd 100644 --- a/Documentation/power/power_supply_class.txt +++ b/Documentation/power/power_supply_class.txt @@ -76,6 +76,10 @@ STATUS - this attribute represents operating status (charging, full, discharging (i.e. powering a load), etc.). This corresponds to BATTERY_STATUS_* values, as defined in battery.h. +CHARGE_TYPE - batteries can typically charge at different rates. +This defines trickle, slow, and fast charges. For batteries that +are already charged or discharging, 'n/a' can be displayed. + HEALTH - represents health of the battery, values corresponds to POWER_SUPPLY_HEALTH_*, defined in battery.h. diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index af17051..10cb875 100644 --- a/drivers/power/olpc_battery.c +++ b/drivers/power/olpc_battery.c @@ -230,6 +230,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)); break; @@ -321,6 +329,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, diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index d30e591..3e0f228 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, static char *status_text[] = { "Unknown", "Charging", "Discharging", "Not charging", "Full" }; + static char *charge_type[] = { + "N/A", "Trickle", "Slow", "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) @@ -87,6 +92,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), diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 0ab6aa1..d0be97c 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -39,6 +39,13 @@ enum { }; enum { + POWER_SUPPLY_CHARGE_TYPE_NONE = 0, + POWER_SUPPLY_CHARGE_TYPE_TRICKLE, + POWER_SUPPLY_CHARGE_TYPE_SLOW, + POWER_SUPPLY_CHARGE_TYPE_FAST, +}; + +enum { POWER_SUPPLY_HEALTH_UNKNOWN = 0, POWER_SUPPLY_HEALTH_GOOD, POWER_SUPPLY_HEALTH_OVERHEAT, @@ -70,6 +77,7 @@ enum { enum power_supply_property { /* Properties of type `int' */ POWER_SUPPLY_PROP_STATUS = 0, + POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_ONLINE, -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-06-30 6:17 [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver Andres Salomon @ 2009-06-30 11:31 ` Mark Brown 2009-06-30 15:04 ` Andres Salomon 2009-06-30 23:14 ` Anton Vorontsov 1 sibling, 1 reply; 11+ messages in thread From: Mark Brown @ 2009-06-30 11:31 UTC (permalink / raw) To: Andres Salomon Cc: cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena On Tue, Jun 30, 2009 at 02:17:30AM -0400, Andres Salomon wrote: > This adds a new sysfs file called 'charge_type' which displays the type of > charging (n/a, trickle charge, slow 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 <dilinger@collabora.co.uk> This looks good to me. Could you please keep me on the CC for any future revisions of this patch, I can make use of this in the WM8350 driver. > + static char *charge_type[] = { > + "N/A", "Trickle", "Slow", "Fast" > + }; I'd be tempted to make "N/A" be "Unknown" to match the style of the rest of the attributes. I'm also not sure that we need a slow type, but equally it shouldn't do any harm. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-06-30 11:31 ` Mark Brown @ 2009-06-30 15:04 ` Andres Salomon 2009-06-30 15:37 ` Anton Vorontsov 0 siblings, 1 reply; 11+ messages in thread From: Andres Salomon @ 2009-06-30 15:04 UTC (permalink / raw) To: Mark Brown Cc: cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena On Tue, 30 Jun 2009 12:31:35 +0100 Mark Brown <broonie@opensource.wolfsonmicro.com> wrote: > On Tue, Jun 30, 2009 at 02:17:30AM -0400, Andres Salomon wrote: > > > This adds a new sysfs file called 'charge_type' which displays the > > type of charging (n/a, trickle charge, slow 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 <dilinger@collabora.co.uk> > > This looks good to me. Could you please keep me on the CC for any > future revisions of this patch, I can make use of this in the WM8350 > driver. Sure. > > > + static char *charge_type[] = { > > + "N/A", "Trickle", "Slow", "Fast" > > + }; > > I'd be tempted to make "N/A" be "Unknown" to match the style of the > rest of the attributes. I'm also not sure that we need a slow type, > but equally it shouldn't do any harm. It's known though, right? :) It could just as easily be "None", "Unknown", etc, but I'm not particularly picky. As far as the slow type, I don't see the need either, but I assumed Anton was aware of devices that differentiated between slow and trickle charging. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-06-30 15:04 ` Andres Salomon @ 2009-06-30 15:37 ` Anton Vorontsov 2009-06-30 15:57 ` Mark Brown 0 siblings, 1 reply; 11+ messages in thread From: Anton Vorontsov @ 2009-06-30 15:37 UTC (permalink / raw) To: Andres Salomon Cc: Mark Brown, cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena On Tue, Jun 30, 2009 at 11:04:30AM -0400, Andres Salomon wrote: > On Tue, 30 Jun 2009 12:31:35 +0100 > Mark Brown <broonie@opensource.wolfsonmicro.com> wrote: > > > On Tue, Jun 30, 2009 at 02:17:30AM -0400, Andres Salomon wrote: > > > > > This adds a new sysfs file called 'charge_type' which displays the > > > type of charging (n/a, trickle charge, slow 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 <dilinger@collabora.co.uk> > > > > This looks good to me. Could you please keep me on the CC for any > > future revisions of this patch, I can make use of this in the WM8350 > > driver. > > Sure. > > > > > > + static char *charge_type[] = { > > > + "N/A", "Trickle", "Slow", "Fast" > > > + }; > > > > I'd be tempted to make "N/A" be "Unknown" to match the style of the > > rest of the attributes. I'm also not sure that we need a slow type, > > but equally it shouldn't do any harm. > > > It's known though, right? :) It could just as easily be "None", > "Unknown", etc, but I'm not particularly picky. These are quite different states, and thinking about it, we might want to introduce both. Default is "Unknown" (0), means that the driver can't report the charging mode at this very moment. And "N/A" is "not applicable", i.e. we're not charging anything right now. > As far as the slow type, I don't see the need either, but I assumed > Anton was aware of devices that differentiated between slow and > trickle charging. Yep, there are two charging modes in Openmoko Neo FreeRunners: - 100 mA. It's "slow" mode -- used when the Neo couldn't negotiate with USB host, so it is permitted to only draw 100 mA from VBUS. - 500/1000 mA. It's so-called "fast" mode, can be enabled after successful negotiation with the USB host. Well, this kind slow charging isn't official terminology, and I'm not sure if we should use it. But I'm fine with it since we can always remove "Slow" mode (i.e. report it as "Fast"), and userspace won't break. Thanks, -- Anton Vorontsov email: cbouatmailru@gmail.com irc://irc.freenode.net/bd2 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-06-30 15:37 ` Anton Vorontsov @ 2009-06-30 15:57 ` Mark Brown 2009-06-30 19:02 ` Anton Vorontsov 0 siblings, 1 reply; 11+ messages in thread From: Mark Brown @ 2009-06-30 15:57 UTC (permalink / raw) To: Anton Vorontsov Cc: Andres Salomon, cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena On Tue, Jun 30, 2009 at 07:37:19PM +0400, Anton Vorontsov wrote: > On Tue, Jun 30, 2009 at 11:04:30AM -0400, Andres Salomon wrote: > > As far as the slow type, I don't see the need either, but I assumed > > Anton was aware of devices that differentiated between slow and > > trickle charging. > Yep, there are two charging modes in Openmoko Neo FreeRunners: > - 100 mA. It's "slow" mode -- used when the Neo couldn't negotiate > with USB host, so it is permitted to only draw 100 mA from VBUS. I strongly suspect you will find that the "slow" mode there is actually a trickle charge. It's a lot more practical to trickle charge in mobile phone sized systems since the batteries are so much smaller than laptop batteries. > - 500/1000 mA. It's so-called "fast" mode, can be enabled after > successful negotiation with the USB host. Even if the 500mA is available you'll not always be able to do a fast charge from a USB supply - some systems draw enough current to require that the USB supply be suppliemented from battery when they're being heavily used. > Well, this kind slow charging isn't official terminology, and > I'm not sure if we should use it. But I'm fine with it since we > can always remove "Slow" mode (i.e. report it as "Fast"), and > userspace won't break. I guess my main question was if it was distinguishable from trickle charging. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-06-30 15:57 ` Mark Brown @ 2009-06-30 19:02 ` Anton Vorontsov 2009-06-30 19:15 ` Mark Brown 0 siblings, 1 reply; 11+ messages in thread From: Anton Vorontsov @ 2009-06-30 19:02 UTC (permalink / raw) To: Mark Brown Cc: Andres Salomon, cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena On Tue, Jun 30, 2009 at 04:57:14PM +0100, Mark Brown wrote: > On Tue, Jun 30, 2009 at 07:37:19PM +0400, Anton Vorontsov wrote: > > On Tue, Jun 30, 2009 at 11:04:30AM -0400, Andres Salomon wrote: > > > > As far as the slow type, I don't see the need either, but I assumed > > > Anton was aware of devices that differentiated between slow and > > > trickle charging. > > > Yep, there are two charging modes in Openmoko Neo FreeRunners: > > > - 100 mA. It's "slow" mode -- used when the Neo couldn't negotiate > > with USB host, so it is permitted to only draw 100 mA from VBUS. > > I strongly suspect you will find that the "slow" mode there is actually > a trickle charge. It's a lot more practical to trickle charge in mobile > phone sized systems since the batteries are so much smaller than laptop > batteries. Could be. Anyway, I was curious what terminology is used in specs, and so I took a look at pcf50633 spec. "When a suitable adapter or USB supply is detected, the battery is charged with a constant precharge current (CC mode). The constant current is selected via the prechgcur bits ... For a Li-ion battery, the precharge current is typically 0.1C (C = charge rate = the charge current which will fully charge the battery in one hour)." And then what is "fast" charge in pcf50633: "Fast charging of a battery is only permitted within a certain temperature window (typically between 0 and 50 °C). ... If charging is via the adapter, the fast charge current is determined by the fstchgcur1 bit settings. If charging is via the USB connector, bits fstchgcur2 determine the fast charge current. For a Li-Ion battery, the fast-charge current is typically between 0.7 C and 1.0 C." There is also precharge-wait and fastcharge-wait modes, FWIW. But we don't expose this information to the userspace. > > - 500/1000 mA. It's so-called "fast" mode, can be enabled after > > successful negotiation with the USB host. > > Even if the 500mA is available you'll not always be able to do a fast > charge from a USB supply - some systems draw enough current to require > that the USB supply be suppliemented from battery when they're being > heavily used. True. Though, for these cases there is an AC charger that can do 2A. ;-) > > Well, this kind slow charging isn't official terminology, and > > I'm not sure if we should use it. But I'm fine with it since we > > can always remove "Slow" mode (i.e. report it as "Fast"), and > > userspace won't break. > > I guess my main question was if it was distinguishable from trickle > charging. Probably not, Fast/Slow/Trickle are quite vague terms anyway. I'd prefer if we could measure this in some real units, but alas... Thanks, -- Anton Vorontsov email: cbouatmailru@gmail.com irc://irc.freenode.net/bd2 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-06-30 19:02 ` Anton Vorontsov @ 2009-06-30 19:15 ` Mark Brown 0 siblings, 0 replies; 11+ messages in thread From: Mark Brown @ 2009-06-30 19:15 UTC (permalink / raw) To: Anton Vorontsov Cc: Andres Salomon, cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena On Tue, Jun 30, 2009 at 11:02:39PM +0400, Anton Vorontsov wrote: > On Tue, Jun 30, 2009 at 04:57:14PM +0100, Mark Brown wrote: > > I strongly suspect you will find that the "slow" mode there is actually > > a trickle charge. It's a lot more practical to trickle charge in mobile > > phone sized systems since the batteries are so much smaller than laptop > > batteries. ... > For a Li-ion battery, the precharge current is typically 0.1C > (C = charge rate = the charge current which will fully charge the > battery in one hour)." Yup, that sounds like a trickle charge all right. > There is also precharge-wait and fastcharge-wait modes, FWIW. > But we don't expose this information to the userspace. Those *probably* boil down to one of the other states - without looking at the datasheet they sound like waiting for the conditions required to do one of the other charges to be satisfied. > Probably not, Fast/Slow/Trickle are quite vague terms anyway. > I'd prefer if we could measure this in some real units, but alas... Fast and trickle charge are fairly well understood terms, I think. For specific numbers you'd need to look at the particular batteries involved, unfortunately, but they do tend to be fairly obvious when looking at a particular charger and/or battery. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-06-30 6:17 [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver Andres Salomon 2009-06-30 11:31 ` Mark Brown @ 2009-06-30 23:14 ` Anton Vorontsov 2009-07-02 13:45 ` Andres Salomon 1 sibling, 1 reply; 11+ messages in thread From: Anton Vorontsov @ 2009-06-30 23:14 UTC (permalink / raw) To: Andres Salomon Cc: cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena, Mark Brown On Tue, Jun 30, 2009 at 02:17:30AM -0400, Andres Salomon wrote: > > This adds a new sysfs file called 'charge_type' which displays the type of > charging (n/a, trickle charge, slow 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 <dilinger@collabora.co.uk> > --- The patch didn't apply cleanly (not sure why, maybe because of my "cosmetic" changes in the previous patches? hm.) Can you please add "Unknown" state before "N/A", and per Mark's comments also remove "Slow" charge type, and resend the patch against battery-2.6.git tree? Mark, since you seem to be interested in this addition, it would be great to see your ack/nak status on an updated patch, so we'll be sure that this is suitable for WM8350. Thanks! -- Anton Vorontsov email: cbouatmailru@gmail.com irc://irc.freenode.net/bd2 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-06-30 23:14 ` Anton Vorontsov @ 2009-07-02 13:45 ` Andres Salomon 2009-07-02 14:06 ` Mark Brown 0 siblings, 1 reply; 11+ messages in thread From: Andres Salomon @ 2009-07-02 13:45 UTC (permalink / raw) To: avorontsov Cc: cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena, Mark Brown On Wed, 1 Jul 2009 03:14:50 +0400 Anton Vorontsov <avorontsov@ru.mvista.com> wrote: > On Tue, Jun 30, 2009 at 02:17:30AM -0400, Andres Salomon wrote: > > > > This adds a new sysfs file called 'charge_type' which displays the > > type of charging (n/a, trickle charge, slow 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 <dilinger@collabora.co.uk> > > --- > > The patch didn't apply cleanly (not sure why, maybe because > of my "cosmetic" changes in the previous patches? hm.) > > Can you please add "Unknown" state before "N/A", and > per Mark's comments also remove "Slow" charge type, and > resend the patch against battery-2.6.git tree? > > Mark, since you seem to be interested in this addition, it > would be great to see your ack/nak status on an updated > patch, so we'll be sure that this is suitable for WM8350. > > Thanks! > An updated patch (against battery-2.6 master) is below. 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 <dilinger@collabora.co.uk> --- Documentation/power/power_supply_class.txt | 5 +++++ drivers/power/olpc_battery.c | 9 +++++++++ drivers/power/power_supply_sysfs.c | 6 ++++++ 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 709d955..9f16c51 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, discharging (i.e. powering a load), etc.). This corresponds to BATTERY_STATUS_* values, as defined in battery.h. +CHARGE_TYPE - batteries can typically charge at different rates. +This defines trickle and fast charges. For batteries that +are already charged or discharging, 'n/a' can be displayed (or +'unknown', if the status is not known). + HEALTH - represents health of the battery, values corresponds to POWER_SUPPLY_HEALTH_*, defined in battery.h. diff --git a/drivers/power/olpc_battery.c b/drivers/power/olpc_battery.c index 602bbd0..8fefe5a 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, 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, diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c index 9deabbd..0814439 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, 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), diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 0ab6aa1..4c7c6fc 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -39,6 +39,13 @@ enum { }; enum { + POWER_SUPPLY_CHARGE_TYPE_UNKNOWN = 0, + POWER_SUPPLY_CHARGE_TYPE_NONE, + POWER_SUPPLY_CHARGE_TYPE_TRICKLE, + POWER_SUPPLY_CHARGE_TYPE_FAST, +}; + +enum { POWER_SUPPLY_HEALTH_UNKNOWN = 0, POWER_SUPPLY_HEALTH_GOOD, POWER_SUPPLY_HEALTH_OVERHEAT, @@ -70,6 +77,7 @@ enum { enum power_supply_property { /* Properties of type `int' */ POWER_SUPPLY_PROP_STATUS = 0, + POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_ONLINE, -- 1.5.6.5 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-07-02 13:45 ` Andres Salomon @ 2009-07-02 14:06 ` Mark Brown 2009-07-02 14:26 ` Anton Vorontsov 0 siblings, 1 reply; 11+ messages in thread From: Mark Brown @ 2009-07-02 14:06 UTC (permalink / raw) To: Andres Salomon Cc: avorontsov, cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena On Thu, Jul 02, 2009 at 09:45:18AM -0400, Andres Salomon wrote: > 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 <dilinger@collabora.co.uk> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver 2009-07-02 14:06 ` Mark Brown @ 2009-07-02 14:26 ` Anton Vorontsov 0 siblings, 0 replies; 11+ messages in thread From: Anton Vorontsov @ 2009-07-02 14:26 UTC (permalink / raw) To: Mark Brown Cc: Andres Salomon, cbou, dwmw2, linux-kernel, richard, Andrew Morton, Paul Fox, dsaxena On Thu, Jul 02, 2009 at 03:06:53PM +0100, Mark Brown wrote: > On Thu, Jul 02, 2009 at 09:45:18AM -0400, Andres Salomon wrote: > > > 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 <dilinger@collabora.co.uk> > > Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Much thanks to both of you. This is now applied to battery-2.6.git (for -next). -- Anton Vorontsov email: cbouatmailru@gmail.com irc://irc.freenode.net/bd2 ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2009-07-02 14:26 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-06-30 6:17 [PATCH 5/5] power_supply: add a charge_type status to the api, and use it for olpc driver Andres Salomon 2009-06-30 11:31 ` Mark Brown 2009-06-30 15:04 ` Andres Salomon 2009-06-30 15:37 ` Anton Vorontsov 2009-06-30 15:57 ` Mark Brown 2009-06-30 19:02 ` Anton Vorontsov 2009-06-30 19:15 ` Mark Brown 2009-06-30 23:14 ` Anton Vorontsov 2009-07-02 13:45 ` Andres Salomon 2009-07-02 14:06 ` Mark Brown 2009-07-02 14:26 ` Anton Vorontsov
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox