Add patches for v5.11
Links: - kernel:7978404d21
- SAM:bee2add45f
- SAM-gen4:e321205faa
- GPE:6ecfdb3905
- Hotplug:595ed62f24
- IPTS:3642d0e4eb
This commit is contained in:
parent
88e2e104f2
commit
51a06b0112
60
configs/surface-5.11.config
Normal file
60
configs/surface-5.11.config
Normal file
|
@ -0,0 +1,60 @@
|
|||
#
|
||||
# Surface Aggregator Module
|
||||
#
|
||||
CONFIG_SURFACE_AGGREGATOR=m
|
||||
CONFIG_SURFACE_AGGREGATOR_ERROR_INJECTION=n
|
||||
CONFIG_SURFACE_AGGREGATOR_BUS=y
|
||||
CONFIG_SURFACE_AGGREGATOR_CDEV=m
|
||||
CONFIG_SURFACE_AGGREGATOR_REGISTRY=m
|
||||
|
||||
CONFIG_SURFACE_ACPI_NOTIFY=m
|
||||
CONFIG_SURFACE_DTX=m
|
||||
CONFIG_SURFACE_PERFMODE=m
|
||||
|
||||
CONFIG_SURFACE_HID=m
|
||||
CONFIG_SURFACE_KBD=m
|
||||
|
||||
CONFIG_BATTERY_SURFACE=m
|
||||
CONFIG_CHARGER_SURFACE=m
|
||||
|
||||
#
|
||||
# Surface Hotplug
|
||||
#
|
||||
CONFIG_SURFACE_HOTPLUG=m
|
||||
|
||||
#
|
||||
# IPTS touchscreen
|
||||
#
|
||||
# This only enables the user interface for IPTS data.
|
||||
# For the touchscreen to work, you need to install iptsd.
|
||||
#
|
||||
CONFIG_MISC_IPTS=m
|
||||
|
||||
#
|
||||
# Cameras: IPU3
|
||||
#
|
||||
CONFIG_VIDEO_IPU3_IMGU=m
|
||||
CONFIG_VIDEO_IPU3_CIO2=m
|
||||
CONFIG_CIO2_BRIDGE=y
|
||||
CONFIG_INTEL_SKL_INT3472=m
|
||||
|
||||
#
|
||||
# Cameras: Sensor drivers
|
||||
#
|
||||
CONFIG_VIDEO_OV5693=m
|
||||
CONFIG_VIDEO_OV8865=m
|
||||
|
||||
#
|
||||
# ALS Sensor for Surface Book 3, Surface Laptop 3, Surface Pro 7
|
||||
#
|
||||
CONFIG_APDS9960=m
|
||||
|
||||
#
|
||||
# Other Drivers
|
||||
#
|
||||
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
|
||||
CONFIG_SURFACE_BOOK1_DGPU_SWITCH=m
|
101
patches/5.11/0001-surface3-oemb.patch
Normal file
101
patches/5.11/0001-surface3-oemb.patch
Normal file
|
@ -0,0 +1,101 @@
|
|||
From be52a2ec3db3f16d7408b40fdaa17b8d066725b3 Mon Sep 17 00:00:00 2001
|
||||
From: Tsuchiya Yuto <kitakar@gmail.com>
|
||||
Date: Sun, 18 Oct 2020 16:42:44 +0900
|
||||
Subject: [PATCH] (surface3-oemb) add DMI matches for Surface 3 with broken DMI
|
||||
table
|
||||
|
||||
On some Surface 3, the DMI table gets corrupted for unknown reasons
|
||||
and breaks existing DMI matching used for device-specific quirks.
|
||||
|
||||
This commit adds the (broken) DMI data into dmi_system_id tables used
|
||||
for quirks so that each driver can enable quirks even on the affected
|
||||
systems.
|
||||
|
||||
On affected systems, DMI data will look like this:
|
||||
$ grep . /sys/devices/virtual/dmi/id/{bios_vendor,board_name,board_vendor,\
|
||||
chassis_vendor,product_name,sys_vendor}
|
||||
/sys/devices/virtual/dmi/id/bios_vendor:American Megatrends Inc.
|
||||
/sys/devices/virtual/dmi/id/board_name:OEMB
|
||||
/sys/devices/virtual/dmi/id/board_vendor:OEMB
|
||||
/sys/devices/virtual/dmi/id/chassis_vendor:OEMB
|
||||
/sys/devices/virtual/dmi/id/product_name:OEMB
|
||||
/sys/devices/virtual/dmi/id/sys_vendor:OEMB
|
||||
|
||||
Expected:
|
||||
$ grep . /sys/devices/virtual/dmi/id/{bios_vendor,board_name,board_vendor,\
|
||||
chassis_vendor,product_name,sys_vendor}
|
||||
/sys/devices/virtual/dmi/id/bios_vendor:American Megatrends Inc.
|
||||
/sys/devices/virtual/dmi/id/board_name:Surface 3
|
||||
/sys/devices/virtual/dmi/id/board_vendor:Microsoft Corporation
|
||||
/sys/devices/virtual/dmi/id/chassis_vendor:Microsoft Corporation
|
||||
/sys/devices/virtual/dmi/id/product_name:Surface 3
|
||||
/sys/devices/virtual/dmi/id/sys_vendor:Microsoft Corporation
|
||||
|
||||
Signed-off-by: Tsuchiya Yuto <kitakar@gmail.com>
|
||||
Patchset: surface3-oemb
|
||||
---
|
||||
drivers/platform/surface/surface3-wmi.c | 7 +++++++
|
||||
sound/soc/codecs/rt5645.c | 9 +++++++++
|
||||
sound/soc/intel/common/soc-acpi-intel-cht-match.c | 8 ++++++++
|
||||
3 files changed, 24 insertions(+)
|
||||
|
||||
diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c
|
||||
index 130b6f52a600..801083aa56d6 100644
|
||||
--- a/drivers/platform/surface/surface3-wmi.c
|
||||
+++ b/drivers/platform/surface/surface3-wmi.c
|
||||
@@ -37,6 +37,13 @@ static const struct dmi_system_id surface3_dmi_table[] = {
|
||||
DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
|
||||
},
|
||||
},
|
||||
+ {
|
||||
+ .matches = {
|
||||
+ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
|
||||
+ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"),
|
||||
+ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"),
|
||||
+ },
|
||||
+ },
|
||||
#endif
|
||||
{ }
|
||||
};
|
||||
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
|
||||
index 420003d062c7..217e488cd4fa 100644
|
||||
--- a/sound/soc/codecs/rt5645.c
|
||||
+++ b/sound/soc/codecs/rt5645.c
|
||||
@@ -3687,6 +3687,15 @@ static const struct dmi_system_id dmi_platform_data[] = {
|
||||
},
|
||||
.driver_data = (void *)&intel_braswell_platform_data,
|
||||
},
|
||||
+ {
|
||||
+ .ident = "Microsoft Surface 3",
|
||||
+ .matches = {
|
||||
+ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
|
||||
+ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"),
|
||||
+ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"),
|
||||
+ },
|
||||
+ .driver_data = (void *)&intel_braswell_platform_data,
|
||||
+ },
|
||||
{
|
||||
/*
|
||||
* Match for the GPDwin which unfortunately uses somewhat
|
||||
diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
|
||||
index 2752dc955733..ef36a316e2ed 100644
|
||||
--- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c
|
||||
+++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
|
||||
@@ -27,6 +27,14 @@ static const struct dmi_system_id cht_table[] = {
|
||||
DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
|
||||
},
|
||||
},
|
||||
+ {
|
||||
+ .callback = cht_surface_quirk_cb,
|
||||
+ .matches = {
|
||||
+ DMI_MATCH(DMI_BIOS_VENDOR, "American Megatrends Inc."),
|
||||
+ DMI_MATCH(DMI_SYS_VENDOR, "OEMB"),
|
||||
+ DMI_MATCH(DMI_PRODUCT_NAME, "OEMB"),
|
||||
+ },
|
||||
+ },
|
||||
{ }
|
||||
};
|
||||
|
||||
--
|
||||
2.30.1
|
||||
|
1118
patches/5.11/0002-wifi.patch
Normal file
1118
patches/5.11/0002-wifi.patch
Normal file
File diff suppressed because it is too large
Load diff
1361
patches/5.11/0003-ipts.patch
Normal file
1361
patches/5.11/0003-ipts.patch
Normal file
File diff suppressed because it is too large
Load diff
334
patches/5.11/0004-surface-sam-over-hid.patch
Normal file
334
patches/5.11/0004-surface-sam-over-hid.patch
Normal file
|
@ -0,0 +1,334 @@
|
|||
From e84ca436738d7fd8781f77e7bbcb813f602dce3c Mon Sep 17 00:00:00 2001
|
||||
From: Maximilian Luz <luzmaximilian@gmail.com>
|
||||
Date: Sat, 25 Jul 2020 17:19:53 +0200
|
||||
Subject: [PATCH] i2c: acpi: Implement RawBytes read access
|
||||
|
||||
Microsoft Surface Pro 4 and Book 1 devices access the MSHW0030 I2C
|
||||
device via a generic serial bus operation region and RawBytes read
|
||||
access. On the Surface Book 1, this access is required to turn on (and
|
||||
off) the discrete GPU.
|
||||
|
||||
Multiple things are to note here:
|
||||
|
||||
a) The RawBytes access is device/driver dependent. The ACPI
|
||||
specification states:
|
||||
|
||||
> Raw accesses assume that the writer has knowledge of the bus that
|
||||
> the access is made over and the device that is being accessed. The
|
||||
> protocol may only ensure that the buffer is transmitted to the
|
||||
> appropriate driver, but the driver must be able to interpret the
|
||||
> buffer to communicate to a register.
|
||||
|
||||
Thus this implementation may likely not work on other devices
|
||||
accessing I2C via the RawBytes accessor type.
|
||||
|
||||
b) The MSHW0030 I2C device is an HID-over-I2C device which seems to
|
||||
serve multiple functions:
|
||||
|
||||
1. It is the main access point for the legacy-type Surface Aggregator
|
||||
Module (also referred to as SAM-over-HID, as opposed to the newer
|
||||
SAM-over-SSH/UART). It has currently not been determined on how
|
||||
support for the legacy SAM should be implemented. Likely via a
|
||||
custom HID driver.
|
||||
|
||||
2. It seems to serve as the HID device for the Integrated Sensor Hub.
|
||||
This might complicate matters with regards to implementing a
|
||||
SAM-over-HID driver required by legacy SAM.
|
||||
|
||||
In light of this, the simplest approach has been chosen for now.
|
||||
However, it may make more sense regarding breakage and compatibility to
|
||||
either provide functionality for replacing or enhancing the default
|
||||
operation region handler via some additional API functions, or even to
|
||||
completely blacklist MSHW0030 from the I2C core and provide a custom
|
||||
driver for it.
|
||||
|
||||
Replacing/enhancing the default operation region handler would, however,
|
||||
either require some sort of secondary driver and access point for it,
|
||||
from which the new API functions would be called and the new handler
|
||||
(part) would be installed, or hard-coding them via some sort of
|
||||
quirk-like interface into the I2C core.
|
||||
|
||||
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
||||
Patchset: surface-sam-over-hid
|
||||
---
|
||||
drivers/i2c/i2c-core-acpi.c | 35 +++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 35 insertions(+)
|
||||
|
||||
diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
|
||||
index 37c510d9347a..aed579942436 100644
|
||||
--- a/drivers/i2c/i2c-core-acpi.c
|
||||
+++ b/drivers/i2c/i2c-core-acpi.c
|
||||
@@ -574,6 +574,28 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client,
|
||||
return (ret == 1) ? 0 : -EIO;
|
||||
}
|
||||
|
||||
+static int acpi_gsb_i2c_write_raw_bytes(struct i2c_client *client,
|
||||
+ u8 *data, u8 data_len)
|
||||
+{
|
||||
+ struct i2c_msg msgs[1];
|
||||
+ int ret = AE_OK;
|
||||
+
|
||||
+ msgs[0].addr = client->addr;
|
||||
+ msgs[0].flags = client->flags;
|
||||
+ msgs[0].len = data_len + 1;
|
||||
+ msgs[0].buf = data;
|
||||
+
|
||||
+ ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ dev_err(&client->adapter->dev, "i2c write failed: %d\n", ret);
|
||||
+ return ret;
|
||||
+ }
|
||||
+
|
||||
+ /* 1 transfer must have completed successfully */
|
||||
+ return (ret == 1) ? 0 : -EIO;
|
||||
+}
|
||||
+
|
||||
static acpi_status
|
||||
i2c_acpi_space_handler(u32 function, acpi_physical_address command,
|
||||
u32 bits, u64 *value64,
|
||||
@@ -675,6 +697,19 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command,
|
||||
}
|
||||
break;
|
||||
|
||||
+ case ACPI_GSB_ACCESS_ATTRIB_RAW_BYTES:
|
||||
+ if (action == ACPI_READ) {
|
||||
+ dev_warn(&adapter->dev,
|
||||
+ "protocol 0x%02x not supported for client 0x%02x\n",
|
||||
+ accessor_type, client->addr);
|
||||
+ ret = AE_BAD_PARAMETER;
|
||||
+ goto err;
|
||||
+ } else {
|
||||
+ status = acpi_gsb_i2c_write_raw_bytes(client,
|
||||
+ gsb->data, info->access_length);
|
||||
+ }
|
||||
+ break;
|
||||
+
|
||||
default:
|
||||
dev_warn(&adapter->dev, "protocol 0x%02x not supported for client 0x%02x\n",
|
||||
accessor_type, client->addr);
|
||||
--
|
||||
2.30.1
|
||||
|
||||
From 79a4b8747237071f0b4b2bda1d57fcfc730fd824 Mon Sep 17 00:00:00 2001
|
||||
From: Maximilian Luz <luzmaximilian@gmail.com>
|
||||
Date: Sat, 13 Feb 2021 16:41:18 +0100
|
||||
Subject: [PATCH] platform/surface: Add driver for Surface Book 1 dGPU switch
|
||||
|
||||
Add driver exposing the discrete GPU power-switch of the Microsoft
|
||||
Surface Book 1 to user-space.
|
||||
|
||||
On the Surface Book 1, the dGPU power is controlled via the Surface
|
||||
System Aggregator Module (SAM). The specific SAM-over-HID command for
|
||||
this is exposed via ACPI. This module provides a simple driver exposing
|
||||
the ACPI call via a sysfs parameter to user-space, so that users can
|
||||
easily power-on/-off the dGPU.
|
||||
|
||||
Patchset: surface-sam-over-hid
|
||||
---
|
||||
drivers/platform/surface/Kconfig | 7 +
|
||||
drivers/platform/surface/Makefile | 1 +
|
||||
.../surface/surfacebook1_dgpu_switch.c | 162 ++++++++++++++++++
|
||||
3 files changed, 170 insertions(+)
|
||||
create mode 100644 drivers/platform/surface/surfacebook1_dgpu_switch.c
|
||||
|
||||
diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig
|
||||
index 2c941cdac9ee..b5dc9148066c 100644
|
||||
--- a/drivers/platform/surface/Kconfig
|
||||
+++ b/drivers/platform/surface/Kconfig
|
||||
@@ -41,6 +41,13 @@ config SURFACE_3_POWER_OPREGION
|
||||
This driver provides 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 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 SURFACE_GPE
|
||||
tristate "Surface GPE/Lid Support Driver"
|
||||
depends on DMI
|
||||
diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile
|
||||
index cedfb027ded1..3d5fa0daa56b 100644
|
||||
--- a/drivers/platform/surface/Makefile
|
||||
+++ b/drivers/platform/surface/Makefile
|
||||
@@ -7,5 +7,6 @@
|
||||
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_BOOK1_DGPU_SWITCH) += surfacebook1_dgpu_switch.o
|
||||
obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o
|
||||
obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o
|
||||
diff --git a/drivers/platform/surface/surfacebook1_dgpu_switch.c b/drivers/platform/surface/surfacebook1_dgpu_switch.c
|
||||
new file mode 100644
|
||||
index 000000000000..8b816ed8f35c
|
||||
--- /dev/null
|
||||
+++ b/drivers/platform/surface/surfacebook1_dgpu_switch.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 = "surfacebook1_dgpu_switch",
|
||||
+ .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.30.1
|
||||
|
21886
patches/5.11/0005-surface-sam.patch
Normal file
21886
patches/5.11/0005-surface-sam.patch
Normal file
File diff suppressed because it is too large
Load diff
446
patches/5.11/0006-surface-hotplug.patch
Normal file
446
patches/5.11/0006-surface-hotplug.patch
Normal file
|
@ -0,0 +1,446 @@
|
|||
From 789f7b475f230ae8eca4a1792cd829f0aefdc190 Mon Sep 17 00:00:00 2001
|
||||
From: Maximilian Luz <luzmaximilian@gmail.com>
|
||||
Date: Thu, 4 Feb 2021 23:06:40 +0100
|
||||
Subject: [PATCH] PCI: Run platform power transition on initial D0 entry
|
||||
|
||||
On some devices and platforms, the initial platform power state is not
|
||||
in sync with the power state of the PCI device.
|
||||
|
||||
pci_enable_device_flags() updates the state of a PCI device by reading
|
||||
from the PCI_PM_CTRL register. This may change the stored power state of
|
||||
the device without running the appropriate platform power transition.
|
||||
|
||||
Due to the stored power-state being changed, the later call to
|
||||
pci_set_power_state(..., PCI_D0) in do_pci_enable_device() can evaluate
|
||||
to a no-op if the stored state has been changed to D0 via that. This
|
||||
will then prevent the appropriate platform power transition to be run,
|
||||
which can on some devices and platforms lead to platform and PCI power
|
||||
state being entirely different, i.e. out-of-sync. On ACPI platforms,
|
||||
this can lead to power resources not being turned on, even though they
|
||||
are marked as required for D0.
|
||||
|
||||
Specifically, on the Microsoft Surface Book 2 and 3, some ACPI power
|
||||
regions that should be "on" for the D0 state (and others) are
|
||||
initialized as "off" in ACPI, whereas the PCI device is in D0. As the
|
||||
state is updated in pci_enable_device_flags() without ensuring that the
|
||||
platform state is also updated, the power resource will never be
|
||||
properly turned on. Instead, it lives in a sort of on-but-marked-as-off
|
||||
zombie-state, which confuses things down the line when attempting to
|
||||
transition the device into D3cold: As the resource is already marked as
|
||||
off, it won't be turned off and the device does not fully enter D3cold,
|
||||
causing increased power consumption during (runtime-)suspend.
|
||||
|
||||
By replacing pci_set_power_state() in do_pci_enable_device() with
|
||||
pci_power_up(), we can force pci_platform_power_transition() to be
|
||||
called, which will then check if the platform power state needs updating
|
||||
and appropriate actions need to be taken.
|
||||
|
||||
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
||||
|
||||
Patchset: surface-hotplug
|
||||
---
|
||||
drivers/pci/pci.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
|
||||
index 790393d1e318..c9fcd5514409 100644
|
||||
--- a/drivers/pci/pci.c
|
||||
+++ b/drivers/pci/pci.c
|
||||
@@ -1800,7 +1800,7 @@ static int do_pci_enable_device(struct pci_dev *dev, int bars)
|
||||
u16 cmd;
|
||||
u8 pin;
|
||||
|
||||
- err = pci_set_power_state(dev, PCI_D0);
|
||||
+ err = pci_power_up(dev);
|
||||
if (err < 0 && err != -EIO)
|
||||
return err;
|
||||
|
||||
--
|
||||
2.30.1
|
||||
|
||||
From 88347b2a5d4d24c78124b1c9fdda42088192199d Mon Sep 17 00:00:00 2001
|
||||
From: Maximilian Luz <luzmaximilian@gmail.com>
|
||||
Date: Fri, 5 Feb 2021 02:26:57 +0100
|
||||
Subject: [PATCH] platform/surface: Add Surface Hot-Plug driver
|
||||
|
||||
Some Surface Book 2 and 3 models have a discrete GPU (dGPU) that is
|
||||
hot-pluggable. On those devices, the dGPU is contained in the base,
|
||||
which can be separated from the tablet part (containing CPU and
|
||||
touchscreen) while the device is running.
|
||||
|
||||
It (in general) is presented as/behaves like a standard PCIe hot-plug
|
||||
capable device, however, this device can also be put into D3cold. In
|
||||
D3cold, the device itself is turned off and can thus not submit any
|
||||
standard PCIe hot-plug events. To properly detect hot-(un)plugging while
|
||||
the dGPU is in D3cold, out-of-band signaling is required. Without this,
|
||||
the device state will only get updated during the next bus-check, eg.
|
||||
via a manually issued lspci call.
|
||||
|
||||
This commit adds a driver to handle out-of-band PCIe hot-(un)plug events
|
||||
on Microsoft Surface devices. On those devices, said events can be
|
||||
detected via GPIO interrupts, which are then forwarded to the
|
||||
corresponding ACPI DSM calls by this driver. The DSM then takes care of
|
||||
issuing the appropriate bus-/device-check, causing the PCI core to
|
||||
properly pick up the device change.
|
||||
|
||||
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20210205012657.1951753-1-luzmaximilian@gmail.com
|
||||
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
||||
Patchset: surface-hotplug
|
||||
---
|
||||
MAINTAINERS | 6 +
|
||||
drivers/platform/surface/Kconfig | 19 ++
|
||||
drivers/platform/surface/Makefile | 1 +
|
||||
drivers/platform/surface/surface_hotplug.c | 282 +++++++++++++++++++++
|
||||
4 files changed, 308 insertions(+)
|
||||
create mode 100644 drivers/platform/surface/surface_hotplug.c
|
||||
|
||||
diff --git a/MAINTAINERS b/MAINTAINERS
|
||||
index 2144ec466377..a4a0519ce88c 100644
|
||||
--- a/MAINTAINERS
|
||||
+++ b/MAINTAINERS
|
||||
@@ -11824,6 +11824,12 @@ L: platform-driver-x86@vger.kernel.org
|
||||
S: Maintained
|
||||
F: drivers/hid/surface-hid/
|
||||
|
||||
+MICROSOFT SURFACE HOT-PLUG DRIVER
|
||||
+M: Maximilian Luz <luzmaximilian@gmail.com>
|
||||
+L: platform-driver-x86@vger.kernel.org
|
||||
+S: Maintained
|
||||
+F: drivers/platform/surface/surface_hotplug.c
|
||||
+
|
||||
MICROSOFT SURFACE PRO 3 BUTTON DRIVER
|
||||
M: Chen Yu <yu.c.chen@intel.com>
|
||||
L: platform-driver-x86@vger.kernel.org
|
||||
diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig
|
||||
index 3ceeb316d56e..2784a480f310 100644
|
||||
--- a/drivers/platform/surface/Kconfig
|
||||
+++ b/drivers/platform/surface/Kconfig
|
||||
@@ -140,6 +140,25 @@ config SURFACE_GPE
|
||||
accordingly. It is required on those devices to allow wake-ups from
|
||||
suspend by opening the lid.
|
||||
|
||||
+config SURFACE_HOTPLUG
|
||||
+ tristate "Surface Hot-Plug Driver"
|
||||
+ depends on GPIOLIB
|
||||
+ help
|
||||
+ Driver for out-of-band hot-plug event signaling on Microsoft Surface
|
||||
+ devices with hot-pluggable PCIe cards.
|
||||
+
|
||||
+ This driver is used on Surface Book (2 and 3) devices with a
|
||||
+ hot-pluggable discrete GPU (dGPU). When not in use, the dGPU on those
|
||||
+ devices can enter D3cold, which prevents in-band (standard) PCIe
|
||||
+ hot-plug signaling. Thus, without this driver, detaching the base
|
||||
+ containing the dGPU will not correctly update the state of the
|
||||
+ corresponding PCIe device if it is in D3cold. This driver adds support
|
||||
+ for out-of-band hot-plug notifications, ensuring that the device state
|
||||
+ is properly updated even when the device in question is in D3cold.
|
||||
+
|
||||
+ Select M or Y here, if you want to (fully) support hot-plugging of
|
||||
+ dGPU devices on the Surface Book 2 and/or 3 during D3cold.
|
||||
+
|
||||
config SURFACE_PERFMODE
|
||||
tristate "Surface Performance-Mode Driver"
|
||||
depends on SURFACE_AGGREGATOR_BUS
|
||||
diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile
|
||||
index 31098983decc..a103fdb3ef1a 100644
|
||||
--- a/drivers/platform/surface/Makefile
|
||||
+++ b/drivers/platform/surface/Makefile
|
||||
@@ -14,5 +14,6 @@ obj-$(CONFIG_SURFACE_AGGREGATOR_REGISTRY) += surface_aggregator_registry.o
|
||||
obj-$(CONFIG_SURFACE_BOOK1_DGPU_SWITCH) += surfacebook1_dgpu_switch.o
|
||||
obj-$(CONFIG_SURFACE_DTX) += surface_dtx.o
|
||||
obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o
|
||||
+obj-$(CONFIG_SURFACE_HOTPLUG) += surface_hotplug.o
|
||||
obj-$(CONFIG_SURFACE_PERFMODE) += surface_perfmode.o
|
||||
obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o
|
||||
diff --git a/drivers/platform/surface/surface_hotplug.c b/drivers/platform/surface/surface_hotplug.c
|
||||
new file mode 100644
|
||||
index 000000000000..cfcc15cfbacb
|
||||
--- /dev/null
|
||||
+++ b/drivers/platform/surface/surface_hotplug.c
|
||||
@@ -0,0 +1,282 @@
|
||||
+// SPDX-License-Identifier: GPL-2.0+
|
||||
+/*
|
||||
+ * Surface Book (2 and later) hot-plug driver.
|
||||
+ *
|
||||
+ * Surface Book devices (can) have a hot-pluggable discrete GPU (dGPU). This
|
||||
+ * driver is responsible for out-of-band hot-plug event signaling on these
|
||||
+ * devices. It is specifically required when the hot-plug device is in D3cold
|
||||
+ * and can thus not generate PCIe hot-plug events itself.
|
||||
+ *
|
||||
+ * Event signaling is handled via ACPI, which will generate the appropriate
|
||||
+ * device-check notifications to be picked up by the PCIe hot-plug driver.
|
||||
+ *
|
||||
+ * Copyright (C) 2019-2021 Maximilian Luz <luzmaximilian@gmail.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/acpi.h>
|
||||
+#include <linux/gpio.h>
|
||||
+#include <linux/interrupt.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/mutex.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+
|
||||
+static const struct acpi_gpio_params shps_base_presence_int = { 0, 0, false };
|
||||
+static const struct acpi_gpio_params shps_base_presence = { 1, 0, false };
|
||||
+static const struct acpi_gpio_params shps_device_power_int = { 2, 0, false };
|
||||
+static const struct acpi_gpio_params shps_device_power = { 3, 0, false };
|
||||
+static const struct acpi_gpio_params shps_device_presence_int = { 4, 0, false };
|
||||
+static const struct acpi_gpio_params shps_device_presence = { 5, 0, false };
|
||||
+
|
||||
+static const struct acpi_gpio_mapping shps_acpi_gpios[] = {
|
||||
+ { "base_presence-int-gpio", &shps_base_presence_int, 1 },
|
||||
+ { "base_presence-gpio", &shps_base_presence, 1 },
|
||||
+ { "device_power-int-gpio", &shps_device_power_int, 1 },
|
||||
+ { "device_power-gpio", &shps_device_power, 1 },
|
||||
+ { "device_presence-int-gpio", &shps_device_presence_int, 1 },
|
||||
+ { "device_presence-gpio", &shps_device_presence, 1 },
|
||||
+ { },
|
||||
+};
|
||||
+
|
||||
+/* 5515a847-ed55-4b27-8352-cd320e10360a */
|
||||
+static const guid_t shps_dsm_guid =
|
||||
+ GUID_INIT(0x5515a847, 0xed55, 0x4b27, 0x83, 0x52, 0xcd, 0x32, 0x0e, 0x10, 0x36, 0x0a);
|
||||
+
|
||||
+#define SHPS_DSM_REVISION 1
|
||||
+
|
||||
+enum shps_dsm_fn {
|
||||
+ SHPS_DSM_FN_PCI_NUM_ENTRIES = 0x01,
|
||||
+ SHPS_DSM_FN_PCI_GET_ENTRIES = 0x02,
|
||||
+ SHPS_DSM_FN_IRQ_BASE_PRESENCE = 0x03,
|
||||
+ SHPS_DSM_FN_IRQ_DEVICE_POWER = 0x04,
|
||||
+ SHPS_DSM_FN_IRQ_DEVICE_PRESENCE = 0x05,
|
||||
+};
|
||||
+
|
||||
+enum shps_irq_type {
|
||||
+ /* NOTE: Must be in order of enum shps_dsm_fn above. */
|
||||
+ SHPS_IRQ_TYPE_BASE_PRESENCE = 0,
|
||||
+ SHPS_IRQ_TYPE_DEVICE_POWER = 1,
|
||||
+ SHPS_IRQ_TYPE_DEVICE_PRESENCE = 2,
|
||||
+ SHPS_NUM_IRQS,
|
||||
+};
|
||||
+
|
||||
+static const char *const shps_gpio_names[] = {
|
||||
+ [SHPS_IRQ_TYPE_BASE_PRESENCE] = "base_presence",
|
||||
+ [SHPS_IRQ_TYPE_DEVICE_POWER] = "device_power",
|
||||
+ [SHPS_IRQ_TYPE_DEVICE_PRESENCE] = "device_presence",
|
||||
+};
|
||||
+
|
||||
+struct shps_device {
|
||||
+ struct mutex lock[SHPS_NUM_IRQS]; /* Protects update in shps_dsm_notify_irq() */
|
||||
+ struct gpio_desc *gpio[SHPS_NUM_IRQS];
|
||||
+ unsigned int irq[SHPS_NUM_IRQS];
|
||||
+};
|
||||
+
|
||||
+#define SHPS_IRQ_NOT_PRESENT ((unsigned int)-1)
|
||||
+
|
||||
+static enum shps_dsm_fn shps_dsm_fn_for_irq(enum shps_irq_type type)
|
||||
+{
|
||||
+ return SHPS_DSM_FN_IRQ_BASE_PRESENCE + type;
|
||||
+}
|
||||
+
|
||||
+static void shps_dsm_notify_irq(struct platform_device *pdev, enum shps_irq_type type)
|
||||
+{
|
||||
+ struct shps_device *sdev = platform_get_drvdata(pdev);
|
||||
+ acpi_handle handle = ACPI_HANDLE(&pdev->dev);
|
||||
+ union acpi_object *result;
|
||||
+ union acpi_object param;
|
||||
+ int value;
|
||||
+
|
||||
+ mutex_lock(&sdev->lock[type]);
|
||||
+
|
||||
+ value = gpiod_get_value_cansleep(sdev->gpio[type]);
|
||||
+ if (value < 0) {
|
||||
+ mutex_unlock(&sdev->lock[type]);
|
||||
+ dev_err(&pdev->dev, "failed to get gpio: %d (irq=%d)\n", type, value);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ dev_dbg(&pdev->dev, "IRQ notification via DSM (irq=%d, value=%d)\n", type, value);
|
||||
+
|
||||
+ param.type = ACPI_TYPE_INTEGER;
|
||||
+ param.integer.value = value;
|
||||
+
|
||||
+ result = acpi_evaluate_dsm(handle, &shps_dsm_guid, SHPS_DSM_REVISION,
|
||||
+ shps_dsm_fn_for_irq(type), ¶m);
|
||||
+
|
||||
+ if (!result) {
|
||||
+ dev_err(&pdev->dev, "IRQ notification via DSM failed (irq=%d, gpio=%d)\n",
|
||||
+ type, value);
|
||||
+
|
||||
+ } else if (result->type != ACPI_TYPE_BUFFER) {
|
||||
+ dev_err(&pdev->dev,
|
||||
+ "IRQ notification via DSM failed: unexpected result type (irq=%d, gpio=%d)\n",
|
||||
+ type, value);
|
||||
+
|
||||
+ } else if (result->buffer.length != 1 || result->buffer.pointer[0] != 0) {
|
||||
+ dev_err(&pdev->dev,
|
||||
+ "IRQ notification via DSM failed: unexpected result value (irq=%d, gpio=%d)\n",
|
||||
+ type, value);
|
||||
+ }
|
||||
+
|
||||
+ mutex_unlock(&sdev->lock[type]);
|
||||
+
|
||||
+ if (result)
|
||||
+ ACPI_FREE(result);
|
||||
+}
|
||||
+
|
||||
+static irqreturn_t shps_handle_irq(int irq, void *data)
|
||||
+{
|
||||
+ struct platform_device *pdev = data;
|
||||
+ struct shps_device *sdev = platform_get_drvdata(pdev);
|
||||
+ int type;
|
||||
+
|
||||
+ /* Figure out which IRQ we're handling. */
|
||||
+ for (type = 0; type < SHPS_NUM_IRQS; type++)
|
||||
+ if (irq == sdev->irq[type])
|
||||
+ break;
|
||||
+
|
||||
+ /* We should have found our interrupt, if not: this is a bug. */
|
||||
+ if (WARN(type >= SHPS_NUM_IRQS, "invalid IRQ number: %d\n", irq))
|
||||
+ return IRQ_HANDLED;
|
||||
+
|
||||
+ /* Forward interrupt to ACPI via DSM. */
|
||||
+ shps_dsm_notify_irq(pdev, type);
|
||||
+ return IRQ_HANDLED;
|
||||
+}
|
||||
+
|
||||
+static int shps_setup_irq(struct platform_device *pdev, enum shps_irq_type type)
|
||||
+{
|
||||
+ unsigned long flags = IRQF_ONESHOT | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING;
|
||||
+ struct shps_device *sdev = platform_get_drvdata(pdev);
|
||||
+ struct gpio_desc *gpiod;
|
||||
+ acpi_handle handle = ACPI_HANDLE(&pdev->dev);
|
||||
+ const char *irq_name;
|
||||
+ const int dsm = shps_dsm_fn_for_irq(type);
|
||||
+ int status, irq;
|
||||
+
|
||||
+ /*
|
||||
+ * Only set up interrupts that we actually need: The Surface Book 3
|
||||
+ * does not have a DSM for base presence, so don't set up an interrupt
|
||||
+ * for that.
|
||||
+ */
|
||||
+ if (!acpi_check_dsm(handle, &shps_dsm_guid, SHPS_DSM_REVISION, BIT(dsm))) {
|
||||
+ dev_dbg(&pdev->dev, "IRQ notification via DSM not present (irq=%d)\n", type);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ gpiod = devm_gpiod_get(&pdev->dev, shps_gpio_names[type], GPIOD_ASIS);
|
||||
+ if (IS_ERR(gpiod))
|
||||
+ return PTR_ERR(gpiod);
|
||||
+
|
||||
+ irq = gpiod_to_irq(gpiod);
|
||||
+ if (irq < 0)
|
||||
+ return irq;
|
||||
+
|
||||
+ irq_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "shps-irq-%d", type);
|
||||
+ if (!irq_name)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ status = devm_request_threaded_irq(&pdev->dev, irq, NULL, shps_handle_irq,
|
||||
+ flags, irq_name, pdev);
|
||||
+ if (status)
|
||||
+ return status;
|
||||
+
|
||||
+ dev_dbg(&pdev->dev, "set up irq %d as type %d\n", irq, type);
|
||||
+
|
||||
+ sdev->gpio[type] = gpiod;
|
||||
+ sdev->irq[type] = irq;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int surface_hotplug_remove(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct shps_device *sdev = platform_get_drvdata(pdev);
|
||||
+ int i;
|
||||
+
|
||||
+ /* Ensure that IRQs have been fully handled and won't trigger any more. */
|
||||
+ for (i = 0; i < SHPS_NUM_IRQS; i++) {
|
||||
+ if (sdev->irq[i] != SHPS_IRQ_NOT_PRESENT)
|
||||
+ disable_irq(sdev->irq[i]);
|
||||
+
|
||||
+ mutex_destroy(&sdev->lock[i]);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int surface_hotplug_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct shps_device *sdev;
|
||||
+ int status, i;
|
||||
+
|
||||
+ /*
|
||||
+ * The MSHW0153 device is also present on the Surface Laptop 3,
|
||||
+ * however that doesn't have a hot-pluggable PCIe device. It also
|
||||
+ * doesn't have any GPIO interrupts/pins under the MSHW0153, so filter
|
||||
+ * it out here.
|
||||
+ */
|
||||
+ if (gpiod_count(&pdev->dev, NULL) < 0)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ status = devm_acpi_dev_add_driver_gpios(&pdev->dev, shps_acpi_gpios);
|
||||
+ if (status)
|
||||
+ return status;
|
||||
+
|
||||
+ sdev = devm_kzalloc(&pdev->dev, sizeof(*sdev), GFP_KERNEL);
|
||||
+ if (!sdev)
|
||||
+ return -ENOMEM;
|
||||
+
|
||||
+ platform_set_drvdata(pdev, sdev);
|
||||
+
|
||||
+ /*
|
||||
+ * Initialize IRQs so that we can safely call surface_hotplug_remove()
|
||||
+ * on errors.
|
||||
+ */
|
||||
+ for (i = 0; i < SHPS_NUM_IRQS; i++)
|
||||
+ sdev->irq[i] = SHPS_IRQ_NOT_PRESENT;
|
||||
+
|
||||
+ /* Set up IRQs. */
|
||||
+ for (i = 0; i < SHPS_NUM_IRQS; i++) {
|
||||
+ mutex_init(&sdev->lock[i]);
|
||||
+
|
||||
+ status = shps_setup_irq(pdev, i);
|
||||
+ if (status) {
|
||||
+ dev_err(&pdev->dev, "failed to set up IRQ %d: %d\n", i, status);
|
||||
+ goto err;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Ensure everything is up-to-date. */
|
||||
+ for (i = 0; i < SHPS_NUM_IRQS; i++)
|
||||
+ if (sdev->irq[i] != SHPS_IRQ_NOT_PRESENT)
|
||||
+ shps_dsm_notify_irq(pdev, i);
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+err:
|
||||
+ surface_hotplug_remove(pdev);
|
||||
+ return status;
|
||||
+}
|
||||
+
|
||||
+static const struct acpi_device_id surface_hotplug_acpi_match[] = {
|
||||
+ { "MSHW0153", 0 },
|
||||
+ { },
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(acpi, surface_hotplug_acpi_match);
|
||||
+
|
||||
+static struct platform_driver surface_hotplug_driver = {
|
||||
+ .probe = surface_hotplug_probe,
|
||||
+ .remove = surface_hotplug_remove,
|
||||
+ .driver = {
|
||||
+ .name = "surface_hotplug",
|
||||
+ .acpi_match_table = surface_hotplug_acpi_match,
|
||||
+ .probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
||||
+ },
|
||||
+};
|
||||
+module_platform_driver(surface_hotplug_driver);
|
||||
+
|
||||
+MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>");
|
||||
+MODULE_DESCRIPTION("Surface Hot-Plug Signaling Driver for Surface Book Devices");
|
||||
+MODULE_LICENSE("GPL");
|
||||
--
|
||||
2.30.1
|
||||
|
233
patches/5.11/0007-surface-typecover.patch
Normal file
233
patches/5.11/0007-surface-typecover.patch
Normal file
|
@ -0,0 +1,233 @@
|
|||
From be2a2310c392ac571f62c5180d1795f132a0f8fd Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl>
|
||||
Date: Thu, 5 Nov 2020 13:09:45 +0100
|
||||
Subject: [PATCH] hid/multitouch: Turn off Type Cover keyboard backlight when
|
||||
suspending
|
||||
|
||||
The Type Cover for Microsoft Surface devices supports a special usb
|
||||
control request to disable or enable the built-in keyboard backlight.
|
||||
On Windows, this request happens when putting the device into suspend or
|
||||
resuming it, without it the backlight of the Type Cover will remain
|
||||
enabled for some time even though the computer is suspended, which looks
|
||||
weird to the user.
|
||||
|
||||
So add support for this special usb control request to hid-multitouch,
|
||||
which is the driver that's handling the Type Cover.
|
||||
|
||||
The reason we have to use a pm_notifier for this instead of the usual
|
||||
suspend/resume methods is that those won't get called in case the usb
|
||||
device is already autosuspended.
|
||||
|
||||
Also, if the device is autosuspended, we have to briefly autoresume it
|
||||
in order to send the request. Doing that should be fine, the usb-core
|
||||
driver does something similar during suspend inside choose_wakeup().
|
||||
|
||||
To make sure we don't send that request to every device but only to
|
||||
devices which support it, add a new quirk
|
||||
MT_CLS_WIN_8_MS_SURFACE_TYPE_COVER to hid-multitouch. For now this quirk
|
||||
is only enabled for the usb id of the Surface Pro 2017 Type Cover, which
|
||||
is where I confirmed that it's working.
|
||||
|
||||
Patchset: surface-typecover
|
||||
---
|
||||
drivers/hid/hid-multitouch.c | 100 ++++++++++++++++++++++++++++++++++-
|
||||
1 file changed, 98 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
|
||||
index 8429ebe7097e..44d48e8bbe1a 100644
|
||||
--- a/drivers/hid/hid-multitouch.c
|
||||
+++ b/drivers/hid/hid-multitouch.c
|
||||
@@ -34,7 +34,10 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/hid.h>
|
||||
#include <linux/module.h>
|
||||
+#include <linux/pm_runtime.h>
|
||||
#include <linux/slab.h>
|
||||
+#include <linux/suspend.h>
|
||||
+#include <linux/usb.h>
|
||||
#include <linux/input/mt.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/string.h>
|
||||
@@ -47,6 +50,7 @@ MODULE_DESCRIPTION("HID multitouch panels");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
#include "hid-ids.h"
|
||||
+#include "usbhid/usbhid.h"
|
||||
|
||||
/* quirks to control the device */
|
||||
#define MT_QUIRK_NOT_SEEN_MEANS_UP BIT(0)
|
||||
@@ -70,12 +74,15 @@ MODULE_LICENSE("GPL");
|
||||
#define MT_QUIRK_WIN8_PTP_BUTTONS BIT(18)
|
||||
#define MT_QUIRK_SEPARATE_APP_REPORT BIT(19)
|
||||
#define MT_QUIRK_FORCE_MULTI_INPUT BIT(20)
|
||||
+#define MT_QUIRK_HAS_TYPE_COVER_BACKLIGHT BIT(21)
|
||||
|
||||
#define MT_INPUTMODE_TOUCHSCREEN 0x02
|
||||
#define MT_INPUTMODE_TOUCHPAD 0x03
|
||||
|
||||
#define MT_BUTTONTYPE_CLICKPAD 0
|
||||
|
||||
+#define MS_TYPE_COVER_FEATURE_REPORT_USAGE 0xff050086
|
||||
+
|
||||
enum latency_mode {
|
||||
HID_LATENCY_NORMAL = 0,
|
||||
HID_LATENCY_HIGH = 1,
|
||||
@@ -167,6 +174,8 @@ struct mt_device {
|
||||
|
||||
struct list_head applications;
|
||||
struct list_head reports;
|
||||
+
|
||||
+ struct notifier_block pm_notifier;
|
||||
};
|
||||
|
||||
static void mt_post_parse_default_settings(struct mt_device *td,
|
||||
@@ -208,6 +217,7 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app);
|
||||
#define MT_CLS_GOOGLE 0x0111
|
||||
#define MT_CLS_RAZER_BLADE_STEALTH 0x0112
|
||||
#define MT_CLS_SMART_TECH 0x0113
|
||||
+#define MT_CLS_WIN_8_MS_SURFACE_TYPE_COVER 0x0114
|
||||
|
||||
#define MT_DEFAULT_MAXCONTACT 10
|
||||
#define MT_MAX_MAXCONTACT 250
|
||||
@@ -367,6 +377,16 @@ static const struct mt_class mt_classes[] = {
|
||||
MT_QUIRK_CONTACT_CNT_ACCURATE |
|
||||
MT_QUIRK_SEPARATE_APP_REPORT,
|
||||
},
|
||||
+ { .name = MT_CLS_WIN_8_MS_SURFACE_TYPE_COVER,
|
||||
+ .quirks = MT_QUIRK_HAS_TYPE_COVER_BACKLIGHT |
|
||||
+ MT_QUIRK_ALWAYS_VALID |
|
||||
+ MT_QUIRK_IGNORE_DUPLICATES |
|
||||
+ MT_QUIRK_HOVERING |
|
||||
+ MT_QUIRK_CONTACT_CNT_ACCURATE |
|
||||
+ MT_QUIRK_STICKY_FINGERS |
|
||||
+ MT_QUIRK_WIN8_PTP_BUTTONS,
|
||||
+ .export_all_inputs = true
|
||||
+ },
|
||||
{ }
|
||||
};
|
||||
|
||||
@@ -1674,6 +1694,69 @@ static void mt_expired_timeout(struct timer_list *t)
|
||||
clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
|
||||
}
|
||||
|
||||
+static void get_type_cover_backlight_field(struct hid_device *hdev,
|
||||
+ struct hid_field **field)
|
||||
+{
|
||||
+ struct hid_report_enum *rep_enum;
|
||||
+ struct hid_report *rep;
|
||||
+ struct hid_field *cur_field;
|
||||
+ int i, j;
|
||||
+
|
||||
+ rep_enum = &hdev->report_enum[HID_FEATURE_REPORT];
|
||||
+ list_for_each_entry(rep, &rep_enum->report_list, list) {
|
||||
+ for (i = 0; i < rep->maxfield; i++) {
|
||||
+ cur_field = rep->field[i];
|
||||
+
|
||||
+ for (j = 0; j < cur_field->maxusage; j++) {
|
||||
+ if (cur_field->usage[j].hid
|
||||
+ == MS_TYPE_COVER_FEATURE_REPORT_USAGE) {
|
||||
+ *field = cur_field;
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void update_keyboard_backlight(struct hid_device *hdev, bool enabled)
|
||||
+{
|
||||
+ struct usb_device *udev = hid_to_usb_dev(hdev);
|
||||
+ struct hid_field *field = NULL;
|
||||
+
|
||||
+ /* Wake up the device in case it's already suspended */
|
||||
+ pm_runtime_get_sync(&udev->dev);
|
||||
+
|
||||
+ get_type_cover_backlight_field(hdev, &field);
|
||||
+ if (!field) {
|
||||
+ hid_err(hdev, "couldn't find backlight field\n");
|
||||
+ goto out;
|
||||
+ }
|
||||
+
|
||||
+ field->value[field->index] = enabled ? 0x01ff00ff : 0x00ff00ff;
|
||||
+ hid_hw_request(hdev, field->report, HID_REQ_SET_REPORT);
|
||||
+
|
||||
+out:
|
||||
+ pm_runtime_put_sync(&udev->dev);
|
||||
+}
|
||||
+
|
||||
+static int mt_pm_notifier(struct notifier_block *notifier,
|
||||
+ unsigned long pm_event,
|
||||
+ void *unused)
|
||||
+{
|
||||
+ struct mt_device *td =
|
||||
+ container_of(notifier, struct mt_device, pm_notifier);
|
||||
+ struct hid_device *hdev = td->hdev;
|
||||
+
|
||||
+ if (td->mtclass.quirks & MT_QUIRK_HAS_TYPE_COVER_BACKLIGHT) {
|
||||
+ if (pm_event == PM_SUSPEND_PREPARE)
|
||||
+ update_keyboard_backlight(hdev, 0);
|
||||
+ else if (pm_event == PM_POST_SUSPEND)
|
||||
+ update_keyboard_backlight(hdev, 1);
|
||||
+ }
|
||||
+
|
||||
+ return NOTIFY_DONE;
|
||||
+}
|
||||
+
|
||||
static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||
{
|
||||
int ret, i;
|
||||
@@ -1697,6 +1780,9 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||
td->inputmode_value = MT_INPUTMODE_TOUCHSCREEN;
|
||||
hid_set_drvdata(hdev, td);
|
||||
|
||||
+ td->pm_notifier.notifier_call = mt_pm_notifier;
|
||||
+ register_pm_notifier(&td->pm_notifier);
|
||||
+
|
||||
INIT_LIST_HEAD(&td->applications);
|
||||
INIT_LIST_HEAD(&td->reports);
|
||||
|
||||
@@ -1726,15 +1812,19 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
|
||||
timer_setup(&td->release_timer, mt_expired_timeout, 0);
|
||||
|
||||
ret = hid_parse(hdev);
|
||||
- if (ret != 0)
|
||||
+ if (ret != 0) {
|
||||
+ unregister_pm_notifier(&td->pm_notifier);
|
||||
return ret;
|
||||
+ }
|
||||
|
||||
if (mtclass->quirks & MT_QUIRK_FIX_CONST_CONTACT_ID)
|
||||
mt_fix_const_fields(hdev, HID_DG_CONTACTID);
|
||||
|
||||
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
|
||||
- if (ret)
|
||||
+ if (ret) {
|
||||
+ unregister_pm_notifier(&td->pm_notifier);
|
||||
return ret;
|
||||
+ }
|
||||
|
||||
ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
|
||||
if (ret)
|
||||
@@ -1770,6 +1860,7 @@ static void mt_remove(struct hid_device *hdev)
|
||||
{
|
||||
struct mt_device *td = hid_get_drvdata(hdev);
|
||||
|
||||
+ unregister_pm_notifier(&td->pm_notifier);
|
||||
del_timer_sync(&td->release_timer);
|
||||
|
||||
sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group);
|
||||
@@ -2121,6 +2212,11 @@ static const struct hid_device_id mt_devices[] = {
|
||||
MT_USB_DEVICE(USB_VENDOR_ID_XIROKU,
|
||||
USB_DEVICE_ID_XIROKU_CSR2) },
|
||||
|
||||
+ /* Microsoft Surface type cover */
|
||||
+ { .driver_data = MT_CLS_WIN_8_MS_SURFACE_TYPE_COVER,
|
||||
+ HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY,
|
||||
+ USB_VENDOR_ID_MICROSOFT, 0x09c0) },
|
||||
+
|
||||
/* Google MT devices */
|
||||
{ .driver_data = MT_CLS_GOOGLE,
|
||||
HID_DEVICE(HID_BUS_ANY, HID_GROUP_ANY, USB_VENDOR_ID_GOOGLE,
|
||||
--
|
||||
2.30.1
|
||||
|
53
patches/5.11/0008-surface-sensors.patch
Normal file
53
patches/5.11/0008-surface-sensors.patch
Normal file
|
@ -0,0 +1,53 @@
|
|||
From 85bf81d420abd726680d219c6cc338af1dd3d480 Mon Sep 17 00:00:00 2001
|
||||
From: Max Leiter <maxwell.leiter@gmail.com>
|
||||
Date: Sat, 19 Dec 2020 17:50:55 -0800
|
||||
Subject: [PATCH] iio:light:apds9960 add detection for MSHW0184 ACPI device in
|
||||
apds9960 driver
|
||||
|
||||
The device is used in the Microsoft Surface Book 3 and Surface Pro 7
|
||||
|
||||
Signed-off-by: Max Leiter <maxwell.leiter@gmail.com>
|
||||
Reviewed-by: Matt Ranostay <matt.ranostay@konsulko.com>
|
||||
Link: https://lore.kernel.org/r/20201220015057.107246-1-maxwell.leiter@gmail.com
|
||||
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
|
||||
Patchset: surface-sensors
|
||||
---
|
||||
drivers/iio/light/apds9960.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c
|
||||
index 547e7f9d6920..df0647856e5d 100644
|
||||
--- a/drivers/iio/light/apds9960.c
|
||||
+++ b/drivers/iio/light/apds9960.c
|
||||
@@ -8,6 +8,7 @@
|
||||
* TODO: gesture + proximity calib offsets
|
||||
*/
|
||||
|
||||
+#include <linux/acpi.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/interrupt.h>
|
||||
@@ -1113,6 +1114,12 @@ static const struct i2c_device_id apds9960_id[] = {
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, apds9960_id);
|
||||
|
||||
+static const struct acpi_device_id apds9960_acpi_match[] = {
|
||||
+ { "MSHW0184" },
|
||||
+ { }
|
||||
+};
|
||||
+MODULE_DEVICE_TABLE(acpi, apds9960_acpi_match);
|
||||
+
|
||||
static const struct of_device_id apds9960_of_match[] = {
|
||||
{ .compatible = "avago,apds9960" },
|
||||
{ }
|
||||
@@ -1124,6 +1131,7 @@ static struct i2c_driver apds9960_driver = {
|
||||
.name = APDS9960_DRV_NAME,
|
||||
.of_match_table = apds9960_of_match,
|
||||
.pm = &apds9960_pm_ops,
|
||||
+ .acpi_match_table = apds9960_acpi_match,
|
||||
},
|
||||
.probe = apds9960_probe,
|
||||
.remove = apds9960_remove,
|
||||
--
|
||||
2.30.1
|
||||
|
7317
patches/5.11/0009-cameras.patch
Normal file
7317
patches/5.11/0009-cameras.patch
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue