From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Darren Hart <dvhart@infradead.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux ACPI <linux-acpi@vger.kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Mario Limonciello <mario.limonciello@dell.com>
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 [thread overview]
Message-ID: <7255712.4ssjnT3GDQ@aspire.rjw.lan> (raw)
In-Reply-To: <1979543.KIEJ8uyRaT@aspire.rjw.lan>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
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 <rafael.j.wysocki@intel.com>
---
This depends on https://patchwork.kernel.org/patch/9685529/
---
drivers/platform/x86/intel-hid.c | 49 ++++++++++++++++++++++++++++++++++-----
1 file changed, 43 insertions(+), 6 deletions(-)
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 <linux/platform_device.h>
#include <linux/input/sparse-keymap.h>
#include <linux/acpi.h>
+#include <linux/suspend.h>
#include <acpi/acpi_bus.h>
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:
next prev parent reply other threads:[~2017-04-26 21:27 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 21:21 [PATCH 0/5] PM / sleep: Support power button wakeup from S2I on recent Dell laptops Rafael J. Wysocki
2017-04-26 21:22 ` [PATCH 1/5] PM / wakeup: Integrate mechanism to abort transitions in progress Rafael J. Wysocki
2017-04-26 21:23 ` [PATCH 2/5] ACPI / sleep: Ignore spurious SCI wakeups from suspend-to-idle Rafael J. Wysocki
2017-04-26 21:24 ` [PATCH 3/5] ACPI / sleep: EC-based wakeup from suspend-to-idle on Dell systems Rafael J. Wysocki
2017-04-27 14:47 ` Mario.Limonciello
2017-04-27 22:26 ` Rafael J. Wysocki
2017-05-04 7:58 ` Zheng, Lv
2017-05-04 14:23 ` Rafael J. Wysocki
2017-05-04 14:26 ` Rafael J. Wysocki
2017-05-05 0:36 ` Zheng, Lv
2017-04-26 21:24 ` [PATCH 4/5] platform: x86: intel-vbtn: Wake up the system from suspend-to-idle Rafael J. Wysocki
2017-04-26 21:27 ` Rafael J. Wysocki [this message]
2017-05-04 14:33 ` [PATCH 0/5] PM / sleep: Support power button wakeup from S2I on recent Dell laptops Rafael J. Wysocki
2017-05-31 23:23 ` [PATCH 0/3] ACPI " Rafael J. Wysocki
2017-05-31 23:24 ` [PATCH 1/3] platform: x86: intel-vbtn: Wake up the system from suspend-to-idle Rafael J. Wysocki
2017-05-31 23:26 ` [PATCH 2/3] platform: x86: intel-hid: " Rafael J. Wysocki
2017-05-31 23:27 ` [PATCH 3/3] ACPI / sleep: EC-based wakeup from suspend-to-idle on recent Dell systems Rafael J. Wysocki
2017-06-05 15:18 ` Mario.Limonciello
2017-06-05 20:51 ` Rafael J. Wysocki
2017-06-01 10:43 ` [PATCH 0/3] ACPI / sleep: Support power button wakeup from S2I on recent Dell laptops Andy Shevchenko
2017-06-01 11:50 ` Tom Lanyon
2017-06-01 14:59 ` Rafael J. Wysocki
2017-06-02 1:06 ` Tom Lanyon
2017-06-02 23:16 ` Rafael J. Wysocki
2017-06-01 15:00 ` Rafael J. Wysocki
2017-06-19 21:48 ` [PATCH v2 " Rafael J. Wysocki
2017-06-19 21:49 ` [PATCH v2 1/3] platform: x86: intel-vbtn: Wake up the system from suspend-to-idle Rafael J. Wysocki
2017-06-19 21:51 ` [PATCH v2 2/3] platform: x86: intel-hid: " Rafael J. Wysocki
2017-06-19 21:53 ` [PATCH v2 3/3] ACPI / sleep: EC-based wakeup from suspend-to-idle on recent Dell systems Rafael J. Wysocki
2017-06-19 23:37 ` Zheng, Lv
2017-06-19 23:46 ` Rafael J. Wysocki
2017-06-21 1:13 ` Zheng, Lv
2017-06-20 0:07 ` Linus Torvalds
2017-06-20 1:13 ` Rafael J. Wysocki
2017-06-20 2:00 ` Linus Torvalds
2017-06-20 21:16 ` Rafael J. Wysocki
2017-06-21 1:13 ` Zheng, Lv
2017-06-22 23:56 ` [PATCH] ACPI / sleep: EC-based wakeup from suspend-to-idle on recent systems Rafael J. Wysocki
2017-06-23 2:40 ` Linus Torvalds
2017-06-27 5:50 ` Tom Lanyon
2017-06-27 6:47 ` Andy Shevchenko
2017-06-27 10:54 ` Tom Lanyon
2017-06-27 11:10 ` Mario.Limonciello
2017-06-27 15:03 ` Rafael J. Wysocki
2017-06-27 16:14 ` Srinivas Pandruvada
2017-07-06 11:41 ` Tom Lanyon
2017-07-07 0:38 ` Srinivas Pandruvada
2017-06-23 6:30 ` Zheng, Lv
2017-06-23 12:13 ` Rafael J. Wysocki
2017-06-23 12:27 ` Rafael J. Wysocki
2017-06-23 13:15 ` [PATCH v2] " Rafael J. Wysocki
2017-06-23 15:37 ` Mario.Limonciello
2017-06-23 16:06 ` Srinivas Pandruvada
2017-06-23 18:01 ` Mario.Limonciello
2017-06-24 0:43 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7255712.4ssjnT3GDQ@aspire.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dvhart@infradead.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mario.limonciello@dell.com \
--cc=mika.westerberg@linux.intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).