Commit 91f9e850 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

platform: x86: intel-vbtn: Wake up the system from suspend-to-idle

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: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
parent d07ff652
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/input/sparse-keymap.h> #include <linux/input/sparse-keymap.h>
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/suspend.h>
#include <acpi/acpi_bus.h> #include <acpi/acpi_bus.h>
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -46,6 +47,7 @@ static const struct key_entry intel_vbtn_keymap[] = { ...@@ -46,6 +47,7 @@ static const struct key_entry intel_vbtn_keymap[] = {
struct intel_vbtn_priv { struct intel_vbtn_priv {
struct input_dev *input_dev; struct input_dev *input_dev;
bool wakeup_mode;
}; };
static int intel_vbtn_input_setup(struct platform_device *device) static int intel_vbtn_input_setup(struct platform_device *device)
...@@ -73,9 +75,15 @@ static void notify_handler(acpi_handle handle, u32 event, void *context) ...@@ -73,9 +75,15 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
struct platform_device *device = context; struct platform_device *device = context;
struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev); struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
if (!sparse_keymap_report_event(priv->input_dev, event, 1, true)) if (priv->wakeup_mode) {
dev_info(&device->dev, "unknown event index 0x%x\n", if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
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) static int intel_vbtn_probe(struct platform_device *device)
...@@ -109,6 +117,7 @@ static int intel_vbtn_probe(struct platform_device *device) ...@@ -109,6 +117,7 @@ static int intel_vbtn_probe(struct platform_device *device)
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return -EBUSY; return -EBUSY;
device_init_wakeup(&device->dev, true);
return 0; return 0;
} }
...@@ -125,10 +134,34 @@ static int intel_vbtn_remove(struct platform_device *device) ...@@ -125,10 +134,34 @@ static int intel_vbtn_remove(struct platform_device *device)
return 0; return 0;
} }
static int intel_vbtn_pm_prepare(struct device *dev)
{
struct intel_vbtn_priv *priv = dev_get_drvdata(dev);
priv->wakeup_mode = true;
return 0;
}
static int intel_vbtn_pm_resume(struct device *dev)
{
struct intel_vbtn_priv *priv = dev_get_drvdata(dev);
priv->wakeup_mode = false;
return 0;
}
static const struct dev_pm_ops intel_vbtn_pm_ops = {
.prepare = intel_vbtn_pm_prepare,
.resume = intel_vbtn_pm_resume,
.restore = intel_vbtn_pm_resume,
.thaw = intel_vbtn_pm_resume,
};
static struct platform_driver intel_vbtn_pl_driver = { static struct platform_driver intel_vbtn_pl_driver = {
.driver = { .driver = {
.name = "intel-vbtn", .name = "intel-vbtn",
.acpi_match_table = intel_vbtn_ids, .acpi_match_table = intel_vbtn_ids,
.pm = &intel_vbtn_pm_ops,
}, },
.probe = intel_vbtn_probe, .probe = intel_vbtn_probe,
.remove = intel_vbtn_remove, .remove = intel_vbtn_remove,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment