Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Input: i8042 - allow KBD and AUX 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.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Rafael J. Wysocki and committed by
Dmitry Torokhov
f13b2065 91c68a7c

+25 -3
+25 -3
drivers/input/serio/i8042.c
··· 1162 1162 1163 1163 static int i8042_pm_suspend(struct device *dev) 1164 1164 { 1165 + int i; 1166 + 1165 1167 i8042_controller_reset(true); 1168 + 1169 + /* Set up serio interrupts for system wakeup. */ 1170 + for (i = 0; i < I8042_NUM_PORTS; i++) { 1171 + struct serio *serio = i8042_ports[i].serio; 1172 + 1173 + if (serio && device_may_wakeup(&serio->dev)) 1174 + enable_irq_wake(i8042_ports[i].irq); 1175 + } 1166 1176 1167 1177 return 0; 1168 1178 } 1169 1179 1170 1180 static int i8042_pm_resume(struct device *dev) 1171 1181 { 1182 + int i; 1183 + 1184 + for (i = 0; i < I8042_NUM_PORTS; i++) { 1185 + struct serio *serio = i8042_ports[i].serio; 1186 + 1187 + if (serio && device_may_wakeup(&serio->dev)) 1188 + disable_irq_wake(i8042_ports[i].irq); 1189 + } 1190 + 1172 1191 /* 1173 1192 * On resume from S2R we always try to reset the controller 1174 1193 * to bring it in a sane state. (In case of S2D we expect ··· 1319 1300 int i; 1320 1301 1321 1302 for (i = 0; i < I8042_NUM_PORTS; i++) { 1322 - if (i8042_ports[i].serio) { 1303 + struct serio *serio = i8042_ports[i].serio; 1304 + 1305 + if (serio) { 1323 1306 printk(KERN_INFO "serio: %s at %#lx,%#lx irq %d\n", 1324 - i8042_ports[i].serio->name, 1307 + serio->name, 1325 1308 (unsigned long) I8042_DATA_REG, 1326 1309 (unsigned long) I8042_COMMAND_REG, 1327 1310 i8042_ports[i].irq); 1328 - serio_register_port(i8042_ports[i].serio); 1311 + serio_register_port(serio); 1312 + device_set_wakeup_capable(&serio->dev, true); 1329 1313 } 1330 1314 } 1331 1315 }