Subject: Re: Blackberry Curve, USB, and NetBSD?
To: John Nemeth <>
From: Terry Moore <>
List: tech-kern
Date: 09/30/2007 11:39:15
At 07:47 AM 9/28/2007 -0700, John Nemeth wrote:
>} allowed to draw current from the computer. The phone is in different
>      There are plenty of things that draw power such as little fans and
>lights which don't have any electronics at all.  Although, I guess it
>is possible that these devices are playing fast and loose with the

I'm not sure that anybody but me is interested in the following 
trivia, but (with apologies to Adam Smith) one should willing to risk 
being tedious in order to be clear.

Technically speaking, those fans, lights and other such "devices" are 
not legal USB devices.  They don't present USB descriptors and they 
rely on the root hub port (or the non-root hub port) to provide 100mA 
forever.  That's not specified behavior of any hub, but it works well 
enough for Wal-Mart and Fry's (i.e., very low level of returns from customers).

Legal USB devices have four collections of power-relevant states:

*) the states (powered, default, address) before the host selects a 
USB configuration,

*) the state (configured) after a USB configuration has been selected 
by the host (in this case, normally we say "the device is configured"),

*) the state in which the device is suspended and cannot wake up the host, and

*) the state in which the device is suspended and CAN wake up the host.

If a device is suspended and cannot wake up the computer, it can only 
draw 0.5mA.

If a device is suspended and can wake up the computer, it can draw 2.5mA.

If a device is not suspended, but has not been configured, it is only 
permitted to draw up 100mA.

If a device is not suspended, but has been configured, it may draw as 
much current as the device specified in its description of the 
selected USB configuration (from 0mA to 500mA, normally either 100mA or 500mA).

The only state in which there's enough power to charge a phone is the last one.

To further complicate matters, not all hubs can provide 
500mA.  Worse, you can't tell, because hubs lie about their 
capabilities in this area (to work better with Windows?).  [I'm 
eliding a number of details, but this is easily demonstrable.]  The 
USB host stack cannot actually tell whether 500mA will really 
work.  So on Windows, the USB class driver often needs to do some 
guessing.  Sometimes this is assisted by clever hardware that 
disconnects, and reconnects with a different personality after it 
determines that it's got a "working partner" on the host side.

Since some host-side software is needed in order to do things right, 
often the product manager makes the conservative choice to "do no 
harm" -- which means (for such devices on NetBSD) that just plugging 
the device in won't let you charge.

BTW, I don't know how ugen works, but I suspect/hope that it doesn't 
send set-config until after an app opens the device.  (That would 
limit you to 100mA.)

On laptops, I'd further hope that ugen would suspend the port to 
minimize power consumption until an app opens the device.  In that 
case, you won't get any power at all for charging.

Umass has to configure the device in order to talk to it.  However, 
the configuration that it chooses might not be the right one (if the 
device offers multiple choices).

Most phones offer a mode in which they are concurrently wireless 
modems and mass storage devices (for example), and this is called a 
"composite" device in USB-speak.  Normally, in this case, the 
function drivers can't choose, because they can't get loaded until 
the overall (device-level) driver has selected a configuration.

This is all to say "it's not that simple" -- don't expect that the 
right answer for a Blackberry will be the right answer for a 
SonyEricsson phone.  (In fact, don't expect that the right answer for 
one model from vendor X is the right answer for all models from 
vendor X -- SymbianOS phones may work differently from WinCE phones, 
which may work differently from "feature phones".   And so forth.)

If people want more info, I'll be happy to offer free advice (worth 
every penny, as the saying goes).  No time to write code, alas, too 
busy attending standards committee meetings.....

Best regards,