Set up GPE interrupts for lid-based wakeup

The newer surface devices Pro 4 and up do not define _PRW to specify
which GPE interrupt belongs to the lid. Thus they may not be marked as
wake-up sources automatically, so we have to do this manually.
This commit is contained in:
qzed 2019-07-26 04:15:42 +02:00
parent be234ec92c
commit 8e6c7b85ca
24 changed files with 384 additions and 90 deletions

View file

@ -1,6 +1,6 @@
From d4ee8b0835a004e816e1aeb3a5d7c47bf9c9a77a Mon Sep 17 00:00:00 2001
From c88960a183f465316b28486bf7a9031563547001 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:55:58 +0200
Date: Fri, 26 Jul 2019 03:40:41 +0200
Subject: [PATCH 01/12] surface-acpi
---
@ -8,9 +8,9 @@ Subject: [PATCH 01/12] surface-acpi
drivers/acpi/acpica/exfield.c | 26 +-
drivers/platform/x86/Kconfig | 97 +
drivers/platform/x86/Makefile | 1 +
drivers/platform/x86/surface_acpi.c | 3761 +++++++++++++++++++++++++++
drivers/platform/x86/surface_acpi.c | 3908 +++++++++++++++++++++++++++
drivers/tty/serdev/core.c | 90 +-
6 files changed, 3958 insertions(+), 19 deletions(-)
6 files changed, 4105 insertions(+), 19 deletions(-)
create mode 100644 drivers/platform/x86/surface_acpi.c
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
@ -201,10 +201,10 @@ index dc29af4d8e2f..2250a32a5527 100644
obj-$(CONFIG_FUJITSU_TABLET) += fujitsu-tablet.o
diff --git a/drivers/platform/x86/surface_acpi.c b/drivers/platform/x86/surface_acpi.c
new file mode 100644
index 000000000000..2874cc85213a
index 000000000000..a17538905642
--- /dev/null
+++ b/drivers/platform/x86/surface_acpi.c
@@ -0,0 +1,3761 @@
@@ -0,0 +1,3908 @@
+#include <asm/unaligned.h>
+#include <linux/acpi.h>
+#include <linux/completion.h>
@ -2388,19 +2388,25 @@ index 000000000000..2874cc85213a
+
+ if (rqst.tc == 0x11 && rqst.cid == 0x0D && status == -EPERM) {
+ /* Base state quirk:
+ * The base state may be queried from ACPI when the EC is
+ * still suspended. In this case it will return '-EPERM'.
+ * Returning 0xff (unknown base status) here will suppress
+ * error messages and cause an immediate re-query of the
+ * state. Delay return to avoid spinning.
+ * The base state may be queried from ACPI when the EC is still
+ * suspended. In this case it will return '-EPERM'. This query
+ * will only be triggered from the ACPI lid GPE interrupt, thus
+ * we are either in laptop or studio mode (base status 0x01 or
+ * 0x02). Furthermore, we will only get here if the device (and
+ * EC) have been suspended.
+ *
+ * We now assume that the device is in laptop mode (0x01). This
+ * has the drawback that it will wake the device when unfolding
+ * it in studio mode, but it also allows us to avoid actively
+ * waiting for the EC to wake up, which may incur a notable
+ * delay.
+ */
+
+ buffer->status = 0x00;
+ buffer->len = 0x03;
+ buffer->data.out.status = 0x00;
+ buffer->data.out.len = 0x01;
+ buffer->data.out.pld[0] = 0xFF;
+ msleep(SG5_QUIRK_BASE_STATE_DELAY);
+ buffer->data.out.pld[0] = 0x01;
+
+ } else if (!status) { // success
+ buffer->status = 0x00;
@ -3665,6 +3671,17 @@ index 000000000000..2874cc85213a
+
+#ifdef CONFIG_SURFACE_ACPI_SID
+
+struct si_lid_device {
+ const char *acpi_path;
+ const u32 gpe_number;
+};
+
+struct si_device_info {
+ const bool has_perf_mode;
+ const struct si_lid_device *lid_device;
+};
+
+
+enum sg5_perf_mode {
+ SG5_PERF_MODE_NORMAL = 1,
+ SG5_PERF_MODE_BATTERY = 2,
@ -3821,10 +3838,13 @@ index 000000000000..2874cc85213a
+const static DEVICE_ATTR_RW(perf_mode);
+
+
+static int surfacegen5_acpi_sid_probe(struct platform_device *pdev)
+static int sid_perf_mode_setup(struct platform_device *pdev, const struct si_device_info *info)
+{
+ int status;
+
+ if (!info->has_perf_mode)
+ return 0;
+
+ // link to ec
+ status = surfacegen5_ec_consumer_register(&pdev->dev);
+ if (status) {
@ -3852,20 +3872,146 @@ index 000000000000..2874cc85213a
+ return status;
+}
+
+static int surfacegen5_acpi_sid_remove(struct platform_device *pdev)
+static void sid_perf_mode_remove(struct platform_device *pdev, const struct si_device_info *info)
+{
+ if (!info->has_perf_mode)
+ return;
+
+ // remove perf_mode attribute
+ sysfs_remove_file(&pdev->dev.kobj, &dev_attr_perf_mode.attr);
+
+ // set exit perf_mode
+ sg5_ec_perf_mode_set(param_perf_mode_exit);
+}
+
+
+static int sid_lid_enable_wakeup(const struct si_device_info *info, bool enable)
+{
+ int action = enable ? ACPI_GPE_ENABLE : ACPI_GPE_DISABLE;
+ int status;
+
+ if (!info->lid_device)
+ return 0;
+
+ status = acpi_set_gpe_wake_mask(NULL, info->lid_device->gpe_number, action);
+ if (status)
+ return -EFAULT;
+
+ return 0;
+}
+
+static int sid_lid_device_setup(struct platform_device *pdev, const struct si_device_info *info)
+{
+ acpi_handle lid_handle;
+ int status;
+
+ if (!info->lid_device)
+ return 0;
+
+ status = acpi_get_handle(NULL, (acpi_string)info->lid_device->acpi_path, &lid_handle);
+ if (status)
+ return -EFAULT;
+
+ status = acpi_setup_gpe_for_wake(lid_handle, NULL, info->lid_device->gpe_number);
+ if (status)
+ return -EFAULT;
+
+ status = acpi_enable_gpe(NULL, info->lid_device->gpe_number);
+ if (status)
+ return -EFAULT;
+
+ return sid_lid_enable_wakeup(info, true);
+}
+
+static void sid_lid_device_remove(struct platform_device *pdev, const struct si_device_info *info)
+{
+ sid_lid_enable_wakeup(info, false);
+}
+
+
+static int surfacegen5_acpi_sid_suspend(struct device *dev)
+{
+ const struct si_device_info *info = dev_get_drvdata(dev);
+ return sid_lid_enable_wakeup(info, true);
+}
+
+static int surfacegen5_acpi_sid_resume(struct device *dev)
+{
+ const struct si_device_info *info = dev_get_drvdata(dev);
+ return sid_lid_enable_wakeup(info, false);
+}
+
+static SIMPLE_DEV_PM_OPS(surfacegen5_acpi_sid_pm, surfacegen5_acpi_sid_suspend, surfacegen5_acpi_sid_resume);
+
+
+static int surfacegen5_acpi_sid_probe(struct platform_device *pdev)
+{
+ const struct si_device_info *info;
+ int status;
+
+ info = acpi_device_get_match_data(&pdev->dev);
+ if (!info)
+ return -ENODEV;
+ platform_set_drvdata(pdev, (void *)info);
+
+ status = sid_perf_mode_setup(pdev, info);
+ if (status)
+ goto err_perf_mode;
+
+ status = sid_lid_device_setup(pdev, info);
+ if (status)
+ goto err_lid;
+
+ return 0;
+
+err_lid:
+ sid_perf_mode_remove(pdev, info);
+err_perf_mode:
+ return status;
+}
+
+static int surfacegen5_acpi_sid_remove(struct platform_device *pdev)
+{
+ const struct si_device_info *info = platform_get_drvdata(pdev);
+
+ sid_perf_mode_remove(pdev, info);
+ sid_lid_device_remove(pdev, info);
+
+ return 0;
+}
+
+
+static const struct si_lid_device lid_device_l17 = {
+ .acpi_path = "\\_SB.LID0",
+ .gpe_number = 0x17,
+};
+
+static const struct si_lid_device lid_device_l57 = {
+ .acpi_path = "\\_SB.LID0",
+ .gpe_number = 0x57,
+};
+
+static const struct si_device_info si_device_pro = {
+ .has_perf_mode = false,
+ .lid_device = &lid_device_l17,
+};
+
+static const struct si_device_info si_device_book = {
+ .has_perf_mode = true,
+ .lid_device = &lid_device_l17,
+};
+
+static const struct si_device_info si_device_laptop = {
+ .has_perf_mode = false,
+ .lid_device = &lid_device_l57,
+};
+
+static const struct acpi_device_id surfacegen5_acpi_sid_match[] = {
+ { "MSHW0107", 0 }, /* Surface Book 2 */
+ { "MSHW0081", (unsigned long)&si_device_pro }, /* Surface Pro 4 and 5 */
+ { "MSHW0080", (unsigned long)&si_device_book }, /* Surface Book 1 */
+ { "MSHW0107", (unsigned long)&si_device_book }, /* Surface Book 2 */
+ { "MSHW0086", (unsigned long)&si_device_laptop }, /* Surface Laptop 1 */
+ { "MSHW0112", (unsigned long)&si_device_laptop }, /* Surface Laptop 2 */
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, surfacegen5_acpi_sid_match);
@ -3876,6 +4022,7 @@ index 000000000000..2874cc85213a
+ .driver = {
+ .name = "surfacegen5_acpi_sid",
+ .acpi_match_table = ACPI_PTR(surfacegen5_acpi_sid_match),
+ .pm = &surfacegen5_acpi_sid_pm,
+ },
+};
+

View file

@ -1,6 +1,6 @@
From 39ac44640326e0509f04e627a84f24b15463c2ba Mon Sep 17 00:00:00 2001
From 37bc0c403af84fc5c6018c7ec1d974607b8040f2 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:56:21 +0200
Date: Fri, 26 Jul 2019 03:41:22 +0200
Subject: [PATCH 02/12] suspend
---

View file

@ -1,6 +1,6 @@
From 6da968469522a258e270802d28b9d5c3f39f6c9d Mon Sep 17 00:00:00 2001
From caff9a677d61eee7429d9a30ed33224bd3b96a42 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:56:55 +0200
Date: Fri, 26 Jul 2019 03:42:15 +0200
Subject: [PATCH 03/12] buttons
---

View file

@ -1,6 +1,6 @@
From e0eef24214cefb6fe6a502887b8d5fabc601b7e4 Mon Sep 17 00:00:00 2001
From a73226e177c1299d14654dbc9578d6cf292046a9 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:57:09 +0200
Date: Fri, 26 Jul 2019 03:42:25 +0200
Subject: [PATCH 04/12] cameras
---

View file

@ -1,6 +1,6 @@
From c0f8399678ef91ad241333dcc4d67ef906423240 Mon Sep 17 00:00:00 2001
From 41b96d9a4fa6078bb9fd827ab7d1d28186680f01 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:57:18 +0200
Date: Fri, 26 Jul 2019 03:42:39 +0200
Subject: [PATCH 05/12] ipts
---
@ -1222,7 +1222,7 @@ index 4a9f139e7b73..a800b93cf33d 100644
static void pch_enable_backlight(const struct intel_crtc_state *crtc_state,
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 184e49036e1d..0f4ab4776c25 100644
index f9167d0e095c..28b729c9d804 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -173,6 +173,7 @@ struct mt_device {

View file

@ -1,6 +1,6 @@
From 05bb46599d34f54fe48fa37503714e015008b5c8 Mon Sep 17 00:00:00 2001
From a86af5d40714c4f6a8bfdef6b4c61e4b36d08375 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:57:29 +0200
Date: Fri, 26 Jul 2019 03:42:50 +0200
Subject: [PATCH 06/12] hid
---
@ -11,10 +11,10 @@ Subject: [PATCH 06/12] hid
4 files changed, 86 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 92452992b368..3cb0f41a64eb 100644
index 50b3c0d89c9c..d08c79a29402 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -801,11 +801,22 @@
@@ -803,11 +803,22 @@
#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3KV1 0x0732
#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_600 0x0750
#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c
@ -57,10 +57,10 @@ index 72d983626afd..133395b45022 100644
.driver_data = MS_PRESENTER },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x091B),
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 0f4ab4776c25..0e0ce017f8d8 100644
index 28b729c9d804..334afd3854a9 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1985,6 +1985,63 @@ static const struct hid_device_id mt_devices[] = {
@@ -1989,6 +1989,63 @@ static const struct hid_device_id mt_devices[] = {
HID_USB_DEVICE(USB_VENDOR_ID_LG,
USB_DEVICE_ID_LG_MELFAS_MT) },
@ -125,10 +125,10 @@ index 0f4ab4776c25..0e0ce017f8d8 100644
{ .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
MT_USB_DEVICE(USB_VENDOR_ID_ASUS,
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 5892f1bd037e..f297f3f6c3b3 100644
index 91e86af44a04..4cc5821cc6a7 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -112,6 +112,17 @@ static const struct hid_device_id hid_quirks[] = {
@@ -113,6 +113,17 @@ static const struct hid_device_id hid_quirks[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_PRO_2), HID_QUIRK_NO_INIT_REPORTS },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2), HID_QUIRK_NO_INIT_REPORTS },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2), HID_QUIRK_NO_INIT_REPORTS },

View file

@ -1,6 +1,6 @@
From bfa1dd672a775831755e12eb62b744300bf80dc3 Mon Sep 17 00:00:00 2001
From fed76ce1e6ffd63209dac031e0192270dc0ea2f5 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:57:47 +0200
Date: Fri, 26 Jul 2019 03:43:03 +0200
Subject: [PATCH 07/12] sdcard-reader
---

View file

@ -1,6 +1,6 @@
From 0692dd2c418ca3759659c7a78fb7b2e67aa3a044 Mon Sep 17 00:00:00 2001
From 022c4cc203690834eedbda3c32dfd1cf3f3f4bc0 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:57:58 +0200
Date: Fri, 26 Jul 2019 03:43:14 +0200
Subject: [PATCH 08/12] wifi
---

View file

@ -1,6 +1,6 @@
From 3e219f8272fdfba67461c37247ab3702aae18774 Mon Sep 17 00:00:00 2001
From 151f176a715d057f3221a6f1721fc9837c2b52ec Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:58:10 +0200
Date: Fri, 26 Jul 2019 03:43:27 +0200
Subject: [PATCH 09/12] surface3-power
---

View file

@ -1,6 +1,6 @@
From 7f4c61ccf081fff8aeff24486c9ba5b08cc8f666 Mon Sep 17 00:00:00 2001
From 71ea506e764b7d53b99bc9c436705f579cc1bdb8 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:58:25 +0200
Date: Fri, 26 Jul 2019 03:43:45 +0200
Subject: [PATCH 10/12] mwlwifi
---

View file

@ -1,6 +1,6 @@
From 35fe2bb16732f1f9746a57daf6163697f0f01f43 Mon Sep 17 00:00:00 2001
From 14a8e46a86c5fcc671601f655dfbed2471addb13 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:58:37 +0200
Date: Fri, 26 Jul 2019 03:43:57 +0200
Subject: [PATCH 11/12] surface-lte
---

View file

@ -1,6 +1,6 @@
From 71ef466ae973e848ac700822c77e345da4844e00 Mon Sep 17 00:00:00 2001
From 49798b92a2f2e3a7906743f76e3550ad01e3b045 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:58:49 +0200
Date: Fri, 26 Jul 2019 03:44:10 +0200
Subject: [PATCH 12/12] surfacebook2-dgpu
---

View file

@ -1,6 +1,6 @@
From fd502fa44599448603c5e1c28bedef1315c4514a Mon Sep 17 00:00:00 2001
From 04eb1901a55b1415f82999f186c8de231deb7f5c Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:45:52 +0200
Date: Fri, 26 Jul 2019 04:10:38 +0200
Subject: [PATCH 01/12] surface-acpi
---
@ -8,9 +8,9 @@ Subject: [PATCH 01/12] surface-acpi
drivers/acpi/acpica/exfield.c | 12 +-
drivers/platform/x86/Kconfig | 97 +
drivers/platform/x86/Makefile | 1 +
drivers/platform/x86/surface_acpi.c | 3761 +++++++++++++++++++++++++++
drivers/platform/x86/surface_acpi.c | 3908 +++++++++++++++++++++++++++
drivers/tty/serdev/core.c | 90 +-
6 files changed, 3957 insertions(+), 6 deletions(-)
6 files changed, 4104 insertions(+), 6 deletions(-)
create mode 100644 drivers/platform/x86/surface_acpi.c
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
@ -180,10 +180,10 @@ index 86cb76677bc8..be1ce92a365d 100644
obj-$(CONFIG_FUJITSU_TABLET) += fujitsu-tablet.o
diff --git a/drivers/platform/x86/surface_acpi.c b/drivers/platform/x86/surface_acpi.c
new file mode 100644
index 000000000000..2874cc85213a
index 000000000000..a17538905642
--- /dev/null
+++ b/drivers/platform/x86/surface_acpi.c
@@ -0,0 +1,3761 @@
@@ -0,0 +1,3908 @@
+#include <asm/unaligned.h>
+#include <linux/acpi.h>
+#include <linux/completion.h>
@ -2367,19 +2367,25 @@ index 000000000000..2874cc85213a
+
+ if (rqst.tc == 0x11 && rqst.cid == 0x0D && status == -EPERM) {
+ /* Base state quirk:
+ * The base state may be queried from ACPI when the EC is
+ * still suspended. In this case it will return '-EPERM'.
+ * Returning 0xff (unknown base status) here will suppress
+ * error messages and cause an immediate re-query of the
+ * state. Delay return to avoid spinning.
+ * The base state may be queried from ACPI when the EC is still
+ * suspended. In this case it will return '-EPERM'. This query
+ * will only be triggered from the ACPI lid GPE interrupt, thus
+ * we are either in laptop or studio mode (base status 0x01 or
+ * 0x02). Furthermore, we will only get here if the device (and
+ * EC) have been suspended.
+ *
+ * We now assume that the device is in laptop mode (0x01). This
+ * has the drawback that it will wake the device when unfolding
+ * it in studio mode, but it also allows us to avoid actively
+ * waiting for the EC to wake up, which may incur a notable
+ * delay.
+ */
+
+ buffer->status = 0x00;
+ buffer->len = 0x03;
+ buffer->data.out.status = 0x00;
+ buffer->data.out.len = 0x01;
+ buffer->data.out.pld[0] = 0xFF;
+ msleep(SG5_QUIRK_BASE_STATE_DELAY);
+ buffer->data.out.pld[0] = 0x01;
+
+ } else if (!status) { // success
+ buffer->status = 0x00;
@ -3644,6 +3650,17 @@ index 000000000000..2874cc85213a
+
+#ifdef CONFIG_SURFACE_ACPI_SID
+
+struct si_lid_device {
+ const char *acpi_path;
+ const u32 gpe_number;
+};
+
+struct si_device_info {
+ const bool has_perf_mode;
+ const struct si_lid_device *lid_device;
+};
+
+
+enum sg5_perf_mode {
+ SG5_PERF_MODE_NORMAL = 1,
+ SG5_PERF_MODE_BATTERY = 2,
@ -3800,10 +3817,13 @@ index 000000000000..2874cc85213a
+const static DEVICE_ATTR_RW(perf_mode);
+
+
+static int surfacegen5_acpi_sid_probe(struct platform_device *pdev)
+static int sid_perf_mode_setup(struct platform_device *pdev, const struct si_device_info *info)
+{
+ int status;
+
+ if (!info->has_perf_mode)
+ return 0;
+
+ // link to ec
+ status = surfacegen5_ec_consumer_register(&pdev->dev);
+ if (status) {
@ -3831,20 +3851,146 @@ index 000000000000..2874cc85213a
+ return status;
+}
+
+static int surfacegen5_acpi_sid_remove(struct platform_device *pdev)
+static void sid_perf_mode_remove(struct platform_device *pdev, const struct si_device_info *info)
+{
+ if (!info->has_perf_mode)
+ return;
+
+ // remove perf_mode attribute
+ sysfs_remove_file(&pdev->dev.kobj, &dev_attr_perf_mode.attr);
+
+ // set exit perf_mode
+ sg5_ec_perf_mode_set(param_perf_mode_exit);
+}
+
+
+static int sid_lid_enable_wakeup(const struct si_device_info *info, bool enable)
+{
+ int action = enable ? ACPI_GPE_ENABLE : ACPI_GPE_DISABLE;
+ int status;
+
+ if (!info->lid_device)
+ return 0;
+
+ status = acpi_set_gpe_wake_mask(NULL, info->lid_device->gpe_number, action);
+ if (status)
+ return -EFAULT;
+
+ return 0;
+}
+
+static int sid_lid_device_setup(struct platform_device *pdev, const struct si_device_info *info)
+{
+ acpi_handle lid_handle;
+ int status;
+
+ if (!info->lid_device)
+ return 0;
+
+ status = acpi_get_handle(NULL, (acpi_string)info->lid_device->acpi_path, &lid_handle);
+ if (status)
+ return -EFAULT;
+
+ status = acpi_setup_gpe_for_wake(lid_handle, NULL, info->lid_device->gpe_number);
+ if (status)
+ return -EFAULT;
+
+ status = acpi_enable_gpe(NULL, info->lid_device->gpe_number);
+ if (status)
+ return -EFAULT;
+
+ return sid_lid_enable_wakeup(info, true);
+}
+
+static void sid_lid_device_remove(struct platform_device *pdev, const struct si_device_info *info)
+{
+ sid_lid_enable_wakeup(info, false);
+}
+
+
+static int surfacegen5_acpi_sid_suspend(struct device *dev)
+{
+ const struct si_device_info *info = dev_get_drvdata(dev);
+ return sid_lid_enable_wakeup(info, true);
+}
+
+static int surfacegen5_acpi_sid_resume(struct device *dev)
+{
+ const struct si_device_info *info = dev_get_drvdata(dev);
+ return sid_lid_enable_wakeup(info, false);
+}
+
+static SIMPLE_DEV_PM_OPS(surfacegen5_acpi_sid_pm, surfacegen5_acpi_sid_suspend, surfacegen5_acpi_sid_resume);
+
+
+static int surfacegen5_acpi_sid_probe(struct platform_device *pdev)
+{
+ const struct si_device_info *info;
+ int status;
+
+ info = acpi_device_get_match_data(&pdev->dev);
+ if (!info)
+ return -ENODEV;
+ platform_set_drvdata(pdev, (void *)info);
+
+ status = sid_perf_mode_setup(pdev, info);
+ if (status)
+ goto err_perf_mode;
+
+ status = sid_lid_device_setup(pdev, info);
+ if (status)
+ goto err_lid;
+
+ return 0;
+
+err_lid:
+ sid_perf_mode_remove(pdev, info);
+err_perf_mode:
+ return status;
+}
+
+static int surfacegen5_acpi_sid_remove(struct platform_device *pdev)
+{
+ const struct si_device_info *info = platform_get_drvdata(pdev);
+
+ sid_perf_mode_remove(pdev, info);
+ sid_lid_device_remove(pdev, info);
+
+ return 0;
+}
+
+
+static const struct si_lid_device lid_device_l17 = {
+ .acpi_path = "\\_SB.LID0",
+ .gpe_number = 0x17,
+};
+
+static const struct si_lid_device lid_device_l57 = {
+ .acpi_path = "\\_SB.LID0",
+ .gpe_number = 0x57,
+};
+
+static const struct si_device_info si_device_pro = {
+ .has_perf_mode = false,
+ .lid_device = &lid_device_l17,
+};
+
+static const struct si_device_info si_device_book = {
+ .has_perf_mode = true,
+ .lid_device = &lid_device_l17,
+};
+
+static const struct si_device_info si_device_laptop = {
+ .has_perf_mode = false,
+ .lid_device = &lid_device_l57,
+};
+
+static const struct acpi_device_id surfacegen5_acpi_sid_match[] = {
+ { "MSHW0107", 0 }, /* Surface Book 2 */
+ { "MSHW0081", (unsigned long)&si_device_pro }, /* Surface Pro 4 and 5 */
+ { "MSHW0080", (unsigned long)&si_device_book }, /* Surface Book 1 */
+ { "MSHW0107", (unsigned long)&si_device_book }, /* Surface Book 2 */
+ { "MSHW0086", (unsigned long)&si_device_laptop }, /* Surface Laptop 1 */
+ { "MSHW0112", (unsigned long)&si_device_laptop }, /* Surface Laptop 2 */
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, surfacegen5_acpi_sid_match);
@ -3855,6 +4001,7 @@ index 000000000000..2874cc85213a
+ .driver = {
+ .name = "surfacegen5_acpi_sid",
+ .acpi_match_table = ACPI_PTR(surfacegen5_acpi_sid_match),
+ .pm = &surfacegen5_acpi_sid_pm,
+ },
+};
+

View file

@ -1,6 +1,6 @@
From 7df077a8111b7218e540040b79a8f9fd93283932 Mon Sep 17 00:00:00 2001
From 8f3f0b0111ce5bfa12a5c052ad6a04874dbdb95e Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:46:31 +0200
Date: Fri, 26 Jul 2019 04:11:02 +0200
Subject: [PATCH 02/12] suspend
---

View file

@ -1,6 +1,6 @@
From 2c5ccf4ac52c3b6c02df5d8dab9c0471d163a073 Mon Sep 17 00:00:00 2001
From 2d257efae93f8da74a84b1329c18474ef49b5a89 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:46:56 +0200
Date: Fri, 26 Jul 2019 04:11:17 +0200
Subject: [PATCH 03/12] buttons
---

View file

@ -1,6 +1,6 @@
From 75e435452af1d7ff64a14e7e9f4e580a1466005c Mon Sep 17 00:00:00 2001
From b3ba77590bcaa2892a0694350b51e83a6b39f1a4 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:47:36 +0200
Date: Fri, 26 Jul 2019 04:11:26 +0200
Subject: [PATCH 04/12] cameras
---

View file

@ -1,6 +1,6 @@
From 12534568128b4f5492d3b5f0cb5eec22fe25c18c Mon Sep 17 00:00:00 2001
From 9cc38f3d190794104ff5bfd56aeaf61316b81146 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:47:48 +0200
Date: Fri, 26 Jul 2019 04:11:35 +0200
Subject: [PATCH 05/12] ipts
---
@ -1226,7 +1226,7 @@ index beca98d2b035..2fce56e17047 100644
static void pch_enable_backlight(const struct intel_crtc_state *crtc_state,
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 1565a307170a..37cc279cb070 100644
index 42bb635895cf..3a362f107188 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -173,6 +173,7 @@ struct mt_device {

View file

@ -1,6 +1,6 @@
From da7dcf5f3b4a5338197cef00d38c5dbe9dbe78be Mon Sep 17 00:00:00 2001
From 0ec364cfc8a59dff3c4417dfc6aab7a1440bddfb Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:48:00 +0200
Date: Fri, 26 Jul 2019 04:11:44 +0200
Subject: [PATCH 06/12] hid
---
@ -11,10 +11,10 @@ Subject: [PATCH 06/12] hid
4 files changed, 86 insertions(+), 6 deletions(-)
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 6537086fb145..9dae634a6299 100644
index b1636ce22060..676175ffe613 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -816,11 +816,22 @@
@@ -819,11 +819,22 @@
#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3KV1 0x0732
#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_600 0x0750
#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c
@ -57,10 +57,10 @@ index 330cb073cb66..f45fea460678 100644
.driver_data = MS_PRESENTER },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, 0x091B),
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 37cc279cb070..80a76d9190a4 100644
index 3a362f107188..1acf6c25dfb9 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -1983,6 +1983,63 @@ static const struct hid_device_id mt_devices[] = {
@@ -1987,6 +1987,63 @@ static const struct hid_device_id mt_devices[] = {
HID_USB_DEVICE(USB_VENDOR_ID_LG,
USB_DEVICE_ID_LG_MELFAS_MT) },
@ -125,10 +125,10 @@ index 37cc279cb070..80a76d9190a4 100644
{ .driver_data = MT_CLS_CONFIDENCE_MINUS_ONE,
MT_USB_DEVICE(USB_VENDOR_ID_ASUS,
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 189bf68eb35c..3c235fb31c47 100644
index 74c0ad21b267..dfe97c2a8278 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -113,6 +113,17 @@ static const struct hid_device_id hid_quirks[] = {
@@ -114,6 +114,17 @@ static const struct hid_device_id hid_quirks[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_SURFACE_PRO_2), HID_QUIRK_NO_INIT_REPORTS },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2), HID_QUIRK_NO_INIT_REPORTS },
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2), HID_QUIRK_NO_INIT_REPORTS },

View file

@ -1,6 +1,6 @@
From d82fac219403ae1fae5bc82ea31de4a0cb3fca85 Mon Sep 17 00:00:00 2001
From f941f295c9f2ac9b1a491ae25c1423bbadfaca7b Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:48:18 +0200
Date: Fri, 26 Jul 2019 04:11:54 +0200
Subject: [PATCH 07/12] sdcard-reader
---

View file

@ -1,6 +1,6 @@
From 82439e5450aba5020207f96aed47523930ff99e4 Mon Sep 17 00:00:00 2001
From 8f081f0ce33e78b5009ee53a9f4ece8f33d6edda Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:48:29 +0200
Date: Fri, 26 Jul 2019 04:12:05 +0200
Subject: [PATCH 08/12] wifi
---

View file

@ -1,6 +1,6 @@
From 39348a5238c550802fe74c8c9ab5f1cddb3e5ae2 Mon Sep 17 00:00:00 2001
From df966e10791947d6cbb18a3cc82ebcf7ff866fe9 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:48:57 +0200
Date: Fri, 26 Jul 2019 04:12:17 +0200
Subject: [PATCH 09/12] surface3-power
---

View file

@ -1,6 +1,6 @@
From e496b127b72277bf2b6526a07aebc4de8f231a56 Mon Sep 17 00:00:00 2001
From ab3c7d815ebd2b978242c4f66f3e560d3549fc33 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:49:10 +0200
Date: Fri, 26 Jul 2019 04:12:32 +0200
Subject: [PATCH 10/12] mwlwifi
---

View file

@ -1,6 +1,6 @@
From a215c906c3b8e890e63c7bbb927d24d3c66c20d9 Mon Sep 17 00:00:00 2001
From 573cac720de62e5200387ceb3179cbf4d18e2b9b Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:49:25 +0200
Date: Fri, 26 Jul 2019 04:12:45 +0200
Subject: [PATCH 11/12] surface-lte
---

View file

@ -1,6 +1,6 @@
From dac7fb27a0b091c5a2c6f53b4139803bb97d3dd4 Mon Sep 17 00:00:00 2001
From 832a72c7ea89dbe9593fc2f2f55e377b168f9d9f Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 20 Jul 2019 23:50:00 +0200
Date: Fri, 26 Jul 2019 04:12:57 +0200
Subject: [PATCH 12/12] surfacebook2-dgpu
---