Charging Devices During Suspend Using your Notebook's USB Port with Linux

You probably have done this before: Plug your phone or mp3 into your Notebook's USB port to charge it. E.g. the Kindle usually only comes with a USB cable and no seperate charger. Did you know you can do this even when your system is in standby mode? I will show you how - without the need to modify anything but software!


It's actually not even difficult. Start by plugging in the device and using lsusb -t to find out to which port it is connected:

/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/8p, 480M
    |__ Port 5: Dev 3, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
    |__ Port 5: Dev 3, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=uvcvideo, 480M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M


Then check cat /proc/acpi/wakeup and find the port in there:

Device  S-state   Status   Sysfs node
EUSB      S4    *disabled  pci:0000:00:1d.7
LID       S4    *disabled

In my case it's not too difficult. I just need to echo EUSB | sudo tee /proc/acpi/wakeup and USB stays on during standby and I can charge my phone. You may have to enable a combination of USB and *HCI devices or even all USB devices in wakeup for the charging to work. But of course that will still be much better than leaving your notebook on.

But be aware that anything that is enabled in /proc/acpi/wakeup draws power all the time during standby. So you probably want to disable it again once your device is charged. If it works, you've just gained a (much more efficient) free (as in no additional cost) portable usb charger!

6 comments:

  1. Could you please elaborate on how you relate an lsusb entry to the respective /proc/acpi/wakeup entry? I have USB{0-6) as well as EUSB and USBE. Is my guess correct that EUSB is for ehci devices? What about uhci devices?

    Thanks!

    ReplyDelete
  2. I would recommend to start by using all and then you can try step by step elimination

    ReplyDelete
  3. All right, thanks. Did a binary search, which sped up things. ;-) Now I can finally wake up my PC from S3 using a keyboard button press.

    ReplyDelete
  4. Hi,

    I'm the guy sitting next to you and LinuxTag and trying to charge my N900 with my laptop on suspend :)

    So actually the charging of the device is a side-effect of the fact that the computer is powering it up in order to be able to wake-up from it. The drawback is that the device can easily power-back your laptop, which is not always desirable.

    ReplyDelete
  5. A, cool! I've been waiting for you! ;)

    Yes, that's true. In my case that never happened though. I use that to have my notebook act as charger all the time. My phone never woke it up.

    ReplyDelete

I appreciate comments. And I do read them.