USB remote wakeup : Wake up system from suspend via a USB HID device (e.g.wireless keyboard)

826 views
Skip to first unread message

Mohammad Saleh Dehghanpour

unread,
Jul 16, 2019, 12:08:26 PM7/16/19
to android-porting

Hello


I have an AOSP tree compiled on my board. I bought a wireless keyboard and connected it to my board via usb port. I expect when the board is in the suspend state, it will wakeup by pressing a key on keyboard. But it is not so.


Anyone has an idea about how to handle remote wakeup for usb in android stack?


I tried several ways in my bootloader (uboot), kernel, etc. But no effect. Additionally I made an experiment and found out that in the sleep state, my usb port (which has a dongle in it) has just 1-5 mA. But it should be higher for the dongle to work!


Thanks

Tranphong Vu

unread,
Jul 16, 2019, 2:06:24 PM7/16/19
to saleh...@gmail.com, android-porting
Sorry i miss the example code for this,
This is example code in my AOSP linux kernel to enable this feature for a usb keyboard.
that uses USB HID driver.

Vào Th 3, 16 thg 7, 2019 vào lúc 23:19 Tranphong Vu <tranphon...@gmail.com> đã viết:
Hi Mohammad Saleh Dehghanpour,

base on your description, i think you need to enable wake up feature in your usb wireless keyboard.
1. Base on my hardware experience, your usb hardware should support this. But we should confirm this
Cat proc/interrupt to get the irq number of your usb wireless device.
Let device enter suspend state
do some thing with your wireless hardware
wake up device. check the number of irq happens for your wirelese device. 
If they are different it means your hardware support this go to step 2. if not your hardware does not,
you can enable this feature.

2. You need to get the driver of your wireless hardware device(usb hid, specific driver ...). dig in this . usb driver would have a Flag to indicate that irq for this device would wake up device.
Only need to set this flag, then done.

Regards,
Vu Tran

Vào Th 3, 16 thg 7, 2019 vào lúc 23:08 Mohammad Saleh Dehghanpour <saleh...@gmail.com> đã viết:
--
--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-porti...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/c0d82a42-d03b-4048-b044-025a64bc19db%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tranphong Vu

unread,
Jul 16, 2019, 2:06:30 PM7/16/19
to saleh...@gmail.com, android-porting
Hi Mohammad Saleh Dehghanpour,

base on your description, i think you need to enable wake up feature in your usb wireless keyboard.
1. Base on my hardware experience, your usb hardware should support this. But we should confirm this
Cat proc/interrupt to get the irq number of your usb wireless device.
Let device enter suspend state
do some thing with your wireless hardware
wake up device. check the number of irq happens for your wirelese device. 
If they are different it means your hardware support this go to step 2. if not your hardware does not,
you can enable this feature.

2. You need to get the driver of your wireless hardware device(usb hid, specific driver ...). dig in this . usb driver would have a Flag to indicate that irq for this device would wake up device.
Only need to set this flag, then done.

Regards,
Vu Tran

Vào Th 3, 16 thg 7, 2019 vào lúc 23:08 Mohammad Saleh Dehghanpour <saleh...@gmail.com> đã viết:

Hello

--

Tranphong Vu

unread,
Jul 17, 2019, 2:27:01 PM7/17/19
to Dehqanpour, android-porting
Hi Dehqanpour,
About 1,
I dont sure that interrupt number is increased when it happens while device in suspend state. But i think system should record this. 
About 2,
Normally android would not be wake up from bluetooth mouse. At you see in my code example, this code is need to wake up device from usb keyboard. So if you want to wake up device from usb wireless mouse you need to aplly this code to your wireless mouse device. 

Now i think you should confirm 1 with usb mouse. Normally usb mouse would wake up device because original hid usb drive apply my example code for usb mouse hid class. You can disable this feature by remove the above code for usb mouse hid.
Then check the irq is increased or not in suspend state. If it is same with your usb mouse you can apply code for your wireless mouse. If not i think you need to find a method to let usb wireless mouse generate irq in suspend state like dont power off usb wireless when device enter suspend state ...

Regards,
Vu tran

On Wed, 17 Jul 2019, 01:53 Dehqanpour, <saleh...@gmail.com> wrote:
Hi Tranphong Vu!

Thank you for your response.

1. I tested the "/proc/interrupts" and pasted a sample of it here:
https://paste.ubuntu.com/p/kf4TqxzBYN/

In my experiment, I found that the keyboard (which is a standard
wireless keyboard) is associated with "xhci-hcd:usb1" IRQ and the
counter increases by two for each key press. (one IRQ for key down and
one for key up which seems reasonable)

BUT the IRQ number , remains the same after suspend (i.e. 62). What is
the problem? Is it my mistake to identify correct IRQ entry?



2. The code snippet you posted was already in my AOSP tree too. I
examined that HID driver which is a well-known generic driver and I
guess the problem is not from there. (maybe I am wrong)


P.S. I also posted my problem in more details at stackoverflow at here:
https://stackoverflow.com/q/56914772/
I wish if you could take a look at it.

Thanks
Saleh



On 7/16/19, Tranphong Vu <tranphon...@gmail.com> wrote:
> Sorry i miss the example code for this,
> This is example code in my AOSP linux kernel to enable this feature for a
> usb keyboard.
> that uses USB HID driver.
>
Reply all
Reply to author
Forward
0 new messages