Update button patches (v3)

This commit is contained in:
qzed 2019-07-21 00:01:46 +02:00
parent 49e4051332
commit be234ec92c
24 changed files with 168 additions and 132 deletions

View file

@ -1,6 +1,6 @@
From e9f55e5da497d27e0908cbffd3ecd0e8f1369ddb Mon Sep 17 00:00:00 2001
From d4ee8b0835a004e816e1aeb3a5d7c47bf9c9a77a Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:43:58 +0200
Date: Sat, 20 Jul 2019 23:55:58 +0200
Subject: [PATCH 01/12] surface-acpi
---

View file

@ -1,6 +1,6 @@
From e851005607738247775e43e9ac4336edd4c09516 Mon Sep 17 00:00:00 2001
From 39ac44640326e0509f04e627a84f24b15463c2ba Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:45:42 +0200
Date: Sat, 20 Jul 2019 23:56:21 +0200
Subject: [PATCH 02/12] suspend
---

View file

@ -1,15 +1,34 @@
From 65be92a4e7a1373a08dc1d75892dc6cafef830d0 Mon Sep 17 00:00:00 2001
From 6da968469522a258e270802d28b9d5c3f39f6c9d Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:49:56 +0200
Date: Sat, 20 Jul 2019 23:56:55 +0200
Subject: [PATCH 03/12] buttons
---
drivers/input/misc/soc_button_array.c | 151 ++++++++++++++++++++--
drivers/platform/x86/surfacepro3_button.c | 38 ++++++
2 files changed, 176 insertions(+), 13 deletions(-)
drivers/input/misc/Kconfig | 6 +-
drivers/input/misc/soc_button_array.c | 141 ++++++++++++++++++++--
drivers/platform/x86/surfacepro3_button.c | 47 ++++++++
3 files changed, 178 insertions(+), 16 deletions(-)
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index ca59a2be9bc5..ea69610370e8 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -781,10 +781,10 @@ config INPUT_IDEAPAD_SLIDEBAR
config INPUT_SOC_BUTTON_ARRAY
tristate "Windows-compatible SoC Button Array"
- depends on KEYBOARD_GPIO
+ depends on KEYBOARD_GPIO && ACPI
help
- Say Y here if you have a SoC-based tablet that originally
- runs Windows 8.
+ Say Y here if you have a SoC-based tablet that originally runs
+ Windows 8 or a Microsoft Surface Book 2, Pro 5, Laptop 1 or later.
To compile this driver as a module, choose M here: the
module will be called soc_button_array.
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index 55cd6e0b409c..171d8a5c8bfd 100644
index 55cd6e0b409c..8c94acbbf574 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -29,6 +29,17 @@ struct soc_button_info {
@ -30,21 +49,22 @@ index 55cd6e0b409c..171d8a5c8bfd 100644
/*
* Some of the buttons like volume up/down are auto repeat, while others
* are not. To support both, we register two platform devices, and put
@@ -91,8 +102,12 @@ soc_button_device_create(struct platform_device *pdev,
@@ -91,8 +102,13 @@ soc_button_device_create(struct platform_device *pdev,
continue;
gpio = soc_button_lookup_gpio(&pdev->dev, info->acpi_index);
- if (!gpio_is_valid(gpio))
+ if (gpio == -EPROBE_DEFER) {
+ error = -EPROBE_DEFER;
+ if (gpio < 0 && gpio != -ENOENT) {
+ error = gpio;
+ goto err_free_mem;
+ } else if (!gpio_is_valid(gpio)) {
+ /* Skip GPIO if not present */
continue;
+ }
gpio_keys[n_buttons].type = info->event_type;
gpio_keys[n_buttons].code = info->event_code;
@@ -310,6 +325,7 @@ static int soc_button_probe(struct platform_device *pdev)
@@ -310,6 +326,7 @@ static int soc_button_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct acpi_device_id *id;
@ -52,7 +72,7 @@ index 55cd6e0b409c..171d8a5c8bfd 100644
struct soc_button_info *button_info;
struct soc_button_data *priv;
struct platform_device *pd;
@@ -320,18 +336,20 @@ static int soc_button_probe(struct platform_device *pdev)
@@ -320,18 +337,20 @@ static int soc_button_probe(struct platform_device *pdev)
if (!id)
return -ENODEV;
@ -82,7 +102,7 @@ index 55cd6e0b409c..171d8a5c8bfd 100644
}
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -357,12 +375,32 @@ static int soc_button_probe(struct platform_device *pdev)
@@ -357,12 +376,32 @@ static int soc_button_probe(struct platform_device *pdev)
if (!priv->children[0] && !priv->children[1])
return -ENODEV;
@ -116,7 +136,7 @@ index 55cd6e0b409c..171d8a5c8bfd 100644
/*
* Definition of buttons on the tablet. The ACPI index of each button
* is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC
@@ -377,9 +415,96 @@ static struct soc_button_info soc_button_PNP0C40[] = {
@@ -377,9 +416,85 @@ static struct soc_button_info soc_button_PNP0C40[] = {
{ }
};
@ -140,13 +160,11 @@ index 55cd6e0b409c..171d8a5c8bfd 100644
+ GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65,
+ 0x49, 0x80, 0x35);
+
+#ifdef CONFIG_ACPI
+
+static int soc_device_check_MSHW0040(struct device *dev)
+{
+ acpi_handle handle = ACPI_HANDLE(dev);
+ union acpi_object *result;
+ u64 oem_platform_rev = 0;
+ u64 oem_platform_rev = 0; // valid revisions are nonzero
+ int gpios;
+
+ // get OEM platform revision
@ -160,32 +178,23 @@ index 55cd6e0b409c..171d8a5c8bfd 100644
+ ACPI_FREE(result);
+ }
+
+ /*
+ * If the revision is zero here, the _DSM evaluation has failed. This
+ * indicates that we have a Pro 4 or Book 1 and this driver should not
+ * be used.
+ */
+ if (oem_platform_rev == 0)
+ return -ENODEV;
+
+ dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev);
+
+ /*
+ * We are _really_ expecting GPIOs here. If we do not get any, this
+ * means the GPIO driver has not been loaded yet (which can happen).
+ * Try again later.
+ */
+ gpios = gpiod_count(dev, NULL);
+ if (gpios < 0)
+ return -EPROBE_DEFER;
+ return -ENODEV;
+
+ return 0;
+}
+
+#else /* CONFIG_ACPI */
+
+static int soc_device_check_MSHW0040(struct device *dev)
+{
+ return -ENODEV;
+}
+
+#endif /* CONFIG_ACPI */
+
+/*
+ * Button infos for Microsoft Surface Book 2 and Surface Pro (2017).
+ * Obtained from DSDT/testing.
@ -216,7 +225,7 @@ index 55cd6e0b409c..171d8a5c8bfd 100644
};
diff --git a/drivers/platform/x86/surfacepro3_button.c b/drivers/platform/x86/surfacepro3_button.c
index 1b491690ce07..eaec30380b11 100644
index 1b491690ce07..96627627060e 100644
--- a/drivers/platform/x86/surfacepro3_button.c
+++ b/drivers/platform/x86/surfacepro3_button.c
@@ -24,6 +24,12 @@
@ -232,7 +241,7 @@ index 1b491690ce07..eaec30380b11 100644
#define SURFACE_BUTTON_NOTIFY_TABLET_MODE 0xc8
#define SURFACE_BUTTON_NOTIFY_PRESS_POWER 0xc6
@@ -146,6 +152,34 @@ static int surface_button_resume(struct device *dev)
@@ -146,6 +152,44 @@ static int surface_button_resume(struct device *dev)
}
#endif
@ -240,12 +249,15 @@ index 1b491690ce07..eaec30380b11 100644
+ * Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device
+ * ID (MSHW0040) for the power/volume buttons. Make sure this is the right
+ * device by checking for the _DSM method and OEM Platform Revision.
+ *
+ * Returns true if the driver should bind to this device, i.e. the device is
+ * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1.
+ */
+static int surface_button_check_MSHW0040(struct acpi_device *dev)
+static bool surface_button_check_MSHW0040(struct acpi_device *dev)
+{
+ acpi_handle handle = dev->handle;
+ union acpi_object *result;
+ u64 oem_platform_rev = 0;
+ u64 oem_platform_rev = 0; // valid revisions are nonzero
+
+ // get OEM platform revision
+ result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
@ -253,6 +265,13 @@ index 1b491690ce07..eaec30380b11 100644
+ MSHW0040_DSM_GET_OMPR,
+ NULL, ACPI_TYPE_INTEGER);
+
+ /*
+ * If evaluating the _DSM fails, the method is not present. This means
+ * that we have either MSHW0028 or MSHW0040 on Pro 4 or Book 1, so we
+ * should use this driver. We use revision 0 indicating it is
+ * unavailable.
+ */
+
+ if (result) {
+ oem_platform_rev = result->integer.value;
+ ACPI_FREE(result);
@ -260,20 +279,19 @@ index 1b491690ce07..eaec30380b11 100644
+
+ dev_dbg(&dev->dev, "OEM Platform Revision %llu\n", oem_platform_rev);
+
+ return oem_platform_rev == 0 ? 0 : -ENODEV;
+ return oem_platform_rev == 0;
+}
+
+
static int surface_button_add(struct acpi_device *device)
{
struct surface_button *button;
@@ -158,6 +192,10 @@ static int surface_button_add(struct acpi_device *device)
@@ -158,6 +202,9 @@ static int surface_button_add(struct acpi_device *device)
strlen(SURFACE_BUTTON_OBJ_NAME)))
return -ENODEV;
+ error = surface_button_check_MSHW0040(device);
+ if (error)
+ return error;
+ if (!surface_button_check_MSHW0040(device))
+ return -ENODEV;
+
button = kzalloc(sizeof(struct surface_button), GFP_KERNEL);
if (!button)

View file

@ -1,6 +1,6 @@
From fe4fe38ef47eddda5f5775bc86931970b99136f7 Mon Sep 17 00:00:00 2001
From e0eef24214cefb6fe6a502887b8d5fabc601b7e4 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:50:29 +0200
Date: Sat, 20 Jul 2019 23:57:09 +0200
Subject: [PATCH 04/12] cameras
---

View file

@ -1,6 +1,6 @@
From 9cd9e021158ba8b9f3fc9c52053f33178d36f400 Mon Sep 17 00:00:00 2001
From c0f8399678ef91ad241333dcc4d67ef906423240 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:50:47 +0200
Date: Sat, 20 Jul 2019 23:57:18 +0200
Subject: [PATCH 05/12] ipts
---

View file

@ -1,6 +1,6 @@
From de20ba5257222ac2d4789cafb9801f4849c8a913 Mon Sep 17 00:00:00 2001
From 05bb46599d34f54fe48fa37503714e015008b5c8 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:51:26 +0200
Date: Sat, 20 Jul 2019 23:57:29 +0200
Subject: [PATCH 06/12] hid
---
@ -11,7 +11,7 @@ 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 97d33b8ed36c..bd7066157b00 100644
index 92452992b368..3cb0f41a64eb 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -801,11 +801,22 @@
@ -125,7 +125,7 @@ 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 e24790c988c0..70f75d60c8c9 100644
index 5892f1bd037e..f297f3f6c3b3 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[] = {

View file

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

View file

@ -1,6 +1,6 @@
From 614cf75ca3c727dbabfab49cdb471e0633110ce3 Mon Sep 17 00:00:00 2001
From 0692dd2c418ca3759659c7a78fb7b2e67aa3a044 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:52:12 +0200
Date: Sat, 20 Jul 2019 23:57:58 +0200
Subject: [PATCH 08/12] wifi
---
@ -85,7 +85,7 @@ index 60db2b969e20..efae99018c3c 100644
api_rev->major_ver;
mwifiex_dbg(adapter, INFO,
diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
index b73f99dc5a72..d96a0ffc9649 100644
index 1fb76d2f5d3f..fb32379da99d 100644
--- a/drivers/net/wireless/marvell/mwifiex/fw.h
+++ b/drivers/net/wireless/marvell/mwifiex/fw.h
@@ -1052,6 +1052,7 @@ struct host_cmd_ds_802_11_ps_mode_enh {

View file

@ -1,6 +1,6 @@
From a3e7b6ab8e6353069d520f29aae5e550863d94fb Mon Sep 17 00:00:00 2001
From 3e219f8272fdfba67461c37247ab3702aae18774 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:52:29 +0200
Date: Sat, 20 Jul 2019 23:58:10 +0200
Subject: [PATCH 09/12] surface3-power
---

View file

@ -1,6 +1,6 @@
From c52333794334d2f60f544af7b27dedc2c0bf017d Mon Sep 17 00:00:00 2001
From 7f4c61ccf081fff8aeff24486c9ba5b08cc8f666 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:52:52 +0200
Date: Sat, 20 Jul 2019 23:58:25 +0200
Subject: [PATCH 10/12] mwlwifi
---

View file

@ -1,6 +1,6 @@
From 0b925c6364aa6a504d590079c4be6ef15928d8cc Mon Sep 17 00:00:00 2001
From 35fe2bb16732f1f9746a57daf6163697f0f01f43 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:53:15 +0200
Date: Sat, 20 Jul 2019 23:58:37 +0200
Subject: [PATCH 11/12] surface-lte
---

View file

@ -1,6 +1,6 @@
From b7412c8ac85479f185e0301bedb47542aa6ade1c Mon Sep 17 00:00:00 2001
From 71ef466ae973e848ac700822c77e345da4844e00 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Tue, 2 Jul 2019 23:58:22 +0200
Date: Sat, 20 Jul 2019 23:58:49 +0200
Subject: [PATCH 12/12] surfacebook2-dgpu
---

View file

@ -1,6 +1,6 @@
From d4d2fa3647f86b84ed6d38c8180cb020eb88627d Mon Sep 17 00:00:00 2001
From fd502fa44599448603c5e1c28bedef1315c4514a Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:22:49 +0200
Date: Sat, 20 Jul 2019 23:45:52 +0200
Subject: [PATCH 01/12] surface-acpi
---

View file

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

View file

@ -1,15 +1,34 @@
From 72bd00dbd59591de9cbcb05ecabf2eaefaec6787 Mon Sep 17 00:00:00 2001
From 2c5ccf4ac52c3b6c02df5d8dab9c0471d163a073 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:25:27 +0200
Date: Sat, 20 Jul 2019 23:46:56 +0200
Subject: [PATCH 03/12] buttons
---
drivers/input/misc/soc_button_array.c | 151 ++++++++++++++++++++--
drivers/platform/x86/surfacepro3_button.c | 38 ++++++
2 files changed, 176 insertions(+), 13 deletions(-)
drivers/input/misc/Kconfig | 6 +-
drivers/input/misc/soc_button_array.c | 141 ++++++++++++++++++++--
drivers/platform/x86/surfacepro3_button.c | 47 ++++++++
3 files changed, 178 insertions(+), 16 deletions(-)
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index e15ed1bb8558..d88951da5e81 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -791,10 +791,10 @@ config INPUT_IDEAPAD_SLIDEBAR
config INPUT_SOC_BUTTON_ARRAY
tristate "Windows-compatible SoC Button Array"
- depends on KEYBOARD_GPIO
+ depends on KEYBOARD_GPIO && ACPI
help
- Say Y here if you have a SoC-based tablet that originally
- runs Windows 8.
+ Say Y here if you have a SoC-based tablet that originally runs
+ Windows 8 or a Microsoft Surface Book 2, Pro 5, Laptop 1 or later.
To compile this driver as a module, choose M here: the
module will be called soc_button_array.
diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
index bb458beecb43..0cd942781bac 100644
index bb458beecb43..bfce5061dede 100644
--- a/drivers/input/misc/soc_button_array.c
+++ b/drivers/input/misc/soc_button_array.c
@@ -29,6 +29,17 @@ struct soc_button_info {
@ -30,21 +49,22 @@ index bb458beecb43..0cd942781bac 100644
/*
* Some of the buttons like volume up/down are auto repeat, while others
* are not. To support both, we register two platform devices, and put
@@ -91,8 +102,12 @@ soc_button_device_create(struct platform_device *pdev,
@@ -91,8 +102,13 @@ soc_button_device_create(struct platform_device *pdev,
continue;
gpio = soc_button_lookup_gpio(&pdev->dev, info->acpi_index);
- if (!gpio_is_valid(gpio))
+ if (gpio == -EPROBE_DEFER) {
+ error = -EPROBE_DEFER;
+ if (gpio < 0 && gpio != -ENOENT) {
+ error = gpio;
+ goto err_free_mem;
+ } else if (!gpio_is_valid(gpio)) {
+ /* Skip GPIO if not present */
continue;
+ }
gpio_keys[n_buttons].type = info->event_type;
gpio_keys[n_buttons].code = info->event_code;
@@ -314,6 +329,7 @@ static int soc_button_probe(struct platform_device *pdev)
@@ -314,6 +330,7 @@ static int soc_button_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct acpi_device_id *id;
@ -52,7 +72,7 @@ index bb458beecb43..0cd942781bac 100644
struct soc_button_info *button_info;
struct soc_button_data *priv;
struct platform_device *pd;
@@ -324,18 +340,20 @@ static int soc_button_probe(struct platform_device *pdev)
@@ -324,18 +341,20 @@ static int soc_button_probe(struct platform_device *pdev)
if (!id)
return -ENODEV;
@ -82,7 +102,7 @@ index bb458beecb43..0cd942781bac 100644
}
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -361,12 +379,32 @@ static int soc_button_probe(struct platform_device *pdev)
@@ -361,12 +380,32 @@ static int soc_button_probe(struct platform_device *pdev)
if (!priv->children[0] && !priv->children[1])
return -ENODEV;
@ -116,7 +136,7 @@ index bb458beecb43..0cd942781bac 100644
/*
* Definition of buttons on the tablet. The ACPI index of each button
* is defined in section 2.8.7.2 of "Windows ACPI Design Guide for SoC
@@ -381,9 +419,96 @@ static struct soc_button_info soc_button_PNP0C40[] = {
@@ -381,9 +420,85 @@ static struct soc_button_info soc_button_PNP0C40[] = {
{ }
};
@ -140,13 +160,11 @@ index bb458beecb43..0cd942781bac 100644
+ GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4, 0x95, 0xed, 0xab, 0x16, 0x65,
+ 0x49, 0x80, 0x35);
+
+#ifdef CONFIG_ACPI
+
+static int soc_device_check_MSHW0040(struct device *dev)
+{
+ acpi_handle handle = ACPI_HANDLE(dev);
+ union acpi_object *result;
+ u64 oem_platform_rev = 0;
+ u64 oem_platform_rev = 0; // valid revisions are nonzero
+ int gpios;
+
+ // get OEM platform revision
@ -160,32 +178,23 @@ index bb458beecb43..0cd942781bac 100644
+ ACPI_FREE(result);
+ }
+
+ /*
+ * If the revision is zero here, the _DSM evaluation has failed. This
+ * indicates that we have a Pro 4 or Book 1 and this driver should not
+ * be used.
+ */
+ if (oem_platform_rev == 0)
+ return -ENODEV;
+
+ dev_dbg(dev, "OEM Platform Revision %llu\n", oem_platform_rev);
+
+ /*
+ * We are _really_ expecting GPIOs here. If we do not get any, this
+ * means the GPIO driver has not been loaded yet (which can happen).
+ * Try again later.
+ */
+ gpios = gpiod_count(dev, NULL);
+ if (gpios < 0)
+ return -EPROBE_DEFER;
+ return -ENODEV;
+
+ return 0;
+}
+
+#else /* CONFIG_ACPI */
+
+static int soc_device_check_MSHW0040(struct device *dev)
+{
+ return -ENODEV;
+}
+
+#endif /* CONFIG_ACPI */
+
+/*
+ * Button infos for Microsoft Surface Book 2 and Surface Pro (2017).
+ * Obtained from DSDT/testing.
@ -216,7 +225,7 @@ index bb458beecb43..0cd942781bac 100644
};
diff --git a/drivers/platform/x86/surfacepro3_button.c b/drivers/platform/x86/surfacepro3_button.c
index 1b491690ce07..eaec30380b11 100644
index 1b491690ce07..96627627060e 100644
--- a/drivers/platform/x86/surfacepro3_button.c
+++ b/drivers/platform/x86/surfacepro3_button.c
@@ -24,6 +24,12 @@
@ -232,7 +241,7 @@ index 1b491690ce07..eaec30380b11 100644
#define SURFACE_BUTTON_NOTIFY_TABLET_MODE 0xc8
#define SURFACE_BUTTON_NOTIFY_PRESS_POWER 0xc6
@@ -146,6 +152,34 @@ static int surface_button_resume(struct device *dev)
@@ -146,6 +152,44 @@ static int surface_button_resume(struct device *dev)
}
#endif
@ -240,12 +249,15 @@ index 1b491690ce07..eaec30380b11 100644
+ * Surface Pro 4 and Surface Book 2 / Surface Pro 2017 use the same device
+ * ID (MSHW0040) for the power/volume buttons. Make sure this is the right
+ * device by checking for the _DSM method and OEM Platform Revision.
+ *
+ * Returns true if the driver should bind to this device, i.e. the device is
+ * either MSWH0028 (Pro 3) or MSHW0040 on a Pro 4 or Book 1.
+ */
+static int surface_button_check_MSHW0040(struct acpi_device *dev)
+static bool surface_button_check_MSHW0040(struct acpi_device *dev)
+{
+ acpi_handle handle = dev->handle;
+ union acpi_object *result;
+ u64 oem_platform_rev = 0;
+ u64 oem_platform_rev = 0; // valid revisions are nonzero
+
+ // get OEM platform revision
+ result = acpi_evaluate_dsm_typed(handle, &MSHW0040_DSM_UUID,
@ -253,6 +265,13 @@ index 1b491690ce07..eaec30380b11 100644
+ MSHW0040_DSM_GET_OMPR,
+ NULL, ACPI_TYPE_INTEGER);
+
+ /*
+ * If evaluating the _DSM fails, the method is not present. This means
+ * that we have either MSHW0028 or MSHW0040 on Pro 4 or Book 1, so we
+ * should use this driver. We use revision 0 indicating it is
+ * unavailable.
+ */
+
+ if (result) {
+ oem_platform_rev = result->integer.value;
+ ACPI_FREE(result);
@ -260,20 +279,19 @@ index 1b491690ce07..eaec30380b11 100644
+
+ dev_dbg(&dev->dev, "OEM Platform Revision %llu\n", oem_platform_rev);
+
+ return oem_platform_rev == 0 ? 0 : -ENODEV;
+ return oem_platform_rev == 0;
+}
+
+
static int surface_button_add(struct acpi_device *device)
{
struct surface_button *button;
@@ -158,6 +192,10 @@ static int surface_button_add(struct acpi_device *device)
@@ -158,6 +202,9 @@ static int surface_button_add(struct acpi_device *device)
strlen(SURFACE_BUTTON_OBJ_NAME)))
return -ENODEV;
+ error = surface_button_check_MSHW0040(device);
+ if (error)
+ return error;
+ if (!surface_button_check_MSHW0040(device))
+ return -ENODEV;
+
button = kzalloc(sizeof(struct surface_button), GFP_KERNEL);
if (!button)

View file

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

View file

@ -1,6 +1,6 @@
From 9ef92ec7722844fad196f74cfb1d5474af2c0130 Mon Sep 17 00:00:00 2001
From 12534568128b4f5492d3b5f0cb5eec22fe25c18c Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:28:10 +0200
Date: Sat, 20 Jul 2019 23:47:48 +0200
Subject: [PATCH 05/12] ipts
---
@ -136,10 +136,10 @@ index 9df65d386d11..40f24ebf88ba 100644
}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a67a63b5aa84..dcb51f687a44 100644
index 0c4a76bca5c6..fada1122556a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3115,6 +3115,9 @@ void i915_gem_object_do_bit_17_swizzle(struct drm_i915_gem_object *obj,
@@ -3119,6 +3119,9 @@ void i915_gem_object_do_bit_17_swizzle(struct drm_i915_gem_object *obj,
void i915_gem_object_save_bit_17_swizzle(struct drm_i915_gem_object *obj,
struct sg_table *pages);

View file

@ -1,6 +1,6 @@
From ee74de82a113853b7ab8b24fc53df2f27ac77821 Mon Sep 17 00:00:00 2001
From da7dcf5f3b4a5338197cef00d38c5dbe9dbe78be Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:28:41 +0200
Date: Sat, 20 Jul 2019 23:48:00 +0200
Subject: [PATCH 06/12] hid
---
@ -11,7 +11,7 @@ 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 adce58f24f76..5cc94abc677e 100644
index 6537086fb145..9dae634a6299 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -816,11 +816,22 @@
@ -125,7 +125,7 @@ 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 77ffba48cc73..517143d5b305 100644
index 189bf68eb35c..3c235fb31c47 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[] = {

View file

@ -1,6 +1,6 @@
From 125a9473c2c9fa07d1c20960543115193a61c9a2 Mon Sep 17 00:00:00 2001
From d82fac219403ae1fae5bc82ea31de4a0cb3fca85 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:29:19 +0200
Date: Sat, 20 Jul 2019 23:48:18 +0200
Subject: [PATCH 07/12] sdcard-reader
---

View file

@ -1,6 +1,6 @@
From ca8db7e884bbf493fb2fc6842a1b5981830d6f19 Mon Sep 17 00:00:00 2001
From 82439e5450aba5020207f96aed47523930ff99e4 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:30:18 +0200
Date: Sat, 20 Jul 2019 23:48:29 +0200
Subject: [PATCH 08/12] wifi
---
@ -85,7 +85,7 @@ index 60db2b969e20..efae99018c3c 100644
api_rev->major_ver;
mwifiex_dbg(adapter, INFO,
diff --git a/drivers/net/wireless/marvell/mwifiex/fw.h b/drivers/net/wireless/marvell/mwifiex/fw.h
index b73f99dc5a72..d96a0ffc9649 100644
index 1fb76d2f5d3f..fb32379da99d 100644
--- a/drivers/net/wireless/marvell/mwifiex/fw.h
+++ b/drivers/net/wireless/marvell/mwifiex/fw.h
@@ -1052,6 +1052,7 @@ struct host_cmd_ds_802_11_ps_mode_enh {

View file

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

View file

@ -1,6 +1,6 @@
From 84bd1e431a109f5edc42b1efd426ce5db251e1a1 Mon Sep 17 00:00:00 2001
From e496b127b72277bf2b6526a07aebc4de8f231a56 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:31:18 +0200
Date: Sat, 20 Jul 2019 23:49:10 +0200
Subject: [PATCH 10/12] mwlwifi
---

View file

@ -1,6 +1,6 @@
From 085e04dce01293f41ec1f48b4212d23a827ada14 Mon Sep 17 00:00:00 2001
From a215c906c3b8e890e63c7bbb927d24d3c66c20d9 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:32:00 +0200
Date: Sat, 20 Jul 2019 23:49:25 +0200
Subject: [PATCH 11/12] surface-lte
---

View file

@ -1,6 +1,6 @@
From ff7a7f5931f8f0aae029daa36209686818aafbe1 Mon Sep 17 00:00:00 2001
From dac7fb27a0b091c5a2c6f53b4139803bb97d3dd4 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Wed, 3 Jul 2019 00:35:24 +0200
Date: Sat, 20 Jul 2019 23:50:00 +0200
Subject: [PATCH 12/12] surfacebook2-dgpu
---