diff options
Diffstat (limited to 'SOURCES/linux-surface.patch')
-rw-r--r-- | SOURCES/linux-surface.patch | 2160 |
1 files changed, 1347 insertions, 813 deletions
diff --git a/SOURCES/linux-surface.patch b/SOURCES/linux-surface.patch index f36ed75..92893a2 100644 --- a/SOURCES/linux-surface.patch +++ b/SOURCES/linux-surface.patch @@ -1,4 +1,4 @@ -From 646a8f056267c0c6efe791753f05c202d5f991c1 Mon Sep 17 00:00:00 2001 +From 0ef12031f24090b026be178e97e6f24d7d316753 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 @@ -40,7 +40,7 @@ Patchset: surface3-oemb 3 files changed, 24 insertions(+) diff --git a/drivers/platform/surface/surface3-wmi.c b/drivers/platform/surface/surface3-wmi.c -index 09ac9cfc40d8..c626109cf445 100644 +index ca4602bcc7de..490b9731068a 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[] = { @@ -58,7 +58,7 @@ index 09ac9cfc40d8..c626109cf445 100644 { } }; diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c -index 197c56047947..9893e9c3cdf7 100644 +index 4b2e027c1033..dc96ec7bcbd5 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3718,6 +3718,15 @@ static const struct dmi_system_id dmi_platform_data[] = { @@ -78,7 +78,7 @@ index 197c56047947..9893e9c3cdf7 100644 /* * 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 c60a5e8e7bc9..e947133a2c36 100644 +index 6beb00858c33..d82d77387a0a 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[] = { @@ -99,7 +99,7 @@ index c60a5e8e7bc9..e947133a2c36 100644 -- 2.36.1 -From 8d5bbcb596dc777e691b738c90fdde519d5ff70b Mon Sep 17 00:00:00 2001 +From 5269ad31e13145b8cd6a1f3a164074489235426e Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto <kitakar@gmail.com> Date: Tue, 29 Sep 2020 17:32:22 +0900 Subject: [PATCH] mwifiex: pcie: add reset_wsid quirk for Surface 3 @@ -284,7 +284,7 @@ index 8ec4176d698f..25370c5a4f59 100644 -- 2.36.1 -From aa1d32ead69fc367cfe67296dda751a5e40b342f Mon Sep 17 00:00:00 2001 +From a001adb78fb6163901066d66ca8f3f2af55acb48 Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto <kitakar@gmail.com> Date: Wed, 30 Sep 2020 18:08:24 +0900 Subject: [PATCH] mwifiex: pcie: (OEMB) add quirk for Surface 3 with broken DMI @@ -346,7 +346,7 @@ index 563dd0d5ac79..32e2f000e57b 100644 -- 2.36.1 -From 4ac41e0c2d8fe11f20a5f79a0bfe0f56db7a5f2e Mon Sep 17 00:00:00 2001 +From 070c7c749c3ad4f55f19a2dc571ac948858ef758 Mon Sep 17 00:00:00 2001 From: Tsuchiya Yuto <kitakar@gmail.com> Date: Sun, 4 Oct 2020 00:11:49 +0900 Subject: [PATCH] mwifiex: pcie: disable bridge_d3 for Surface gen4+ @@ -501,7 +501,7 @@ index 25370c5a4f59..a1de111ad1db 100644 -- 2.36.1 -From bfcc84af31034dbdd24013dc9a26abe285b40f6c Mon Sep 17 00:00:00 2001 +From a32df1183abf331656d8136ee338e331bb10a3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl> Date: Tue, 3 Nov 2020 13:28:04 +0100 Subject: [PATCH] mwifiex: Add quirk resetting the PCI bridge on MS Surface @@ -668,7 +668,7 @@ index a1de111ad1db..0e429779bb04 100644 -- 2.36.1 -From 58c6afc494c4e3b99d616ecbcaaae4fc2a2793f3 Mon Sep 17 00:00:00 2001 +From a38c2caa97b3ede384d6cde8bdf6f75136e475a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl> Date: Thu, 25 Mar 2021 11:33:02 +0100 Subject: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell @@ -704,14 +704,14 @@ Patchset: mwifiex 1 file changed, 15 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c -index 42234d5f602d..72202a744564 100644 +index e48c3ad069bb..d7704d4e568d 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -63,6 +63,7 @@ static struct usb_driver btusb_driver; - #define BTUSB_INTEL_BROKEN_SHUTDOWN_LED 0x2000000 - #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000 - #define BTUSB_INTEL_NO_WBS_SUPPORT 0x8000000 -+#define BTUSB_LOWER_LESCAN_INTERVAL 0x10000000 + #define BTUSB_INTEL_BROKEN_SHUTDOWN_LED BIT(24) + #define BTUSB_INTEL_BROKEN_INITIAL_NCMD BIT(25) + #define BTUSB_INTEL_NO_WBS_SUPPORT BIT(26) ++#define BTUSB_LOWER_LESCAN_INTERVAL BIT(27) static const struct usb_device_id btusb_table[] = { /* Generic Bluetooth USB device */ @@ -723,7 +723,7 @@ index 42234d5f602d..72202a744564 100644 /* Intel Bluetooth devices */ { USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED }, -@@ -3751,6 +3753,19 @@ static int btusb_probe(struct usb_interface *intf, +@@ -3775,6 +3777,19 @@ static int btusb_probe(struct usb_interface *intf, if (id->driver_info & BTUSB_MARVELL) hdev->set_bdaddr = btusb_set_bdaddr_marvell; @@ -746,7 +746,7 @@ index 42234d5f602d..72202a744564 100644 -- 2.36.1 -From 2fca431e32e851a81ec218ef3dc87563d7cd0e68 Mon Sep 17 00:00:00 2001 +From 2280f1ac0ec588e341cdf2dcf689758555783024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= <verdre@v0yd.nl> Date: Tue, 10 Nov 2020 12:49:56 +0100 Subject: [PATCH] mwifiex: Use non-posted PCI register writes @@ -803,7 +803,7 @@ index 24bcd22a2618..b4ad0113a035 100644 -- 2.36.1 -From d4c4b533922f980a4cf0ad48db72506b3cba3a01 Mon Sep 17 00:00:00 2001 +From 8b13cea0f23f2556cd4c7bc10b567272b385bbea Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> Date: Sat, 27 Feb 2021 00:45:52 +0100 Subject: [PATCH] ath10k: Add module parameters to override board files @@ -825,7 +825,7 @@ Patchset: ath10k 1 file changed, 58 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c -index 8f5b8eb368fa..80c1bac732bc 100644 +index 9e1f483e1362..34cfce241e4a 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -36,6 +36,9 @@ static bool skip_otp; @@ -858,7 +858,7 @@ index 8f5b8eb368fa..80c1bac732bc 100644 static const struct ath10k_hw_params ath10k_hw_params_list[] = { { .id = QCA988X_HW_2_0_VERSION, -@@ -844,6 +853,42 @@ static int ath10k_init_configure_target(struct ath10k *ar) +@@ -860,6 +869,42 @@ static int ath10k_init_configure_target(struct ath10k *ar) return 0; } @@ -901,7 +901,7 @@ index 8f5b8eb368fa..80c1bac732bc 100644 static const struct firmware *ath10k_fetch_fw_file(struct ath10k *ar, const char *dir, const char *file) -@@ -858,6 +903,19 @@ static const struct firmware *ath10k_fetch_fw_file(struct ath10k *ar, +@@ -874,6 +919,19 @@ static const struct firmware *ath10k_fetch_fw_file(struct ath10k *ar, if (dir == NULL) dir = "."; @@ -924,7 +924,7 @@ index 8f5b8eb368fa..80c1bac732bc 100644 -- 2.36.1 -From e2a9cc1c420b8f9584c85914b6b8c8cb38b2fecc Mon Sep 17 00:00:00 2001 +From 39a0f300b7a779d283f758e0aa5ff2ba2511177e 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] misc: mei: Add missing IPTS device IDs @@ -948,10 +948,10 @@ index 64ce3f830262..c208a1e3a7c1 100644 #define MEI_DEV_ID_JSP_N 0x4DE0 /* Jasper Lake Point N */ diff --git a/drivers/misc/mei/pci-me.c b/drivers/misc/mei/pci-me.c -index a738253dbd05..4e1c3fe09e53 100644 +index 33e58821e478..fde0ad009b17 100644 --- a/drivers/misc/mei/pci-me.c +++ b/drivers/misc/mei/pci-me.c -@@ -96,6 +96,7 @@ static const struct pci_device_id mei_me_pci_tbl[] = { +@@ -97,6 +97,7 @@ static const struct pci_device_id mei_me_pci_tbl[] = { {MEI_PCI_DEVICE(MEI_DEV_ID_CMP_H_3, MEI_ME_PCH8_ITOUCH_CFG)}, {MEI_PCI_DEVICE(MEI_DEV_ID_ICP_LP, MEI_ME_PCH12_CFG)}, @@ -962,7 +962,7 @@ index a738253dbd05..4e1c3fe09e53 100644 -- 2.36.1 -From c7d40fe3f9a803b17f8529caa7bc4b58c0a2e66a Mon Sep 17 00:00:00 2001 +From d4410624127fad830c6ee347453688765034593b Mon Sep 17 00:00:00 2001 From: Dorian Stoll <dorian.stoll@tmsp.io> Date: Thu, 6 Aug 2020 11:20:41 +0200 Subject: [PATCH] misc: Add support for Intel Precise Touch & Stylus @@ -1003,23 +1003,23 @@ Patchset: ipts create mode 100644 drivers/misc/ipts/uapi.h diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig -index 0f5a49fc7c9e..12b081bc875a 100644 +index 41d2bb0ae23a..effb258d4848 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig -@@ -487,4 +487,5 @@ source "drivers/misc/cardreader/Kconfig" +@@ -500,4 +500,5 @@ source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" source "drivers/misc/pvpanic/Kconfig" +source "drivers/misc/ipts/Kconfig" endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile -index a086197af544..972cae33ba36 100644 +index 70e800e9127f..a8d1e9447025 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile -@@ -59,3 +59,4 @@ obj-$(CONFIG_UACCE) += uacce/ - obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o +@@ -60,3 +60,4 @@ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o + obj-$(CONFIG_OPEN_DICE) += open-dice.o +obj-$(CONFIG_MISC_IPTS) += ipts/ diff --git a/drivers/misc/ipts/Kconfig b/drivers/misc/ipts/Kconfig new file mode 100644 @@ -2427,7 +2427,7 @@ index 000000000000..53fb86a88f97 -- 2.36.1 -From af203d5ea529b8d75dfcb53b993bd7c060d258a2 Mon Sep 17 00:00:00 2001 +From 4272f294f24ca0ac68c7acdbb9cbc7d86a094fa3 Mon Sep 17 00:00:00 2001 From: Liban Hannan <liban.p@gmail.com> Date: Tue, 12 Apr 2022 23:31:12 +0100 Subject: [PATCH] iommu: ipts: use IOMMU passthrough mode for IPTS @@ -2449,10 +2449,10 @@ Patchset: ipts 1 file changed, 24 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c -index ab2273300346..a91eed82bb39 100644 +index ba9a63cac47c..5f18ec206696 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c -@@ -57,6 +57,8 @@ +@@ -37,6 +37,8 @@ #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) #define IS_USB_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB) #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) @@ -2461,7 +2461,7 @@ index ab2273300346..a91eed82bb39 100644 #define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e) #define IOAPIC_RANGE_START (0xfee00000) -@@ -332,12 +334,14 @@ int intel_iommu_enabled = 0; +@@ -307,12 +309,14 @@ int intel_iommu_enabled = 0; EXPORT_SYMBOL_GPL(intel_iommu_enabled); static int dmar_map_gfx = 1; @@ -2476,7 +2476,7 @@ index ab2273300346..a91eed82bb39 100644 int intel_iommu_gfx_mapped; EXPORT_SYMBOL_GPL(intel_iommu_gfx_mapped); -@@ -2987,6 +2991,9 @@ static int device_def_domain_type(struct device *dev) +@@ -2724,6 +2728,9 @@ static int device_def_domain_type(struct device *dev) if ((iommu_identity_mapping & IDENTMAP_GFX) && IS_GFX_DEVICE(pdev)) return IOMMU_DOMAIN_IDENTITY; @@ -2486,7 +2486,7 @@ index ab2273300346..a91eed82bb39 100644 } return 0; -@@ -3423,6 +3430,9 @@ static int __init init_dmars(void) +@@ -3160,6 +3167,9 @@ static int __init init_dmars(void) if (!dmar_map_gfx) iommu_identity_mapping |= IDENTMAP_GFX; @@ -2496,7 +2496,7 @@ index ab2273300346..a91eed82bb39 100644 check_tylersburg_isoch(); ret = si_domain_init(hw_pass_through); -@@ -5664,6 +5674,17 @@ static void quirk_iommu_igfx(struct pci_dev *dev) +@@ -4931,6 +4941,17 @@ static void quirk_iommu_igfx(struct pci_dev *dev) dmar_map_gfx = 0; } @@ -2514,7 +2514,7 @@ index ab2273300346..a91eed82bb39 100644 /* G4x/GM45 integrated gfx dmar support is totally busted. */ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_igfx); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_igfx); -@@ -5699,6 +5720,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx); +@@ -4966,6 +4987,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163A, quirk_iommu_igfx); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163D, quirk_iommu_igfx); @@ -2527,9 +2527,66 @@ index ab2273300346..a91eed82bb39 100644 -- 2.36.1 -From a992351b539f71c2d037d717d09052d2a7c454fc Mon Sep 17 00:00:00 2001 +From 097657e71c5be762bf979a3113103a10fd2d7948 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Tue, 8 Jun 2021 00:24:47 +0200 +Date: Fri, 27 May 2022 04:34:36 +0200 +Subject: [PATCH] platform/surface: aggregator: Allow is_ssam_device() to be + used when CONFIG_SURFACE_AGGREGATOR_BUS is disabled + +In SSAM subsystem drivers that handle both ACPI and SSAM-native client +devices, we may want to check whether we have a SSAM (native) client +device. Further, we may want to do this even when instantiation thereof +cannot happen due to CONFIG_SURFACE_AGGREGATOR_BUS=n. Currently, doing +so causes an error due to an undefined reference error due to +ssam_device_type being placed in the bus source unit. + +Therefore, if CONFIG_SURFACE_AGGREGATOR_BUS is not defined, simply let +is_ssam_device() return false to prevent this error. + +Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-2-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Patchset: surface-sam +--- + include/linux/surface_aggregator/device.h | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h +index cc257097eb05..62b38b4487eb 100644 +--- a/include/linux/surface_aggregator/device.h ++++ b/include/linux/surface_aggregator/device.h +@@ -177,6 +177,8 @@ struct ssam_device_driver { + void (*remove)(struct ssam_device *sdev); + }; + ++#ifdef CONFIG_SURFACE_AGGREGATOR_BUS ++ + extern struct bus_type ssam_bus_type; + extern const struct device_type ssam_device_type; + +@@ -193,6 +195,15 @@ static inline bool is_ssam_device(struct device *d) + return d->type == &ssam_device_type; + } + ++#else /* CONFIG_SURFACE_AGGREGATOR_BUS */ ++ ++static inline bool is_ssam_device(struct device *d) ++{ ++ return false; ++} ++ ++#endif /* CONFIG_SURFACE_AGGREGATOR_BUS */ ++ + /** + * to_ssam_device() - Casts the given device to a SSAM client device. + * @d: The device to cast. +-- +2.36.1 + +From d562e9d16ba3e9c6c5ff1211e2b70144cedd82d2 Mon Sep 17 00:00:00 2001 +From: Maximilian Luz <luzmaximilian@gmail.com> +Date: Fri, 27 May 2022 04:34:37 +0200 Subject: [PATCH] platform/surface: aggregator: Allow devices to be marked as hot-removed @@ -2551,13 +2608,16 @@ used during client driver teardown to check if any communication attempts should be avoided. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-3-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- include/linux/surface_aggregator/device.h | 48 +++++++++++++++++++++-- 1 file changed, 45 insertions(+), 3 deletions(-) diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h -index cc257097eb05..491aa7e9f4bc 100644 +index 62b38b4487eb..6df7c8d4e50e 100644 --- a/include/linux/surface_aggregator/device.h +++ b/include/linux/surface_aggregator/device.h @@ -148,17 +148,30 @@ struct ssam_device_uid { @@ -2594,7 +2654,7 @@ index cc257097eb05..491aa7e9f4bc 100644 }; /** -@@ -240,6 +253,35 @@ struct ssam_device *ssam_device_alloc(struct ssam_controller *ctrl, +@@ -251,6 +264,35 @@ struct ssam_device *ssam_device_alloc(struct ssam_controller *ctrl, int ssam_device_add(struct ssam_device *sdev); void ssam_device_remove(struct ssam_device *sdev); @@ -2633,9 +2693,9 @@ index cc257097eb05..491aa7e9f4bc 100644 -- 2.36.1 -From 8c9b27fdeb07fd4c83bb0d9d79776f21640d39d6 Mon Sep 17 00:00:00 2001 +From 48200d7535f3220bc293f016965eceaf7b07c072 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Tue, 8 Jun 2021 00:48:22 +0200 +Date: Fri, 27 May 2022 04:34:38 +0200 Subject: [PATCH] platform/surface: aggregator: Allow notifiers to avoid communication on unregistering @@ -2655,6 +2715,9 @@ also add a convenience wrapper for those, defaulting to allow communication. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-4-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- .../driver-api/surface_aggregator/client.rst | 6 +- @@ -2849,10 +2912,10 @@ index 74bfdffaf7b0..50a2b4926c06 100644 int ssam_controller_event_enable(struct ssam_controller *ctrl, struct ssam_event_registry reg, diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h -index 491aa7e9f4bc..ad245c6b00d0 100644 +index 6df7c8d4e50e..c418f7f2732d 100644 --- a/include/linux/surface_aggregator/device.h +++ b/include/linux/surface_aggregator/device.h -@@ -472,4 +472,70 @@ static inline void ssam_remove_clients(struct device *dev) {} +@@ -483,4 +483,70 @@ static inline void ssam_remove_clients(struct device *dev) {} sdev->uid.instance, ret); \ } @@ -2926,9 +2989,9 @@ index 491aa7e9f4bc..ad245c6b00d0 100644 -- 2.36.1 -From 9c5a46d6a755d4c9546f44a4e13ef5a92bc98b2d Mon Sep 17 00:00:00 2001 +From dacf08a098a2e6f4e94d1e2942bc55650610f08b Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Tue, 8 Jun 2021 01:20:49 +0200 +Date: Fri, 27 May 2022 04:34:39 +0200 Subject: [PATCH] platform/surface: aggregator_registry: Use client device wrappers for notifier registration @@ -2936,6 +2999,9 @@ Use newly introduced client device wrapper functions for notifier registration and unregistration. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-5-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- drivers/platform/surface/surface_aggregator_registry.c | 6 +++--- @@ -2975,9 +3041,9 @@ index ce2bd88feeaa..9f630e890ff7 100644 -- 2.36.1 -From 86e1009150f92b4e756f6be81e80d45a42a9d497 Mon Sep 17 00:00:00 2001 +From d37dad7828ee0eb07f43a5fa8e65f4e42578aee0 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Thu, 28 Oct 2021 03:37:06 +0200 +Date: Fri, 27 May 2022 04:34:40 +0200 Subject: [PATCH] power/supply: surface_charger: Use client device wrappers for notifier registration @@ -2985,6 +3051,10 @@ Use newly introduced client device wrapper functions for notifier registration and unregistration. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-6-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- drivers/power/supply/surface_charger.c | 4 ++-- @@ -3015,9 +3085,9 @@ index a060c36c7766..59182d55742d 100644 -- 2.36.1 -From 033434def6261f801001c8d76b4a525b33b77372 Mon Sep 17 00:00:00 2001 +From aa33fbfcae2a5180a73a0c7c4d191b5a86dc3a5c Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Thu, 28 Oct 2021 03:38:09 +0200 +Date: Fri, 27 May 2022 04:34:41 +0200 Subject: [PATCH] power/supply: surface_battery: Use client device wrappers for notifier registration @@ -3025,6 +3095,10 @@ Use newly introduced client device wrapper functions for notifier registration and unregistration. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-7-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- drivers/power/supply/surface_battery.c | 4 ++-- @@ -3055,9 +3129,9 @@ index 5ec2e6bb2465..540707882bb0 100644 -- 2.36.1 -From 2971cc213e3adb104ac7de5a0feff4237a255166 Mon Sep 17 00:00:00 2001 +From 4e747fd2e517665eb7d8282b0c7c5c77b907e298 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Tue, 8 Jun 2021 01:33:02 +0200 +Date: Fri, 27 May 2022 04:34:42 +0200 Subject: [PATCH] HID: surface-hid: Add support for hot-removal Add support for hot-removal of SSAM HID client devices. @@ -3073,6 +3147,9 @@ prevent timeouts that can slow down device removal and cause issues, e.g. when quickly re-attaching the device. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-8-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- drivers/hid/surface-hid/surface_hid_core.c | 38 +++++++++++++++++++++- @@ -3166,9 +3243,9 @@ index e46330b2e561..87637f813de2 100644 -- 2.36.1 -From f579f070fff7d5245cc08e08f888e2522ac62024 Mon Sep 17 00:00:00 2001 +From 1261ddf08d3e8ea6a66fa8f3127e1e931b70dae3 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Sun, 31 Oct 2021 12:34:08 +0100 +Date: Fri, 27 May 2022 04:34:43 +0200 Subject: [PATCH] platform/surface: aggregator: Add comment for KIP subsystem category @@ -3183,6 +3260,9 @@ re-attached, as well as the state that the keyboard cover is currently in (e.g. folded-back, folded laptop-like, closed, etc.). Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-9-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- include/linux/surface_aggregator/serial_hub.h | 2 +- @@ -3204,9 +3284,9 @@ index c3de43edcffa..26b95ec12733 100644 -- 2.36.1 -From 8102d2904cbbddf212983a946dcbd3612dde060a Mon Sep 17 00:00:00 2001 +From 0bd82a6a348dc780edee3feb0c1619e74b9928e5 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Fri, 29 Apr 2022 22:42:32 +0200 +Date: Fri, 27 May 2022 04:34:44 +0200 Subject: [PATCH] platform/surface: aggregator_registry: Generify subsystem hub functionality @@ -3231,6 +3311,9 @@ Lastly, also drop the undocumented and unused sysfs "state" attribute of the base hub. It has at best been useful for debugging. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-10-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- .../surface/surface_aggregator_registry.c | 269 ++++++++++-------- @@ -3591,9 +3674,53 @@ index 9f630e890ff7..09cbeee2428b 100644 -- 2.36.1 -From 54a66b25ae897b15bb5bb5d5f4d930f3332f7c3f Mon Sep 17 00:00:00 2001 +From 29688869f641940bcf1a42b0dbeb0e7e55af47a3 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Fri, 29 Apr 2022 23:02:06 +0200 +Date: Fri, 27 May 2022 04:34:45 +0200 +Subject: [PATCH] platform/surface: aggregator_registry: Change device ID for + base hub + +Use the target category of the (base) hub as instance id in the +(virtual) hub device UID. This makes association of the hub with the +respective subsystem easier. + +Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-11-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> +Patchset: surface-sam +--- + drivers/platform/surface/surface_aggregator_registry.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c +index 09cbeee2428b..b11ce87c7184 100644 +--- a/drivers/platform/surface/surface_aggregator_registry.c ++++ b/drivers/platform/surface/surface_aggregator_registry.c +@@ -43,7 +43,7 @@ static const struct software_node ssam_node_root = { + + /* Base device hub (devices attached to Surface Book 3 base). */ + static const struct software_node ssam_node_hub_base = { +- .name = "ssam:00:00:02:00:00", ++ .name = "ssam:00:00:02:11:00", + .parent = &ssam_node_root, + }; + +@@ -535,7 +535,7 @@ static int ssam_base_hub_probe(struct ssam_device *sdev) + } + + static const struct ssam_device_id ssam_base_hub_match[] = { +- { SSAM_VDEV(HUB, 0x02, SSAM_ANY_IID, 0x00) }, ++ { SSAM_VDEV(HUB, 0x02, SSAM_SSH_TC_BAS, 0x00) }, + { }, + }; + +-- +2.36.1 + +From 431a0450a5d32e9091a248f8a81acea4b2188699 Mon Sep 17 00:00:00 2001 +From: Maximilian Luz <luzmaximilian@gmail.com> +Date: Fri, 27 May 2022 04:34:46 +0200 Subject: [PATCH] platform/surface: aggregator_registry: Add KIP device hub Add a Surface System Aggregator Module (SSAM) client device hub for @@ -3614,13 +3741,16 @@ been (re-)attached. To do this, use the previously generified SSAM subsystem hub framework. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-12-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- .../surface/surface_aggregator_registry.c | 103 +++++++++++++++++- 1 file changed, 101 insertions(+), 2 deletions(-) diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c -index 09cbeee2428b..1e60435c7cce 100644 +index b11ce87c7184..f15cef60630f 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -551,6 +551,93 @@ static struct ssam_device_driver ssam_base_hub_driver = { @@ -3698,7 +3828,7 @@ index 09cbeee2428b..1e60435c7cce 100644 +} + +static const struct ssam_device_id ssam_kip_hub_match[] = { -+ { SSAM_SDEV(KIP, 0x01, 0x00, 0x00) }, ++ { SSAM_VDEV(HUB, 0x01, SSAM_SSH_TC_KIP, 0x00) }, + { }, +}; + @@ -3753,9 +3883,9 @@ index 09cbeee2428b..1e60435c7cce 100644 -- 2.36.1 -From 6a2326ef63c3ac8b8dc45c6efee6933f649a1618 Mon Sep 17 00:00:00 2001 +From f61f1f111b7b347e642755879542bc8c4778617f Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Wed, 27 Oct 2021 22:33:03 +0200 +Date: Fri, 27 May 2022 04:34:47 +0200 Subject: [PATCH] platform/surface: aggregator_registry: Add support for keyboard cover on Surface Pro 8 @@ -3778,28 +3908,31 @@ need to be registered under the KIP device hub, which in turn will remove and re-create/re-initialize those devices as needed. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Link: https://lore.kernel.org/r/20220527023447.2460025-13-luzmaximilian@gmail.com +Reviewed-by: Hans de Goede <hdegoede@redhat.com> +Signed-off-by: Hans de Goede <hdegoede@redhat.com> Patchset: surface-sam --- .../surface/surface_aggregator_registry.c | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c -index 1e60435c7cce..ab69669316bd 100644 +index f15cef60630f..bf3303f1aa71 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c -@@ -47,6 +47,12 @@ static const struct software_node ssam_node_hub_base = { - .parent = &ssam_node_root, +@@ -41,6 +41,12 @@ static const struct software_node ssam_node_root = { + .name = "ssam_platform_hub", }; +/* KIP device hub (connects keyboard cover devices on Surface Pro 8). */ +static const struct software_node ssam_node_hub_kip = { -+ .name = "ssam:01:0e:01:00:00", ++ .name = "ssam:00:00:01:0e:00", + .parent = &ssam_node_root, +}; + - /* AC adapter. */ - static const struct software_node ssam_node_bat_ac = { - .name = "ssam:01:02:01:01:01", + /* Base device hub (devices attached to Surface Book 3 base). */ + static const struct software_node ssam_node_hub_base = { + .name = "ssam:00:00:02:11:00", @@ -155,6 +161,30 @@ static const struct software_node ssam_node_hid_base_iid6 = { .parent = &ssam_node_hub_base, }; @@ -3851,7 +3984,436 @@ index 1e60435c7cce..ab69669316bd 100644 -- 2.36.1 -From 97b2239771769f3d843c72d143e7d683a7472700 Mon Sep 17 00:00:00 2001 +From a0044e1fad27f45d2bf251c831b37c78e10b6933 Mon Sep 17 00:00:00 2001 +From: Maximilian Luz <luzmaximilian@gmail.com> +Date: Tue, 14 Jun 2022 13:17:49 +0200 +Subject: [PATCH] platform/surface: aggregator: Reserve more event- and + target-categories + +With the introduction of the Surface Laptop Studio, more event- and +target categories have been added. Therefore, increase the number of +reserved events and extend the enum of know target categories to +accommodate this. + +Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Patchset: surface-sam +--- + drivers/platform/surface/aggregator/trace.h | 80 +++++++++++-------- + include/linux/surface_aggregator/serial_hub.h | 75 +++++++++-------- + 2 files changed, 85 insertions(+), 70 deletions(-) + +diff --git a/drivers/platform/surface/aggregator/trace.h b/drivers/platform/surface/aggregator/trace.h +index de64cf169060..cc9e73fbc18e 100644 +--- a/drivers/platform/surface/aggregator/trace.h ++++ b/drivers/platform/surface/aggregator/trace.h +@@ -76,7 +76,7 @@ TRACE_DEFINE_ENUM(SSAM_SSH_TC_HID); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_TCH); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_BKL); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_TAM); +-TRACE_DEFINE_ENUM(SSAM_SSH_TC_ACC); ++TRACE_DEFINE_ENUM(SSAM_SSH_TC_ACC0); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_UFI); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_USC); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_PEN); +@@ -85,6 +85,11 @@ TRACE_DEFINE_ENUM(SSAM_SSH_TC_AUD); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_SMC); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_KPD); + TRACE_DEFINE_ENUM(SSAM_SSH_TC_REG); ++TRACE_DEFINE_ENUM(SSAM_SSH_TC_SPT); ++TRACE_DEFINE_ENUM(SSAM_SSH_TC_SYS); ++TRACE_DEFINE_ENUM(SSAM_SSH_TC_ACC1); ++TRACE_DEFINE_ENUM(SSAM_SSH_TC_SHB); ++TRACE_DEFINE_ENUM(SSAM_SSH_TC_POS); + + #define SSAM_PTR_UID_LEN 9 + #define SSAM_U8_FIELD_NOT_APPLICABLE ((u16)-1) +@@ -229,40 +234,45 @@ static inline u32 ssam_trace_get_request_tc(const struct ssh_packet *p) + + #define ssam_show_ssh_tc(rqid) \ + __print_symbolic(rqid, \ +- { SSAM_SSH_TC_NOT_APPLICABLE, "N/A" }, \ +- { SSAM_SSH_TC_SAM, "SAM" }, \ +- { SSAM_SSH_TC_BAT, "BAT" }, \ +- { SSAM_SSH_TC_TMP, "TMP" }, \ +- { SSAM_SSH_TC_PMC, "PMC" }, \ +- { SSAM_SSH_TC_FAN, "FAN" }, \ +- { SSAM_SSH_TC_PoM, "PoM" }, \ +- { SSAM_SSH_TC_DBG, "DBG" }, \ +- { SSAM_SSH_TC_KBD, "KBD" }, \ +- { SSAM_SSH_TC_FWU, "FWU" }, \ +- { SSAM_SSH_TC_UNI, "UNI" }, \ +- { SSAM_SSH_TC_LPC, "LPC" }, \ +- { SSAM_SSH_TC_TCL, "TCL" }, \ +- { SSAM_SSH_TC_SFL, "SFL" }, \ +- { SSAM_SSH_TC_KIP, "KIP" }, \ +- { SSAM_SSH_TC_EXT, "EXT" }, \ +- { SSAM_SSH_TC_BLD, "BLD" }, \ +- { SSAM_SSH_TC_BAS, "BAS" }, \ +- { SSAM_SSH_TC_SEN, "SEN" }, \ +- { SSAM_SSH_TC_SRQ, "SRQ" }, \ +- { SSAM_SSH_TC_MCU, "MCU" }, \ +- { SSAM_SSH_TC_HID, "HID" }, \ +- { SSAM_SSH_TC_TCH, "TCH" }, \ +- { SSAM_SSH_TC_BKL, "BKL" }, \ +- { SSAM_SSH_TC_TAM, "TAM" }, \ +- { SSAM_SSH_TC_ACC, "ACC" }, \ +- { SSAM_SSH_TC_UFI, "UFI" }, \ +- { SSAM_SSH_TC_USC, "USC" }, \ +- { SSAM_SSH_TC_PEN, "PEN" }, \ +- { SSAM_SSH_TC_VID, "VID" }, \ +- { SSAM_SSH_TC_AUD, "AUD" }, \ +- { SSAM_SSH_TC_SMC, "SMC" }, \ +- { SSAM_SSH_TC_KPD, "KPD" }, \ +- { SSAM_SSH_TC_REG, "REG" } \ ++ { SSAM_SSH_TC_NOT_APPLICABLE, "N/A" }, \ ++ { SSAM_SSH_TC_SAM, "SAM" }, \ ++ { SSAM_SSH_TC_BAT, "BAT" }, \ ++ { SSAM_SSH_TC_TMP, "TMP" }, \ ++ { SSAM_SSH_TC_PMC, "PMC" }, \ ++ { SSAM_SSH_TC_FAN, "FAN" }, \ ++ { SSAM_SSH_TC_PoM, "PoM" }, \ ++ { SSAM_SSH_TC_DBG, "DBG" }, \ ++ { SSAM_SSH_TC_KBD, "KBD" }, \ ++ { SSAM_SSH_TC_FWU, "FWU" }, \ ++ { SSAM_SSH_TC_UNI, "UNI" }, \ ++ { SSAM_SSH_TC_LPC, "LPC" }, \ ++ { SSAM_SSH_TC_TCL, "TCL" }, \ ++ { SSAM_SSH_TC_SFL, "SFL" }, \ ++ { SSAM_SSH_TC_KIP, "KIP" }, \ ++ { SSAM_SSH_TC_EXT, "EXT" }, \ ++ { SSAM_SSH_TC_BLD, "BLD" }, \ ++ { SSAM_SSH_TC_BAS, "BAS" }, \ ++ { SSAM_SSH_TC_SEN, "SEN" }, \ ++ { SSAM_SSH_TC_SRQ, "SRQ" }, \ ++ { SSAM_SSH_TC_MCU, "MCU" }, \ ++ { SSAM_SSH_TC_HID, "HID" }, \ ++ { SSAM_SSH_TC_TCH, "TCH" }, \ ++ { SSAM_SSH_TC_BKL, "BKL" }, \ ++ { SSAM_SSH_TC_TAM, "TAM" }, \ ++ { SSAM_SSH_TC_ACC0, "ACC0" }, \ ++ { SSAM_SSH_TC_UFI, "UFI" }, \ ++ { SSAM_SSH_TC_USC, "USC" }, \ ++ { SSAM_SSH_TC_PEN, "PEN" }, \ ++ { SSAM_SSH_TC_VID, "VID" }, \ ++ { SSAM_SSH_TC_AUD, "AUD" }, \ ++ { SSAM_SSH_TC_SMC, "SMC" }, \ ++ { SSAM_SSH_TC_KPD, "KPD" }, \ ++ { SSAM_SSH_TC_REG, "REG" }, \ ++ { SSAM_SSH_TC_SPT, "SPT" }, \ ++ { SSAM_SSH_TC_SYS, "SYS" }, \ ++ { SSAM_SSH_TC_ACC1, "ACC1" }, \ ++ { SSAM_SSH_TC_SHB, "SMB" }, \ ++ { SSAM_SSH_TC_POS, "POS" } \ + ) + + DECLARE_EVENT_CLASS(ssam_frame_class, +diff --git a/include/linux/surface_aggregator/serial_hub.h b/include/linux/surface_aggregator/serial_hub.h +index 26b95ec12733..45501b6e54e8 100644 +--- a/include/linux/surface_aggregator/serial_hub.h ++++ b/include/linux/surface_aggregator/serial_hub.h +@@ -201,7 +201,7 @@ static inline u16 ssh_crc(const u8 *buf, size_t len) + * exception of zero, which is not an event ID. Thus, this is also the + * absolute maximum number of event handlers that can be registered. + */ +-#define SSH_NUM_EVENTS 34 ++#define SSH_NUM_EVENTS 38 + + /* + * SSH_NUM_TARGETS - The number of communication targets used in the protocol. +@@ -292,40 +292,45 @@ struct ssam_span { + * Windows driver. + */ + enum ssam_ssh_tc { +- /* Category 0x00 is invalid for EC use. */ +- SSAM_SSH_TC_SAM = 0x01, /* Generic system functionality, real-time clock. */ +- SSAM_SSH_TC_BAT = 0x02, /* Battery/power subsystem. */ +- SSAM_SSH_TC_TMP = 0x03, /* Thermal subsystem. */ +- SSAM_SSH_TC_PMC = 0x04, +- SSAM_SSH_TC_FAN = 0x05, +- SSAM_SSH_TC_PoM = 0x06, +- SSAM_SSH_TC_DBG = 0x07, +- SSAM_SSH_TC_KBD = 0x08, /* Legacy keyboard (Laptop 1/2). */ +- SSAM_SSH_TC_FWU = 0x09, +- SSAM_SSH_TC_UNI = 0x0a, +- SSAM_SSH_TC_LPC = 0x0b, +- SSAM_SSH_TC_TCL = 0x0c, +- SSAM_SSH_TC_SFL = 0x0d, +- SSAM_SSH_TC_KIP = 0x0e, /* Manages detachable peripherals (Pro X/8 keyboard cover) */ +- SSAM_SSH_TC_EXT = 0x0f, +- SSAM_SSH_TC_BLD = 0x10, +- SSAM_SSH_TC_BAS = 0x11, /* Detachment system (Surface Book 2/3). */ +- SSAM_SSH_TC_SEN = 0x12, +- SSAM_SSH_TC_SRQ = 0x13, +- SSAM_SSH_TC_MCU = 0x14, +- SSAM_SSH_TC_HID = 0x15, /* Generic HID input subsystem. */ +- SSAM_SSH_TC_TCH = 0x16, +- SSAM_SSH_TC_BKL = 0x17, +- SSAM_SSH_TC_TAM = 0x18, +- SSAM_SSH_TC_ACC = 0x19, +- SSAM_SSH_TC_UFI = 0x1a, +- SSAM_SSH_TC_USC = 0x1b, +- SSAM_SSH_TC_PEN = 0x1c, +- SSAM_SSH_TC_VID = 0x1d, +- SSAM_SSH_TC_AUD = 0x1e, +- SSAM_SSH_TC_SMC = 0x1f, +- SSAM_SSH_TC_KPD = 0x20, +- SSAM_SSH_TC_REG = 0x21, /* Extended event registry. */ ++ /* Category 0x00 is invalid for EC use. */ ++ SSAM_SSH_TC_SAM = 0x01, /* Generic system functionality, real-time clock. */ ++ SSAM_SSH_TC_BAT = 0x02, /* Battery/power subsystem. */ ++ SSAM_SSH_TC_TMP = 0x03, /* Thermal subsystem. */ ++ SSAM_SSH_TC_PMC = 0x04, ++ SSAM_SSH_TC_FAN = 0x05, ++ SSAM_SSH_TC_PoM = 0x06, ++ SSAM_SSH_TC_DBG = 0x07, ++ SSAM_SSH_TC_KBD = 0x08, /* Legacy keyboard (Laptop 1/2). */ ++ SSAM_SSH_TC_FWU = 0x09, ++ SSAM_SSH_TC_UNI = 0x0a, ++ SSAM_SSH_TC_LPC = 0x0b, ++ SSAM_SSH_TC_TCL = 0x0c, ++ SSAM_SSH_TC_SFL = 0x0d, ++ SSAM_SSH_TC_KIP = 0x0e, /* Manages detachable peripherals (Pro X/8 keyboard cover) */ ++ SSAM_SSH_TC_EXT = 0x0f, ++ SSAM_SSH_TC_BLD = 0x10, ++ SSAM_SSH_TC_BAS = 0x11, /* Detachment system (Surface Book 2/3). */ ++ SSAM_SSH_TC_SEN = 0x12, ++ SSAM_SSH_TC_SRQ = 0x13, ++ SSAM_SSH_TC_MCU = 0x14, ++ SSAM_SSH_TC_HID = 0x15, /* Generic HID input subsystem. */ ++ SSAM_SSH_TC_TCH = 0x16, ++ SSAM_SSH_TC_BKL = 0x17, ++ SSAM_SSH_TC_TAM = 0x18, ++ SSAM_SSH_TC_ACC0 = 0x19, ++ SSAM_SSH_TC_UFI = 0x1a, ++ SSAM_SSH_TC_USC = 0x1b, ++ SSAM_SSH_TC_PEN = 0x1c, ++ SSAM_SSH_TC_VID = 0x1d, ++ SSAM_SSH_TC_AUD = 0x1e, ++ SSAM_SSH_TC_SMC = 0x1f, ++ SSAM_SSH_TC_KPD = 0x20, ++ SSAM_SSH_TC_REG = 0x21, /* Extended event registry. */ ++ SSAM_SSH_TC_SPT = 0x22, ++ SSAM_SSH_TC_SYS = 0x23, ++ SSAM_SSH_TC_ACC1 = 0x24, ++ SSAM_SSH_TC_SHB = 0x25, ++ SSAM_SSH_TC_POS = 0x26, /* For obtaining Laptop Studio screen position. */ + }; + + +-- +2.36.1 + +From 0de5abea7880ab860df0db95fa4c1b990731a140 Mon Sep 17 00:00:00 2001 +From: Maximilian Luz <luzmaximilian@gmail.com> +Date: Thu, 16 Jun 2022 01:50:12 +0200 +Subject: [PATCH] platform/surface: aggregator: Add helper macros for requests + with argument and return value + +Add helper macros for synchronous stack-allocated Surface Aggregator +request with both argument and return value, similar to the current +argument-only and return-value-only ones. + +Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Patchset: surface-sam +--- + include/linux/surface_aggregator/controller.h | 125 ++++++++++++++++++ + include/linux/surface_aggregator/device.h | 36 +++++ + 2 files changed, 161 insertions(+) + +diff --git a/include/linux/surface_aggregator/controller.h b/include/linux/surface_aggregator/controller.h +index 50a2b4926c06..d11a1c6e3186 100644 +--- a/include/linux/surface_aggregator/controller.h ++++ b/include/linux/surface_aggregator/controller.h +@@ -469,6 +469,67 @@ struct ssam_request_spec_md { + return 0; \ + } + ++/** ++ * SSAM_DEFINE_SYNC_REQUEST_WR() - Define synchronous SAM request function with ++ * both argument and return value. ++ * @name: Name of the generated function. ++ * @atype: Type of the request's argument. ++ * @rtype: Type of the request's return value. ++ * @spec: Specification (&struct ssam_request_spec) defining the request. ++ * ++ * Defines a function executing the synchronous SAM request specified by @spec, ++ * with the request taking an argument of type @atype and having a return value ++ * of type @rtype. The generated function takes care of setting up the request ++ * and response structs, buffer allocation, as well as execution of the request ++ * itself, returning once the request has been fully completed. The required ++ * transport buffer will be allocated on the stack. ++ * ++ * The generated function is defined as ``static int name(struct ++ * ssam_controller *ctrl, const atype *arg, rtype *ret)``, returning the status ++ * of the request, which is zero on success and negative on failure. The ++ * ``ctrl`` parameter is the controller via which the request is sent. The ++ * request argument is specified via the ``arg`` pointer. The request's return ++ * value is written to the memory pointed to by the ``ret`` parameter. ++ * ++ * Refer to ssam_request_sync_onstack() for more details on the behavior of ++ * the generated function. ++ */ ++#define SSAM_DEFINE_SYNC_REQUEST_WR(name, atype, rtype, spec...) \ ++ static int name(struct ssam_controller *ctrl, const atype *arg, rtype *ret) \ ++ { \ ++ struct ssam_request_spec s = (struct ssam_request_spec)spec; \ ++ struct ssam_request rqst; \ ++ struct ssam_response rsp; \ ++ int status; \ ++ \ ++ rqst.target_category = s.target_category; \ ++ rqst.target_id = s.target_id; \ ++ rqst.command_id = s.command_id; \ ++ rqst.instance_id = s.instance_id; \ ++ rqst.flags = s.flags | SSAM_REQUEST_HAS_RESPONSE; \ ++ rqst.length = sizeof(atype); \ ++ rqst.payload = (u8 *)arg; \ ++ \ ++ rsp.capacity = sizeof(rtype); \ ++ rsp.length = 0; \ ++ rsp.pointer = (u8 *)ret; \ ++ \ ++ status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \ ++ if (status) \ ++ return status; \ ++ \ ++ if (rsp.length != sizeof(rtype)) { \ ++ struct device *dev = ssam_controller_device(ctrl); \ ++ dev_err(dev, \ ++ "rqst: invalid response length, expected %zu, got %zu (tc: %#04x, cid: %#04x)", \ ++ sizeof(rtype), rsp.length, rqst.target_category,\ ++ rqst.command_id); \ ++ return -EIO; \ ++ } \ ++ \ ++ return 0; \ ++ } ++ + /** + * SSAM_DEFINE_SYNC_REQUEST_MD_N() - Define synchronous multi-device SAM + * request function with neither argument nor return value. +@@ -613,6 +674,70 @@ struct ssam_request_spec_md { + return 0; \ + } + ++/** ++ * SSAM_DEFINE_SYNC_REQUEST_MD_WR() - Define synchronous multi-device SAM ++ * request function with both argument and return value. ++ * @name: Name of the generated function. ++ * @atype: Type of the request's argument. ++ * @rtype: Type of the request's return value. ++ * @spec: Specification (&struct ssam_request_spec_md) defining the request. ++ * ++ * Defines a function executing the synchronous SAM request specified by @spec, ++ * with the request taking an argument of type @atype and having a return value ++ * of type @rtype. Device specifying parameters are not hard-coded, but instead ++ * must be provided to the function. The generated function takes care of ++ * setting up the request and response structs, buffer allocation, as well as ++ * execution of the request itself, returning once the request has been fully ++ * completed. The required transport buffer will be allocated on the stack. ++ * ++ * The generated function is defined as ``static int name(struct ++ * ssam_controller *ctrl, u8 tid, u8 iid, const atype *arg, rtype *ret)``, ++ * returning the status of the request, which is zero on success and negative ++ * on failure. The ``ctrl`` parameter is the controller via which the request ++ * is sent, ``tid`` the target ID for the request, and ``iid`` the instance ID. ++ * The request argument is specified via the ``arg`` pointer. The request's ++ * return value is written to the memory pointed to by the ``ret`` parameter. ++ * ++ * Refer to ssam_request_sync_onstack() for more details on the behavior of ++ * the generated function. ++ */ ++#define SSAM_DEFINE_SYNC_REQUEST_MD_WR(name, atype, rtype, spec...) \ ++ static int name(struct ssam_controller *ctrl, u8 tid, u8 iid, \ ++ const atype *arg, rtype *ret) \ ++ { \ ++ struct ssam_request_spec_md s = (struct ssam_request_spec_md)spec; \ ++ struct ssam_request rqst; \ ++ struct ssam_response rsp; \ ++ int status; \ ++ \ ++ rqst.target_category = s.target_category; \ ++ rqst.target_id = tid; \ ++ rqst.command_id = s.command_id; \ ++ rqst.instance_id = iid; \ ++ rqst.flags = s.flags | SSAM_REQUEST_HAS_RESPONSE; \ ++ rqst.length = sizeof(atype); \ ++ rqst.payload = (u8 *)arg; \ ++ \ ++ rsp.capacity = sizeof(rtype); \ ++ rsp.length = 0; \ ++ rsp.pointer = (u8 *)ret; \ ++ \ ++ status = ssam_request_sync_onstack(ctrl, &rqst, &rsp, sizeof(atype)); \ ++ if (status) \ ++ return status; \ ++ \ ++ if (rsp.length != sizeof(rtype)) { \ ++ struct device *dev = ssam_controller_device(ctrl); \ ++ dev_err(dev, \ ++ "rqst: invalid response length, expected %zu, got %zu (tc: %#04x, cid: %#04x)", \ ++ sizeof(rtype), rsp.length, rqst.target_category,\ ++ rqst.command_id); \ ++ return -EIO; \ ++ } \ ++ \ ++ return 0; \ ++ } ++ + + /* -- Event notifier/callbacks. --------------------------------------------- */ + +diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h +index c418f7f2732d..6cf7e80312d5 100644 +--- a/include/linux/surface_aggregator/device.h ++++ b/include/linux/surface_aggregator/device.h +@@ -483,6 +483,42 @@ static inline void ssam_remove_clients(struct device *dev) {} + sdev->uid.instance, ret); \ + } + ++/** ++ * SSAM_DEFINE_SYNC_REQUEST_CL_WR() - Define synchronous client-device SAM ++ * request function with argument and return value. ++ * @name: Name of the generated function. ++ * @atype: Type of the request's argument. ++ * @rtype: Type of the request's return value. ++ * @spec: Specification (&struct ssam_request_spec_md) defining the request. ++ * ++ * Defines a function executing the synchronous SAM request specified by @spec, ++ * with the request taking an argument of type @atype and having a return value ++ * of type @rtype. Device specifying parameters are not hard-coded, but instead ++ * are provided via the client device, specifically its UID, supplied when ++ * calling this function. The generated function takes care of setting up the ++ * request struct, buffer allocation, as well as execution of the request ++ * itself, returning once the request has been fully completed. The required ++ * transport buffer will be allocated on the stack. ++ * ++ * The generated function is defined as ``static int name(struct ssam_device ++ * *sdev, const atype *arg, rtype *ret)``, returning the status of the request, ++ * which is zero on success and negative on failure. The ``sdev`` parameter ++ * specifies both the target device of the request and by association the ++ * controller via which the request is sent. The request's argument is ++ * specified via the ``arg`` pointer. The request's return value is written to ++ * the memory pointed to by the ``ret`` parameter. ++ * ++ * Refer to ssam_request_sync_onstack() for more details on the behavior of ++ * the generated function. ++ */ ++#define SSAM_DEFINE_SYNC_REQUEST_CL_WR(name, atype, rtype, spec...) \ ++ SSAM_DEFINE_SYNC_REQUEST_MD_WR(__raw_##name, atype, rtype, spec) \ ++ static int name(struct ssam_device *sdev, const atype *arg, rtype *ret) \ ++ { \ ++ return __raw_##name(sdev->ctrl, sdev->uid.target, \ ++ sdev->uid.instance, arg, ret); \ ++ } ++ + + /* -- Helpers for client-device notifiers. ---------------------------------- */ + +-- +2.36.1 + +From 87e36bd7600f7fcc19cabbf24226b0e93970aae0 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> Date: Tue, 8 Jun 2021 03:19:20 +0200 Subject: [PATCH] platform/surface: Add KIP tablet-mode switch @@ -3874,191 +4436,166 @@ Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> Patchset: surface-sam --- MAINTAINERS | 6 + - drivers/platform/surface/Kconfig | 22 ++ + drivers/platform/surface/Kconfig | 23 + drivers/platform/surface/Makefile | 1 + - .../surface/surface_kip_tablet_switch.c | 245 ++++++++++++++++++ - 4 files changed, 274 insertions(+) - create mode 100644 drivers/platform/surface/surface_kip_tablet_switch.c + .../surface/surface_aggregator_tabletsw.c | 535 ++++++++++++++++++ + 4 files changed, 565 insertions(+) + create mode 100644 drivers/platform/surface/surface_aggregator_tabletsw.c diff --git a/MAINTAINERS b/MAINTAINERS -index d9b2f1731ee0..4d83cd26e299 100644 +index f468864fd268..e8131f6d7a97 100644 --- a/MAINTAINERS +++ b/MAINTAINERS -@@ -12823,6 +12823,12 @@ L: platform-driver-x86@vger.kernel.org - S: Maintained - F: drivers/platform/surface/surface_hotplug.c +@@ -13035,6 +13035,12 @@ F: drivers/scsi/smartpqi/smartpqi*.[ch] + F: include/linux/cciss*.h + F: include/uapi/linux/cciss*.h -+MICROSOFT SURFACE KIP TABLET-MODE SWITCH ++MICROSOFT SURFACE AGGREGATOR TABLET-MODE SWITCH +M: Maximilian Luz <luzmaximilian@gmail.com> +L: platform-driver-x86@vger.kernel.org +S: Maintained -+F: drivers/platform/surface/surface_kip_tablet_switch.c ++F: drivers/platform/surface/surface_aggregator_tablet_switch.c + - MICROSOFT SURFACE PLATFORM PROFILE DRIVER + MICROSOFT SURFACE BATTERY AND AC DRIVERS M: Maximilian Luz <luzmaximilian@gmail.com> - L: platform-driver-x86@vger.kernel.org + L: linux-pm@vger.kernel.org diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig -index 463f1ec5c14e..9c228090c35b 100644 +index eb79fbed8059..b152e930cc84 100644 --- a/drivers/platform/surface/Kconfig +++ b/drivers/platform/surface/Kconfig -@@ -156,6 +156,28 @@ config SURFACE_HOTPLUG - 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. +@@ -99,6 +99,29 @@ config SURFACE_AGGREGATOR_REGISTRY + the respective client devices. Drivers for these devices still need to + be selected via the other options. -+config SURFACE_KIP_TABLET_SWITCH -+ tristate "Surface KIP Tablet-Mode Switch Driver" ++config SURFACE_AGGREGATOR_TABLET_SWITCH ++ tristate "Surface Aggregator Generic Tablet-Mode Switch Driver" + depends on SURFACE_AGGREGATOR + depends on SURFACE_AGGREGATOR_BUS + depends on INPUT + help + Provides a tablet-mode switch input device on Microsoft Surface models -+ using the KIP subsystem for detachable keyboards (e.g. keyboard -+ covers). ++ using the KIP subsystem for detachable keyboards (e.g. keyboard covers) ++ or the POS subsystem for device/screen posture changes. + + The KIP subsystem is used on newer Surface generations to handle -+ detachable input peripherals, specifically the keyboard cover -+ (containing keyboard and touchpad) on the Surface Pro 8. This module -+ provides a driver to let user-space know when the device should be -+ considered in tablet-mode due to the keyboard cover being detached or -+ folded back (essentially signaling when the keyboard is not available -+ for input). It does so by creating a tablet-mode switch input device, -+ sending the standard SW_TABLET_MODE event on mode change. ++ detachable input peripherals, specifically the keyboard cover (containing ++ keyboard and touchpad) on the Surface Pro 8 and Surface Pro X. The POS ++ subsystem is used for device posture change notifications on the Surface ++ Laptop Studio. This module provides a driver to let user-space know when ++ the device should be considered in tablet-mode due to the keyboard cover ++ being detached or folded back (essentially signaling when the keyboard is ++ not available for input). It does so by creating a tablet-mode switch ++ input device, sending the standard SW_TABLET_MODE event on mode change. + + Select M or Y here, if you want to provide tablet-mode switch input -+ events on the Surface Pro 8. ++ events on the Surface Pro 8, Surface Pro X, and Surface Laptop Studio. + - config SURFACE_PLATFORM_PROFILE - tristate "Surface Platform Profile Driver" - depends on ACPI + config SURFACE_DTX + tristate "Surface DTX (Detachment System) Driver" + depends on SURFACE_AGGREGATOR diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile -index 32889482de55..6d9291c993c4 100644 +index 0fc9cd3e4dd9..18b27898543e 100644 --- a/drivers/platform/surface/Makefile +++ b/drivers/platform/surface/Makefile -@@ -14,5 +14,6 @@ obj-$(CONFIG_SURFACE_AGGREGATOR_REGISTRY) += surface_aggregator_registry.o +@@ -10,6 +10,7 @@ obj-$(CONFIG_SURFACE_ACPI_NOTIFY) += surface_acpi_notify.o + obj-$(CONFIG_SURFACE_AGGREGATOR) += aggregator/ + obj-$(CONFIG_SURFACE_AGGREGATOR_CDEV) += surface_aggregator_cdev.o + obj-$(CONFIG_SURFACE_AGGREGATOR_REGISTRY) += surface_aggregator_registry.o ++obj-$(CONFIG_SURFACE_AGGREGATOR_TABLET_SWITCH) += surface_aggregator_tabletsw.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_KIP_TABLET_SWITCH) += surface_kip_tablet_switch.o - obj-$(CONFIG_SURFACE_PLATFORM_PROFILE) += surface_platform_profile.o - obj-$(CONFIG_SURFACE_PRO3_BUTTON) += surfacepro3_button.o -diff --git a/drivers/platform/surface/surface_kip_tablet_switch.c b/drivers/platform/surface/surface_kip_tablet_switch.c +diff --git a/drivers/platform/surface/surface_aggregator_tabletsw.c b/drivers/platform/surface/surface_aggregator_tabletsw.c new file mode 100644 -index 000000000000..27371da71ef2 +index 000000000000..6f402d2ca894 --- /dev/null -+++ b/drivers/platform/surface/surface_kip_tablet_switch.c -@@ -0,0 +1,245 @@ ++++ b/drivers/platform/surface/surface_aggregator_tabletsw.c +@@ -0,0 +1,535 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* -+ * Surface System Aggregator Module (SSAM) tablet mode switch via KIP -+ * subsystem. ++ * Surface System Aggregator Module (SSAM) tablet mode switch driver. + * + * Copyright (C) 2022 Maximilian Luz <luzmaximilian@gmail.com> + */ + ++#include <asm/unaligned.h> +#include <linux/input.h> +#include <linux/kernel.h> +#include <linux/module.h> -+#include <linux/platform_device.h> +#include <linux/types.h> +#include <linux/workqueue.h> + +#include <linux/surface_aggregator/controller.h> +#include <linux/surface_aggregator/device.h> + -+#define SSAM_EVENT_KIP_CID_LID_STATE 0x1d + -+enum ssam_kip_lid_state { -+ SSAM_KIP_LID_STATE_DISCONNECTED = 0x01, -+ SSAM_KIP_LID_STATE_CLOSED = 0x02, -+ SSAM_KIP_LID_STATE_LAPTOP = 0x03, -+ SSAM_KIP_LID_STATE_FOLDED_CANVAS = 0x04, -+ SSAM_KIP_LID_STATE_FOLDED_BACK = 0x05, ++/* -- SSAM generic tablet switch driver framework. -------------------------- */ ++ ++struct ssam_tablet_sw; ++ ++struct ssam_tablet_sw_ops { ++ int (*get_state)(struct ssam_tablet_sw *sw, u32 *state); ++ const char *(*state_name)(struct ssam_tablet_sw *sw, u32 state); ++ bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw, u32 state); +}; + -+struct ssam_kip_sw { ++struct ssam_tablet_sw { + struct ssam_device *sdev; + -+ enum ssam_kip_lid_state state; ++ u32 state; + struct work_struct update_work; + struct input_dev *mode_switch; + ++ struct ssam_tablet_sw_ops ops; + struct ssam_event_notifier notif; +}; + -+SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_get_lid_state, u8, { -+ .target_category = SSAM_SSH_TC_KIP, -+ .target_id = 0x01, -+ .command_id = 0x1d, -+ .instance_id = 0x00, -+}); -+ -+static int ssam_kip_get_lid_state(struct ssam_kip_sw *sw, enum ssam_kip_lid_state *state) -+{ -+ int status; -+ u8 raw; ++struct ssam_tablet_sw_desc { ++ struct { ++ const char *name; ++ const char *phys; ++ } dev; + -+ status = ssam_retry(__ssam_kip_get_lid_state, sw->sdev->ctrl, &raw); -+ if (status < 0) { -+ dev_err(&sw->sdev->dev, "failed to query KIP lid state: %d\n", status); -+ return status; -+ } ++ struct { ++ u32 (*notify)(struct ssam_event_notifier *nf, const struct ssam_event *event); ++ int (*get_state)(struct ssam_tablet_sw *sw, u32 *state); ++ const char *(*state_name)(struct ssam_tablet_sw *sw, u32 state); ++ bool (*state_is_tablet_mode)(struct ssam_tablet_sw *sw, u32 state); ++ } ops; + -+ *state = raw; -+ return 0; -+} ++ struct { ++ struct ssam_event_registry reg; ++ struct ssam_event_id id; ++ enum ssam_event_mask mask; ++ u8 flags; ++ } event; ++}; + +static ssize_t state_show(struct device *dev, struct device_attribute *attr, char *buf) +{ -+ struct ssam_kip_sw *sw = dev_get_drvdata(dev); -+ const char *state; -+ -+ switch (sw->state) { -+ case SSAM_KIP_LID_STATE_DISCONNECTED: -+ state = "disconnected"; -+ break; -+ -+ case SSAM_KIP_LID_STATE_CLOSED: -+ state = "closed"; -+ break; -+ -+ case SSAM_KIP_LID_STATE_LAPTOP: -+ state = "laptop"; -+ break; -+ -+ case SSAM_KIP_LID_STATE_FOLDED_CANVAS: -+ state = "folded-canvas"; -+ break; -+ -+ case SSAM_KIP_LID_STATE_FOLDED_BACK: -+ state = "folded-back"; -+ break; -+ -+ default: -+ state = "<unknown>"; -+ dev_warn(dev, "unknown KIP lid state: %d\n", sw->state); -+ break; -+ } ++ struct ssam_tablet_sw *sw = dev_get_drvdata(dev); ++ const char *state = sw->ops.state_name(sw, sw->state); + + return sysfs_emit(buf, "%s\n", state); +} +static DEVICE_ATTR_RO(state); + -+static struct attribute *ssam_kip_sw_attrs[] = { ++static struct attribute *ssam_tablet_sw_attrs[] = { + &dev_attr_state.attr, + NULL, +}; + -+static const struct attribute_group ssam_kip_sw_group = { -+ .attrs = ssam_kip_sw_attrs, ++static const struct attribute_group ssam_tablet_sw_group = { ++ .attrs = ssam_tablet_sw_attrs, +}; + -+static void ssam_kip_sw_update_workfn(struct work_struct *work) ++static void ssam_tablet_sw_update_workfn(struct work_struct *work) +{ -+ struct ssam_kip_sw *sw = container_of(work, struct ssam_kip_sw, update_work); -+ enum ssam_kip_lid_state state; ++ struct ssam_tablet_sw *sw = container_of(work, struct ssam_tablet_sw, update_work); + int tablet, status; ++ u32 state; + -+ status = ssam_kip_get_lid_state(sw, &state); ++ status = sw->ops.get_state(sw, &state); + if (status) + return; + @@ -4067,52 +4604,48 @@ index 000000000000..27371da71ef2 + sw->state = state; + + /* Send SW_TABLET_MODE event. */ -+ tablet = state != SSAM_KIP_LID_STATE_LAPTOP; ++ tablet = sw->ops.state_is_tablet_mode(sw, state); + input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet); + input_sync(sw->mode_switch); +} + -+static u32 ssam_kip_sw_notif(struct ssam_event_notifier *nf, const struct ssam_event *event) ++static int __maybe_unused ssam_tablet_sw_resume(struct device *dev) +{ -+ struct ssam_kip_sw *sw = container_of(nf, struct ssam_kip_sw, notif); -+ -+ if (event->command_id != SSAM_EVENT_KIP_CID_LID_STATE) -+ return 0; /* Return "unhandled". */ -+ -+ if (event->length < 1) { -+ dev_err(&sw->sdev->dev, "unexpected payload size: %u\n", event->length); -+ return 0; -+ } -+ -+ schedule_work(&sw->update_work); -+ return SSAM_NOTIF_HANDLED; -+} -+ -+static int __maybe_unused ssam_kip_sw_resume(struct device *dev) -+{ -+ struct ssam_kip_sw *sw = dev_get_drvdata(dev); ++ struct ssam_tablet_sw *sw = dev_get_drvdata(dev); + + schedule_work(&sw->update_work); + return 0; +} -+static SIMPLE_DEV_PM_OPS(ssam_kip_sw_pm_ops, NULL, ssam_kip_sw_resume); ++static SIMPLE_DEV_PM_OPS(ssam_tablet_sw_pm_ops, NULL, ssam_tablet_sw_resume); + -+static int ssam_kip_sw_probe(struct ssam_device *sdev) ++static int ssam_tablet_sw_probe(struct ssam_device *sdev) +{ -+ struct ssam_kip_sw *sw; ++ const struct ssam_tablet_sw_desc *desc; ++ struct ssam_tablet_sw *sw; + int tablet, status; + ++ desc = ssam_device_get_match_data(sdev); ++ if (!desc) { ++ WARN(1, "no driver match data specified"); ++ return -EINVAL; ++ } ++ + sw = devm_kzalloc(&sdev->dev, sizeof(*sw), GFP_KERNEL); + if (!sw) + return -ENOMEM; + + sw->sdev = sdev; -+ INIT_WORK(&sw->update_work, ssam_kip_sw_update_workfn); ++ ++ sw->ops.get_state = desc->ops.get_state; ++ sw->ops.state_name = desc->ops.state_name; ++ sw->ops.state_is_tablet_mode = desc->ops.state_is_tablet_mode; ++ ++ INIT_WORK(&sw->update_work, ssam_tablet_sw_update_workfn); + + ssam_device_set_drvdata(sdev, sw); + + /* Get initial state. */ -+ status = ssam_kip_get_lid_state(sw, &sw->state); ++ status = sw->ops.get_state(sw, &sw->state); + if (status) + return status; + @@ -4121,12 +4654,12 @@ index 000000000000..27371da71ef2 + if (!sw->mode_switch) + return -ENOMEM; + -+ sw->mode_switch->name = "Microsoft Surface KIP Tablet Mode Switch"; -+ sw->mode_switch->phys = "ssam/01:0e:01:00:01/input0"; ++ sw->mode_switch->name = desc->dev.name; ++ sw->mode_switch->phys = desc->dev.phys; + sw->mode_switch->id.bustype = BUS_HOST; + sw->mode_switch->dev.parent = &sdev->dev; + -+ tablet = sw->state != SSAM_KIP_LID_STATE_LAPTOP; ++ tablet = sw->ops.state_is_tablet_mode(sw, sw->state); + input_set_capability(sw->mode_switch, EV_SW, SW_TABLET_MODE); + input_report_switch(sw->mode_switch, SW_TABLET_MODE, tablet); + @@ -4136,18 +4669,17 @@ index 000000000000..27371da71ef2 + + /* Set up notifier. */ + sw->notif.base.priority = 0; -+ sw->notif.base.fn = ssam_kip_sw_notif; -+ sw->notif.event.reg = SSAM_EVENT_REGISTRY_SAM; -+ sw->notif.event.id.target_category = SSAM_SSH_TC_KIP, -+ sw->notif.event.id.instance = 0, -+ sw->notif.event.mask = SSAM_EVENT_MASK_TARGET; ++ sw->notif.base.fn = desc->ops.notify; ++ sw->notif.event.reg = desc->event.reg; ++ sw->notif.event.id = desc->event.id; ++ sw->notif.event.mask = desc->event.mask; + sw->notif.event.flags = SSAM_EVENT_SEQUENCED; + + status = ssam_device_notifier_register(sdev, &sw->notif); + if (status) + return status; + -+ status = sysfs_create_group(&sdev->dev.kobj, &ssam_kip_sw_group); ++ status = sysfs_create_group(&sdev->dev.kobj, &ssam_tablet_sw_group); + if (status) + goto err; + @@ -4161,41 +4693,363 @@ index 000000000000..27371da71ef2 + return status; +} + -+static void ssam_kip_sw_remove(struct ssam_device *sdev) ++static void ssam_tablet_sw_remove(struct ssam_device *sdev) +{ -+ struct ssam_kip_sw *sw = ssam_device_get_drvdata(sdev); ++ struct ssam_tablet_sw *sw = ssam_device_get_drvdata(sdev); + -+ sysfs_remove_group(&sdev->dev.kobj, &ssam_kip_sw_group); ++ sysfs_remove_group(&sdev->dev.kobj, &ssam_tablet_sw_group); + + ssam_device_notifier_unregister(sdev, &sw->notif); + cancel_work_sync(&sw->update_work); +} + -+static const struct ssam_device_id ssam_kip_sw_match[] = { -+ { SSAM_SDEV(KIP, 0x01, 0x00, 0x01) }, ++ ++/* -- SSAM KIP tablet switch implementation. -------------------------------- */ ++ ++#define SSAM_EVENT_KIP_CID_COVER_STATE_CHANGED 0x1d ++ ++enum ssam_kip_cover_state { ++ SSAM_KIP_COVER_STATE_DISCONNECTED = 0x01, ++ SSAM_KIP_COVER_STATE_CLOSED = 0x02, ++ SSAM_KIP_COVER_STATE_LAPTOP = 0x03, ++ SSAM_KIP_COVER_STATE_FOLDED_CANVAS = 0x04, ++ SSAM_KIP_COVER_STATE_FOLDED_BACK = 0x05, ++}; ++ ++static const char* ssam_kip_cover_state_name(struct ssam_tablet_sw *sw, u32 state) ++{ ++ switch (state) { ++ case SSAM_KIP_COVER_STATE_DISCONNECTED: ++ return "disconnected"; ++ ++ case SSAM_KIP_COVER_STATE_CLOSED: ++ return "closed"; ++ ++ case SSAM_KIP_COVER_STATE_LAPTOP: ++ return "laptop"; ++ ++ case SSAM_KIP_COVER_STATE_FOLDED_CANVAS: ++ return "folded-canvas"; ++ ++ case SSAM_KIP_COVER_STATE_FOLDED_BACK: ++ return "folded-back"; ++ ++ default: ++ dev_warn(&sw->sdev->dev, "unknown KIP cover state: %u\n", state); ++ return "<unknown>"; ++ } ++} ++ ++static bool ssam_kip_cover_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 state) ++{ ++ switch (state) { ++ case SSAM_KIP_COVER_STATE_DISCONNECTED: ++ case SSAM_KIP_COVER_STATE_FOLDED_CANVAS: ++ case SSAM_KIP_COVER_STATE_FOLDED_BACK: ++ return true; ++ ++ case SSAM_KIP_COVER_STATE_CLOSED: ++ case SSAM_KIP_COVER_STATE_LAPTOP: ++ return false; ++ ++ default: ++ dev_warn(&sw->sdev->dev, "unknown KIP cover state: %d\n", sw->state); ++ return true; ++ } ++} ++ ++SSAM_DEFINE_SYNC_REQUEST_R(__ssam_kip_get_cover_state, u8, { ++ .target_category = SSAM_SSH_TC_KIP, ++ .target_id = 0x01, ++ .command_id = 0x1d, ++ .instance_id = 0x00, ++}); ++ ++static int ssam_kip_get_cover_state(struct ssam_tablet_sw *sw, u32 *state) ++{ ++ int status; ++ u8 raw; ++ ++ status = ssam_retry(__ssam_kip_get_cover_state, sw->sdev->ctrl, &raw); ++ if (status < 0) { ++ dev_err(&sw->sdev->dev, "failed to query KIP lid state: %d\n", status); ++ return status; ++ } ++ ++ *state = raw; ++ return 0; ++} ++ ++static u32 ssam_kip_sw_notif(struct ssam_event_notifier *nf, const struct ssam_event *event) ++{ ++ struct ssam_tablet_sw *sw = container_of(nf, struct ssam_tablet_sw, notif); ++ ++ if (event->command_id != SSAM_EVENT_KIP_CID_COVER_STATE_CHANGED) ++ return 0; /* Return "unhandled". */ ++ ++ if (event->length < 1) { ++ dev_warn(&sw->sdev->dev, "unexpected payload size: %u\n", event->length); ++ } ++ ++ schedule_work(&sw->update_work); ++ return SSAM_NOTIF_HANDLED; ++} ++ ++static const struct ssam_tablet_sw_desc ssam_kip_sw_desc = { ++ .dev = { ++ .name = "Microsoft Surface KIP Tablet Mode Switch", ++ .phys = "ssam/01:0e:01:00:01/input0", ++ }, ++ .ops = { ++ .notify = ssam_kip_sw_notif, ++ .get_state = ssam_kip_get_cover_state, ++ .state_name = ssam_kip_cover_state_name, ++ .state_is_tablet_mode = ssam_kip_cover_state_is_tablet_mode, ++ }, ++ .event = { ++ .reg = SSAM_EVENT_REGISTRY_SAM, ++ .id = { ++ .target_category = SSAM_SSH_TC_KIP, ++ .instance = 0, ++ }, ++ .mask = SSAM_EVENT_MASK_TARGET, ++ }, ++}; ++ ++ ++/* -- SSAM POS tablet switch implementation. -------------------------------- */ ++ ++static bool tablet_mode_in_slate_state = true; ++module_param(tablet_mode_in_slate_state, bool, S_IRUGO); ++MODULE_PARM_DESC(tablet_mode_in_slate_state, "Enable tablet mode in slate device posture, default is 'true'"); ++ ++#define SSAM_EVENT_POS_CID_POSTURE_CHANGED 0x03 ++#define SSAM_POS_MAX_SOURCES 4 ++ ++enum ssam_pos_state { ++ SSAM_POS_POSTURE_LID_CLOSED = 0x00, ++ SSAM_POS_POSTURE_LAPTOP = 0x01, ++ SSAM_POS_POSTURE_SLATE = 0x02, ++ SSAM_POS_POSTURE_TABLET = 0x03, ++}; ++ ++struct ssam_sources_list { ++ __le32 count; ++ __le32 id[SSAM_POS_MAX_SOURCES]; ++} __packed; ++ ++static const char* ssam_pos_state_name(struct ssam_tablet_sw *sw, u32 state) ++{ ++ switch (state) { ++ case SSAM_POS_POSTURE_LID_CLOSED: ++ return "closed"; ++ ++ case SSAM_POS_POSTURE_LAPTOP: ++ return "laptop"; ++ ++ case SSAM_POS_POSTURE_SLATE: ++ return "slate"; ++ ++ case SSAM_POS_POSTURE_TABLET: ++ return "tablet"; ++ ++ default: ++ dev_warn(&sw->sdev->dev, "unknown device posture: %u\n", state); ++ return "<unknown>"; ++ } ++} ++ ++static bool ssam_pos_state_is_tablet_mode(struct ssam_tablet_sw *sw, u32 state) ++{ ++ switch (state) { ++ case SSAM_POS_POSTURE_LAPTOP: ++ case SSAM_POS_POSTURE_LID_CLOSED: ++ return false; ++ ++ case SSAM_POS_POSTURE_SLATE: ++ return tablet_mode_in_slate_state; ++ ++ case SSAM_POS_POSTURE_TABLET: ++ return true; ++ ++ default: ++ dev_warn(&sw->sdev->dev, "unknown device posture: %u\n", state); ++ return true; ++ } ++} ++ ++static int ssam_pos_get_sources_list(struct ssam_tablet_sw *sw, struct ssam_sources_list *sources) ++{ ++ struct ssam_request rqst; ++ struct ssam_response rsp; ++ int status; ++ ++ rqst.target_category = SSAM_SSH_TC_POS; ++ rqst.target_id = 0x01; ++ rqst.command_id = 0x01; ++ rqst.instance_id = 0x00; ++ rqst.flags = SSAM_REQUEST_HAS_RESPONSE; ++ rqst.length = 0; ++ rqst.payload = NULL; ++ ++ rsp.capacity = sizeof(*sources); ++ rsp.length = 0; ++ rsp.pointer = (u8 *)sources; ++ ++ status = ssam_retry(ssam_request_sync_onstack, sw->sdev->ctrl, &rqst, &rsp, 0); ++ if (status) ++ return status; ++ ++ /* We need at least the 'sources->count' field. */ ++ if (rsp.length < sizeof(__le32)) { ++ dev_err(&sw->sdev->dev, "received source list response is too small\n"); ++ return -EPROTO; ++ } ++ ++ /* Make sure 'sources->count' matches with the response length. */ ++ if (get_unaligned_le32(&sources->count) * sizeof(__le32) + sizeof(__le32) != rsp.length) { ++ dev_err(&sw->sdev->dev, "mismatch between number of sources and response size\n"); ++ return -EPROTO; ++ } ++ ++ return 0; ++} ++ ++static int ssam_pos_get_source(struct ssam_tablet_sw *sw, u32 *source_id) ++{ ++ struct ssam_sources_list sources = {}; ++ int status; ++ ++ status = ssam_pos_get_sources_list(sw, &sources); ++ if (status) ++ return status; ++ ++ if (sources.count == 0) { ++ dev_err(&sw->sdev->dev, "no posture sources found\n"); ++ return -ENODEV; ++ } ++ ++ /* ++ * We currently don't know what to do with more than one posture souce. ++ * At the moment, only one source seems to be used/provided. The ++ * WARN_ON() here should hopefully let us know quickly once there is a ++ * device that provides multiple sources, at which point we can then ++ * try to figure out how to handle them. ++ */ ++ WARN_ON(sources.count > 1); ++ ++ *source_id = get_unaligned_le32(&sources.id[0]); ++ return 0; ++} ++ ++SSAM_DEFINE_SYNC_REQUEST_WR(__ssam_pos_get_posture_for_source, __le32, __le32, { ++ .target_category = SSAM_SSH_TC_POS, ++ .target_id = 0x01, ++ .command_id = 0x02, ++ .instance_id = 0x00, ++}); ++ ++static int ssam_pos_get_posture_for_source(struct ssam_tablet_sw *sw, u32 source_id, u32 *posture) ++{ ++ __le32 source_le = cpu_to_le32(source_id); ++ __le32 rspval_le = 0; ++ int status; ++ ++ status = ssam_retry(__ssam_pos_get_posture_for_source, sw->sdev->ctrl, ++ &source_le, &rspval_le); ++ if (status) ++ return status; ++ ++ *posture = le32_to_cpu(rspval_le); ++ return 0; ++} ++ ++static int ssam_pos_get_posture(struct ssam_tablet_sw *sw, u32 *state) ++{ ++ u32 source_id; ++ int status; ++ ++ status = ssam_pos_get_source(sw, &source_id); ++ if (status) { ++ dev_err(&sw->sdev->dev, "failed to get posture source ID: %d\n", status); ++ return status; ++ } ++ ++ status = ssam_pos_get_posture_for_source(sw, source_id, state); ++ if (status) { ++ dev_err(&sw->sdev->dev, "failed to get posture value for source %u: %d\n", ++ source_id, status); ++ return status; ++ } ++ ++ return 0; ++} ++ ++static u32 ssam_pos_sw_notif(struct ssam_event_notifier *nf, const struct ssam_event *event) ++{ ++ struct ssam_tablet_sw *sw = container_of(nf, struct ssam_tablet_sw, notif); ++ ++ if (event->command_id != SSAM_EVENT_POS_CID_POSTURE_CHANGED) ++ return 0; /* Return "unhandled". */ ++ ++ if (event->length != sizeof(__le32) * 3) { ++ dev_warn(&sw->sdev->dev, "unexpected payload size: %u\n", event->length); ++ } ++ ++ schedule_work(&sw->update_work); ++ return SSAM_NOTIF_HANDLED; ++} ++ ++static const struct ssam_tablet_sw_desc ssam_pos_sw_desc = { ++ .dev = { ++ .name = "Microsoft Surface POS Tablet Mode Switch", ++ .phys = "ssam/01:26:01:00:01/input0", ++ }, ++ .ops = { ++ .notify = ssam_pos_sw_notif, ++ .get_state = ssam_pos_get_posture, ++ .state_name = ssam_pos_state_name, ++ .state_is_tablet_mode = ssam_pos_state_is_tablet_mode, ++ }, ++ .event = { ++ .reg = SSAM_EVENT_REGISTRY_SAM, ++ .id = { ++ .target_category = SSAM_SSH_TC_POS, ++ .instance = 0, ++ }, ++ .mask = SSAM_EVENT_MASK_TARGET, ++ }, ++}; ++ ++ ++/* -- Driver registration. -------------------------------------------------- */ ++ ++static const struct ssam_device_id ssam_tablet_sw_match[] = { ++ { SSAM_SDEV(KIP, 0x01, 0x00, 0x01), (unsigned long)&ssam_kip_sw_desc }, ++ { SSAM_SDEV(POS, 0x01, 0x00, 0x01), (unsigned long)&ssam_pos_sw_desc }, + { }, +}; -+MODULE_DEVICE_TABLE(ssam, ssam_kip_sw_match); ++MODULE_DEVICE_TABLE(ssam, ssam_tablet_sw_match); + -+static struct ssam_device_driver ssam_kip_sw_driver = { -+ .probe = ssam_kip_sw_probe, -+ .remove = ssam_kip_sw_remove, -+ .match_table = ssam_kip_sw_match, ++static struct ssam_device_driver ssam_tablet_sw_driver = { ++ .probe = ssam_tablet_sw_probe, ++ .remove = ssam_tablet_sw_remove, ++ .match_table = ssam_tablet_sw_match, + .driver = { -+ .name = "surface_kip_tablet_mode_switch", ++ .name = "surface_aggregator_tablet_mode_switch", + .probe_type = PROBE_PREFER_ASYNCHRONOUS, -+ .pm = &ssam_kip_sw_pm_ops, ++ .pm = &ssam_tablet_sw_pm_ops, + }, +}; -+module_ssam_device_driver(ssam_kip_sw_driver); ++module_ssam_device_driver(ssam_tablet_sw_driver); + +MODULE_AUTHOR("Maximilian Luz <luzmaximilian@gmail.com>"); -+MODULE_DESCRIPTION("Tablet mode switch driver for Surface devices using KIP subsystem"); ++MODULE_DESCRIPTION("Tablet mode switch driver for Surface devices using the Surface Aggregator Module"); +MODULE_LICENSE("GPL"); -- 2.36.1 -From 58cb6fbb1b2613b195cdc7adfb7261888028e3c9 Mon Sep 17 00:00:00 2001 +From b5a8577c9a5de65f6954fbd2c952a6d97933482e Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> Date: Wed, 27 Oct 2021 22:33:03 +0200 Subject: [PATCH] platform/surface: aggregator_registry: Add support for tablet @@ -4213,7 +5067,7 @@ Patchset: surface-sam 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c -index ab69669316bd..c666392d4a9a 100644 +index bf3303f1aa71..8f249df673a4 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -77,6 +77,12 @@ static const struct software_node ssam_node_tmp_pprof = { @@ -4245,11 +5099,55 @@ index ab69669316bd..c666392d4a9a 100644 -- 2.36.1 -From a330b47584598d3b8c4e80993787d7e5f1a1784e Mon Sep 17 00:00:00 2001 +From b7a5dfd805b01a1867d3637c6e6d0a490c4fc903 Mon Sep 17 00:00:00 2001 +From: Maximilian Luz <luzmaximilian@gmail.com> +Date: Thu, 16 Jun 2022 02:30:16 +0200 +Subject: [PATCH] platform/surface: aggregator_registry: Add support for tablet + mode switch on Surface Laptop Studio + +Add a POS subsystem tablet-mode switch device for the Surface Laptop +Studio. The respective driver for this device provides SW_TABLET_MODE +input events for user-space based on the posture of the screen. + +Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> +Patchset: surface-sam +--- + drivers/platform/surface/surface_aggregator_registry.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c +index 8f249df673a4..f1c5905f1c16 100644 +--- a/drivers/platform/surface/surface_aggregator_registry.c ++++ b/drivers/platform/surface/surface_aggregator_registry.c +@@ -191,6 +191,12 @@ static const struct software_node ssam_node_hid_kip_iid5 = { + .parent = &ssam_node_hub_kip, + }; + ++/* Tablet-mode switch via POS subsystem. */ ++static const struct software_node ssam_node_pos_tablet_switch = { ++ .name = "ssam:01:26:01:00:01", ++ .parent = &ssam_node_root, ++}; ++ + /* + * Devices for 5th- and 6th-generations models: + * - Surface Book 2, +@@ -237,6 +243,7 @@ static const struct software_node *ssam_node_group_sls[] = { + &ssam_node_bat_ac, + &ssam_node_bat_main, + &ssam_node_tmp_pprof, ++ &ssam_node_pos_tablet_switch, + &ssam_node_hid_tid1_keyboard, + &ssam_node_hid_tid1_penstash, + &ssam_node_hid_tid1_touchpad, +-- +2.36.1 + +From b2d3071a17e7641ed2a87112b25927ee9582043e Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> Date: Sat, 21 May 2022 00:30:46 +0200 Subject: [PATCH] platform/surface: aggregator: Move device registry helper - function to core module + functions to core module Move helper functions for client device registration to the core module. This simplifies addition of future DT/OF support and also allows us to @@ -4472,10 +5370,10 @@ index abbbb5b08b07..4bba60884bb5 100644 - return bus_unregister(&ssam_bus_type); -} diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c -index c666392d4a9a..3261c8141841 100644 +index f1c5905f1c16..c680792a037e 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c -@@ -279,76 +279,6 @@ static const struct software_node *ssam_node_group_sp8[] = { +@@ -286,76 +286,6 @@ static const struct software_node *ssam_node_group_sp8[] = { }; @@ -4552,7 +5450,7 @@ index c666392d4a9a..3261c8141841 100644 /* -- SSAM generic subsystem hub driver framework. -------------------------- */ enum ssam_hub_state { -@@ -378,7 +308,6 @@ struct ssam_hub { +@@ -385,7 +315,6 @@ struct ssam_hub { static void ssam_hub_update_workfn(struct work_struct *work) { struct ssam_hub *hub = container_of(work, struct ssam_hub, update_work.work); @@ -4560,7 +5458,7 @@ index c666392d4a9a..3261c8141841 100644 enum ssam_hub_state state; int status = 0; -@@ -418,7 +347,7 @@ static void ssam_hub_update_workfn(struct work_struct *work) +@@ -425,7 +354,7 @@ static void ssam_hub_update_workfn(struct work_struct *work) hub->state = state; if (hub->state == SSAM_HUB_CONNECTED) @@ -4569,7 +5467,7 @@ index c666392d4a9a..3261c8141841 100644 else ssam_remove_clients(&hub->sdev->dev); -@@ -762,7 +691,7 @@ static int ssam_platform_hub_probe(struct platform_device *pdev) +@@ -769,7 +698,7 @@ static int ssam_platform_hub_probe(struct platform_device *pdev) set_secondary_fwnode(&pdev->dev, root); @@ -4579,10 +5477,10 @@ index c666392d4a9a..3261c8141841 100644 set_secondary_fwnode(&pdev->dev, NULL); software_node_unregister_node_group(nodes); diff --git a/include/linux/surface_aggregator/device.h b/include/linux/surface_aggregator/device.h -index ad245c6b00d0..6ae110e830b4 100644 +index 6cf7e80312d5..6e75fb605479 100644 --- a/include/linux/surface_aggregator/device.h +++ b/include/linux/surface_aggregator/device.h -@@ -364,11 +364,48 @@ void ssam_device_driver_unregister(struct ssam_device_driver *d); +@@ -375,11 +375,48 @@ void ssam_device_driver_unregister(struct ssam_device_driver *d); /* -- Helpers for controller and hub devices. ------------------------------- */ #ifdef CONFIG_SURFACE_AGGREGATOR_BUS @@ -4634,7 +5532,7 @@ index ad245c6b00d0..6ae110e830b4 100644 -- 2.36.1 -From cefc65cdcead1c23ab8a793d8a3779fed1e6f86d Mon Sep 17 00:00:00 2001 +From 05c3fb864633d525a61f9e11788cce689482040b Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> Date: Sat, 21 May 2022 00:39:56 +0200 Subject: [PATCH] platform/surface: aggregator: Move subsystem hub drivers to @@ -4649,18 +5547,36 @@ While doing so, also remove a small bit of code duplication. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> Patchset: surface-sam --- + MAINTAINERS | 6 + drivers/platform/surface/Kconfig | 35 +- drivers/platform/surface/Makefile | 1 + - .../platform/surface/surface_aggregator_hub.c | 363 +++++++++++++++++ + .../platform/surface/surface_aggregator_hub.c | 371 ++++++++++++++++++ .../surface/surface_aggregator_registry.c | 371 +----------------- - 4 files changed, 396 insertions(+), 374 deletions(-) + 5 files changed, 410 insertions(+), 374 deletions(-) create mode 100644 drivers/platform/surface/surface_aggregator_hub.c +diff --git a/MAINTAINERS b/MAINTAINERS +index e8131f6d7a97..119767089831 100644 +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -13112,6 +13112,12 @@ F: include/linux/surface_acpi_notify.h + F: include/linux/surface_aggregator/ + F: include/uapi/linux/surface_aggregator/ + ++MICROSOFT SURFACE SYSTEM AGGREGATOR HUB DRIVER ++M: Maximilian Luz <luzmaximilian@gmail.com> ++L: platform-driver-x86@vger.kernel.org ++S: Maintained ++F: drivers/platform/surface/surface_aggregator_hub.c ++ + MICROTEK X6 SCANNER + M: Oliver Neukum <oliver@neukum.org> + S: Maintained diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig -index 9c228090c35b..c685ec440535 100644 +index b152e930cc84..b629e82af97c 100644 --- a/drivers/platform/surface/Kconfig +++ b/drivers/platform/surface/Kconfig -@@ -79,18 +79,45 @@ config SURFACE_AGGREGATOR_CDEV +@@ -72,18 +72,45 @@ config SURFACE_AGGREGATOR_CDEV The provided interface is intended for debugging and development only, and should not be used otherwise. @@ -4711,23 +5627,23 @@ index 9c228090c35b..c685ec440535 100644 Devices provided via this registry are: - Platform profile (performance-/cooling-mode) device (5th- and later diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile -index 6d9291c993c4..fccd33e6780d 100644 +index 18b27898543e..53344330939b 100644 --- a/drivers/platform/surface/Makefile +++ b/drivers/platform/surface/Makefile -@@ -10,6 +10,7 @@ obj-$(CONFIG_SURFACE_3_POWER_OPREGION) += surface3_power.o +@@ -9,6 +9,7 @@ obj-$(CONFIG_SURFACE_3_POWER_OPREGION) += surface3_power.o obj-$(CONFIG_SURFACE_ACPI_NOTIFY) += surface_acpi_notify.o obj-$(CONFIG_SURFACE_AGGREGATOR) += aggregator/ obj-$(CONFIG_SURFACE_AGGREGATOR_CDEV) += surface_aggregator_cdev.o +obj-$(CONFIG_SURFACE_AGGREGATOR_HUB) += surface_aggregator_hub.o obj-$(CONFIG_SURFACE_AGGREGATOR_REGISTRY) += surface_aggregator_registry.o + obj-$(CONFIG_SURFACE_AGGREGATOR_TABLET_SWITCH) += surface_aggregator_tabletsw.o obj-$(CONFIG_SURFACE_DTX) += surface_dtx.o - obj-$(CONFIG_SURFACE_GPE) += surface_gpe.o diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c new file mode 100644 -index 000000000000..20b1c38debfe +index 000000000000..43061514be38 --- /dev/null +++ b/drivers/platform/surface/surface_aggregator_hub.c -@@ -0,0 +1,363 @@ +@@ -0,0 +1,371 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Surface System Aggregator Module (SSAM) subsystem device hubs. @@ -4760,6 +5676,12 @@ index 000000000000..20b1c38debfe + SSAM_HUB_HOT_REMOVED, +}; + ++struct ssam_hub; ++ ++struct ssam_hub_ops { ++ int (*get_state)(struct ssam_hub *hub, enum ssam_hub_state *state); ++}; ++ +struct ssam_hub { + struct ssam_device *sdev; + @@ -4770,20 +5692,20 @@ index 000000000000..20b1c38debfe + unsigned long connect_delay; + + struct ssam_event_notifier notif; -+ -+ int (*get_state)(struct ssam_hub *hub, enum ssam_hub_state *state); ++ struct ssam_hub_ops ops; +}; + -+struct ssam_hub_info { ++struct ssam_hub_desc { + struct { + struct ssam_event_registry reg; + struct ssam_event_id id; + enum ssam_event_mask mask; -+ u8 flags; + } event; + -+ u32 (*notify)(struct ssam_event_notifier *nf, const struct ssam_event *event); -+ int (*get_state)(struct ssam_hub *hub, enum ssam_hub_state *state); ++ struct { ++ u32 (*notify)(struct ssam_event_notifier *nf, const struct ssam_event *event); ++ int (*get_state)(struct ssam_hub *hub, enum ssam_hub_state *state); ++ } ops; + + unsigned long connect_delay_ms; +}; @@ -4794,7 +5716,7 @@ index 000000000000..20b1c38debfe + enum ssam_hub_state state; + int status = 0; + -+ status = hub->get_state(hub, &state); ++ status = hub->ops.get_state(hub, &state); + if (status) + return; + @@ -4878,12 +5800,12 @@ index 000000000000..20b1c38debfe + +static int ssam_hub_probe(struct ssam_device *sdev) +{ -+ const struct ssam_hub_info *info; ++ const struct ssam_hub_desc *desc; + struct ssam_hub *hub; + int status; + -+ info = ssam_device_get_match_data(sdev); -+ if (!info) { ++ desc = ssam_device_get_match_data(sdev); ++ if (!desc) { + WARN(1, "no driver match data specified"); + return -EINVAL; + } @@ -4896,14 +5818,14 @@ index 000000000000..20b1c38debfe + hub->state = SSAM_HUB_UNINITIALIZED; + + hub->notif.base.priority = INT_MAX; /* This notifier should run first. */ -+ hub->notif.base.fn = info->notify; -+ hub->notif.event.reg = info->event.reg; -+ hub->notif.event.id = info->event.id; -+ hub->notif.event.mask = info->event.mask; -+ hub->notif.event.flags = info->event.flags; ++ hub->notif.base.fn = desc->ops.notify; ++ hub->notif.event.reg = desc->event.reg; ++ hub->notif.event.id = desc->event.id; ++ hub->notif.event.mask = desc->event.mask; ++ hub->notif.event.flags = SSAM_EVENT_SEQUENCED; + -+ hub->connect_delay = msecs_to_jiffies(info->connect_delay_ms); -+ hub->get_state = info->get_state; ++ hub->connect_delay = msecs_to_jiffies(desc->connect_delay_ms); ++ hub->ops.get_state = desc->ops.get_state; + + INIT_DELAYED_WORK(&hub->update_work, ssam_hub_update_workfn); + @@ -4987,7 +5909,7 @@ index 000000000000..20b1c38debfe + return 0; +} + -+static const struct ssam_hub_info base_hub = { ++static const struct ssam_hub_desc base_hub = { + .event = { + .reg = SSAM_EVENT_REGISTRY_SAM, + .id = { @@ -4995,10 +5917,11 @@ index 000000000000..20b1c38debfe + .instance = 0, + }, + .mask = SSAM_EVENT_MASK_NONE, -+ .flags = SSAM_EVENT_SEQUENCED, + }, -+ .notify = ssam_base_hub_notif, -+ .get_state = ssam_base_hub_query_state, ++ .ops = { ++ .notify = ssam_base_hub_notif, ++ .get_state = ssam_base_hub_query_state, ++ }, + .connect_delay_ms = SSAM_BASE_UPDATE_CONNECT_DELAY, +}; + @@ -5051,7 +5974,7 @@ index 000000000000..20b1c38debfe + return SSAM_NOTIF_HANDLED; +} + -+static const struct ssam_hub_info kip_hub = { ++static const struct ssam_hub_desc kip_hub = { + .event = { + .reg = SSAM_EVENT_REGISTRY_SAM, + .id = { @@ -5059,10 +5982,11 @@ index 000000000000..20b1c38debfe + .instance = 0, + }, + .mask = SSAM_EVENT_MASK_TARGET, -+ .flags = SSAM_EVENT_SEQUENCED, + }, -+ .notify = ssam_kip_hub_notif, -+ .get_state = ssam_kip_hub_query_state, ++ .ops = { ++ .notify = ssam_kip_hub_notif, ++ .get_state = ssam_kip_hub_query_state, ++ }, + .connect_delay_ms = SSAM_KIP_UPDATE_CONNECT_DELAY, +}; + @@ -5070,8 +5994,8 @@ index 000000000000..20b1c38debfe +/* -- Driver registration. -------------------------------------------------- */ + +static const struct ssam_device_id ssam_hub_match[] = { -+ { SSAM_VDEV(HUB, 0x02, SSAM_ANY_IID, 0x00), (unsigned long)&base_hub }, -+ { SSAM_SDEV(KIP, 0x01, 0x00, 0x00), (unsigned long)&kip_hub }, ++ { SSAM_VDEV(HUB, 0x01, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub }, ++ { SSAM_VDEV(HUB, 0x02, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub }, + { } +}; +MODULE_DEVICE_TABLE(ssam, ssam_hub_match); @@ -5092,7 +6016,7 @@ index 000000000000..20b1c38debfe +MODULE_DESCRIPTION("Subsystem device hub driver for Surface System Aggregator Module"); +MODULE_LICENSE("GPL"); diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c -index 3261c8141841..11b51aa9ea73 100644 +index c680792a037e..0cbb7f3a6b2d 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -11,14 +11,11 @@ @@ -5110,7 +6034,7 @@ index 3261c8141841..11b51aa9ea73 100644 #include <linux/surface_aggregator/device.h> -@@ -279,335 +276,6 @@ static const struct software_node *ssam_node_group_sp8[] = { +@@ -286,335 +283,6 @@ static const struct software_node *ssam_node_group_sp8[] = { }; @@ -5340,7 +6264,7 @@ index 3261c8141841..11b51aa9ea73 100644 -} - -static const struct ssam_device_id ssam_base_hub_match[] = { -- { SSAM_VDEV(HUB, 0x02, SSAM_ANY_IID, 0x00) }, +- { SSAM_VDEV(HUB, 0x02, SSAM_SSH_TC_BAS, 0x00) }, - { }, -}; - @@ -5427,7 +6351,7 @@ index 3261c8141841..11b51aa9ea73 100644 -} - -static const struct ssam_device_id ssam_kip_hub_match[] = { -- { SSAM_SDEV(KIP, 0x01, 0x00, 0x00) }, +- { SSAM_VDEV(HUB, 0x01, SSAM_SSH_TC_KIP, 0x00) }, - { }, -}; - @@ -5446,7 +6370,7 @@ index 3261c8141841..11b51aa9ea73 100644 /* -- SSAM platform/meta-hub driver. ---------------------------------------- */ static const struct acpi_device_id ssam_platform_hub_match[] = { -@@ -720,44 +388,7 @@ static struct platform_driver ssam_platform_hub_driver = { +@@ -727,44 +395,7 @@ static struct platform_driver ssam_platform_hub_driver = { .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, }; @@ -5495,69 +6419,7 @@ index 3261c8141841..11b51aa9ea73 100644 -- 2.36.1 -From e2d2b665e1877096405e8c6b84922880d4bb795b Mon Sep 17 00:00:00 2001 -From: Maximilian Luz <luzmaximilian@gmail.com> -Date: Sat, 21 May 2022 00:51:05 +0200 -Subject: [PATCH] platform/surface: aggregator: Be consistent with hub device - IDs - -Currently, we use a virtual device ID for the base (BAS) hub but an -actual device ID for the KIP hub. Let's be consistent about the naming -format and make all hubs virtual, with their instance ID reflecting the -subsystem. - -Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com> -Patchset: surface-sam ---- - drivers/platform/surface/surface_aggregator_hub.c | 4 ++-- - .../platform/surface/surface_aggregator_registry.c | 12 ++++++------ - 2 files changed, 8 insertions(+), 8 deletions(-) - -diff --git a/drivers/platform/surface/surface_aggregator_hub.c b/drivers/platform/surface/surface_aggregator_hub.c -index 20b1c38debfe..c473bdebf90c 100644 ---- a/drivers/platform/surface/surface_aggregator_hub.c -+++ b/drivers/platform/surface/surface_aggregator_hub.c -@@ -340,8 +340,8 @@ static const struct ssam_hub_info kip_hub = { - /* -- Driver registration. -------------------------------------------------- */ - - static const struct ssam_device_id ssam_hub_match[] = { -- { SSAM_VDEV(HUB, 0x02, SSAM_ANY_IID, 0x00), (unsigned long)&base_hub }, -- { SSAM_SDEV(KIP, 0x01, 0x00, 0x00), (unsigned long)&kip_hub }, -+ { SSAM_VDEV(HUB, 0x01, SSAM_SSH_TC_KIP, 0x00), (unsigned long)&kip_hub }, -+ { SSAM_VDEV(HUB, 0x02, SSAM_SSH_TC_BAS, 0x00), (unsigned long)&base_hub }, - { } - }; - MODULE_DEVICE_TABLE(ssam, ssam_hub_match); -diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c -index 11b51aa9ea73..cee7121e7fa6 100644 ---- a/drivers/platform/surface/surface_aggregator_registry.c -+++ b/drivers/platform/surface/surface_aggregator_registry.c -@@ -38,15 +38,15 @@ static const struct software_node ssam_node_root = { - .name = "ssam_platform_hub", - }; - --/* Base device hub (devices attached to Surface Book 3 base). */ --static const struct software_node ssam_node_hub_base = { -- .name = "ssam:00:00:02:00:00", -+/* KIP device hub (connects keyboard cover devices on Surface Pro 8). */ -+static const struct software_node ssam_node_hub_kip = { -+ .name = "ssam:00:00:01:0e:00", - .parent = &ssam_node_root, - }; - --/* KIP device hub (connects keyboard cover devices on Surface Pro 8). */ --static const struct software_node ssam_node_hub_kip = { -- .name = "ssam:01:0e:01:00:00", -+/* Base device hub (devices attached to Surface Book 3 base). */ -+static const struct software_node ssam_node_hub_base = { -+ .name = "ssam:00:00:02:11:00", - .parent = &ssam_node_root, - }; - --- -2.36.1 - -From 525b0a215a224a430766886ae4f382f5684095f2 Mon Sep 17 00:00:00 2001 +From 8de2bf13dcbae29464f19bd544484586f3950a29 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> Date: Sat, 21 May 2022 00:57:40 +0200 Subject: [PATCH] platform/surface: Update copyright year of various drivers @@ -5770,7 +6632,7 @@ index 9c3cbae2d4bd..4e387a031351 100644 #ifndef _SURFACE_AGGREGATOR_SSH_REQUEST_LAYER_H diff --git a/drivers/platform/surface/aggregator/trace.h b/drivers/platform/surface/aggregator/trace.h -index de64cf169060..7be0bb097dea 100644 +index cc9e73fbc18e..2a2c17771d01 100644 --- a/drivers/platform/surface/aggregator/trace.h +++ b/drivers/platform/surface/aggregator/trace.h @@ -2,7 +2,7 @@ @@ -5783,7 +6645,7 @@ index de64cf169060..7be0bb097dea 100644 #undef TRACE_SYSTEM diff --git a/drivers/platform/surface/surface_acpi_notify.c b/drivers/platform/surface/surface_acpi_notify.c -index 8339988d95c1..acc958b43b57 100644 +index 7b758f8cc137..b0a83255d060 100644 --- a/drivers/platform/surface/surface_acpi_notify.c +++ b/drivers/platform/surface/surface_acpi_notify.c @@ -8,7 +8,7 @@ @@ -5809,7 +6671,7 @@ index 30fb50fde450..492c82e69182 100644 #include <linux/fs.h> diff --git a/drivers/platform/surface/surface_aggregator_registry.c b/drivers/platform/surface/surface_aggregator_registry.c -index cee7121e7fa6..3f81db28a702 100644 +index 0cbb7f3a6b2d..d5655f6a4a41 100644 --- a/drivers/platform/surface/surface_aggregator_registry.c +++ b/drivers/platform/surface/surface_aggregator_registry.c @@ -6,7 +6,7 @@ @@ -5835,7 +6697,7 @@ index 1203b9a82993..ed36944467f9 100644 #include <linux/fs.h> diff --git a/drivers/platform/surface/surface_gpe.c b/drivers/platform/surface/surface_gpe.c -index c1775db29efb..b7e48ba100b6 100644 +index ec66fde28e75..27365cbe1ee9 100644 --- a/drivers/platform/surface/surface_gpe.c +++ b/drivers/platform/surface/surface_gpe.c @@ -4,7 +4,7 @@ @@ -5876,7 +6738,7 @@ index 6373d3b5eb7f..fbf2e11fd6ce 100644 -- 2.36.1 -From 25d1faa2928596cc4902653225e57741688730a4 Mon Sep 17 00:00:00 2001 +From 28746d1a90e755dd3f55da6e66ce7e9726bfccf0 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 @@ -5933,10 +6795,10 @@ Patchset: surface-sam-over-hid 1 file changed, 35 insertions(+) diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c -index 85ed4c1d4924..942c1c9a4ea5 100644 +index 08b561f0709d..d7c397bce0f0 100644 --- a/drivers/i2c/i2c-core-acpi.c +++ b/drivers/i2c/i2c-core-acpi.c -@@ -624,6 +624,28 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client, +@@ -619,6 +619,28 @@ static int acpi_gsb_i2c_write_bytes(struct i2c_client *client, return (ret == 1) ? 0 : -EIO; } @@ -5965,7 +6827,7 @@ index 85ed4c1d4924..942c1c9a4ea5 100644 static acpi_status i2c_acpi_space_handler(u32 function, acpi_physical_address command, u32 bits, u64 *value64, -@@ -725,6 +747,19 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command, +@@ -720,6 +742,19 @@ i2c_acpi_space_handler(u32 function, acpi_physical_address command, } break; @@ -5988,7 +6850,7 @@ index 85ed4c1d4924..942c1c9a4ea5 100644 -- 2.36.1 -From 2ec19064dafe6c2150f2fab606ad38fcfdc757d0 Mon Sep 17 00:00:00 2001 +From 9d1d2f048b6080077fd57c755cb132c3fa8e7399 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 @@ -6011,12 +6873,12 @@ Patchset: surface-sam-over-hid create mode 100644 drivers/platform/surface/surfacebook1_dgpu_switch.c diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig -index c685ec440535..3d3659b87ba4 100644 +index b629e82af97c..68656e8f309e 100644 --- a/drivers/platform/surface/Kconfig +++ b/drivers/platform/surface/Kconfig -@@ -133,6 +133,13 @@ config SURFACE_AGGREGATOR_REGISTRY - the respective client devices. Drivers for these devices still need to - be selected via the other options. +@@ -149,6 +149,13 @@ config SURFACE_AGGREGATOR_TABLET_SWITCH + Select M or Y here, if you want to provide tablet-mode switch input + events on the Surface Pro 8, Surface Pro X, and Surface Laptop Studio. +config SURFACE_BOOK1_DGPU_SWITCH + tristate "Surface Book 1 dGPU Switch Driver" @@ -6029,13 +6891,13 @@ index c685ec440535..3d3659b87ba4 100644 tristate "Surface DTX (Detachment System) Driver" depends on SURFACE_AGGREGATOR diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile -index fccd33e6780d..20408730f425 100644 +index 53344330939b..7efcd0cdb532 100644 --- a/drivers/platform/surface/Makefile +++ b/drivers/platform/surface/Makefile -@@ -12,6 +12,7 @@ obj-$(CONFIG_SURFACE_AGGREGATOR) += aggregator/ - obj-$(CONFIG_SURFACE_AGGREGATOR_CDEV) += surface_aggregator_cdev.o +@@ -12,6 +12,7 @@ obj-$(CONFIG_SURFACE_AGGREGATOR_CDEV) += surface_aggregator_cdev.o obj-$(CONFIG_SURFACE_AGGREGATOR_HUB) += surface_aggregator_hub.o obj-$(CONFIG_SURFACE_AGGREGATOR_REGISTRY) += surface_aggregator_registry.o + obj-$(CONFIG_SURFACE_AGGREGATOR_TABLET_SWITCH) += surface_aggregator_tabletsw.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 @@ -6211,7 +7073,7 @@ index 000000000000..8b816ed8f35c -- 2.36.1 -From 0e6a0910bdec9c3b4d9658207c7b2cde6d86d375 Mon Sep 17 00:00:00 2001 +From 152ccacc3342985462a38d441abbdf7a8945dfcb Mon Sep 17 00:00:00 2001 From: Sachi King <nakato@nakato.io> Date: Tue, 5 Oct 2021 00:05:09 +1100 Subject: [PATCH] Input: soc_button_array - support AMD variant Surface devices @@ -6233,10 +7095,10 @@ Patchset: surface-button 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c -index cb6ec59a045d..4e8944f59def 100644 +index cbb1599a520e..f044c731c6a9 100644 --- a/drivers/input/misc/soc_button_array.c +++ b/drivers/input/misc/soc_button_array.c -@@ -474,8 +474,8 @@ static const struct soc_device_data soc_device_INT33D3 = { +@@ -495,8 +495,8 @@ static const struct soc_device_data soc_device_MSHW0028 = { * Both, the Surface Pro 4 (surfacepro3_button.c) and the above mentioned * devices use MSHW0040 for power and volume buttons, however the way they * have to be addressed differs. Make sure that we only load this drivers @@ -6247,7 +7109,7 @@ index cb6ec59a045d..4e8944f59def 100644 */ #define MSHW0040_DSM_REVISION 0x01 #define MSHW0040_DSM_GET_OMPR 0x02 // get OEM Platform Revision -@@ -486,31 +486,14 @@ static const guid_t MSHW0040_DSM_UUID = +@@ -507,31 +507,14 @@ static const guid_t MSHW0040_DSM_UUID = static int soc_device_check_MSHW0040(struct device *dev) { acpi_handle handle = ACPI_HANDLE(dev); @@ -6288,7 +7150,7 @@ index cb6ec59a045d..4e8944f59def 100644 -- 2.36.1 -From 6224cf2d064ad98e8aa6153be11cbee3fc760cdc Mon Sep 17 00:00:00 2001 +From bbd06fea568d91284defb36d91818f57bd861358 Mon Sep 17 00:00:00 2001 From: Sachi King <nakato@nakato.io> Date: Tue, 5 Oct 2021 00:22:57 +1100 Subject: [PATCH] platform/surface: surfacepro3_button: don't load on amd @@ -6360,416 +7222,45 @@ index 242fb690dcaf..30eea54dbb47 100644 -- 2.36.1 -From a8a665d668c8b626813a8fefe5c2be602fdabf31 Mon Sep 17 00:00:00 2001 -From: Hans de Goede <hdegoede@redhat.com> -Date: Thu, 24 Feb 2022 12:02:40 +0100 -Subject: [PATCH] Input: soc_button_array - add support for Microsoft Surface 3 - (MSHW0028) buttons - -The drivers/platform/surface/surface3_button.c code is alsmost a 1:1 copy -of the soc_button_array code. - -The only big difference is that it binds to an i2c_client rather then to -a platform_device. The cause of this is the ACPI resources for the MSHW0028 -device containing a bogus I2cSerialBusV2 resource which causes the kernel -to instantiate an i2c_client for it instead of a platform_device. - -Add "MSHW0028" to the ignore_serial_bus_ids[] list in drivers/apci/scan.c, -so that a platform_device will be instantiated and add support for -the MSHW0028 HID to soc_button_array. +From 218c6d1a0995bc905e4d24e0ea6d3d164a884fd5 Mon Sep 17 00:00:00 2001 +From: Duke Lee <krnhotwings@gmail.com> +Date: Fri, 10 Jun 2022 13:49:48 -0700 +Subject: [PATCH] platform/x86/intel: hid: Add Surface Go to VGBS allow list -This fully replaces surface3_button, which will be removed in a separate -commit (since it binds to the now no longer created i2c_client it no -longer does anyyhing after this commit). +The Surface Go reports Chassis Type 9 (Laptop,) so the device needs to be +added to dmi_vgbs_allow_list to enable tablet mode when an attached Type +Cover is folded back. -Note the MSHW0028 id is used by Microsoft to describe the tablet buttons on -both the Surface 3 and the Surface 3 Pro and the actual API/implementation -for the Surface 3 Pro is quite different. The changes in this commit should -not impact the separate surfacepro3_button driver: +Relevant bug report and discussion: +https://github.com/linux-surface/linux-surface/issues/837 -1. Because of the bogus I2cSerialBusV2 resource problem that driver binds - to the acpi_device itself, so instantiating a platform_device instead of - an i2c_client does not matter. - -2. The soc_button_array driver will not bind to the MSHW0028 device on - the Surface 3 Pro, because it has no GPIO resources. - -Signed-off-by: Hans de Goede <hdegoede@redhat.com> -Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com +Signed-off-by: Duke Lee <krnhotwings@gmail.com> Patchset: surface-button --- - drivers/acpi/scan.c | 5 +++++ - drivers/input/misc/soc_button_array.c | 24 +++++++++++++++++++++++- - 2 files changed, 28 insertions(+), 1 deletion(-) + drivers/platform/x86/intel/hid.c | 6 ++++++ + 1 file changed, 6 insertions(+) -diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c -index 8b2e5ef15559..c82b1bfa1c3d 100644 ---- a/drivers/acpi/scan.c -+++ b/drivers/acpi/scan.c -@@ -1753,6 +1753,11 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device) - */ - {"BCM4752", }, - {"LNV4752", }, -+ /* -+ * Some ACPI devs contain SerialBus resources even though they are not -+ * attached to a serial bus at all. -+ */ -+ {"MSHW0028", }, - {} - }; - -diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c -index 4e8944f59def..f044c731c6a9 100644 ---- a/drivers/input/misc/soc_button_array.c -+++ b/drivers/input/misc/soc_button_array.c -@@ -469,6 +469,27 @@ static const struct soc_device_data soc_device_INT33D3 = { - .button_info = soc_button_INT33D3, +diff --git a/drivers/platform/x86/intel/hid.c b/drivers/platform/x86/intel/hid.c +index 216d31e3403d..79cff1fc675c 100644 +--- a/drivers/platform/x86/intel/hid.c ++++ b/drivers/platform/x86/intel/hid.c +@@ -122,6 +122,12 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = { + DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x360 Convertible 15-df0xxx"), + }, + }, ++ { ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"), ++ DMI_MATCH(DMI_PRODUCT_NAME, "Surface Go"), ++ }, ++ }, + { } }; -+/* -+ * Button info for Microsoft Surface 3 (non pro), this is indentical to -+ * the PNP0C40 info except that the home button is active-high. -+ * -+ * The Surface 3 Pro also has a MSHW0028 ACPI device, but that uses a custom -+ * version of the drivers/platform/x86/intel/hid.c 5 button array ACPI API -+ * instead. A check() callback is not necessary though as the Surface 3 Pro -+ * MSHW0028 ACPI device's resource table does not contain any GPIOs. -+ */ -+static const struct soc_button_info soc_button_MSHW0028[] = { -+ { "power", 0, EV_KEY, KEY_POWER, false, true, true }, -+ { "home", 1, EV_KEY, KEY_LEFTMETA, false, true, false }, -+ { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false, true }, -+ { "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false, true }, -+ { } -+}; -+ -+static const struct soc_device_data soc_device_MSHW0028 = { -+ .button_info = soc_button_MSHW0028, -+}; -+ - /* - * Special device check for Surface Book 2 and Surface Pro (2017). - * Both, the Surface Pro 4 (surfacepro3_button.c) and the above mentioned -@@ -518,7 +539,8 @@ static const struct acpi_device_id soc_button_acpi_match[] = { - { "ID9001", (unsigned long)&soc_device_INT33D3 }, - { "ACPI0011", 0 }, - -- /* Microsoft Surface Devices (5th and 6th generation) */ -+ /* Microsoft Surface Devices (3th, 5th and 6th generation) */ -+ { "MSHW0028", (unsigned long)&soc_device_MSHW0028 }, - { "MSHW0040", (unsigned long)&soc_device_MSHW0040 }, - - { } -- 2.36.1 -From 0e038f31633b889e5c4bd8b888fac74a69ac3b0f Mon Sep 17 00:00:00 2001 -From: Hans de Goede <hdegoede@redhat.com> -Date: Thu, 24 Feb 2022 12:02:41 +0100 -Subject: [PATCH] platform/surface: Remove Surface 3 Button driver - -The Surface 3 buttons are now handled by the generic soc_button_array -driver. As part of adding support to soc_button_array the ACPI code -now instantiates a platform_device rather then an i2c_client so there -no longer is an i2c_client for this driver to bind to. - -Signed-off-by: Hans de Goede <hdegoede@redhat.com> -Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com -Patchset: surface-button ---- - drivers/platform/surface/Kconfig | 7 - - drivers/platform/surface/Makefile | 1 - - drivers/platform/surface/surface3_button.c | 247 --------------------- - 3 files changed, 255 deletions(-) - delete mode 100644 drivers/platform/surface/surface3_button.c - -diff --git a/drivers/platform/surface/Kconfig b/drivers/platform/surface/Kconfig -index 3d3659b87ba4..126f940ee95a 100644 ---- a/drivers/platform/surface/Kconfig -+++ b/drivers/platform/surface/Kconfig -@@ -28,13 +28,6 @@ config SURFACE3_WMI - To compile this driver as a module, choose M here: the module will - be called surface3-wmi. - --config SURFACE_3_BUTTON -- tristate "Power/home/volume buttons driver for Microsoft Surface 3 tablet" -- depends on ACPI -- depends on KEYBOARD_GPIO && I2C -- help -- This driver handles the power/home/volume buttons on the Microsoft Surface 3 tablet. -- - config SURFACE_3_POWER_OPREGION - tristate "Surface 3 battery platform operation region support" - depends on ACPI -diff --git a/drivers/platform/surface/Makefile b/drivers/platform/surface/Makefile -index 20408730f425..ea407549286c 100644 ---- a/drivers/platform/surface/Makefile -+++ b/drivers/platform/surface/Makefile -@@ -5,7 +5,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_ACPI_NOTIFY) += surface_acpi_notify.o - obj-$(CONFIG_SURFACE_AGGREGATOR) += aggregator/ -diff --git a/drivers/platform/surface/surface3_button.c b/drivers/platform/surface/surface3_button.c -deleted file mode 100644 -index 48d77e7aae76..000000000000 ---- a/drivers/platform/surface/surface3_button.c -+++ /dev/null -@@ -1,247 +0,0 @@ --// SPDX-License-Identifier: GPL-2.0-only --/* -- * Supports for the button array on the Surface tablets. -- * -- * (C) Copyright 2016 Red Hat, Inc -- * -- * Based on soc_button_array.c: -- * -- * {C} Copyright 2014 Intel Corporation -- */ -- --#include <linux/module.h> --#include <linux/input.h> --#include <linux/init.h> --#include <linux/kernel.h> --#include <linux/i2c.h> --#include <linux/slab.h> --#include <linux/acpi.h> --#include <linux/gpio/consumer.h> --#include <linux/gpio_keys.h> --#include <linux/gpio.h> --#include <linux/platform_device.h> -- -- --#define SURFACE_BUTTON_OBJ_NAME "TEV2" --#define MAX_NBUTTONS 4 -- --/* -- * 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 -- * buttons into them based on whether the key should be auto repeat. -- */ --#define BUTTON_TYPES 2 -- --/* -- * Power button, Home button, Volume buttons support is supposed to -- * be covered by drivers/input/misc/soc_button_array.c, which is implemented -- * according to "Windows ACPI Design Guide for SoC Platforms". -- * However surface 3 seems not to obey the specs, instead it uses -- * device TEV2(MSHW0028) for declaring the GPIOs. The gpios are also slightly -- * different in which the Home button is active high. -- * Compared to surfacepro3_button.c which also handles MSHW0028, the Surface 3 -- * is a reduce platform and thus uses GPIOs, not ACPI events. -- * We choose an I2C driver here because we need to access the resources -- * declared under the device node, while surfacepro3_button.c only needs -- * the ACPI companion node. -- */ --static const struct acpi_device_id surface3_acpi_match[] = { -- { "MSHW0028", 0 }, -- { } --}; --MODULE_DEVICE_TABLE(acpi, surface3_acpi_match); -- --struct surface3_button_info { -- const char *name; -- int acpi_index; -- unsigned int event_type; -- unsigned int event_code; -- bool autorepeat; -- bool wakeup; -- bool active_low; --}; -- --struct surface3_button_data { -- struct platform_device *children[BUTTON_TYPES]; --}; -- --/* -- * Get the Nth GPIO number from the ACPI object. -- */ --static int surface3_button_lookup_gpio(struct device *dev, int acpi_index) --{ -- struct gpio_desc *desc; -- int gpio; -- -- desc = gpiod_get_index(dev, NULL, acpi_index, GPIOD_ASIS); -- if (IS_ERR(desc)) -- return PTR_ERR(desc); -- -- gpio = desc_to_gpio(desc); -- -- gpiod_put(desc); -- -- return gpio; --} -- --static struct platform_device * --surface3_button_device_create(struct i2c_client *client, -- const struct surface3_button_info *button_info, -- bool autorepeat) --{ -- const struct surface3_button_info *info; -- struct platform_device *pd; -- struct gpio_keys_button *gpio_keys; -- struct gpio_keys_platform_data *gpio_keys_pdata; -- int n_buttons = 0; -- int gpio; -- int error; -- -- gpio_keys_pdata = devm_kzalloc(&client->dev, -- sizeof(*gpio_keys_pdata) + -- sizeof(*gpio_keys) * MAX_NBUTTONS, -- GFP_KERNEL); -- if (!gpio_keys_pdata) -- return ERR_PTR(-ENOMEM); -- -- gpio_keys = (void *)(gpio_keys_pdata + 1); -- -- for (info = button_info; info->name; info++) { -- if (info->autorepeat != autorepeat) -- continue; -- -- gpio = surface3_button_lookup_gpio(&client->dev, -- info->acpi_index); -- if (!gpio_is_valid(gpio)) -- continue; -- -- gpio_keys[n_buttons].type = info->event_type; -- gpio_keys[n_buttons].code = info->event_code; -- gpio_keys[n_buttons].gpio = gpio; -- gpio_keys[n_buttons].active_low = info->active_low; -- gpio_keys[n_buttons].desc = info->name; -- gpio_keys[n_buttons].wakeup = info->wakeup; -- n_buttons++; -- } -- -- if (n_buttons == 0) { -- error = -ENODEV; -- goto err_free_mem; -- } -- -- gpio_keys_pdata->buttons = gpio_keys; -- gpio_keys_pdata->nbuttons = n_buttons; -- gpio_keys_pdata->rep = autorepeat; -- -- pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO); -- if (!pd) { -- error = -ENOMEM; -- goto err_free_mem; -- } -- -- error = platform_device_add_data(pd, gpio_keys_pdata, -- sizeof(*gpio_keys_pdata)); -- if (error) -- goto err_free_pdev; -- -- error = platform_device_add(pd); -- if (error) -- goto err_free_pdev; -- -- return pd; -- --err_free_pdev: -- platform_device_put(pd); --err_free_mem: -- devm_kfree(&client->dev, gpio_keys_pdata); -- return ERR_PTR(error); --} -- --static int surface3_button_remove(struct i2c_client *client) --{ -- struct surface3_button_data *priv = i2c_get_clientdata(client); -- -- int i; -- -- for (i = 0; i < BUTTON_TYPES; i++) -- if (priv->children[i]) -- platform_device_unregister(priv->children[i]); -- -- return 0; --} -- --static struct surface3_button_info surface3_button_surface3[] = { -- { "power", 0, EV_KEY, KEY_POWER, false, true, true }, -- { "home", 1, EV_KEY, KEY_LEFTMETA, false, true, false }, -- { "volume_up", 2, EV_KEY, KEY_VOLUMEUP, true, false, true }, -- { "volume_down", 3, EV_KEY, KEY_VOLUMEDOWN, true, false, true }, -- { } --}; -- --static int surface3_button_probe(struct i2c_client *client, -- const struct i2c_device_id *id) --{ -- struct device *dev = &client->dev; -- struct surface3_button_data *priv; -- struct platform_device *pd; -- int i; -- int error; -- -- if (strncmp(acpi_device_bid(ACPI_COMPANION(&client->dev)), -- SURFACE_BUTTON_OBJ_NAME, -- strlen(SURFACE_BUTTON_OBJ_NAME))) -- return -ENODEV; -- -- error = gpiod_count(dev, NULL); -- if (error < 0) { -- dev_dbg(dev, "no GPIO attached, ignoring...\n"); -- return error; -- } -- -- priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); -- if (!priv) -- return -ENOMEM; -- -- i2c_set_clientdata(client, priv); -- -- for (i = 0; i < BUTTON_TYPES; i++) { -- pd = surface3_button_device_create(client, -- surface3_button_surface3, -- i == 0); -- if (IS_ERR(pd)) { -- error = PTR_ERR(pd); -- if (error != -ENODEV) { -- surface3_button_remove(client); -- return error; -- } -- continue; -- } -- -- priv->children[i] = pd; -- } -- -- if (!priv->children[0] && !priv->children[1]) -- return -ENODEV; -- -- return 0; --} -- --static const struct i2c_device_id surface3_id[] = { -- { } --}; --MODULE_DEVICE_TABLE(i2c, surface3_id); -- --static struct i2c_driver surface3_driver = { -- .probe = surface3_button_probe, -- .remove = surface3_button_remove, -- .id_table = surface3_id, -- .driver = { -- .name = "surface3", -- .acpi_match_table = ACPI_PTR(surface3_acpi_match), -- }, --}; --module_i2c_driver(surface3_driver); -- --MODULE_AUTHOR("Benjamin Tissoires <benjamin.tissoires@gmail.com>"); --MODULE_DESCRIPTION("surface3 button array driver"); --MODULE_LICENSE("GPL v2"); --- -2.36.1 - -From f5d22c97a860e9002ad31c8bf1c00b629c432ba7 Mon Sep 17 00:00:00 2001 +From e42467a6c2b0397194dd542921c05b4f075de29f 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 @@ -6805,7 +7296,7 @@ Patchset: surface-typecover 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c -index 99eabfb4145b..bbfcae39f375 100644 +index 6bb3890b0f2c..c28349e90156 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -34,7 +34,10 @@ @@ -6987,7 +7478,7 @@ index 99eabfb4145b..bbfcae39f375 100644 del_timer_sync(&td->release_timer); sysfs_remove_group(&hdev->dev.kobj, &mt_attribute_group); -@@ -2174,6 +2265,11 @@ static const struct hid_device_id mt_devices[] = { +@@ -2180,6 +2271,11 @@ static const struct hid_device_id mt_devices[] = { MT_USB_DEVICE(USB_VENDOR_ID_XIROKU, USB_DEVICE_ID_XIROKU_CSR2) }, @@ -7002,7 +7493,7 @@ index 99eabfb4145b..bbfcae39f375 100644 -- 2.36.1 -From f8ac6cc2a4f1f3020b1bcb476dc355a0e3d938ce Mon Sep 17 00:00:00 2001 +From a18a2ab98dd916aa70519b8abf9a1970e54ae4f6 Mon Sep 17 00:00:00 2001 From: PJungkamp <p.jungkamp@gmail.com> Date: Fri, 25 Feb 2022 12:04:25 +0100 Subject: [PATCH] hid/multitouch: Add support for surface pro type cover tablet @@ -7031,7 +7522,7 @@ Patchset: surface-typecover 1 file changed, 122 insertions(+), 26 deletions(-) diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c -index bbfcae39f375..d53228452501 100644 +index c28349e90156..61142639be26 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -76,6 +76,7 @@ MODULE_LICENSE("GPL"); @@ -7302,7 +7793,7 @@ index bbfcae39f375..d53228452501 100644 -- 2.36.1 -From 93fa65ace198e7abaa1a27e42f3ebcf509022902 Mon Sep 17 00:00:00 2001 +From 36666be7e25bc5cfc387a2b3cdd03f694e1e2a6a Mon Sep 17 00:00:00 2001 From: Werner Sembach <wse@tuxedocomputers.com> Date: Wed, 27 Apr 2022 17:40:53 +0200 Subject: [PATCH] ACPI: battery: Make "not-charging" the default on no charging @@ -7385,7 +7876,7 @@ index dc208f5f5a1f..306513fec1e1 100644 -- 2.36.1 -From a29f2ab8670becc07a56ccdfe3a7a1fe64730803 Mon Sep 17 00:00:00 2001 +From 940d757175c48957b7cd8667039757fa5b579b37 Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> Date: Wed, 25 May 2022 14:20:10 +0200 Subject: [PATCH] HID: hid-input: add Surface Go battery quirk @@ -7406,10 +7897,10 @@ Patchset: surface-battery 2 files changed, 3 insertions(+) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h -index 78bd3ddda442..288766674c6a 100644 +index c297c63f3ec5..e233726d9a74 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h -@@ -405,6 +405,7 @@ +@@ -413,6 +413,7 @@ #define USB_DEVICE_ID_ASUS_UX550VE_TOUCHSCREEN 0x2544 #define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN 0x2706 #define I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN 0x261A @@ -7418,10 +7909,10 @@ index 78bd3ddda442..288766674c6a 100644 #define USB_VENDOR_ID_ELECOM 0x056e #define USB_DEVICE_ID_ELECOM_BM084 0x0061 diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c -index 56ec27398a00..263a977801bf 100644 +index c6b27aab9041..48c1c02c69f4 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c -@@ -336,6 +336,8 @@ static const struct hid_device_id hid_battery_quirks[] = { +@@ -381,6 +381,8 @@ static const struct hid_device_id hid_battery_quirks[] = { HID_BATTERY_QUIRK_IGNORE }, { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_SURFACE_GO_TOUCHSCREEN), HID_BATTERY_QUIRK_IGNORE }, @@ -7433,7 +7924,7 @@ index 56ec27398a00..263a977801bf 100644 -- 2.36.1 -From bab798deb7e8defbe4a0f5bb02e6254a3261c21c Mon Sep 17 00:00:00 2001 +From 62c1ed9a1011c9c316d9996fa8b5472949779535 Mon Sep 17 00:00:00 2001 From: Hans de Goede <hdegoede@redhat.com> Date: Sun, 10 Oct 2021 20:56:57 +0200 Subject: [PATCH] ACPI: delay enumeration of devices with a _DEP pointing to an @@ -7493,10 +7984,10 @@ Patchset: cameras 1 file changed, 3 insertions(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c -index c82b1bfa1c3d..2227625202aa 100644 +index 762b61f67e6c..2c0f39a7f2a1 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c -@@ -2130,6 +2130,9 @@ static acpi_status acpi_bus_check_add_2(acpi_handle handle, u32 lvl_not_used, +@@ -2122,6 +2122,9 @@ static acpi_status acpi_bus_check_add_2(acpi_handle handle, u32 lvl_not_used, static void acpi_default_enumeration(struct acpi_device *device) { @@ -7509,7 +8000,7 @@ index c82b1bfa1c3d..2227625202aa 100644 -- 2.36.1 -From afc8f21e4250f6ff57c9385be877943253491d94 Mon Sep 17 00:00:00 2001 +From 682453621bd191154379cfb587b6250225981d50 Mon Sep 17 00:00:00 2001 From: zouxiaoh <xiaohong.zou@intel.com> Date: Fri, 25 Jun 2021 08:52:59 +0800 Subject: [PATCH] iommu: intel-ipu: use IOMMU passthrough mode for Intel IPUs @@ -7535,10 +8026,10 @@ Patchset: cameras 1 file changed, 30 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c -index a91eed82bb39..0d16c6bf0e0b 100644 +index 5f18ec206696..2b31e531f510 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c -@@ -57,6 +57,12 @@ +@@ -37,6 +37,12 @@ #define IS_GFX_DEVICE(pdev) ((pdev->class >> 16) == PCI_BASE_CLASS_DISPLAY) #define IS_USB_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_SERIAL_USB) #define IS_ISA_DEVICE(pdev) ((pdev->class >> 8) == PCI_CLASS_BRIDGE_ISA) @@ -7551,7 +8042,7 @@ index a91eed82bb39..0d16c6bf0e0b 100644 #define IS_IPTS(pdev) ((pdev)->vendor == PCI_VENDOR_ID_INTEL && \ ((pdev)->device == 0x9d3e)) #define IS_AZALIA(pdev) ((pdev)->vendor == 0x8086 && (pdev)->device == 0x3a3e) -@@ -335,12 +341,14 @@ EXPORT_SYMBOL_GPL(intel_iommu_enabled); +@@ -310,12 +316,14 @@ EXPORT_SYMBOL_GPL(intel_iommu_enabled); static int dmar_map_gfx = 1; static int dmar_map_ipts = 1; @@ -7566,7 +8057,7 @@ index a91eed82bb39..0d16c6bf0e0b 100644 #define IDENTMAP_IPTS 16 int intel_iommu_gfx_mapped; -@@ -2992,6 +3000,9 @@ static int device_def_domain_type(struct device *dev) +@@ -2729,6 +2737,9 @@ static int device_def_domain_type(struct device *dev) if ((iommu_identity_mapping & IDENTMAP_GFX) && IS_GFX_DEVICE(pdev)) return IOMMU_DOMAIN_IDENTITY; @@ -7576,7 +8067,7 @@ index a91eed82bb39..0d16c6bf0e0b 100644 if ((iommu_identity_mapping & IDENTMAP_IPTS) && IS_IPTS(pdev)) return IOMMU_DOMAIN_IDENTITY; } -@@ -3430,6 +3441,9 @@ static int __init init_dmars(void) +@@ -3167,6 +3178,9 @@ static int __init init_dmars(void) if (!dmar_map_gfx) iommu_identity_mapping |= IDENTMAP_GFX; @@ -7586,7 +8077,7 @@ index a91eed82bb39..0d16c6bf0e0b 100644 if (!dmar_map_ipts) iommu_identity_mapping |= IDENTMAP_IPTS; -@@ -5674,6 +5688,18 @@ static void quirk_iommu_igfx(struct pci_dev *dev) +@@ -4941,6 +4955,18 @@ static void quirk_iommu_igfx(struct pci_dev *dev) dmar_map_gfx = 0; } @@ -7605,7 +8096,7 @@ index a91eed82bb39..0d16c6bf0e0b 100644 static void quirk_iommu_ipts(struct pci_dev *dev) { if (!IS_IPTS(dev)) -@@ -5685,6 +5711,7 @@ static void quirk_iommu_ipts(struct pci_dev *dev) +@@ -4952,6 +4978,7 @@ static void quirk_iommu_ipts(struct pci_dev *dev) pci_info(dev, "Passthrough IOMMU for IPTS\n"); dmar_map_ipts = 0; } @@ -7613,7 +8104,7 @@ index a91eed82bb39..0d16c6bf0e0b 100644 /* G4x/GM45 integrated gfx dmar support is totally busted. */ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2a40, quirk_iommu_igfx); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x2e00, quirk_iommu_igfx); -@@ -5720,6 +5747,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx); +@@ -4987,6 +5014,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x1632, quirk_iommu_igfx); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163A, quirk_iommu_igfx); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x163D, quirk_iommu_igfx); @@ -7626,7 +8117,7 @@ index a91eed82bb39..0d16c6bf0e0b 100644 -- 2.36.1 -From 997c2b1f0237bc456dc61e869e78a4487bca07d9 Mon Sep 17 00:00:00 2001 +From 75c9a2ede854cfaa86e1a79ed40a2d8763a0e45a Mon Sep 17 00:00:00 2001 From: Daniel Scally <djrscally@gmail.com> Date: Sun, 10 Oct 2021 20:57:02 +0200 Subject: [PATCH] platform/x86: int3472: Enable I2c daisy chain @@ -7663,7 +8154,7 @@ index 22f61b47f9e5..e1de1ff40bba 100644 -- 2.36.1 -From c3c397ab746342288b4299b452c3ae2fd615be44 Mon Sep 17 00:00:00 2001 +From 12ef137e4f5748917c80c2460cd2df3c14359693 Mon Sep 17 00:00:00 2001 From: Daniel Scally <djrscally@gmail.com> Date: Thu, 28 Oct 2021 21:55:16 +0100 Subject: [PATCH] media: i2c: Add driver for DW9719 VCM @@ -7682,10 +8173,10 @@ Patchset: cameras create mode 100644 drivers/media/i2c/dw9719.c diff --git a/MAINTAINERS b/MAINTAINERS -index 4d83cd26e299..0e0e1e53e49c 100644 +index 119767089831..74fec6350ad9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS -@@ -5865,6 +5865,13 @@ T: git git://linuxtv.org/media_tree.git +@@ -6002,6 +6002,13 @@ T: git git://linuxtv.org/media_tree.git F: Documentation/devicetree/bindings/media/i2c/dongwoon,dw9714.txt F: drivers/media/i2c/dw9714.c @@ -7700,10 +8191,10 @@ index 4d83cd26e299..0e0e1e53e49c 100644 M: Dongchun Zhu <dongchun.zhu@mediatek.com> L: linux-media@vger.kernel.org diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig -index 69c56e24a612..d9fac304f451 100644 +index 2b20aa6c37b1..49d1c59334e3 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig -@@ -1466,6 +1466,17 @@ config VIDEO_DW9714 +@@ -806,6 +806,17 @@ config VIDEO_DW9714 capability. This is designed for linear control of voice coil motors, controlled via I2C serial interface. @@ -7720,19 +8211,19 @@ index 69c56e24a612..d9fac304f451 100644 + config VIDEO_DW9768 tristate "DW9768 lens voice coil support" - depends on I2C && VIDEO_V4L2 + depends on I2C && VIDEO_DEV diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile -index b01f6cd05ee8..ba8b31d79222 100644 +index 3e1696963e7f..9dfda069e006 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile -@@ -24,6 +24,7 @@ obj-$(CONFIG_VIDEO_SAA6752HS) += saa6752hs.o - obj-$(CONFIG_VIDEO_AD5820) += ad5820.o - obj-$(CONFIG_VIDEO_AK7375) += ak7375.o - obj-$(CONFIG_VIDEO_DW9714) += dw9714.o -+obj-$(CONFIG_VIDEO_DW9719) += dw9719.o - obj-$(CONFIG_VIDEO_DW9768) += dw9768.o - obj-$(CONFIG_VIDEO_DW9807_VCM) += dw9807-vcm.o - obj-$(CONFIG_VIDEO_ADV7170) += adv7170.o +@@ -29,6 +29,7 @@ obj-$(CONFIG_VIDEO_CS5345) += cs5345.o + obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o + obj-$(CONFIG_VIDEO_CX25840) += cx25840/ + obj-$(CONFIG_VIDEO_DW9714) += dw9714.o ++obj-$(CONFIG_VIDEO_DW9719) += dw9719.o + obj-$(CONFIG_VIDEO_DW9768) += dw9768.o + obj-$(CONFIG_VIDEO_DW9807_VCM) += dw9807-vcm.o + obj-$(CONFIG_VIDEO_ET8EK8) += et8ek8/ diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c new file mode 100644 index 000000000000..8451c75b696b @@ -8169,7 +8660,7 @@ index 000000000000..8451c75b696b -- 2.36.1 -From 49bf34135d89166093cfea5f817e5ac6862b0ccf Mon Sep 17 00:00:00 2001 +From f593c5339ca9bb85d4bc1eff3d5b90543b433c9e Mon Sep 17 00:00:00 2001 From: Daniel Scally <djrscally@gmail.com> Date: Mon, 13 Dec 2021 22:38:17 +0000 Subject: [PATCH] media: entity: Skip non-data links in graph iteration @@ -8185,7 +8676,7 @@ Patchset: cameras 1 file changed, 6 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c -index b411f9796191..d0563ee4b28b 100644 +index 8ab0913d8d82..a8631f74dcee 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -295,6 +295,12 @@ static void media_graph_walk_iter(struct media_graph *graph) @@ -8204,7 +8695,7 @@ index b411f9796191..d0563ee4b28b 100644 -- 2.36.1 -From 84e122d9c2fa461ce17b61989b5676c695a07fba Mon Sep 17 00:00:00 2001 +From cc5f72a20e5e849d7a11b41d653554be2009933f Mon Sep 17 00:00:00 2001 From: Daniel Scally <djrscally@gmail.com> Date: Mon, 13 Dec 2021 22:53:09 +0000 Subject: [PATCH] media: media.h: Add new media link type @@ -8288,7 +8779,7 @@ index 200fa8462b90..afbae7213d35 100644 -- 2.36.1 -From b9085eecf59dc89d1b82337697e455b31cdd4e1c Mon Sep 17 00:00:00 2001 +From 38b3de96c747d8be99ec8b255b5b9280c2799dd0 Mon Sep 17 00:00:00 2001 From: Daniel Scally <djrscally@gmail.com> Date: Mon, 13 Dec 2021 22:36:31 +0000 Subject: [PATCH] media: entity: Add link_type_name() helper @@ -8305,7 +8796,7 @@ Patchset: cameras 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c -index d0563ee4b28b..1a7d0a4fb9e8 100644 +index a8631f74dcee..4bd80ce1a33d 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -44,6 +44,20 @@ static inline const char *intf_type(struct media_interface *intf) @@ -8343,7 +8834,7 @@ index d0563ee4b28b..1a7d0a4fb9e8 100644 -- 2.36.1 -From 6f6547dac5f877a7c07c0f947167d3af109888fb Mon Sep 17 00:00:00 2001 +From 727823e3ceb808a4cd61f69695e41311420cdb2a Mon Sep 17 00:00:00 2001 From: Daniel Scally <djrscally@gmail.com> Date: Mon, 13 Dec 2021 22:54:10 +0000 Subject: [PATCH] media: entity: Add support for ancillary links @@ -8360,10 +8851,10 @@ Patchset: cameras 2 files changed, 41 insertions(+) diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c -index 1a7d0a4fb9e8..d7e2f78a83cc 100644 +index 4bd80ce1a33d..1ff60d411ea9 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c -@@ -1032,3 +1032,25 @@ void media_remove_intf_links(struct media_interface *intf) +@@ -1025,3 +1025,25 @@ void media_remove_intf_links(struct media_interface *intf) mutex_unlock(&mdev->graph_mutex); } EXPORT_SYMBOL_GPL(media_remove_intf_links); @@ -8390,10 +8881,10 @@ index 1a7d0a4fb9e8..d7e2f78a83cc 100644 +} +EXPORT_SYMBOL_GPL(media_create_ancillary_link); diff --git a/include/media/media-entity.h b/include/media/media-entity.h -index fea489f03d57..2a58defc4886 100644 +index 742918962d46..1d13b8939a11 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h -@@ -1108,4 +1108,23 @@ void media_remove_intf_links(struct media_interface *intf); +@@ -1121,4 +1121,23 @@ void media_remove_intf_links(struct media_interface *intf); (((entity)->ops && (entity)->ops->operation) ? \ (entity)->ops->operation((entity) , ##args) : -ENOIOCTLCMD) @@ -8420,7 +8911,7 @@ index fea489f03d57..2a58defc4886 100644 -- 2.36.1 -From eb85a0a2c18d5596e996322286ffb1bcc326443c Mon Sep 17 00:00:00 2001 +From 87967cea56c8a58da1fc741497b2c1992d2c4a91 Mon Sep 17 00:00:00 2001 From: Daniel Scally <djrscally@gmail.com> Date: Fri, 26 Nov 2021 22:55:50 +0000 Subject: [PATCH] media: v4l2-async: Create links during @@ -8493,7 +8984,7 @@ index 0404267f1ae4..436bd6900fd8 100644 -- 2.36.1 -From 613f354f08b44f7e0909c7ffde8f9ce69c81acc8 Mon Sep 17 00:00:00 2001 +From 8e5a392560fed1d042ae6d9a84ff6d704fcc4015 Mon Sep 17 00:00:00 2001 From: Daniel Scally <djrscally@gmail.com> Date: Wed, 4 May 2022 23:21:45 +0100 Subject: [PATCH] media: ipu3-cio2: Move functionality from .complete() to @@ -8608,7 +9099,50 @@ index 0e9b0503b62a..50682a7b2a07 100644 -- 2.36.1 -From cdc9fb2f64ebffa0f587d9dcebb5070703a784a3 Mon Sep 17 00:00:00 2001 +From 04ec896483e11443b551beb9ad8d647918a88178 Mon Sep 17 00:00:00 2001 +From: Daniel Scally <djrscally@gmail.com> +Date: Thu, 2 Jun 2022 22:15:56 +0100 +Subject: [PATCH] media: ipu3-cio2: Re-add .complete() to ipu3-cio2 + +Removing the .complete() callback had some unintended consequences. +Because the VCM driver is not directly linked to the ipu3-cio2 +driver .bound() never gets called for it, which means its devnode +is never created if it probes late. Because .complete() waits for +any sub-notifiers to also be complete it is captured in that call. + +Signed-off-by: Daniel Scally <djrscally@gmail.com> +Patchset: cameras +--- + drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +index 50682a7b2a07..ff79582a583d 100644 +--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c ++++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +@@ -1429,9 +1429,18 @@ static void cio2_notifier_unbind(struct v4l2_async_notifier *notifier, + cio2->queue[s_asd->csi2.port].sensor = NULL; + } + ++/* .complete() is called after all subdevices have been located */ ++static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) ++{ ++ struct cio2_device *cio2 = to_cio2_device(notifier); ++ ++ return v4l2_device_register_subdev_nodes(&cio2->v4l2_dev); ++} ++ + static const struct v4l2_async_notifier_operations cio2_async_ops = { + .bound = cio2_notifier_bound, + .unbind = cio2_notifier_unbind, ++ .complete = cio2_notifier_complete, + }; + + static int cio2_parse_firmware(struct cio2_device *cio2) +-- +2.36.1 + +From f1c39233f6c15b93d566724eef4a439993061b12 Mon Sep 17 00:00:00 2001 From: Sachi King <nakato@nakato.io> Date: Sat, 29 May 2021 17:47:38 +1000 Subject: [PATCH] ACPI: Add quirk for Surface Laptop 4 AMD missing irq 7 @@ -8675,7 +9209,7 @@ index 0d01e7f5078c..2b06cf5f2b1f 100644 -- 2.36.1 -From fceaab89173a0d9d3e55d3b90e06c15ca4f04cc7 Mon Sep 17 00:00:00 2001 +From db041584a330a1d5c30c6436161e8d77dcc5a4db Mon Sep 17 00:00:00 2001 From: Maximilian Luz <luzmaximilian@gmail.com> Date: Thu, 3 Jun 2021 14:04:26 +0200 Subject: [PATCH] ACPI: Add AMD 13" Surface Laptop 4 model to irq 7 override |