From patchwork Wed Apr 26 21:24:54 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: 9702065 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 C6C72603F4 for ; Wed, 26 Apr 2017 21:34:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B70832858E for ; Wed, 26 Apr 2017 21:34:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB7FC285EA; Wed, 26 Apr 2017 21:34:09 +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=unavailable 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 653362858E for ; Wed, 26 Apr 2017 21:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030595AbdDZVdq (ORCPT ); Wed, 26 Apr 2017 17:33:46 -0400 Received: from cloudserver094114.home.net.pl ([79.96.170.134]:50903 "EHLO cloudserver094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030580AbdDZVdn (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 72b3467c29bcd172; 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 4/5] platform: x86: intel-vbtn: Wake up the system from suspend-to-idle Date: Wed, 26 Apr 2017 23:24:54 +0200 Message-ID: <2369689.4LNdffUpJi@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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rafael J. Wysocki Allow the intel-vbtn 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 --- drivers/platform/x86/intel-vbtn.c | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) Index: linux-pm/drivers/platform/x86/intel-vbtn.c =================================================================== --- linux-pm.orig/drivers/platform/x86/intel-vbtn.c +++ linux-pm/drivers/platform/x86/intel-vbtn.c @@ -23,6 +23,7 @@ #include #include #include +#include #include MODULE_LICENSE("GPL"); @@ -42,6 +43,7 @@ static const struct key_entry intel_vbtn struct intel_vbtn_priv { struct input_dev *input_dev; + bool wakeup_mode; }; static int intel_vbtn_input_setup(struct platform_device *device) @@ -69,9 +71,15 @@ static void notify_handler(acpi_handle h struct platform_device *device = context; struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); - if (!sparse_keymap_report_event(priv->input_dev, event, 1, true)) - dev_info(&device->dev, "unknown event index 0x%x\n", - event); + if (priv->wakeup_mode) { + if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) { + pm_wakeup_hard_event(&device->dev); + return; + } + } else if (sparse_keymap_report_event(priv->input_dev, event, 1, true)) { + return; + } + dev_info(&device->dev, "unknown event index 0x%x\n", event); } static int intel_vbtn_probe(struct platform_device *device) @@ -105,6 +113,7 @@ static int intel_vbtn_probe(struct platf if (ACPI_FAILURE(status)) return -EBUSY; + device_init_wakeup(&device->dev, true); return 0; } @@ -121,10 +130,33 @@ static int intel_vbtn_remove(struct plat return 0; } +static int intel_vbtn_pm_prepare(struct device *dev) +{ + struct platform_device *device = to_platform_device(dev); + struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); + + priv->wakeup_mode = true; + return 0; +} + +static void intel_vbtn_pm_complete(struct device *dev) +{ + struct platform_device *device = to_platform_device(dev); + struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); + + priv->wakeup_mode = false; +} + +static const struct dev_pm_ops intel_vbtn_pm_ops = { + .prepare = intel_vbtn_pm_prepare, + .complete = intel_vbtn_pm_complete, +}; + static struct platform_driver intel_vbtn_pl_driver = { .driver = { .name = "intel-vbtn", .acpi_match_table = intel_vbtn_ids, + .pm = &intel_vbtn_pm_ops, }, .probe = intel_vbtn_probe, .remove = intel_vbtn_remove,