Skip to contentSkip to conversation

power_supply class/framework question

DISCUSSION Brian Swetland 4 participants 6 messages Aug 8, 2009 – Aug 10, 2009

lore
Share & tools
lore
#0 lore raw

(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

#1 lore raw

Hi!

Quoted 10 lines

(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.

Quoted 4 lines

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

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
Quoted 16 lines · Pavel Machek

Hi!

Quoted 10 lines

(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).

Quoted 8 lines

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

Quoted 4 lines

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?

Signature · 3 lines
Anton Vorontsov
email: [email protected]
irc://irc.freenode.net/bd2
#3 lore raw
Quoted 17 lines · Anton Vorontsov
Quoted 16 lines · Pavel Machek
Quoted 7 lines

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).

Quoted 4 lines

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).

Quoted 4 lines
Quoted 1 line

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

#4 lore raw
Quoted 8 lines · Brian Swetland
Quoted 2 lines · Anton Vorontsov

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.

Quoted 3 lines

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).

#5 lore raw
Quoted 10 lines · Mark Brown
Quoted 5 lines
Quoted 2 lines

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