Skip to contentSkip to conversation

How to wakup system from standby via USB keyboard

DISCUSSION Wu Zhangjin 3 participants 7 messages Aug 21, 2009 – Aug 23, 2009

lore
Share & tools
lore
#0 lore raw

Hi All,

After reading some documents in Documentation/ and the Internet, I found there is an interface /proc/acpi/wakeup to set the wakeup devices on machines support ACPI. but my machine does not support ACPI, no /proc/acpi/wakeup there.

my machine is FuLoong2F, which is loongson based machine, it does not support ACPI, but currently, I have made it support basic standby mode for it has a 'wait' mode(after setting it's frequency to ZERO) and can be waked up via an external interrupt. and here is the basic framework:

0. suspend:

arch_suspend_disable_irqs(disable all interrupts)

...

fuloong_pm_enter()

...

arch_suspend_enable_irqs(enable all interrupts)

1. fuloong_pm_enter:

setup_wakeup_interrupts()

loongson_pm_enter(put loongson into 'wait' mode)

3. setup_wakeup_interrupts

if the interrupt line is connected to loongson directly, no setup need to do, but if there is an interrupt line connected to loongson indirectly(i.e via i8259A), I need to get through the interrupt path via enable(un-mask) the interrupts in interrupt controller and resuming the devices earlier manually or enable the interrupt bit on the devices and even or set a flag of the device driver to tell the system not suspend this device.

I have tried the first(resuming earlier) and second method(enable the interrupt bit) on the 8042 keyboard o YeeLoong(another loongson-based machine, a netbook, i8042 is connected to i8259A directly), it works well, but not tried the third method yet.

I guess the /proc/acpi/wakeup based method in user-space should be something like this, but is there any relative method in kernel space?

there are only USB interfaces on FuLoong2F machines, I guess it will be very hard to get through the interrupt path via the above two methods(I have tried to enable the USB interrupt in south bright, but not work), so, is there an easier method to do it?

Thanks & Regards,
Wu Zhangjin

#1 lore raw
Quoted 45 lines · Wu Zhangjin

Hi All,

After reading some documents in Documentation/ and the Internet, I found there is an interface /proc/acpi/wakeup to set the wakeup devices on machines support ACPI. but my machine does not support ACPI, no /proc/acpi/wakeup there.

my machine is FuLoong2F, which is loongson based machine, it does not support ACPI, but currently, I have made it support basic standby mode for it has a 'wait' mode(after setting it's frequency to ZERO) and can be waked up via an external interrupt. and here is the basic framework:

0. suspend:

arch_suspend_disable_irqs(disable all interrupts)

...

fuloong_pm_enter()

...

arch_suspend_enable_irqs(enable all interrupts)

1. fuloong_pm_enter:

setup_wakeup_interrupts()

loongson_pm_enter(put loongson into 'wait' mode)

3. setup_wakeup_interrupts

if the interrupt line is connected to loongson directly, no setup need to do, but if there is an interrupt line connected to loongson indirectly(i.e via i8259A), I need to get through the interrupt path via enable(un-mask) the interrupts in interrupt controller and resuming the devices earlier manually or enable the interrupt bit on the devices and even or set a flag of the device driver to tell the system not suspend this device.

I have tried the first(resuming earlier) and second method(enable the interrupt bit) on the 8042 keyboard o YeeLoong(another loongson-based machine, a netbook, i8042 is connected to i8259A directly), it works well, but not tried the third method yet.

Quoted 7 lines

I guess the /proc/acpi/wakeup based method in user-space should be something like this, but is there any relative method in kernel space?

there are only USB interfaces on FuLoong2F machines, I guess it will be very hard to get through the interrupt path via the above two methods(I have tried to enable the USB interrupt in south bright, but not work), so, is there an easier method to do it?

Is your USB controller a PCI one?

Rafael

#2 lore raw
Quoted 49 lines · Rafael J. Wysocki
Quoted 48 lines · Wu Zhangjin

Hi All,

After reading some documents in Documentation/ and the Internet, I found there is an interface /proc/acpi/wakeup to set the wakeup devices on machines support ACPI. but my machine does not support ACPI, no /proc/acpi/wakeup there.

my machine is FuLoong2F, which is loongson based machine, it does not support ACPI, but currently, I have made it support basic standby mode for it has a 'wait' mode(after setting it's frequency to ZERO) and can be waked up via an external interrupt. and here is the basic framework:

0. suspend:

arch_suspend_disable_irqs(disable all interrupts)

...

fuloong_pm_enter()

...

arch_suspend_enable_irqs(enable all interrupts)

1. fuloong_pm_enter:

setup_wakeup_interrupts()

loongson_pm_enter(put loongson into 'wait' mode)

3. setup_wakeup_interrupts

if the interrupt line is connected to loongson directly, no setup need to do, but if there is an interrupt line connected to loongson indirectly(i.e via i8259A), I need to get through the interrupt path via enable(un-mask) the interrupts in interrupt controller and resuming the devices earlier manually or enable the interrupt bit on the devices and even or set a flag of the device driver to tell the system not suspend this device.

I have tried the first(resuming earlier) and second method(enable the interrupt bit) on the 8042 keyboard o YeeLoong(another loongson-based machine, a netbook, i8042 is connected to i8259A directly), it works well, but not tried the third method yet.

I guess the /proc/acpi/wakeup based method in user-space should be something like this, but is there any relative method in kernel space?

Quoted 6 lines
Quoted 4 lines

there are only USB interfaces on FuLoong2F machines, I guess it will be very hard to get through the interrupt path via the above two methods(I have tried to enable the USB interrupt in south bridge, but not work), so, is there an easier method to do it?

Is your USB controller a PCI one?

Yes.

and I just checked the file: drivers/usb/host/ohci-pci.c, there are two functions ohci_pci_suspend/ohci_pci_resume there, perhaps I can call these two functions directly to resume it earlier and suspend it again before the real resuming, any easier methods? is there a flag to tell the system not suspend it or just not disable the interrupt request?

Thanks,
Wu Zhangjin

#3 lore raw
Quoted 57 lines · Wu Zhangjin
Quoted 49 lines · Rafael J. Wysocki
Quoted 48 lines · Wu Zhangjin

Hi All,

After reading some documents in Documentation/ and the Internet, I found there is an interface /proc/acpi/wakeup to set the wakeup devices on machines support ACPI. but my machine does not support ACPI, no /proc/acpi/wakeup there.

my machine is FuLoong2F, which is loongson based machine, it does not support ACPI, but currently, I have made it support basic standby mode for it has a 'wait' mode(after setting it's frequency to ZERO) and can be waked up via an external interrupt. and here is the basic framework:

0. suspend:

arch_suspend_disable_irqs(disable all interrupts)

...

fuloong_pm_enter()

...

arch_suspend_enable_irqs(enable all interrupts)

1. fuloong_pm_enter:

setup_wakeup_interrupts()

loongson_pm_enter(put loongson into 'wait' mode)

3. setup_wakeup_interrupts

if the interrupt line is connected to loongson directly, no setup need to do, but if there is an interrupt line connected to loongson indirectly(i.e via i8259A), I need to get through the interrupt path via enable(un-mask) the interrupts in interrupt controller and resuming the devices earlier manually or enable the interrupt bit on the devices and even or set a flag of the device driver to tell the system not suspend this device.

I have tried the first(resuming earlier) and second method(enable the interrupt bit) on the 8042 keyboard o YeeLoong(another loongson-based machine, a netbook, i8042 is connected to i8259A directly), it works well, but not tried the third method yet.

I guess the /proc/acpi/wakeup based method in user-space should be something like this, but is there any relative method in kernel space?

Quoted 6 lines
Quoted 4 lines

there are only USB interfaces on FuLoong2F machines, I guess it will be very hard to get through the interrupt path via the above two methods(I have tried to enable the USB interrupt in south bridge, but not work), so, is there an easier method to do it?

Is your USB controller a PCI one?

Quoted 7 lines

Yes.

and I just checked the file: drivers/usb/host/ohci-pci.c, there are two functions ohci_pci_suspend/ohci_pci_resume there, perhaps I can call these two functions directly to resume it earlier and suspend it again before the real resuming, any easier methods? is there a flag to tell the system not suspend it or just not disable the interrupt request?

I think the interface you're looking for is

/sys/bus/usb/devices/usbN/../power/wakeup

where N is the USB bus number. This file defaults to "disabled"; if you write "enabled" to it then the USB host controller will be enabled as a wakeup source. This should work even without ACPI; it uses the PCI PME mechanism.

However you need to realize something: If you enable USB wakeups then unplugging your USB keyboard or mouse will cause the computer to wake up.

Alan Stern

#4 lore raw
Quoted 67 lines · Alan Stern
Quoted 57 lines · Wu Zhangjin
Quoted 49 lines · Rafael J. Wysocki
Quoted 48 lines · Wu Zhangjin

Hi All,

After reading some documents in Documentation/ and the Internet, I found there is an interface /proc/acpi/wakeup to set the wakeup devices on machines support ACPI. but my machine does not support ACPI, no /proc/acpi/wakeup there.

my machine is FuLoong2F, which is loongson based machine, it does not support ACPI, but currently, I have made it support basic standby mode for it has a 'wait' mode(after setting it's frequency to ZERO) and can be waked up via an external interrupt. and here is the basic framework:

0. suspend:

arch_suspend_disable_irqs(disable all interrupts)

...

fuloong_pm_enter()

...

arch_suspend_enable_irqs(enable all interrupts)

1. fuloong_pm_enter:

setup_wakeup_interrupts()

loongson_pm_enter(put loongson into 'wait' mode)

3. setup_wakeup_interrupts

if the interrupt line is connected to loongson directly, no setup need to do, but if there is an interrupt line connected to loongson indirectly(i.e via i8259A), I need to get through the interrupt path via enable(un-mask) the interrupts in interrupt controller and resuming the devices earlier manually or enable the interrupt bit on the devices and even or set a flag of the device driver to tell the system not suspend this device.

I have tried the first(resuming earlier) and second method(enable the interrupt bit) on the 8042 keyboard o YeeLoong(another loongson-based machine, a netbook, i8042 is connected to i8259A directly), it works well, but not tried the third method yet.

I guess the /proc/acpi/wakeup based method in user-space should be something like this, but is there any relative method in kernel space?

Quoted 6 lines
Quoted 4 lines

there are only USB interfaces on FuLoong2F machines, I guess it will be very hard to get through the interrupt path via the above two methods(I have tried to enable the USB interrupt in south bridge, but not work), so, is there an easier method to do it?

Is your USB controller a PCI one?

Quoted 7 lines

Yes.

and I just checked the file: drivers/usb/host/ohci-pci.c, there are two functions ohci_pci_suspend/ohci_pci_resume there, perhaps I can call these two functions directly to resume it earlier and suspend it again before the real resuming, any easier methods? is there a flag to tell the system not suspend it or just not disable the interrupt request?

Quoted 9 lines

I think the interface you're looking for is

/sys/bus/usb/devices/usbN/../power/wakeup

where N is the USB bus number. This file defaults to "disabled"; if you write "enabled" to it then the USB host controller will be enabled as a wakeup source. This should work even without ACPI; it uses the PCI PME mechanism.

I checked the /sys/bus/usb.../wakeup interfaces, seems the usbN/power/wakeup interfaces are enabled by default in my machine, but the usbN/N-X:Y/power/wakeup is not available. so, I can not wakeup the system via any USB devices.

Here is the output:

$ find /sys/bus/usb/devices/usb1/ -name "wakeup" -exec echo {} \; -exec
cat '{}' \;
/sys/bus/usb/devices/usb1/power/wakeup
enabled
/sys/bus/usb/devices/usb1/1-0:1.0/power/wakeup

/sys/bus/usb/devices/usb1/1-3/power/wakeup enabled /sys/bus/usb/devices/usb1/1-3/1-3:1.0/power/wakeup

/sys/bus/usb/devices/usb1/1-3/1-3:1.1/power/wakeup

/sys/bus/usb/devices/usb1/1-4/power/wakeup enabled /sys/bus/usb/devices/usb1/1-4/1-4:1.0/power/wakeup

$ find /sys/bus/usb/devices/usb2/ -name "wakeup" -exec echo {} \; -exec
cat '{}' \;
/sys/bus/usb/devices/usb2/power/wakeup
enabled
/sys/bus/usb/devices/usb2/2-0:1.0/power/wakeup

Thanks,
Wu Zhangjin

#5 lore raw
Quoted 15 lines · Wu Zhangjin
Quoted 9 lines

I think the interface you're looking for is

/sys/bus/usb/devices/usbN/../power/wakeup

where N is the USB bus number. This file defaults to "disabled"; if you write "enabled" to it then the USB host controller will be enabled as a wakeup source. This should work even without ACPI; it uses the PCI PME mechanism.

I checked the /sys/bus/usb.../wakeup interfaces, seems the usbN/power/wakeup interfaces are enabled by default in my machine, but the usbN/N-X:Y/power/wakeup is not available. so, I can not wakeup the system via any USB devices.

Quoted 6 lines

Here is the output:

$ find /sys/bus/usb/devices/usb1/ -name "wakeup" -exec echo {} \; -exec
cat '{}' \;
/sys/bus/usb/devices/usb1/power/wakeup
enabled

...

You did not read what I wrote.

You shouldn't look at: /sys/bus/usb/devices/usb1/power/wakeup.
You should look at: /sys/bus/usb/devices/usb1/../power/wakeup.

The N-X:Y/power/wakeup interfaces don't matter; the kernel doesn't use them.

Alan Stern

#6 lore raw
Quoted 25 lines · Alan Stern
Quoted 21 lines · Wu Zhangjin
Quoted 9 lines

I think the interface you're looking for is

/sys/bus/usb/devices/usbN/../power/wakeup

where N is the USB bus number. This file defaults to "disabled"; if you write "enabled" to it then the USB host controller will be enabled as a wakeup source. This should work even without ACPI; it uses the PCI PME mechanism.

I checked the /sys/bus/usb.../wakeup interfaces, seems the usbN/power/wakeup interfaces are enabled by default in my machine, but the usbN/N-X:Y/power/wakeup is not available. so, I can not wakeup the system via any USB devices.

Here is the output:

$ find /sys/bus/usb/devices/usb1/ -name "wakeup" -exec echo {} \; -exec
cat '{}' \;
/sys/bus/usb/devices/usb1/power/wakeup
enabled

...

Quoted 8 lines

You did not read what I wrote.

You shouldn't look at: /sys/bus/usb/devices/usb1/power/wakeup.
You should look at: /sys/bus/usb/devices/usb1/../power/wakeup.

The N-X:Y/power/wakeup interfaces don't matter; the kernel doesn't use them.

Sorry, I at first thought .. is only an ellipsis, because the TAB key of keyboard can not list the files(Seems only symbol links to pci/ directories) :-)

There is really a such file in system of FuLoong2F, but seems the USB controller is 'not' a PCI one(sorry for my mistake in the last E-mail), this USB interface is integrated in the CS5536 southbridge, and CS5536(from AMD) is connected to the PCI bus.

the connection is like this:

----------------------------------------

|         Loongson2F                   |
|                                      |                 ------------- 
|     CPU internal northbridge         |                 |            |
|(bonito64 compatiable, PCI controller)| <----PCI BUS -->| AMD CS5536 |
---------------------------------------                  |(USB inside)|
                                                         --------------
$ cat /sys/bus/usb/devices/usb1/../power/wakeup
[empty here]

but in YeeLoong System, for there is a NEC USB controller connect to PCI BUS directly.

----------------------------------------

|         Loongson2F                   |
|            |                         |                 ------------- 
|     CPU internal northbridge         |                 |            |
|(bonito64 compatiable, PCI controller)| <----PCI BUS -->| AMD CS5536 |
---------------------------------------      |           |(USB inside)|
                                             |            --------------
                                             ---- USB HC

and the wakeup interface is really there:

$ cat /sys/bus/usb/devices/usb1/../power/wakeup
disabled

but after I enabled it,

$ echo enabled > /sys/bus/usb/devices/usb1/../power/wakeup

and ensured the USB interrupt is not disabled in the northbridge, but unfortunately, I can NOT wakeup YeeLoong from standby mode via the keyboard or mouse connect to NEC USB interface :-(

BTW: I have tested this wakeup interface on two different X86 machines, both of them can be waked up from a USB keyboard or Mouse.

perhaps I have missed something else.

Thanks & Regards,
Wu Zhangjin