Update v4.19 patches

Changes:
  SAM:
  - Move lid/GPE workaround into separate independent module.
  - A bus and device type has been implemented for SAM devices.
  - Detach devices attached to the base when the cliboard is being
    detached on the Surface Book 3.
  - Internal restructuring.

Links:
- kernel: 2926c01232
- SAM: 08bbb7272a
This commit is contained in:
Maximilian Luz 2020-08-18 06:01:34 +02:00
parent 45baf0b1a0
commit 5507e69098
No known key found for this signature in database
GPG key ID: 70EC0937F6C26F02
23 changed files with 6785 additions and 5469 deletions

View file

@ -12,15 +12,14 @@ CONFIG_SURFACE_SAM=m
CONFIG_SURFACE_SAM_SSH=m
CONFIG_SURFACE_SAM_SSH_ERROR_INJECTION=n
CONFIG_SURFACE_SAM_DEBUGFS=m
CONFIG_SURFACE_SAM_DEVICE_HUB=m
CONFIG_SURFACE_SAM_SAN=m
CONFIG_SURFACE_SAM_VHF=m
CONFIG_SURFACE_SAM_KBD=m
CONFIG_SURFACE_SAM_DTX=m
CONFIG_SURFACE_SAM_HPS=m
CONFIG_SURFACE_SAM_SID=m
CONFIG_SURFACE_SAM_SID_GPELID=m
CONFIG_SURFACE_SAM_SID_PERFMODE=m
CONFIG_SURFACE_SAM_SID_VHF=m
CONFIG_SURFACE_SAM_SID_POWER=m
CONFIG_SURFACE_SAM_PERFMODE=m
CONFIG_SURFACE_SAM_HID=m
CONFIG_SURFACE_SAM_PSY=m
#
# Other Drivers
@ -29,3 +28,4 @@ CONFIG_INPUT_SOC_BUTTON_ARRAY=m
CONFIG_SURFACE_3_BUTTON=m
CONFIG_SURFACE_3_POWER_OPREGION=m
CONFIG_SURFACE_PRO3_BUTTON=m
CONFIG_SURFACE_GPE=m

View file

@ -1,7 +1,7 @@
From 7758260ca65d048fc048997fde2b2835aeb56bf2 Mon Sep 17 00:00:00 2001
From 642ccc9a85515f6330b90ec2e8024af737b165ab Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 28 Sep 2019 18:00:43 +0200
Subject: [PATCH 1/9] surface3-power
Subject: [PATCH 01/10] surface3-power
---
drivers/platform/x86/Kconfig | 7 +

View file

@ -1,7 +1,7 @@
From 4ddb434540558cdfbf4c6a7302e5cf96a1cf016c Mon Sep 17 00:00:00 2001
From ace1524a2a614b411772973a07a0f9894db71527 Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Date: Sun, 5 Jul 2020 14:56:20 +0300
Subject: [PATCH 2/9] surface3-touchscreen-dma-fix
Subject: [PATCH 02/10] surface3-touchscreen-dma-fix
---
drivers/dma/dw/core.c | 12 ------------

View file

@ -1,7 +1,7 @@
From 319a7962c8241d6d42765f31f932e3e71502e642 Mon Sep 17 00:00:00 2001
From 3e7fd7e46281ea36ec0b3f7f75e32ba0dc4a2b41 Mon Sep 17 00:00:00 2001
From: Chih-Wei Huang <cwhuang@linux.org.tw>
Date: Tue, 18 Sep 2018 11:01:37 +0800
Subject: [PATCH 3/9] surface3-oemb
Subject: [PATCH 03/10] surface3-oemb
---
drivers/platform/x86/surface3-wmi.c | 7 +++++++

View file

@ -1,7 +1,7 @@
From 56a637b630a48dc4483c1d6e9dfbf09b324abb1b Mon Sep 17 00:00:00 2001
From 44ae2b5f2dec6f2bca7381728a0ebfde27efad17 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 27 Jul 2019 17:51:37 +0200
Subject: [PATCH 4/9] surface-buttons
Subject: [PATCH 04/10] surface-buttons
---
drivers/input/misc/Kconfig | 6 +-

View file

@ -1,7 +1,7 @@
From b6a4004590ccd476e3880c03d8e9fb4b80a54eba Mon Sep 17 00:00:00 2001
From f8393b3a5b16f19cc9af9bc171f65187a9a2c54e Mon Sep 17 00:00:00 2001
From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com>
Date: Sat, 28 Sep 2019 17:48:21 +0200
Subject: [PATCH 7/9] suspend
Subject: [PATCH 05/10] suspend
---
drivers/nvme/host/core.c | 36 ++++++++++++--

View file

@ -1,7 +1,7 @@
From bfa54c16d6e9e112be44081b80d422100b839ead Mon Sep 17 00:00:00 2001
From a330d174c772715c1f6979cc9e8ec8268d1b85e2 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 28 Sep 2019 17:58:17 +0200
Subject: [PATCH 8/9] ipts
Subject: [PATCH 06/10] ipts
---
drivers/gpu/drm/i915/Makefile | 3 +

View file

@ -1,7 +1,7 @@
From a2cac7e8bbc67148a6480cde4ccb9bd455e5892e Mon Sep 17 00:00:00 2001
From d37d94b2f9fbd5ca3529b3b8590a212a3a1a2dd7 Mon Sep 17 00:00:00 2001
From: kitakar5525 <34676735+kitakar5525@users.noreply.github.com>
Date: Thu, 20 Feb 2020 16:51:11 +0900
Subject: [PATCH 9/9] wifi
Subject: [PATCH 07/10] wifi
---
.../net/wireless/marvell/mwifiex/cfg80211.c | 26 ++++++

View file

@ -1,7 +1,7 @@
From dff041886f4e1e942fcabb40a2fc1a6e9556374f Mon Sep 17 00:00:00 2001
From 6ee10706e5bf1737d7757a14f3ed97fab6fa269c Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 25 Jul 2020 17:19:53 +0200
Subject: [PATCH 6/9] surface-sam-over-hid
Subject: [PATCH 09/10] surface-sam-over-hid
---
drivers/i2c/i2c-core-acpi.c | 35 +++++++++++++++++++++++++++++++++++

View file

@ -0,0 +1,355 @@
From 77983168ece982bcb6aa6940d778f408d0005b6c Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sun, 16 Aug 2020 23:39:56 +0200
Subject: [PATCH 10/10] surface-gpe
---
drivers/platform/x86/Kconfig | 9 +
drivers/platform/x86/Makefile | 1 +
drivers/platform/x86/surface_gpe.c | 302 +++++++++++++++++++++++++++++
3 files changed, 312 insertions(+)
create mode 100644 drivers/platform/x86/surface_gpe.c
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 2ad19dc64a4af..a95121eae8965 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1167,6 +1167,15 @@ config SURFACE_3_POWER_OPREGION
Select this option to enable support for ACPI operation
region of the Surface 3 battery platform driver.
+config SURFACE_GPE
+ tristate "Surface GPE/Lid Driver"
+ depends on ACPI
+ help
+ This driver marks the GPEs related to the ACPI lid device found on
+ Microsoft Surface devices as wakeup sources and prepares them
+ accordingly. It is required on those devices to allow wake-ups from
+ suspend by opening the lid.
+
config INTEL_PUNIT_IPC
tristate "Intel P-Unit IPC Driver"
---help---
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 2ea90039a3e49..49238e9d4abf6 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -82,6 +82,7 @@ obj-$(CONFIG_TOUCHSCREEN_DMI) += touchscreen_dmi.o
obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o
obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o
obj-$(CONFIG_SURFACE_3_POWER_OPREGION) += surface3_power.o
+obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o
obj-$(CONFIG_INTEL_PUNIT_IPC) += intel_punit_ipc.o
obj-$(CONFIG_INTEL_BXTWC_PMIC_TMU) += intel_bxtwc_tmu.o
obj-$(CONFIG_INTEL_TELEMETRY) += intel_telemetry_core.o \
diff --git a/drivers/platform/x86/surface_gpe.c b/drivers/platform/x86/surface_gpe.c
new file mode 100644
index 0000000000000..fee4cde12f05e
--- /dev/null
+++ b/drivers/platform/x86/surface_gpe.c
@@ -0,0 +1,302 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Pseudo device and driver to enable wakeup from suspend via the lid by
+ * properly configuring the respective GPEs on Microsoft Surface devices.
+ */
+
+#include <linux/acpi.h>
+#include <linux/dmi.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+
+struct surface_lid_device {
+ u32 gpe_number;
+};
+
+static const struct surface_lid_device lid_device_l17 = {
+ .gpe_number = 0x17,
+};
+
+static const struct surface_lid_device lid_device_l4D = {
+ .gpe_number = 0x4D,
+};
+
+static const struct surface_lid_device lid_device_l4F = {
+ .gpe_number = 0x4F,
+};
+
+static const struct surface_lid_device lid_device_l57 = {
+ .gpe_number = 0x57,
+};
+
+
+// Note: When changing this don't forget to change the MODULE_ALIAS below.
+static const struct dmi_system_id dmi_lid_device_table[] = {
+ {
+ .ident = "Surface Pro 4",
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 4"),
+ },
+ .driver_data = (void *)&lid_device_l17,
+ },
+ {
+ .ident = "Surface Pro 5",
+ .matches = {
+ /*
+ * We match for SKU here due to generic product name
+ * "Surface Pro".
+ */
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1796"),
+ },
+ .driver_data = (void *)&lid_device_l4F,
+ },
+ {
+ .ident = "Surface Pro 5 (LTE)",
+ .matches = {
+ /*
+ * We match for SKU here due to generic product name
+ * "Surface Pro"
+ */
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Pro_1807"),
+ },
+ .driver_data = (void *)&lid_device_l4F,
+ },
+ {
+ .ident = "Surface Pro 6",
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 6"),
+ },
+ .driver_data = (void *)&lid_device_l4F,
+ },
+ {
+ .ident = "Surface Pro 7",
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Pro 7"),
+ },
+ .driver_data = (void *)&lid_device_l4D,
+ },
+ {
+ .ident = "Surface Book 1",
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book"),
+ },
+ .driver_data = (void *)&lid_device_l17,
+ },
+ {
+ .ident = "Surface Book 2",
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book 2"),
+ },
+ .driver_data = (void *)&lid_device_l17,
+ },
+ {
+ .ident = "Surface Book 3",
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Book 3"),
+ },
+ .driver_data = (void *)&lid_device_l4D,
+ },
+ {
+ .ident = "Surface Laptop 1",
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop"),
+ },
+ .driver_data = (void *)&lid_device_l57,
+ },
+ {
+ .ident = "Surface Laptop 2",
+ .matches = {
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Surface Laptop 2"),
+ },
+ .driver_data = (void *)&lid_device_l57,
+ },
+ {
+ .ident = "Surface Laptop 3 (Intel 13\")",
+ .matches = {
+ /*
+ * We match for SKU here due to different vairants: The
+ * AMD (15") version does not rely on GPEs.
+ */
+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
+ DMI_EXACT_MATCH(DMI_PRODUCT_SKU, "Surface_Laptop_3_1867:1868"),
+ },
+ .driver_data = (void *)&lid_device_l4D,
+ },
+ { }
+};
+
+
+static int surface_lid_enable_wakeup(struct device *dev,
+ const struct surface_lid_device *lid,
+ bool enable)
+{
+ int action = enable ? ACPI_GPE_ENABLE : ACPI_GPE_DISABLE;
+ acpi_status status;
+
+ status = acpi_set_gpe_wake_mask(NULL, lid->gpe_number, action);
+ if (status) {
+ dev_err(dev, "failed to set GPE wake mask: %d\n", status);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+
+static int surface_gpe_suspend(struct device *dev)
+{
+ const struct surface_lid_device *lid;
+
+ lid = dev_get_platdata(dev);
+ return surface_lid_enable_wakeup(dev, lid, true);
+}
+
+static int surface_gpe_resume(struct device *dev)
+{
+ const struct surface_lid_device *lid;
+
+ lid = dev_get_platdata(dev);
+ return surface_lid_enable_wakeup(dev, lid, false);
+}
+
+static SIMPLE_DEV_PM_OPS(surface_gpe_pm, surface_gpe_suspend, surface_gpe_resume);
+
+
+static int surface_gpe_probe(struct platform_device *pdev)
+{
+ const struct surface_lid_device *lid;
+ int status;
+
+ lid = dev_get_platdata(&pdev->dev);
+ if (!lid)
+ return -ENODEV;
+
+ status = acpi_mark_gpe_for_wake(NULL, lid->gpe_number);
+ if (status) {
+ dev_err(&pdev->dev, "failed to mark GPE for wake: %d\n", status);
+ return -EINVAL;
+ }
+
+ status = acpi_enable_gpe(NULL, lid->gpe_number);
+ if (status) {
+ dev_err(&pdev->dev, "failed to enable GPE: %d\n", status);
+ return -EINVAL;
+ }
+
+ status = surface_lid_enable_wakeup(&pdev->dev, lid, false);
+ if (status) {
+ acpi_disable_gpe(NULL, lid->gpe_number);
+ return status;
+ }
+
+ return 0;
+}
+
+static int surface_gpe_remove(struct platform_device *pdev)
+{
+ struct surface_lid_device *lid = dev_get_platdata(&pdev->dev);
+
+ /* restore default behavior without this module */
+ surface_lid_enable_wakeup(&pdev->dev, lid, false);
+ acpi_disable_gpe(NULL, lid->gpe_number);
+
+ return 0;
+}
+
+static struct platform_driver surface_gpe_driver = {
+ .probe = surface_gpe_probe,
+ .remove = surface_gpe_remove,
+ .driver = {
+ .name = "surface_gpe",
+ .pm = &surface_gpe_pm,
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ },
+};
+
+
+static struct platform_device *surface_gpe_device;
+
+static int __init surface_gpe_init(void)
+{
+ const struct dmi_system_id *match;
+ const struct surface_lid_device *lid;
+
+ struct platform_device *pdev;
+ int status;
+
+ surface_gpe_device = NULL;
+
+ match = dmi_first_match(dmi_lid_device_table);
+ if (!match) {
+ pr_info(KBUILD_MODNAME": no device detected, exiting\n");
+ return 0;
+ }
+
+ lid = match->driver_data;
+
+ status = platform_driver_register(&surface_gpe_driver);
+ if (status)
+ return status;
+
+ pdev = platform_device_alloc("surface_gpe", PLATFORM_DEVID_NONE);
+ if (!pdev) {
+ platform_driver_unregister(&surface_gpe_driver);
+ return -ENOMEM;
+ }
+
+ status = platform_device_add_data(pdev, lid, sizeof(*lid));
+ if (status) {
+ platform_device_put(pdev);
+ platform_driver_unregister(&surface_gpe_driver);
+ return status;
+ }
+
+ status = platform_device_add(pdev);
+ if (status) {
+ platform_device_put(pdev);
+ platform_driver_unregister(&surface_gpe_driver);
+ return status;
+ }
+
+ surface_gpe_device = pdev;
+ return 0;
+}
+
+static void __exit surface_gpe_exit(void)
+{
+ if (!surface_gpe_device)
+ return;
+
+ platform_device_unregister(surface_gpe_device);
+ platform_driver_unregister(&surface_gpe_driver);
+}
+
+module_init(surface_gpe_init);
+module_exit(surface_gpe_exit);
+
+MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>");
+MODULE_DESCRIPTION("Surface GPE/Lid Driver");
+MODULE_LICENSE("GPL");
+
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfacePro:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfacePro4:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfacePro6:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfacePro7:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceBook:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceBook2:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceBook3:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceLaptop:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceLaptop2:*");
+MODULE_ALIAS("dmi:*:svnMicrosoftCorporation:pnSurfaceLaptop3:*");
--
2.28.0

View file

@ -1 +0,0 @@
../../../patches/4.19/0005-surface-sam.patch

View file

@ -0,0 +1 @@
../../../patches/4.19/0005-suspend.patch

View file

@ -0,0 +1 @@
../../../patches/4.19/0006-ipts.patch

View file

@ -1 +0,0 @@
../../../patches/4.19/0006-surface-sam-over-hid.patch

View file

@ -1 +0,0 @@
../../../patches/4.19/0007-suspend.patch

View file

@ -0,0 +1 @@
../../../patches/4.19/0007-wifi.patch

View file

@ -1 +0,0 @@
../../../patches/4.19/0008-ipts.patch

View file

@ -0,0 +1 @@
../../../patches/4.19/0008-surface-sam.patch

View file

@ -0,0 +1 @@
../../../patches/4.19/0009-surface-sam-over-hid.patch

View file

@ -1 +0,0 @@
../../../patches/4.19/0009-wifi.patch

View file

@ -0,0 +1 @@
../../../patches/4.19/0010-surface-gpe.patch

View file

@ -24,11 +24,12 @@ source=(
0002-surface3-touchscreen-dma-fix.patch
0003-surface3-oemb.patch
0004-surface-buttons.patch
0005-surface-sam.patch
0006-surface-sam-over-hid.patch
0007-suspend.patch
0008-ipts.patch
0009-wifi.patch
0005-suspend.patch
0006-ipts.patch
0007-wifi.patch
0008-surface-sam.patch
0009-surface-sam-over-hid.patch
0010-surface-gpe.patch
)
validpgpkeys=(
'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds
@ -39,16 +40,17 @@ sha256sums=('9c4ebf21fe949f80fbcfbbd6e7fe181040d325e89475e230ab53ef01f9d55605'
'SKIP'
'4e68572e7cc4c5368f0236e0792660ae8498373988625dca46e509399a7eaea6'
'a13581d3c6dc595206e4fe7fcf6b542e7a1bdbe96101f0f010fc5be49f99baf2'
'930997898a624430f476e9add2ae22a1953f30d28b0f88c92cedc49d522dd150'
'91ffa503907109951878e1ef58dd5ebe4deef7a75a3c4e06dbad747418869acb'
'02b670f7e2f1ab7ae00aebbc3569d7757a228fb662ae81203bacb1f704dd9c5a'
'38e4c43a780f62582340bfcd7a1e22558b5d98719e8463e35dec6571322fe51a'
'3dbcdc0cf83fbc1a97634ab736ddfc2518034758c2aed19ac406a3a1dee40377'
'6c521827ec9d6dcd89c895c1dc140457163347311adb4f441f62d6fb6ecaca26'
'bfbc9ce608433badd5b856f2941d4c71070bb8e01b97313091d4339766f0fa4c'
'a9d05b5564ada9305a87eabdc78b7d27d58d597481b49c98af93319bdc57f83e'
'56d31e9aa1425403c6c1cd7dc9a79d026c866bdd29effdb951bfaea91816386c'
'44c73f31333c98049f287a1949ce12d47d6d1810fca22b90aa3b5d21bfa648b6')
'c04b7652fbc7dbca65bfd64e7123adcb6da9dae0ab33d85be58907b5b9de1c66'
'fd7947445ac061cd6e1fe0f08ac544cb1f64acef373ebbafff8fc35e1e5fca2e'
'60fa93019ad2ad2a915d532761c0d496a991f133cd0dfac0e10933a06e804b1c'
'eb49152ccffac67adde2ccc3851754d5c0276657ba979d0cacd4ea47110dd473'
'60d09f7234cb4ed0d5dbdc9444c5815c459e2cd89926e95ffadef67369238614'
'49de4afebf12d41bc0a484ab3f4267041f6c6c4f62f1af7429e23acd2eb54d0f'
'6381243b6fe07dd45b14450d44041d6e962174e3bd32e726a34d0240064f60f8'
'e7088d9aace068df6d1cd5d77262cc5756c8bfea046c11b2acaba43b43b0baca'
'939fa0ead281a4ca23ac9c8d935c84e612fd96148a53d68a055d813eb0ea9550'
'639419729d561a5a1c792ad151830f256a0b9bdf284019ec2646748365e69096'
'1ad17b0a6dffe38d260dc0e46a3fc390f9ee019f4d59708e13732c3ee50e13f1')
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase