Update v4.19 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: f26a027064
This commit is contained in:
Maximilian Luz 2020-09-08 16:27:50 +02:00
parent 032f5515f6
commit d3992b7362
No known key found for this signature in database
GPG key ID: 70EC0937F6C26F02
12 changed files with 3044 additions and 688 deletions

View file

@ -29,3 +29,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 18f7e6de49eef0ee98564426d44d76837533bf8a Mon Sep 17 00:00:00 2001
From b422fc5ba72b16acef3b968747f059d6bdf98b8e Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 28 Sep 2019 18:00:43 +0200
Subject: [PATCH 01/10] surface3-power

View file

@ -1,4 +1,4 @@
From ef3cff04bed31c9af8d5ab9fe9fe3ef385be173a Mon Sep 17 00:00:00 2001
From b893f9530c82d2e1638c5d3a1ec68495ed074ae5 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 02/10] surface3-touchscreen-dma-fix

View file

@ -1,4 +1,4 @@
From 05e083e1986a24e98daa3e93a588072bf40ea850 Mon Sep 17 00:00:00 2001
From 43fa4088439b8bbc5f0da0294d0632daf93cea42 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 03/10] surface3-oemb

View file

@ -1,4 +1,4 @@
From f7ec6afbc7fa9fbcd7881d1fb1b44ace16bf30cd Mon Sep 17 00:00:00 2001
From 63f089ec36f3a1d2da9835e3cb2c7215f9502635 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 27 Jul 2019 17:51:37 +0200
Subject: [PATCH 04/10] surface-buttons

View file

@ -1,4 +1,4 @@
From 08c0598c88362465f96ae8e14f828b402be4d73e Mon Sep 17 00:00:00 2001
From 0aed72e4a7fedaa863fb959468368d58c512faea 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 05/10] suspend

View file

@ -1,4 +1,4 @@
From 6392525b59f427b67bc11eb50e763f9c65e39823 Mon Sep 17 00:00:00 2001
From ba999a4990cd55ef2bb8f7ccb0859d7e9437ea0e Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 28 Sep 2019 17:58:17 +0200
Subject: [PATCH 06/10] ipts

View file

@ -1,4 +1,4 @@
From f94e254ee1e8e1819e2a03be4a65adce30db70a5 Mon Sep 17 00:00:00 2001
From c888f3c6fccaee39aeb651af86e692a040136f4d 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 07/10] wifi

File diff suppressed because it is too large Load diff

View file

@ -1,11 +1,15 @@
From 8dc9e12587916215c01d702770f3845bd37cdb64 Mon Sep 17 00:00:00 2001
From 7cbba449789e1256a45457876fec5b3e41b09785 Mon Sep 17 00:00:00 2001
From: Maximilian Luz <luzmaximilian@gmail.com>
Date: Sat, 25 Jul 2020 17:19:53 +0200
Subject: [PATCH 09/10] 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 eb05693593875..c2b5a2aca731d 100644
@ -60,6 +64,204 @@ index eb05693593875..c2b5a2aca731d 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 2ad19dc64a4af..57131ca5eb1e8 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1167,6 +1167,13 @@ config SURFACE_3_POWER_OPREGION
Select this option to enable support for ACPI operation
region of the Surface 3 battery platform driver.
+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 INTEL_PUNIT_IPC
tristate "Intel P-Unit IPC Driver"
---help---
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 2ea90039a3e49..3911b95487c72 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_BOOK1_DGPU_SWITCH) += sb1_dgpu_sw.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/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 2a05ca7718732e91c9c15e9cfcb0c8c1cfa7ec16 Mon Sep 17 00:00:00 2001
From 59276f3647266b4e58b51a493a7afaef6576e652 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
@ -6,17 +6,17 @@ 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(+)
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 2ad19dc64a4af..a95121eae8965 100644
index 57131ca5eb1e8..e2c05d95f8b2a 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.
@@ -1174,6 +1174,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 2ad19dc64a4af..a95121eae8965 100644
tristate "Intel P-Unit IPC Driver"
---help---
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 2ea90039a3e49..49238e9d4abf6 100644
index 3911b95487c72..0dfc55b07a483 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
@@ -83,6 +83,7 @@ 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_BOOK1_DGPU_SWITCH) += sb1_dgpu_sw.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
index 0000000000000..451ca1f981fe1
--- /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
+/*
+ * Pseudo device and driver to enable wakeup from suspend via the lid by
@ -282,12 +282,9 @@ index 0000000000000..fee4cde12f05e
+{
+ 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

@ -40,17 +40,17 @@ sha256sums=('6912db1c242d72ce9c8d4ff71982ac935d97690822af5c1c6ec22412b31667a4'
'SKIP'
'4e68572e7cc4c5368f0236e0792660ae8498373988625dca46e509399a7eaea6'
'a13581d3c6dc595206e4fe7fcf6b542e7a1bdbe96101f0f010fc5be49f99baf2'
'c04b7652fbc7dbca65bfd64e7123adcb6da9dae0ab33d85be58907b5b9de1c66'
'528e8fe10c3a4fb06ad88ab6e61343fcd804c9d199559ba8363c50953f2fe0ef'
'fc516fbfa8e4c7632dde47f089b7d0dd4983c743efc07f5a8ad191ee5dffe77f'
'c42547c8260013ec964f1c32ed704924a8ae90ba6a98dad1ed5b5314174f2135'
'0cc22be9ffa63c2cd68fa87b2ba105b311a88700787d14eac138e06411538004'
'7d538cb728da8356ef7dbb1fea5a3cee11a88c9287c2488ce2558a52e67b0347'
'c03124218acdd3c390dbe6289234e012e2d5bcbcc70c3a9ee431d1cdabd2df21'
'282530740dbcd5b8cd287112980bc4d64bf116726a5ef58f015497d2623aad74'
'c9a13bae39fd811fc9d44c5b76a05905f4278e1815dfbdccae1df222b8d1d627'
'892e599c771497eb3e0d9b74db5d4e1d19712a63a76d8833423d921f298e08b0'
'4f096dc4c29735974cd9c2cbbc35a6224ba2c2db8a36105c6cd0b0e28e89236c')
'd0fc46eebfb42efdde0b1b1a67f057b56222595b640274b240f5e1cdf36d40c3'
'9f8a60f8126c6e7c981703d2e0a7d103d52b6efb1b3143bf435df8b366890b3a'
'7a6d841e2a582e6be73020a7466bde3ec9fd4844fcea17132fe0bfcda6883d1f'
'c9b3cfe6232601ae300a84e27442f8e142b68dffb9705f916701738de47e1106'
'120a086f499e0ca1243b036fdad6083988c903dd753aa7405f7159faeaa1c466'
'6e74d4d048a9a0c86b3c035ead610edce02cf151c8b541bd15effadc4d0fcf02'
'e69e08011ca2dac4f0a23e943b882598eb315b5b59285f6f544223c33447c527'
'6fa55e170b6fef45c95d1dec00661ea58c6b49941cb8913899dcdbc217cdb3c4'
'fdf3970e01a1f0ab2d5edfa878326d9c3ee499c05eb8afad104bd410a9fc9e80'
'7a241025ca99e12e3b681f3eb57c1dcdb4da73ecc03a82d6e894f8182a826b17'
'a71e8bb9ef3c6db39f94b39c0794a795d8aa9e70eb1841114f7cb85da0b8abfd')
export KBUILD_BUILD_HOST=archlinux
export KBUILD_BUILD_USER=$pkgbase