LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   How to power off USB port (https://www.linuxquestions.org/questions/linux-hardware-18/how-to-power-off-usb-port-613304/)

pyro 01-13-2008 12:44 PM

How to power off USB port
 
Hi,
is it possible to power off a USB port by software?

The problem is my USB UMTS modem which hangs from time to time. The router with the modem should be placed under the roof, so you can't just remove the modem and plug it in again. It would be possible to reboot the whole machine, but isn't there a clean solution?

Thanks in advance

Pyro

Brian1 01-13-2008 01:58 PM

I guess you can try unloading the usb modules related to the device. Then reload them.

Brian

pyro 01-13-2008 05:42 PM

The problem is the firmware of the device, if the device hangs, unloading the module won't help.
I have to reset the device, so switching off the USB port would be the safest way.


Pyro

elliott678 01-13-2008 05:46 PM

I'm not sure this is possible, there seems to always be power going to the USB port when the system is on, it doesn't appear to be software controllable. If you are going to be putting this somewhere where it would be hard to reset manually, the obvious option would be to get a good modem that doesn't require this.

osor 01-13-2008 08:37 PM

There used to be something in sysfs for individual device power management. You could do something like:
Code:

echo "2" > /sys/path/to/device/power/state
To reduce the power to power state “2”. The problem was that it only worked correctly for a few devices. Also, it was not clear what the power states meant across all types of devices on all types of buses. As of July 2007, this feature has been removed from the linux kernel, and AFAIK, there is no pending replacement.

pyro 01-14-2008 12:21 PM

Hi,

I'm not sure if the USB port can be powered off by software, but it should get powered off, if the device consumes too much power.

I will try an older kernel next month. I don't have much spare time now.

Things aren't that easy anymore as they were with LPT ;)

Thanks

Pyro

dracolich 01-14-2008 04:34 PM

Perhaps you could put a hub between the root usb port and the device. Then when the device hangs you can try to reset the hub or move the modem to another port on the hub. Other than that I would have to agree with elliott678. The closest thing you can do without an actual shutdown/restart would be to unload the modules for usb_ehci, or usb_ohci depending on your setup, as long as they're not builtin to the kernel. Check the output of lsmod.

neonsignal 07-26-2009 10:21 AM

/sys/bus/usb/devices interface
 
You can power down a usb port (eg 1-2) by:

echo suspend >/sys/bus/usb/devices/1-2/power/level

and to turn it back on:

echo auto >/sys/bus/usb/devices/1-2/power/level

However, my understanding is that the suspend is done by the slave device, so if it has hung, it is possible it might not suspend. Likewise, this cannot be used to turn off a usb parasitic device (usb lights and the like), which have no communications interface.

A usb master can turn off power if too much current is drawn by the device, but I don't know if this power control can be done from software (might depend on the particular chips being used).

Geremia 01-22-2014 01:27 PM

This thread is useful: https://stackoverflow.com/questions/...wer-on-and-off


All times are GMT -5. The time now is 08:26 AM.