Skip to contentSkip to conversation

Input: Replace surface3_button code with soc_button_array

PATCH In review Hans de Goede 5 participants 9 messages Feb 24, 2022 – Mar 2, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover Input: Replace surface3_button code with soc_button_array

Hi All,

I noticed that the surface3_button code was pretty much a 1:1 copy of soc_button_array. This series adds support to soc_button_array for the MSHW0028 device on the Microsoft Surface 3 (non pro) and removes the now no longer needed surface3_button driver.

Rafael, this includes an addition to ignore_serial_bus_ids[] in drivers/apci/scan.c, may we have your ack for merging this through the input or pdx86 tree please ?

Dmitry, I believe it would be best to keep these 2 patches together and merge both through either the input or the pdx86 tree. If you are ok with me merging this through the pdx86 tree may I have your Ack for that ?

If you prefer merging this through the input tree please consider this my ack for also merge 2/2 through the input tree.

Note both patches can also be merged through separate trees without issues but keeping them together seems better to me.

Regards,

Hans

Hans de Goede (2):
Input: soc_button_array - add support for Microsoft Surface 3

    (MSHW0028) buttons

platform/surface: Remove Surface 3 Button driver

 drivers/acpi/scan.c                        |   5 +
 drivers/input/misc/soc_button_array.c      |  24 +-
 drivers/platform/surface/Kconfig           |   7 -
 drivers/platform/surface/Makefile          |   1 -
 drivers/platform/surface/surface3_button.c | 247 ---------------------
 5 files changed, 28 insertions(+), 256 deletions(-)
 delete mode 100644 drivers/platform/surface/surface3_button.c
Signature · 1 line
2.35.1
#1 lore raw

PATCH 1/2 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.

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).

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:

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.

---
 drivers/acpi/scan.c                   |  5 +++++
 drivers/input/misc/soc_button_array.c | 24 +++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
drivers/acpi/scan.c +5 -0
index 4463c2eda61e..e993c8b253f5 100644
@@ -1749,6 +1749,11 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
 		{"INT3515", },
 		/* Non-conforming _HID for Cirrus Logic already released */
 		{"CLSA0100", },
+	/*
+	 * Some ACPI devs contain SerialBus resources even though they are not
+	 * attached to a serial bus at all.
+	 */
+		{"MSHW0028", },
 	/*
 	 * HIDs of device with an UartSerialBusV2 resource for which userspace
 	 * expects a regular tty cdev to be created (instead of the in kernel
drivers/input/misc/soc_button_array.c +23 -1
index cb6ec59a045d..cbb1599a520e 100644
@@ -469,6 +469,27 @@ static const struct soc_device_data soc_device_INT33D3 = {
 	.button_info = soc_button_INT33D3,
 };
 
+/*
+ * 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
@@ -535,7 +556,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 },
 
 	{ }
Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] Input: soc_button_array - add support for Microsoft Surface 3 (MSHW0028) buttons

Quoted 21 lines · Hans de Goede

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.

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).

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:

Quoted 8 lines

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.

Looks good to me.

maintainer Acked-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] Input: soc_button_array - add support for Microsoft Surface 3 (MSHW0028) buttons

In reply to Hans de Goede
Quoted 22 lines · Hans de Goede

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.

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).

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:

Quoted 8 lines

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.

for the change in scan.c and I'm expecting that you'll take care of this series yourself. Otherwise, please let me know.

Quoted 66 lines
---
 drivers/acpi/scan.c                   |  5 +++++
 drivers/input/misc/soc_button_array.c | 24 +++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 1 deletion(-)
drivers/acpi/scan.c +5 -0
index 4463c2eda61e..e993c8b253f5 100644
@@ -1749,6 +1749,11 @@ static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
                {"INT3515", },
                /* Non-conforming _HID for Cirrus Logic already released */
                {"CLSA0100", },
+       /*
+        * Some ACPI devs contain SerialBus resources even though they are not
+        * attached to a serial bus at all.
+        */
+               {"MSHW0028", },
        /*
         * HIDs of device with an UartSerialBusV2 resource for which userspace
         * expects a regular tty cdev to be created (instead of the in kernel
drivers/input/misc/soc_button_array.c +23 -2
index cb6ec59a045d..cbb1599a520e 100644
@@ -469,6 +469,27 @@ static const struct soc_device_data soc_device_INT33D3 = {
        .button_info = soc_button_INT33D3,
 };
 
+/*
+ * 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
@@ -535,7 +556,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.35.1

maintainer Acked-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] Input: soc_button_array - add support for Microsoft Surface 3 (MSHW0028) buttons

In reply to Hans de Goede
Quoted 21 lines · Hans de Goede

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.

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).

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:

Quoted 8 lines

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.

Please feel free to merge through platform tree.

Thanks.

Signature · 1 line
Dmitry
#5 lore raw

PATCH 2/2 platform/surface: Remove Surface 3 Button driver

In reply to Hans de Goede

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.

---
 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
drivers/platform/surface/Kconfig +0 -7
index 463f1ec5c14e..eb79fbed8059 100644
@@ -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
drivers/platform/surface/Makefile +0 -1
index 32889482de55..0fc9cd3e4dd9 100644
@@ -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/
drivers/platform/surface/surface3_button.c deleted +0 -247

247 lines not on this page · raw message

Signature · 1 line
2.35.1
maintainer Reviewed-by on v1 2/2
#6 lore raw

Re: [PATCH 2/2] platform/surface: Remove Surface 3 Button driver

Quoted 6 lines · Hans de Goede

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.

Looks good to me.

Reviewed-by on the v1 series
#7 lore raw
In reply to Hans de Goede
Quoted 6 lines · Hans de Goede

Hi All,

I noticed that the surface3_button code was pretty much a 1:1 copy of soc_button_array. This series adds support to soc_button_array for the MSHW0028 device on the Microsoft Surface 3 (non pro) and removes the now no longer needed surface3_button driver.

Thanks, I like esp. patch 2 in this series.

Quoted 14 lines

Rafael, this includes an addition to ignore_serial_bus_ids[] in drivers/apci/scan.c, may we have your ack for merging this through the input or pdx86 tree please ?

Dmitry, I believe it would be best to keep these 2 patches together and merge both through either the input or the pdx86 tree. If you are ok with me merging this through the pdx86 tree may I have your Ack for that ?

If you prefer merging this through the input tree please consider this my ack for also merge 2/2 through the input tree.

Note both patches can also be merged through separate trees without issues but keeping them together seems better to me.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#8 lore raw
In reply to Hans de Goede

Hi All,

Quoted 16 lines · Hans de Goede

Hi All,

I noticed that the surface3_button code was pretty much a 1:1 copy of soc_button_array. This series adds support to soc_button_array for the MSHW0028 device on the Microsoft Surface 3 (non pro) and removes the now no longer needed surface3_button driver.

Rafael, this includes an addition to ignore_serial_bus_ids[] in drivers/apci/scan.c, may we have your ack for merging this through the input or pdx86 tree please ?

Dmitry, I believe it would be best to keep these 2 patches together and merge both through either the input or the pdx86 tree. If you are ok with me merging this through the pdx86 tree may I have your Ack for that ?

Quoted 5 lines

If you prefer merging this through the input tree please consider this my ack for also merge 2/2 through the input tree.

Note both patches can also be merged through separate trees without issues but keeping them together seems better to me.

Thank you all for the reviews + acks,

I've added this series to my review-hans (soon to be for-next) branch now.

Regards,

Hans

Quoted 13 lines

Hans de Goede (2):
Input: soc_button_array - add support for Microsoft Surface 3

    (MSHW0028) buttons

platform/surface: Remove Surface 3 Button driver

 drivers/acpi/scan.c                        |   5 +
 drivers/input/misc/soc_button_array.c      |  24 +-
 drivers/platform/surface/Kconfig           |   7 -
 drivers/platform/surface/Makefile          |   1 -
 drivers/platform/surface/surface3_button.c | 247 ---------------------
 5 files changed, 28 insertions(+), 256 deletions(-)
 delete mode 100644 drivers/platform/surface/surface3_button.c