forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/platform/x86/intel-hid.c
....@@ -1,19 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * Intel HID event & 5 button array driver
34 *
45 * Copyright (C) 2015 Alex Hung <alex.hung@canonical.com>
56 * Copyright (C) 2015 Andrew Lutomirski <luto@kernel.org>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
177 */
188
199 #include <linux/acpi.h>
....@@ -30,8 +20,10 @@
3020
3121 static const struct acpi_device_id intel_hid_ids[] = {
3222 {"INT33D5", 0},
23
+ {"INTC1051", 0},
3324 {"", 0},
3425 };
26
+MODULE_DEVICE_TABLE(acpi, intel_hid_ids);
3527
3628 /* In theory, these are HID usages. */
3729 static const struct key_entry intel_hid_keymap[] = {
....@@ -99,6 +91,13 @@
9991 .matches = {
10092 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
10193 DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Tablet Gen 2"),
94
+ },
95
+ },
96
+ {
97
+ .ident = "Microsoft Surface Go 3",
98
+ .matches = {
99
+ DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
100
+ DMI_MATCH(DMI_PRODUCT_NAME, "Surface Go 3"),
102101 },
103102 },
104103 { }
....@@ -277,35 +276,45 @@
277276
278277 static int intel_hid_pm_prepare(struct device *device)
279278 {
279
+ if (device_may_wakeup(device)) {
280
+ struct intel_hid_priv *priv = dev_get_drvdata(device);
281
+
282
+ priv->wakeup_mode = true;
283
+ }
284
+ return 0;
285
+}
286
+
287
+static void intel_hid_pm_complete(struct device *device)
288
+{
280289 struct intel_hid_priv *priv = dev_get_drvdata(device);
281290
282
- priv->wakeup_mode = true;
283
- return 0;
291
+ priv->wakeup_mode = false;
284292 }
285293
286294 static int intel_hid_pl_suspend_handler(struct device *device)
287295 {
288
- if (pm_suspend_via_firmware()) {
296
+ intel_button_array_enable(device, false);
297
+
298
+ if (!pm_suspend_no_platform())
289299 intel_hid_set_enable(device, false);
290
- intel_button_array_enable(device, false);
291
- }
300
+
292301 return 0;
293302 }
294303
295304 static int intel_hid_pl_resume_handler(struct device *device)
296305 {
297
- struct intel_hid_priv *priv = dev_get_drvdata(device);
306
+ intel_hid_pm_complete(device);
298307
299
- priv->wakeup_mode = false;
300
- if (pm_resume_via_firmware()) {
308
+ if (!pm_suspend_no_platform())
301309 intel_hid_set_enable(device, true);
302
- intel_button_array_enable(device, true);
303
- }
310
+
311
+ intel_button_array_enable(device, true);
304312 return 0;
305313 }
306314
307315 static const struct dev_pm_ops intel_hid_pl_pm_ops = {
308316 .prepare = intel_hid_pm_prepare,
317
+ .complete = intel_hid_pm_complete,
309318 .freeze = intel_hid_pl_suspend_handler,
310319 .thaw = intel_hid_pl_resume_handler,
311320 .restore = intel_hid_pl_resume_handler,
....@@ -515,6 +524,12 @@
515524 }
516525
517526 device_init_wakeup(&device->dev, true);
527
+ /*
528
+ * In order for system wakeup to work, the EC GPE has to be marked as
529
+ * a wakeup one, so do that here (this setting will persist, but it has
530
+ * no effect until the wakeup mask is set for the EC GPE).
531
+ */
532
+ acpi_ec_mark_gpe_for_wake();
518533 return 0;
519534
520535 err_remove_notify:
....@@ -548,7 +563,6 @@
548563 .probe = intel_hid_probe,
549564 .remove = intel_hid_remove,
550565 };
551
-MODULE_DEVICE_TABLE(acpi, intel_hid_ids);
552566
553567 /*
554568 * Unfortunately, some laptops provide a _HID="INT33D5" device with