Update v5.8 patches

Changes:
- SAM:
  - Fix bug where second Surface Book 3 battery would be set up
    incorrectly.
  - Continued work on internal documentation and cleanup.
  - Other minor bugfixes.

- SAM-over-HID:
  - Add dGPU switch module for SB1.

- GPE:
  - Cleanup and formatting.

Links:
- SAM: c5f84f1f9a
- SAM-over-HID: 9d2a927ac8
- GPE: a9d97ed280
- kernel: 6f814d29c3
This commit is contained in:
Maximilian Luz 2020-09-08 16:37:03 +02:00
parent 6836b92298
commit b586e3bddb
No known key found for this signature in database
GPG key ID: 70EC0937F6C26F02
8 changed files with 3038 additions and 682 deletions

View file

@ -32,3 +32,4 @@ CONFIG_SURFACE_3_BUTTON=m
CONFIG_SURFACE_3_POWER_OPREGION=m
CONFIG_SURFACE_PRO3_BUTTON=m
CONFIG_SURFACE_GPE=m
CONFIG_SURFACE_BOOK1_DGPU_SWITCH=m

View file

@ -1,4 +1,4 @@
From e56ab1f796646568a6f183bc64cbbbe615e3ec3d Mon Sep 17 00:00:00 2001
From 7cd3be5c7f76a886083272c6dd562d7217dc0767 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 1/6] surface3-oemb

View file

@ -1,4 +1,4 @@
From 4e625be82e0c20fd760e84c51c90b12129178e39 Mon Sep 17 00:00:00 2001
From 2a3ed3370f323ca5026a37f9ad2dedb23fd378ca 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 2/6] wifi

View file

@ -1,4 +1,4 @@
From 617b52707ec79582c381c551cc77c53a3ee12c21 Mon Sep 17 00:00:00 2001
From ba612c1a501963c3b941275a4d5f2b3b215b8a5b Mon Sep 17 00:00:00 2001
From: Dorian Stoll <dorian.stoll@tmsp.io>
Date: Thu, 30 Jul 2020 13:21:53 +0200
Subject: [PATCH 3/6] ipts

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,15 @@
From 6e0b3fb32080f8059019df7ee0bc0aec064ae7e7 Mon Sep 17 00:00:00 2001
From 06d09ff5e8976c38cee7a3989461e5f0c6192a13 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 25 Jul 2020 17:19:53 +0200
Subject: [PATCH 5/6] surface-sam-over-hid
---
drivers/i2c/i2c-core-acpi.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
drivers/i2c/i2c-core-acpi.c | 35 +++++++
drivers/platform/x86/Kconfig | 7 ++
drivers/platform/x86/Makefile | 1 +
drivers/platform/x86/sb1_dgpu_sw.c | 162 +++++++++++++++++++++++++++++
4 files changed, 205 insertions(+)
create mode 100644 drivers/platform/x86/sb1_dgpu_sw.c
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index 2ade99b105b91..60b9cb51d5f7e 100644
@ -60,6 +64,204 @@ index 2ade99b105b91..60b9cb51d5f7e 100644
default:
dev_warn(&adapter->dev, "protocol 0x%02x not supported for client 0x%02x\n",
accessor_type, client->addr);
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 0581a54cf562f..14db2795ff638 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -879,6 +879,13 @@ config SURFACE_PRO3_BUTTON
help
This driver handles the power/home/volume buttons on the Microsoft Surface Pro 3/4 tablet.
+config SURFACE_BOOK1_DGPU_SWITCH
+ tristate "Surface Book 1 dGPU Switch Driver"
+ depends on ACPI && SYSFS
+ help
+ This driver provides a sysfs switch to set the power-state of the
+ discrete GPU found on the Microsoft Surface Book 1.
+
config MSI_LAPTOP
tristate "MSI Laptop Extras"
depends on ACPI
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 2b85852a1a872..5156523b58639 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -85,6 +85,7 @@ obj-$(CONFIG_SURFACE3_WMI) += surface3-wmi.o
obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o
obj-$(CONFIG_SURFACE_3_POWER_OPREGION) += surface3_power.o
obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o
+obj-$(CONFIG_SURFACE_BOOK1_DGPU_SWITCH) += sb1_dgpu_sw.o
# MSI
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
diff --git a/drivers/platform/x86/sb1_dgpu_sw.c b/drivers/platform/x86/sb1_dgpu_sw.c
new file mode 100644
index 0000000000000..8c66ed5110fda
--- /dev/null
+++ b/drivers/platform/x86/sb1_dgpu_sw.c
@@ -0,0 +1,162 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/acpi.h>
+#include <linux/platform_device.h>
+
+
+#ifdef pr_fmt
+#undef pr_fmt
+#endif
+#define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
+
+
+static const guid_t dgpu_sw_guid = GUID_INIT(0x6fd05c69, 0xcde3, 0x49f4,
+ 0x95, 0xed, 0xab, 0x16, 0x65, 0x49, 0x80, 0x35);
+
+#define DGPUSW_ACPI_PATH_DSM "\\_SB_.PCI0.LPCB.EC0_.VGBI"
+#define DGPUSW_ACPI_PATH_HGON "\\_SB_.PCI0.RP05.HGON"
+#define DGPUSW_ACPI_PATH_HGOF "\\_SB_.PCI0.RP05.HGOF"
+
+
+static int sb1_dgpu_sw_dsmcall(void)
+{
+ union acpi_object *ret;
+ acpi_handle handle;
+ acpi_status status;
+
+ status = acpi_get_handle(NULL, DGPUSW_ACPI_PATH_DSM, &handle);
+ if (status)
+ return -EINVAL;
+
+ ret = acpi_evaluate_dsm_typed(handle, &dgpu_sw_guid, 1, 1, NULL, ACPI_TYPE_BUFFER);
+ if (!ret)
+ return -EINVAL;
+
+ ACPI_FREE(ret);
+ return 0;
+}
+
+static int sb1_dgpu_sw_hgon(void)
+{
+ struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
+ acpi_status status;
+
+ status = acpi_evaluate_object(NULL, DGPUSW_ACPI_PATH_HGON, NULL, &buf);
+ if (status) {
+ pr_err("failed to run HGON: %d\n", status);
+ return -EINVAL;
+ }
+
+ if (buf.pointer)
+ ACPI_FREE(buf.pointer);
+
+ pr_info("turned-on dGPU via HGON\n");
+ return 0;
+}
+
+static int sb1_dgpu_sw_hgof(void)
+{
+ struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL};
+ acpi_status status;
+
+ status = acpi_evaluate_object(NULL, DGPUSW_ACPI_PATH_HGOF, NULL, &buf);
+ if (status) {
+ pr_err("failed to run HGOF: %d\n", status);
+ return -EINVAL;
+ }
+
+ if (buf.pointer)
+ ACPI_FREE(buf.pointer);
+
+ pr_info("turned-off dGPU via HGOF\n");
+ return 0;
+}
+
+
+static ssize_t dgpu_dsmcall_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ int status, value;
+
+ status = kstrtoint(buf, 0, &value);
+ if (status < 0)
+ return status;
+
+ if (value != 1)
+ return -EINVAL;
+
+ status = sb1_dgpu_sw_dsmcall();
+
+ return status < 0 ? status : len;
+}
+
+static ssize_t dgpu_power_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t len)
+{
+ bool power;
+ int status;
+
+ status = kstrtobool(buf, &power);
+ if (status < 0)
+ return status;
+
+ if (power)
+ status = sb1_dgpu_sw_hgon();
+ else
+ status = sb1_dgpu_sw_hgof();
+
+ return status < 0 ? status : len;
+}
+
+static DEVICE_ATTR_WO(dgpu_dsmcall);
+static DEVICE_ATTR_WO(dgpu_power);
+
+static struct attribute *sb1_dgpu_sw_attrs[] = {
+ &dev_attr_dgpu_dsmcall.attr,
+ &dev_attr_dgpu_power.attr,
+ NULL,
+};
+
+static const struct attribute_group sb1_dgpu_sw_attr_group = {
+ .attrs = sb1_dgpu_sw_attrs,
+};
+
+
+static int sb1_dgpu_sw_probe(struct platform_device *pdev)
+{
+ return sysfs_create_group(&pdev->dev.kobj, &sb1_dgpu_sw_attr_group);
+}
+
+static int sb1_dgpu_sw_remove(struct platform_device *pdev)
+{
+ sysfs_remove_group(&pdev->dev.kobj, &sb1_dgpu_sw_attr_group);
+ return 0;
+}
+
+/*
+ * The dGPU power seems to be actually handled by MSHW0040. However, that is
+ * also the power-/volume-button device with a mainline driver. So let's use
+ * MSHW0041 instead for now, which seems to be the LTCH (latch/DTX) device.
+ */
+static const struct acpi_device_id sb1_dgpu_sw_match[] = {
+ { "MSHW0041", },
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, sb1_dgpu_sw_match);
+
+static struct platform_driver sb1_dgpu_sw = {
+ .probe = sb1_dgpu_sw_probe,
+ .remove = sb1_dgpu_sw_remove,
+ .driver = {
+ .name = "sb1_dgpu_sw",
+ .acpi_match_table = sb1_dgpu_sw_match,
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
+ },
+};
+module_platform_driver(sb1_dgpu_sw);
+
+MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>");
+MODULE_DESCRIPTION("Discrete GPU Power-Switch for Surface Book 1");
+MODULE_LICENSE("GPL");
--
2.28.0

View file

@ -1,4 +1,4 @@
From d82b636e7d95da69503a18f55dea28503c23511a Mon Sep 17 00:00:00 2001
From dfe3b509e98f3f8b1df867927490e3862655b7a4 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sun, 16 Aug 2020 23:39:56 +0200
Subject: [PATCH 6/6] surface-gpe
@ -6,17 +6,17 @@ Subject: [PATCH 6/6] surface-gpe
---
drivers/platform/x86/Kconfig | 9 +
drivers/platform/x86/Makefile | 1 +
drivers/platform/x86/surface_gpe.c | 302 +++++++++++++++++++++++++++++
3 files changed, 312 insertions(+)
drivers/platform/x86/surface_gpe.c | 299 +++++++++++++++++++++++++++++
3 files changed, 309 insertions(+)
create mode 100644 drivers/platform/x86/surface_gpe.c
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 0581a54cf562f..2d0b403842396 100644
index 14db2795ff638..c64267319696c 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -879,6 +879,15 @@ config SURFACE_PRO3_BUTTON
help
This driver handles the power/home/volume buttons on the Microsoft Surface Pro 3/4 tablet.
@@ -886,6 +886,15 @@ config SURFACE_BOOK1_DGPU_SWITCH
This driver provides a sysfs switch to set the power-state of the
discrete GPU found on the Microsoft Surface Book 1.
+config SURFACE_GPE
+ tristate "Surface GPE/Lid Driver"
@ -31,23 +31,23 @@ index 0581a54cf562f..2d0b403842396 100644
tristate "MSI Laptop Extras"
depends on ACPI
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 2b85852a1a872..a64ce216719ab 100644
index 5156523b58639..ef0c3fcab3194 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -85,6 +85,7 @@ obj-$(CONFIG_SURFACE3_WMI) += surface3-wmi.o
obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o
@@ -86,6 +86,7 @@ obj-$(CONFIG_SURFACE_3_BUTTON) += surface3_button.o
obj-$(CONFIG_SURFACE_3_POWER_OPREGION) += surface3_power.o
obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o
obj-$(CONFIG_SURFACE_BOOK1_DGPU_SWITCH) += sb1_dgpu_sw.o
+obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o
# MSI
obj-$(CONFIG_MSI_LAPTOP) += msi-laptop.o
diff --git a/drivers/platform/x86/surface_gpe.c b/drivers/platform/x86/surface_gpe.c
new file mode 100644
index 0000000000000..3031a94cddeb7
index 0000000000000..4c141fef7a5f4
--- /dev/null
+++ b/drivers/platform/x86/surface_gpe.c
@@ -0,0 +1,302 @@
@@ -0,0 +1,299 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Surface GPE/Lid driver to enable wakeup from suspend via the lid by
@ -282,12 +282,9 @@ index 0000000000000..3031a94cddeb7
+{
+ 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");

View file

@ -38,14 +38,14 @@ validpgpkeys=(
)
sha256sums=('d44dfae454432db7bdf8f0a12461626c35d5133da9a1445410c174395ac20c76'
'181330a9cf4517abbbe29b93165bc859ad8ca14a43582f4e1d69aae2b5ecc2c9'
'28d8988615b71b80710cec7d110ad31d078bfd3cb61852c381ab8b6d8bc870b0'
'1f65b3f042db87952468e99be3f1f688f62dda18401bf9716cb734f5571288b5'
'8dbaa21d2c03621b0c5d96c4fbcc7a839bea5a34a5f2279a409c3b404756e753'
'240312181b9049bb38cbc629d2f6ec2fccc6ebd2c9f9a417ce4dace4b1671cc2'
'17320989d284da8d45f7ef9db4b8acb0bbd660e334f4501b11391bf250a4d47f'
'6ae7a48aabf3cd19928c43c7fa89f311da21315efc5612e3e9f10e126488ae50'
'0c07cbe9bea55d8059c9f785e53b49019cf7e46eb3f866968c3da1425f370827'
'c6776a89b3d8cd52d8f9920b6b7b2449f26f20b539f07e945ef90a01aa0a0f1b'
'd1b9badf1ca432e6df7e6042a8a5fefa5b0ac6c65e1c122957db67b4f3f3aeab')
'a4077505868f3ce12601948e01c42e6486d022681019702238c5ef2f73ce7b41'
'db1a236a5f3ee524ae13c410561962a663660b33156d79a60bd71b4b5f094677'
'984be5bde800d60d1c64c7018a65b0931cd74335919b393429646685e18ce7bc'
'91c5bd34b2d9bbb981720296e81fd47914c327c1fc83a3501471f298a7b27c11'
'14bd1b3e74af2b6e60afae9bc008d59f789ffd4d1e9e9721ed0e950c2d48585a'
'b07f659bdbf60a1992657cfc581fa3b4a97d1caca2c26d54f252f722e8ae6c46')
export KBUILD_BUILD_HOST=archlinux