public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* power_supply class/framework question
@ 2009-08-08  2:19 Brian Swetland
  2009-08-10 15:00 ` Pavel Machek
  0 siblings, 1 reply; 6+ messages in thread
From: Brian Swetland @ 2009-08-08  2:19 UTC (permalink / raw)
  To: Anton Vorontsov, David Woodhouse; +Cc: linux-kernel

(feel free to redirect me to a different mailing list if there's a
more appropriate place to ask this question)

I'm working on cleaning up some code to more correctly use the power
supply framework (have the battery driver receive notification from
the wall/usb power supplies, etc), and ran into a slight snag.  For
mobile usb powered devices, we need to know how much current can
safely be consumed by the charge circuit -- generally this is one of:
none, <500mA or 1000mA, which correspond to "no power supply", "usb
power supply", or "wall power supply".

I can use power_supply_am_i_supplied() to determine if I'm receiving
power, but there's no way to determine either how much (if I have one
power supply that indicates max current available) or which supply (if
I define a separate "ac" and "usb" power supply).

I'd be happy to throw together some patches to handle this, but was
wondering if there was any preference in how such information would be
made available.

Thanks,

Brian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: power_supply class/framework question
  2009-08-08  2:19 power_supply class/framework question Brian Swetland
@ 2009-08-10 15:00 ` Pavel Machek
  2009-08-10 15:28   ` Anton Vorontsov
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2009-08-10 15:00 UTC (permalink / raw)
  To: Brian Swetland; +Cc: Anton Vorontsov, David Woodhouse, linux-kernel

Hi!

> (feel free to redirect me to a different mailing list if there's a
> more appropriate place to ask this question)
> 
> I'm working on cleaning up some code to more correctly use the power
> supply framework (have the battery driver receive notification from
> the wall/usb power supplies, etc), and ran into a slight snag.  For
> mobile usb powered devices, we need to know how much current can
> safely be consumed by the charge circuit -- generally this is one of:
> none, <500mA or 1000mA, which correspond to "no power supply", "usb
> power supply", or "wall power supply".

Actuallly, it is one of 'none', 100mA (min power USB has to supplly),
500mA (max powe USB can supply by spec), 1A (wall).

For example sharp zaurus can only supply cca 300mA out of its port.

> I can use power_supply_am_i_supplied() to determine if I'm receiving
> power, but there's no way to determine either how much (if I have one
> power supply that indicates max current available) or which supply (if
> I define a separate "ac" and "usb" power supply).

Should am_i_supplied() just return miliamps?
								Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: power_supply class/framework question
  2009-08-10 15:00 ` Pavel Machek
@ 2009-08-10 15:28   ` Anton Vorontsov
  2009-08-10 16:14     ` Brian Swetland
  0 siblings, 1 reply; 6+ messages in thread
From: Anton Vorontsov @ 2009-08-10 15:28 UTC (permalink / raw)
  To: Pavel Machek
  Cc: Brian Swetland, Anton Vorontsov, David Woodhouse, linux-kernel

On Mon, Aug 10, 2009 at 05:00:11PM +0200, Pavel Machek wrote:
> Hi!
> 
> > (feel free to redirect me to a different mailing list if there's a
> > more appropriate place to ask this question)
> > 
> > I'm working on cleaning up some code to more correctly use the power
> > supply framework (have the battery driver receive notification from
> > the wall/usb power supplies, etc), and ran into a slight snag.  For
> > mobile usb powered devices, we need to know how much current can
> > safely be consumed by the charge circuit -- generally this is one of:
> > none, <500mA or 1000mA, which correspond to "no power supply", "usb
> > power supply", or "wall power supply".
> 
> Actuallly, it is one of 'none', 100mA (min power USB has to supplly),
> 500mA (max powe USB can supply by spec), 1A (wall).
> 
> For example sharp zaurus can only supply cca 300mA out of its port.
> 
> > I can use power_supply_am_i_supplied() to determine if I'm receiving
> > power, but there's no way to determine either how much (if I have one
> > power supply that indicates max current available) or which supply (if
> > I define a separate "ac" and "usb" power supply).
> 
> Should am_i_supplied() just return miliamps?

Or enum power_supply_type, with the following priority:
mains (wall), usb, battery?

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: power_supply class/framework question
  2009-08-10 15:28   ` Anton Vorontsov
@ 2009-08-10 16:14     ` Brian Swetland
  2009-08-10 16:35       ` Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: Brian Swetland @ 2009-08-10 16:14 UTC (permalink / raw)
  To: avorontsov; +Cc: Pavel Machek, Anton Vorontsov, David Woodhouse, linux-kernel

On Mon, Aug 10, 2009 at 8:28 AM, Anton
Vorontsov<avorontsov@ru.mvista.com> wrote:
> On Mon, Aug 10, 2009 at 05:00:11PM +0200, Pavel Machek wrote:
>> > I'm working on cleaning up some code to more correctly use the power
>> > supply framework (have the battery driver receive notification from
>> > the wall/usb power supplies, etc), and ran into a slight snag.  For
>> > mobile usb powered devices, we need to know how much current can
>> > safely be consumed by the charge circuit -- generally this is one of:
>> > none, <500mA or 1000mA, which correspond to "no power supply", "usb
>> > power supply", or "wall power supply".
>>
>> Actuallly, it is one of 'none', 100mA (min power USB has to supplly),
>> 500mA (max powe USB can supply by spec), 1A (wall).
>>
>> > I can use power_supply_am_i_supplied() to determine if I'm receiving
>> > power, but there's no way to determine either how much (if I have one
>> > power supply that indicates max current available) or which supply (if
>> > I define a separate "ac" and "usb" power supply).
>>
>> Should am_i_supplied() just return miliamps?
>
> Or enum power_supply_type, with the following priority:
> mains (wall), usb, battery?

Either of those would work, though in the case of USB, as Pavel
correctly points out, we'd need to differentiate between
non-enumerated and enumerated, so perhaps max available milliamps
would be best.  Or USB could just not indicate that it's supplied
until after enumeration is successful.

Brian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: power_supply class/framework question
  2009-08-10 16:14     ` Brian Swetland
@ 2009-08-10 16:35       ` Mark Brown
  2009-08-10 16:53         ` Brian Swetland
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2009-08-10 16:35 UTC (permalink / raw)
  To: Brian Swetland
  Cc: avorontsov, Pavel Machek, Anton Vorontsov, David Woodhouse,
	linux-kernel

On Mon, Aug 10, 2009 at 09:14:01AM -0700, Brian Swetland wrote:
> On Mon, Aug 10, 2009 at 8:28 AM, Anton
> Vorontsov<avorontsov@ru.mvista.com> wrote:

> > Or enum power_supply_type, with the following priority:
> > mains (wall), usb, battery?

> Either of those would work, though in the case of USB, as Pavel
> correctly points out, we'd need to differentiate between

I think we'll need to be able to report a list of supplies rather than
just one - for example, a lot of battery operated devices will use a
combination of USB and battery if the current draw exceeds what the USB
supply is able to deliver.

> non-enumerated and enumerated, so perhaps max available milliamps
> would be best.  Or USB could just not indicate that it's supplied
> until after enumeration is successful.

The 100mA from an unconfigured USB supply may still be a reasonable
proportion of the power that the device needs in some situations -
things like backlights and radios aren't going to be a good idea but
other things don't burn quite so much power.

USB also has some other current limit options which can be configured
(and sometimes people arrange for special hardware which provides limits
completely out of spec).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: power_supply class/framework question
  2009-08-10 16:35       ` Mark Brown
@ 2009-08-10 16:53         ` Brian Swetland
  0 siblings, 0 replies; 6+ messages in thread
From: Brian Swetland @ 2009-08-10 16:53 UTC (permalink / raw)
  To: Mark Brown
  Cc: avorontsov, Pavel Machek, Anton Vorontsov, David Woodhouse,
	linux-kernel

On Mon, Aug 10, 2009 at 9:35 AM, Mark
Brown<broonie@opensource.wolfsonmicro.com> wrote:
>> > Or enum power_supply_type, with the following priority:
>> > mains (wall), usb, battery?
>
>> Either of those would work, though in the case of USB, as Pavel
>> correctly points out, we'd need to differentiate between
>
> I think we'll need to be able to report a list of supplies rather than
> just one - for example, a lot of battery operated devices will use a
> combination of USB and battery if the current draw exceeds what the USB
> supply is able to deliver.

Certainly -- though the case I'm dealing with the battery driver
wanting to know how much power is available upstream (via calling
am_i_supplied()) so it can decide if it can turn on the charger (and
if it should use low or highspeed charging).  The way I'm currently
handling this is that I have an "ac" supply (power brick) and a "usb"
supply, only one of which will be supplying power to the "battery"
supply (battery & charger).  In my case I'd never have multiple
upstream supplies active simultaneously, but I'm not sure if that'd
hold true for everyone.

Brian

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-10 16:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-08  2:19 power_supply class/framework question Brian Swetland
2009-08-10 15:00 ` Pavel Machek
2009-08-10 15:28   ` Anton Vorontsov
2009-08-10 16:14     ` Brian Swetland
2009-08-10 16:35       ` Mark Brown
2009-08-10 16:53         ` Brian Swetland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox