From patchwork Mon Mar 9 23:08:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 5972181 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BEB539F380 for ; Mon, 9 Mar 2015 22:45:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C923B20431 for ; Mon, 9 Mar 2015 22:45:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB9EE203B6 for ; Mon, 9 Mar 2015 22:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752864AbbCIWpD (ORCPT ); Mon, 9 Mar 2015 18:45:03 -0400 Received: from v094114.home.net.pl ([79.96.170.134]:60325 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1751298AbbCIWpC (ORCPT ); Mon, 9 Mar 2015 18:45:02 -0400 Received: from aftr193.neoplus.adsl.tpnet.pl (178.42.251.193) (HELO vostro.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer v0.80) id 7e1cb5216e49e417; Mon, 9 Mar 2015 23:45:00 +0100 From: "Rafael J. Wysocki" To: Dmitry Torokhov Cc: Kristen Carlson Accardi , Linux PM list , Linux Kernel Mailing List , linux-input@vger.kernel.org Subject: Re: [PATCH] i8042 / PM: Allow PC keyboard to wake up from suspend-to-idle Date: Tue, 10 Mar 2015 00:08:43 +0100 Message-ID: <2514027.izE5Direg3@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/3.19.0+; KDE/4.11.5; x86_64; ; ) In-Reply-To: <3127745.ybR8YAlvTb@vostro.rjw.lan> References: <2197217.yzvHkR7SyK@vostro.rjw.lan> <20150309180004.GA22993@dtor-ws> <3127745.ybR8YAlvTb@vostro.rjw.lan> MIME-Version: 1.0 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Monday, March 09, 2015 11:41:12 PM Rafael J. Wysocki wrote: > On Monday, March 09, 2015 11:00:04 AM Dmitry Torokhov wrote: > > Hi Rafael, > > > > On Mon, Mar 09, 2015 at 04:19:50PM +0100, Rafael J. Wysocki wrote: > > > From: Rafael J. Wysocki > > > > > > 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. > > > > 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 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. Signed-off-by: Rafael J. Wysocki --- drivers/input/serio/i8042.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-pm/drivers/input/serio/i8042.c =================================================================== --- linux-pm.orig/drivers/input/serio/i8042.c +++ linux-pm/drivers/input/serio/i8042.c @@ -1162,13 +1162,32 @@ static int i8042_controller_resume(bool static 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); } } }