Skip to content

Commit 91f9e85

Browse files
committed
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: Rafael J. Wysocki <[email protected]> Acked-by: Andy Shevchenko <[email protected]>
1 parent d07ff65 commit 91f9e85

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

drivers/platform/x86/intel-vbtn.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/platform_device.h>
2424
#include <linux/input/sparse-keymap.h>
2525
#include <linux/acpi.h>
26+
#include <linux/suspend.h>
2627
#include <acpi/acpi_bus.h>
2728

2829
MODULE_LICENSE("GPL");
@@ -46,6 +47,7 @@ static const struct key_entry intel_vbtn_keymap[] = {
4647

4748
struct intel_vbtn_priv {
4849
struct input_dev *input_dev;
50+
bool wakeup_mode;
4951
};
5052

5153
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)
7375
struct platform_device *device = context;
7476
struct intel_vbtn_priv *priv = dev_get_drvdata(&device->dev);
7577

76-
if (!sparse_keymap_report_event(priv->input_dev, event, 1, true))
77-
dev_info(&device->dev, "unknown event index 0x%x\n",
78-
event);
78+
if (priv->wakeup_mode) {
79+
if (sparse_keymap_entry_from_scancode(priv->input_dev, event)) {
80+
pm_wakeup_hard_event(&device->dev);
81+
return;
82+
}
83+
} else if (sparse_keymap_report_event(priv->input_dev, event, 1, true)) {
84+
return;
85+
}
86+
dev_info(&device->dev, "unknown event index 0x%x\n", event);
7987
}
8088

8189
static int intel_vbtn_probe(struct platform_device *device)
@@ -109,6 +117,7 @@ static int intel_vbtn_probe(struct platform_device *device)
109117
if (ACPI_FAILURE(status))
110118
return -EBUSY;
111119

120+
device_init_wakeup(&device->dev, true);
112121
return 0;
113122
}
114123

@@ -125,10 +134,34 @@ static int intel_vbtn_remove(struct platform_device *device)
125134
return 0;
126135
}
127136

137+
static int intel_vbtn_pm_prepare(struct device *dev)
138+
{
139+
struct intel_vbtn_priv *priv = dev_get_drvdata(dev);
140+
141+
priv->wakeup_mode = true;
142+
return 0;
143+
}
144+
145+
static int intel_vbtn_pm_resume(struct device *dev)
146+
{
147+
struct intel_vbtn_priv *priv = dev_get_drvdata(dev);
148+
149+
priv->wakeup_mode = false;
150+
return 0;
151+
}
152+
153+
static const struct dev_pm_ops intel_vbtn_pm_ops = {
154+
.prepare = intel_vbtn_pm_prepare,
155+
.resume = intel_vbtn_pm_resume,
156+
.restore = intel_vbtn_pm_resume,
157+
.thaw = intel_vbtn_pm_resume,
158+
};
159+
128160
static struct platform_driver intel_vbtn_pl_driver = {
129161
.driver = {
130162
.name = "intel-vbtn",
131163
.acpi_match_table = intel_vbtn_ids,
164+
.pm = &intel_vbtn_pm_ops,
132165
},
133166
.probe = intel_vbtn_probe,
134167
.remove = intel_vbtn_remove,

0 commit comments

Comments
 (0)