i8042 / PM: Allow PC keyboard to wake up from suspend-to-idle
Subsystems (2)
PATCH 1/1 i8042 / PM: Allow PC keyboard to wake up from suspend-to-idle
From: Rafael J. Wysocki <[email protected]>
If they keyboard interrupt is registered, mark the i8042 platform device as wakeup-capable and check the user space wakeup setting in i8042_pm_suspend() and i8042_pm_resume() to enable or disable, respectively, the keyboard interrupt to wake up the system.
This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle after writing "enabled" to the i8042 device's power/wakeup sysfs attribute.
--- drivers/input/serio/i8042.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/input/serio/i8042.c +6 -0
@@ -1163,12 +1163,17 @@ static int i8042_controller_resume(boolstatic int i8042_pm_suspend (struct device *dev) {i8042_controller_reset (true); +if (device_may_wakeup (&i8042_platform_device->dev)) +enable_irq_wake (I8042_KBD_IRQ );return 0 ; }static int i8042_pm_resume (struct device *dev) { +if (device_may_wakeup (&i8042_platform_device->dev)) +disable_irq_wake (I8042_KBD_IRQ ); +/* * On resume from S2R we always try to reset the controller * to bring it in a sane state. (In case of S2D we expect
@@ -1406,6 +1411,7 @@ static int __init i8042_setup_kbd(void)if (error) goto err_free_irq; +device_set_wakeup_capable (&i8042_platform_device->dev, true); i8042_kbd_irq_registered = true;return 0 ;
Dmitry Torokhov
maintainerHi Rafael,
Quoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If they keyboard interrupt is registered, mark the i8042 platform device as wakeup-capable and check the user space wakeup setting in
i8042_pm_suspend()andi8042_pm_resume()to enable or disable, respectively, the keyboard interrupt to wake up the system.This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle after writing "enabled" to the i8042 device's power/wakeup sysfs attribute.
Why do we do that for KBD but not AUX port? Should we mark individual serio port be wakeup capable and not the whole i8042.
Also, why exactly is this needed? My laptops seem to resume just fine from keyboard activity without this patch...
Thanks.
Quoted 37 lines
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/input/serio/i8042.c | 6 ++++++ 1 file changed, 6 insertions(+)Index:
linux-pm/drivers/input/serio/i8042.c
===================================================================drivers/input/serio/i8042.c +6
-0@@ -1163,12 +1163,17 @@ static int i8042_controller_resume(boolstatic int i8042_pm_suspend (struct device *dev) {i8042_controller_reset (true); +if (device_may_wakeup (&i8042_platform_device->dev)) +enable_irq_wake (I8042_KBD_IRQ );return 0 ; }static int i8042_pm_resume (struct device *dev) { +if (device_may_wakeup (&i8042_platform_device->dev)) +disable_irq_wake (I8042_KBD_IRQ ); +/* * On resume from S2R we always try to reset the controller * to bring it in a sane state. (In case of S2D we expect @@ -1406,6 +1411,7 @@ static int __init i8042_setup_kbd(void)if (error) goto err_free_irq; +device_set_wakeup_capable (&i8042_platform_device->dev, true); i8042_kbd_irq_registered = true;return 0 ;
Signature · 1 line
Dmitry
Quoted 10 lines · Dmitry Torokhov
Hi Rafael,
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If they keyboard interrupt is registered, mark the i8042 platform device as wakeup-capable and check the user space wakeup setting in
i8042_pm_suspend()andi8042_pm_resume()to enable or disable, respectively, the keyboard interrupt to wake up the system.
Quoted 6 lines
Quoted 3 lines
This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle after writing "enabled" to the i8042 device's power/wakeup sysfs attribute.
Why do we do that for KBD but not AUX port? Should we mark individual serio port be wakeup capable and not the whole i8042.
We can do that, but only after the port serio device has been registered.
I guess I can add code for that to i8042_register_ports(). Let me try that.
Quoted 2 lines
Also, why exactly is this needed? My laptops seem to resume just fine from keyboard activity without this patch...
Mine don't. At least not from suspend-to-idle ("echo freeze > /sys/power/state").
Whether or not the PC keyboard wakes them up from suspend-to-RAM depends on the BIOS. That only works for one of my laptops, but this patch doesn't help here.
Rafael
Quoted 15 lines · Rafael J. Wysocki
Quoted 14 lines · Dmitry Torokhov
Hi Rafael,
Quoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If they keyboard interrupt is registered, mark the i8042 platform device as wakeup-capable and check the user space wakeup setting in
i8042_pm_suspend()andi8042_pm_resume()to enable or disable, respectively, the keyboard interrupt to wake up the system.This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle after writing "enabled" to the i8042 device's power/wakeup sysfs attribute.
Quoted 6 lines
Quoted 2 lines
Why do we do that for KBD but not AUX port? Should we mark individual serio port be wakeup capable and not the whole i8042.
We can do that, but only after the port serio device has been registered.
I guess I can add code for that to
i8042_register_ports(). Let me try that.
Yeah, that works too. And you're right that there's no reason to do that for keyboard only.
Patch below.
Rafael
---
From: Rafael J. Wysocki <[email protected]>
Subject: i8042 / PM: Allow i8042 ports to wake up from suspend-to-idle
While registering serio device for i8042, mark them as wakeup-capable and check their user space wakeup settings in i8042_pm_suspend() and i8042_pm_resume() to enable or disable, respectively, their interrupts to wake up the system.
This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle, among other things, after writing "enabled" to the keyboard serio device's power/wakeup sysfs attribute.
--- drivers/input/serio/i8042.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/input/serio/i8042.c +25 -3
@@ -1162,13 +1162,32 @@ static int i8042_controller_resume(boolstatic int i8042_pm_suspend (struct device *dev) { +int i; +i8042_controller_reset (true); +/* Set up serio interrupts for system wakeup. */ +for (i =0 ; i <I8042_NUM_PORTS ; i++) { +struct serio *serio = i8042_ports[i].serio; + +if (serio &&device_may_wakeup (&serio->dev)) +enable_irq_wake (i8042_ports[i].irq); + } +return 0 ; }static int i8042_pm_resume (struct device *dev) { +int i; + +for (i =0 ; i <I8042_NUM_PORTS ; i++) { +struct serio *serio = i8042_ports[i].serio; + +if (serio &&device_may_wakeup (&serio->dev)) +disable_irq_wake (i8042_ports[i].irq); + } +/* * On resume from S2R we always try to reset the controller * to bring it in a sane state. (In case of S2D we expect
@@ -1300,13 +1319,16 @@ static void __init i8042_register_ports(int i;for (i =0 ; i <I8042_NUM_PORTS ; i++) { -if (i8042_ports[i].serio) { +struct serio *serio = i8042_ports[i].serio; + +if (serio) {printk (KERN_INFO "serio: %s at %#lx,%#lx irq %d\n" , - i8042_ports[i].serio->name, + serio->name, (unsigned long )I8042_DATA_REG , (unsigned long )I8042_COMMAND_REG , i8042_ports[i].irq); -serio_register_port (i8042_ports[i].serio); +serio_register_port (serio); +device_set_wakeup_capable (&serio->dev, true); } } }
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · Rafael J. Wysocki
Quoted 16 lines · Dmitry Torokhov
Hi Rafael,
Quoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If they keyboard interrupt is registered, mark the i8042 platform device as wakeup-capable and check the user space wakeup setting in
i8042_pm_suspend()andi8042_pm_resume()to enable or disable, respectively, the keyboard interrupt to wake up the system.This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle after writing "enabled" to the i8042 device's power/wakeup sysfs attribute.
Why do we do that for KBD but not AUX port? Should we mark individual serio port be wakeup capable and not the whole i8042.
Quoted 8 lines
Quoted 3 lines
We can do that, but only after the port serio device has been registered.
I guess I can add code for that to
i8042_register_ports(). Let me try that.Yeah, that works too. And you're right that there's no reason to do that for keyboard only.
Patch below.
Applied, thank you.
Quoted 80 lines
Rafael
---
From: Rafael J. Wysocki <[email protected]>
Subject: i8042 / PM: Allow i8042 ports to wake up from suspend-to-idleWhile registering serio device for i8042, mark them as wakeup-capable and check their user space wakeup settings in
i8042_pm_suspend()andi8042_pm_resume()to enable or disable, respectively, their interrupts to wake up the system.This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle, among other things, after writing "enabled" to the keyboard serio device's power/wakeup sysfs attribute.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/input/serio/i8042.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)Index:
linux-pm/drivers/input/serio/i8042.c
===================================================================drivers/input/serio/i8042.c +25
-3@@ -1162,13 +1162,32 @@ static int i8042_controller_resume(boolstatic int i8042_pm_suspend (struct device *dev) { +int i; +i8042_controller_reset (true); +/* Set up serio interrupts for system wakeup. */ +for (i =0 ; i <I8042_NUM_PORTS ; i++) { +struct serio *serio = i8042_ports[i].serio; + +if (serio &&device_may_wakeup (&serio->dev)) +enable_irq_wake (i8042_ports[i].irq); + } +return 0 ; }static int i8042_pm_resume (struct device *dev) { +int i; + +for (i =0 ; i <I8042_NUM_PORTS ; i++) { +struct serio *serio = i8042_ports[i].serio; + +if (serio &&device_may_wakeup (&serio->dev)) +disable_irq_wake (i8042_ports[i].irq); + } +/* * On resume from S2R we always try to reset the controller * to bring it in a sane state. (In case of S2D we expect @@ -1300,13 +1319,16 @@ static void __init i8042_register_ports(int i;for (i =0 ; i <I8042_NUM_PORTS ; i++) { -if (i8042_ports[i].serio) { +struct serio *serio = i8042_ports[i].serio; + +if (serio) {printk (KERN_INFO "serio: %s at %#lx,%#lx irq %d\n" , - i8042_ports[i].serio->name, + serio->name, (unsigned long )I8042_DATA_REG , (unsigned long )I8042_COMMAND_REG , i8042_ports[i].irq); -serio_register_port (i8042_ports[i].serio); +serio_register_port (serio); +device_set_wakeup_capable (&serio->dev, true); } } }
Signature · 1 line
Dmitry
Quoted 19 lines · Rafael J. Wysocki
Quoted 18 lines · Rafael J. Wysocki
Quoted 16 lines · Dmitry Torokhov
Hi Rafael,
Quoted 10 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If they keyboard interrupt is registered, mark the i8042 platform device as wakeup-capable and check the user space wakeup setting in
i8042_pm_suspend()andi8042_pm_resume()to enable or disable, respectively, the keyboard interrupt to wake up the system.This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle after writing "enabled" to the i8042 device's power/wakeup sysfs attribute.
Why do we do that for KBD but not AUX port? Should we mark individual serio port be wakeup capable and not the whole i8042.
Quoted 6 lines
Quoted 3 lines
We can do that, but only after the port serio device has been registered.
I guess I can add code for that to
i8042_register_ports(). Let me try that.Yeah, that works too. And you're right that there's no reason to do that for keyboard only.
Actually, are you sure?
Resuming on mouse click is reasonable, resuming on mouse move is not, as table vibrations are likely to cause that.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 24 lines · Pavel Machek
Quoted 23 lines · Rafael J. Wysocki
Quoted 21 lines · Rafael J. Wysocki
Quoted 10 lines · Dmitry Torokhov
Hi Rafael,
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
If they keyboard interrupt is registered, mark the i8042 platform device as wakeup-capable and check the user space wakeup setting in
i8042_pm_suspend()andi8042_pm_resume()to enable or disable, respectively, the keyboard interrupt to wake up the system.Quoted 6 lines
Quoted 3 lines
This makes it possible to use the PC keyboard to wake up the system from suspend-to-idle after writing "enabled" to the i8042 device's power/wakeup sysfs attribute.
Why do we do that for KBD but not AUX port? Should we mark individual serio port be wakeup capable and not the whole i8042.
We can do that, but only after the port serio device has been registered.
I guess I can add code for that to
i8042_register_ports(). Let me try that.
Quoted 7 lines
Quoted 2 lines
Yeah, that works too. And you're right that there's no reason to do that for keyboard only.
Actually, are you sure?
Resuming on mouse click is reasonable, resuming on mouse move is not, as table vibrations are likely to cause that.
This is disabled by default, so user space has to enable it anyway if it wants to.
Rafael
Quoted 11 lines
Quoted 8 lines
Quoted 3 lines
Yeah, that works too. And you're right that there's no reason to do that for keyboard only.
Actually, are you sure?
Resuming on mouse click is reasonable, resuming on mouse move is not, as table vibrations are likely to cause that.
This is disabled by default, so user space has to enable it anyway if it wants to.
Good. (But still, for suspend-to-RAM, only mouse _click_ will resume the machine, as the optical sensor is powered down, no?)
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 6 lines · Pavel Machek
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Yeah, that works too. And you're right that there's no reason to do that for keyboard only.
Actually, are you sure?
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Resuming on mouse click is reasonable, resuming on mouse move is not, as table vibrations are likely to cause that.
This is disabled by default, so user space has to enable it anyway if it wants to.
Good. (But still, for suspend-to-RAM, only mouse _click_ will resume the machine, as the optical sensor is powered down, no?)
I'm not sure really. I have mice that resume from suspend-to-RAM on a movement too, but those are USB.
Rafael