From patchwork Wed Apr 26 21:27:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 9702055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B9819603F4 for ; Wed, 26 Apr 2017 21:33:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A84102858E for ; Wed, 26 Apr 2017 21:33:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D128285EA; Wed, 26 Apr 2017 21:33:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4882E2858E for ; Wed, 26 Apr 2017 21:33:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030588AbdDZVdn (ORCPT ); Wed, 26 Apr 2017 17:33:43 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:49104 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030579AbdDZVdn (ORCPT ); Wed, 26 Apr 2017 17:33:43 -0400 Received: from 79.184.252.54.ipv4.supernova.orange.pl (79.184.252.54) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.82) id e62cd8ded5d1d030; Wed, 26 Apr 2017 23:33:42 +0200 From: "Rafael J. Wysocki" To: Linux PM Cc: Andy Shevchenko , Darren Hart , LKML , Linux ACPI , Srinivas Pandruvada , Thomas Gleixner , Mika Westerberg , Mario Limonciello Subject: [PATCH 5/5] platform: x86: intel-hid: Wake up the system from suspend-to-idle Date: Wed, 26 Apr 2017 23:27:06 +0200 Message-ID: <7255712.4ssjnT3GDQ@aspire.rjw.lan> User-Agent: KMail/4.14.10 (Linux/4.11.0-rc6+; KDE/4.14.9; x86_64; ; ) In-Reply-To: <1979543.KIEJ8uyRaT@aspire.rjw.lan> References: <1979543.KIEJ8uyRaT@aspire.rjw.lan> MIME-Version: 1.0 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki Allow the intel-hid driver to wake up the system from suspend-to-idle by configuring its platform device as a wakeup one by default and switching it over to a system wakeup events triggering mode during system suspend transitions. Signed-off-by: Rafael J. Wysocki --- This depends on https://patchwork.kernel.org/patch/9685529/ --- drivers/platform/x86/intel-hid.c | 49 ++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" 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/platform/x86/intel-hid.c =================================================================== --- linux-pm.orig/drivers/platform/x86/intel-hid.c +++ linux-pm/drivers/platform/x86/intel-hid.c @@ -23,6 +23,7 @@ #include #include #include +#include #include MODULE_LICENSE("GPL"); @@ -75,6 +76,7 @@ static const struct key_entry intel_arra struct intel_hid_priv { struct input_dev *input_dev; struct input_dev *array; + bool wakeup_mode; }; static int intel_hid_set_enable(struct device *device, int enable) @@ -118,23 +120,44 @@ static void intel_button_array_enable(st dev_warn(device, "failed to set button capability\n"); } -static int intel_hid_pl_suspend_handler(struct device *device) +static int intel_hid_pm_prepare(struct device *dev) { - intel_hid_set_enable(device, 0); - intel_button_array_enable(device, false); + struct platform_device *device = to_platform_device(dev); + struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); + priv->wakeup_mode = true; return 0; } -static int intel_hid_pl_resume_handler(struct device *device) +static void intel_hid_pm_complete(struct device *dev) +{ + struct platform_device *device = to_platform_device(dev); + struct intel_hid_priv *priv = dev_get_drvdata(&device->dev); + + priv->wakeup_mode = false; +} + +static int intel_hid_pl_suspend_handler(struct device *device) { - intel_hid_set_enable(device, 1); - intel_button_array_enable(device, true); + if (pm_suspend_via_firmware()) { + intel_hid_set_enable(device, 0); + intel_button_array_enable(device, false); + } + return 0; +} +static int intel_hid_pl_resume_handler(struct device *device) +{ + if (pm_resume_via_firmware()) { + intel_hid_set_enable(device, 1); + intel_button_array_enable(device, true); + } return 0; } static const struct dev_pm_ops intel_hid_pl_pm_ops = { + .prepare = intel_hid_pm_prepare, + .complete = intel_hid_pm_complete, .freeze = intel_hid_pl_suspend_handler, .thaw = intel_hid_pl_resume_handler, .restore = intel_hid_pl_resume_handler, @@ -206,6 +229,19 @@ static void notify_handler(acpi_handle h unsigned long long ev_index; acpi_status status; + if (priv->wakeup_mode) { + /* Wake up on 5-button array events only. */ + if (event == 0xc0 || !priv->array) + return; + + if (sparse_keymap_entry_from_scancode(priv->array, event)) + pm_wakeup_hard_event(&device->dev); + else + dev_info(&device->dev, "unknown event 0x%x\n", event); + + return; + } + /* 0xC0 is for HID events, other values are for 5 button array */ if (event != 0xc0) { if (!priv->array || @@ -292,6 +328,7 @@ static int intel_hid_probe(struct platfo "failed to enable HID power button\n"); } + device_init_wakeup(&device->dev, true); return 0; err_remove_notify: