Re: Ability to limit to 100mA and/or disable USB power entirely

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/04/2012, Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
...
> I am not so sure if this is feasible as there are many non-compliant
> USB hub and non-compliant USB device out there and Linux needs
> to support them.

Surely having an option that defaults to the current behaviour cannot
break support.

I know that unpowered hubs will only allow 1 unit load (100mA upto USB
2.0, 150mA in 3.0), so USB can limit to minimum power.

But can a powered hub be told to restrict a specific port to 1 unit load?

> http://en.wikipedia.org/wiki/USB_hub
>
>> Apparently USB ports can be disabled, and when this occurs no power is
>> supplied. However, I think the ability to disable a port is also not
>> exposed by the USB drivers.
>
> You can suspend a port.

That will still use power.

> http://www.mjmwired.net/kernel/Documentation/usb/power-management.txt

I think I've seen that before. I've just had another look. I couldn't
find what I want this time either.

>
>> There are many use-cases for this. In the interest of saving
>> electricity, it is desirable to unplug unused devices. USB ports can
>> be plugged only about 1500 times before they ware out, and sometimes
>> the ports are fairly inaccessible behind the base unit of a computer.
>> Some badly designed devices will often need resetting by physically
>> replugging. If a USB device is plugged into a host device that is
>> remotely monitored, it is not possible to physically reconnect the
>> device. A less serious and more fun use-case is the automation of USB
>> 'decorations', which simply use the 5V power supply.
>
> Or this crazy USB Hub based AVR programmer.
> http://www.pjrc.com/hub_isp/

Ha! Yes! That looks very interesting.

Well this tells me it's not possible to cut the power on a port. If it
were possible, I'm sure sure the author of an article /that/ in depth
would know about it, and if that was the case then the bistable is
unnecessary.

I know that when a USB port gets overloaded or shorted, it cuts the
power. So there /is/ built-in possibility for this. Is there really no
way of accessing this functionality? It's such a shame and a massive
oversight in the hardware if there isn't.

Are there /any/ specific USB hub models at all, that offer to the OS
specific power control over their ports?

I think each port should have 3 additional power options: Off, 100mA,
500mA. If the spec allows powered devices to run without VBUS (which I
very much doubt), I would hope for a 4th option, 0mA, which cuts VBUS
but still allows data transfer.

>
>> It seems an oversight that USB devices cannot be programmatically
>> disconnected and reconnected in GNU/Linux OSes. I would appreciate it
>> if they could, if possible, and I know for sure that others would too.

It seems a huge oversight in general in the USB spec that USB devices
cannot be programmatically disconnected and reconnected. Surely it
should have been a requirement of the standard. :-(


On 09/04/2012, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
...
> I'm sorry; what you're asking for is not possible.  The USB controller
> hardware most commonly used in desktop and laptop systems does not
> offer any way for software to restrict the amount of current.  In USB,
> the amount of current used is determined by the device, not by the
> host.  If you want to reduce a phone's usage to 100 mA, you have to do
> it by telling the phone -- telling the host won't accomplish anything.

Yes, although isn't this done in a standard way? The host should tell
the device to keep below 100mA, and the host should cut the power if
the device overloads.

>
> Furthermore, what makes you think that even at 100 mA, the phone's
> battery isn't being recharged (just more slowly)?

It's much less likely, and at least I save 2W. When my phone is on, it
will actually gradually discharge while plugged into my laptop.
Clearly 500mA isn't enough while I'm using it. Of course, 100mA will
gradually charge it while it's off.

>
>> Apparently USB ports can be disabled, and when this occurs no power is
>> supplied.
>
> No, power is still supplied when the port is disabled.

Oh. :-(

What about overload protection?

>
>>  However, I think the ability to disable a port is also not
>> exposed by the USB drivers.
>
> It isn't.  However it is possible to suspend a port.  While this
> doesn't restrict the amount of current either, almost all USB devices
> will drastically reduce their power consumption when suspended.  Of
> course, you can't use a device while it is suspended, so this might not
> help.

No, it doesn't. I'm talking about battery powered devices. Suspending
will probably just suspend communication while still drawing 500mA to
charge it's battery.

...
> Disconnecting and reconnecting are physical acts -- they require
> somebody to unplug and replug a cable.  There is no way to do these
> things in software.  (Not unless your computer has a robot hand that
> can unplug and replug USB cables :-)

They can quite happily be approximated by transistors.


The next 10 emails were about Soft-Detach, which as I understand it,
is a device feature in only some devices that doesn't even do what I'm
asking, because simulation won't affect real power.


Thanks,
James.
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux