Skip to contentSkip to conversation

platform/x86: x86-android-tablets: Split into multiple files + gpio_keys rework

PATCH In review Hans de Goede 2 participants 16 messages Feb 20, 2023 – Feb 21, 2023

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

cover platform/x86: x86-android-tablets: Split into multiple files + gpio_keys rework

Hi All,

The single x86-android-tablets.c file was becoming a bit unyieldly, so this series splits it into multiple files. Besides the split this also reworks the gpio_keys a bit and uses the new gpio_keys code to replace the (ugly, buggy) peaq-wmi code for the special button on the Peaq C1010.

Regards,

Hans

Hans de Goede (9):
platform/x86: x86-android-tablets: Move into its own subdir platform/x86: x86-android-tablets: Move core code into new core.c file platform/x86: x86-android-tablets: Move DMI match table into its own
dmi.c file
platform/x86: x86-android-tablets: Move shared power-supply fw-nodes
to a separate file
platform/x86: x86-android-tablets: Move Asus tablets to their own file platform/x86: x86-android-tablets: Move Lenovo tablets to their own
file
platform/x86: x86-android-tablets: Move remaining tablets to other.c platform/x86: x86-android-tablets: Add gpio_keys support to

    x86_android_tablet_init()
  platform/x86: x86-android-tablets: Add support for the Dolby button on
    Peaq C1010
 MAINTAINERS                                   |    2 +-
 drivers/platform/x86/Kconfig                  |   24 +-
 drivers/platform/x86/Makefile                 |    3 +-
 drivers/platform/x86/peaq-wmi.c               |  128 --
 drivers/platform/x86/x86-android-tablets.c    | 1884 -----------------
 .../platform/x86/x86-android-tablets/Kconfig  |   21 +
 .../platform/x86/x86-android-tablets/Makefile |    9 +
 .../platform/x86/x86-android-tablets/asus.c   |  324 +++
 .../platform/x86/x86-android-tablets/core.c   |  391 ++++
 .../platform/x86/x86-android-tablets/dmi.c    |  175 ++
 .../platform/x86/x86-android-tablets/lenovo.c |  417 ++++
 .../platform/x86/x86-android-tablets/other.c  |  518 +++++
 .../x86/x86-android-tablets/shared-psy-info.c |  100 +
 .../x86/x86-android-tablets/shared-psy-info.h |   32 +
 .../x86-android-tablets/x86-android-tablets.h |   81 +
 15 files changed, 2071 insertions(+), 2038 deletions(-)
 delete mode 100644 drivers/platform/x86/peaq-wmi.c
 delete mode 100644 drivers/platform/x86/x86-android-tablets.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/Kconfig
 create mode 100644 drivers/platform/x86/x86-android-tablets/Makefile
 create mode 100644 drivers/platform/x86/x86-android-tablets/asus.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/core.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/dmi.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/lenovo.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/other.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/shared-psy-info.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/shared-psy-info.h
 create mode 100644 drivers/platform/x86/x86-android-tablets/x86-android-tablets.h
Signature · 1 line
2.39.1
#1 lore raw

PATCH 1/9 platform/x86: x86-android-tablets: Move into its own subdir

Move the x86-android-tablets code into its own subdir, this is a preparation patch for splitting the somewhat large file into multiple smaller files.

---
 MAINTAINERS                                   |  2 +-
 drivers/platform/x86/Kconfig                  | 17 +--------------
 drivers/platform/x86/Makefile                 |  2 +-
 .../platform/x86/x86-android-tablets/Kconfig  | 21 +++++++++++++++++++
 .../platform/x86/x86-android-tablets/Makefile |  8 +++++++
 .../x86-android-tablets-main.c}               |  4 ++--
 6 files changed, 34 insertions(+), 20 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/Kconfig
 create mode 100644 drivers/platform/x86/x86-android-tablets/Makefile
 rename drivers/platform/x86/{x86-android-tablets.c => x86-android-tablets/x86-android-tablets-main.c} (99%)
MAINTAINERS +1 -1
index 0c051a973e6b..87cc1e6b37c0 100644
@@ -22634,7 +22634,7 @@ M:	Hans de Goede <[email protected]>
 L:	[email protected]
 S:	Maintained
 T:	git git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git
-F:	drivers/platform/x86/x86-android-tablets.c
+F:	drivers/platform/x86/x86-android-tablets/
 
 X86 PLATFORM DRIVERS
 M:	Hans de Goede <[email protected]>
drivers/platform/x86/Kconfig +1 -16
index ec7c2b4e1721..8b4e03fe5bff 100644
@@ -977,22 +977,7 @@ config TOUCHSCREEN_DMI
 	  the OS-image for the device. This option supplies the missing info.
 	  Enable this for x86 tablets with Silead or Chipone touchscreens.
 
-config X86_ANDROID_TABLETS
-	tristate "X86 Android tablet support"
-	depends on I2C && SPI && SERIAL_DEV_BUS && ACPI && EFI && GPIOLIB
-	help
-	  X86 tablets which ship with Android as (part of) the factory image
-	  typically have various problems with their DSDTs. The factory kernels
-	  shipped on these devices typically have device addresses and GPIOs
-	  hardcoded in the kernel, rather than specified in their DSDT.
-
-	  With the DSDT containing a random collection of devices which may or
-	  may not actually be present. This driver contains various fixes for
-	  such tablets, including instantiating kernel devices for devices which
-	  are missing from the DSDT.
-
-	  If you have a x86 Android tablet say Y or M here, for a generic x86
-	  distro config say M here.
+source "drivers/platform/x86/x86-android-tablets/Kconfig"
 
 config FW_ATTR_CLASS
 	tristate
drivers/platform/x86/Makefile +1 -1
index 1d3d1b02541b..0d9cc9af6ba7 100644
@@ -112,7 +112,7 @@ obj-$(CONFIG_SERIAL_MULTI_INSTANTIATE)	+= serial-multi-instantiate.o
 obj-$(CONFIG_MLX_PLATFORM)		+= mlx-platform.o
 obj-$(CONFIG_TOUCHSCREEN_DMI)		+= touchscreen_dmi.o
 obj-$(CONFIG_WIRELESS_HOTKEY)		+= wireless-hotkey.o
-obj-$(CONFIG_X86_ANDROID_TABLETS)	+= x86-android-tablets.o
+obj-$(CONFIG_X86_ANDROID_TABLETS)	+= x86-android-tablets/
 
 # Intel uncore drivers
 obj-$(CONFIG_INTEL_IPS)				+= intel_ips.o
drivers/platform/x86/x86-android-tablets/Kconfig new file +21 -0
new file mode 100644
index 000000000000..8a0a0242ed92
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# X86 Android tablet support Kconfig
+#
+
+config X86_ANDROID_TABLETS
+	tristate "X86 Android tablet support"
+	depends on I2C && SPI && SERIAL_DEV_BUS && ACPI && EFI && GPIOLIB
+	help
+	  X86 tablets which ship with Android as (part of) the factory image
+	  typically have various problems with their DSDTs. The factory kernels
+	  shipped on these devices typically have device addresses and GPIOs
+	  hardcoded in the kernel, rather than specified in their DSDT.
+
+	  With the DSDT containing a random collection of devices which may or
+	  may not actually be present. This driver contains various fixes for
+	  such tablets, including instantiating kernel devices for devices which
+	  are missing from the DSDT.
+
+	  If you have a x86 Android tablet say Y or M here, for a generic x86
+	  distro config say M here.
drivers/platform/x86/x86-android-tablets/Makefile new file +8 -0
new file mode 100644
index 000000000000..b4d789ff6e70
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0+
+#
+# X86 Android tablet support Makefile
+#
+
+obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets.o
+
+x86-android-tablets-y := x86-android-tablets-main.o
drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c renamed from drivers/platform/x86/x86-android-tablets.c +2 -2
similarity index 99%
rename from drivers/platform/x86/x86-android-tablets.c
rename to drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c
index 8405e1c58d52..08cc5e158460 100644
@@ -34,8 +34,8 @@
 #include <linux/spi/spi.h>
 #include <linux/string.h>
 /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
-#include "../../gpio/gpiolib.h"
-#include "../../gpio/gpiolib-acpi.h"
+#include "../../../gpio/gpiolib.h"
+#include "../../../gpio/gpiolib-acpi.h"
 
 /*
  * Helper code to get Linux IRQ numbers given a description of the IRQ source
Signature · 1 line
2.39.1
#2 lore raw

Re: [PATCH 1/9] platform/x86: x86-android-tablets: Move into its own subdir

Quoted 3 lines · Hans de Goede

Move the x86-android-tablets code into its own subdir, this is a preparation patch for splitting the somewhat large file into multiple smaller files.

I'm in favour of the move, but some comments here and there...

...

Quoted 1 line

+# SPDX-License-Identifier: GPL-2.0+

Perhaps switch to "-or-later"?

...

drivers/platform/x86/x86-android-tablets/Kconfig line 8

Quoted 3 lines
drivers/platform/x86/x86-android-tablets/Kconfig new file +3 -0
+config X86_ANDROID_TABLETS
+	tristate "X86 Android tablet support"
+	depends on I2C && SPI && SERIAL_DEV_BUS && ACPI && EFI && GPIOLIB

I'm wondering if we can increase (compile) test coverage by splitting and refactoring like

	depends on ACPI && EFI
	depends on (I2C && SPI && SERIAL_DEV_BUS && GPIOLIB) || COMPILE_TEST
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

PATCH 2/9 platform/x86: x86-android-tablets: Move core code into new core.c file

In reply to Hans de Goede

Move the helpers to get irqs + gpios as well as the core code for instantiating all the devices missing from ACPI into a new core.c file.

---
 .../platform/x86/x86-android-tablets/Makefile |   2 +-
 .../platform/x86/x86-android-tablets/core.c   | 363 ++++++++++++++++
 .../x86-android-tablets-main.c                | 406 +-----------------
 .../x86-android-tablets/x86-android-tablets.h |  77 ++++
 4 files changed, 443 insertions(+), 405 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/core.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/x86-android-tablets.h
drivers/platform/x86/x86-android-tablets/Makefile +1 -1
index b4d789ff6e70..49c6bda1f817 100644
@@ -5,4 +5,4 @@
 
 obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets.o
 
-x86-android-tablets-y := x86-android-tablets-main.o
+x86-android-tablets-y := core.o x86-android-tablets-main.o
drivers/platform/x86/x86-android-tablets/core.c new file +363 -0

363 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c +2 -404

431 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/x86-android-tablets.h new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.39.1
#4 lore raw

Re: [PATCH 2/9] platform/x86: x86-android-tablets: Move core code into new core.c file

Quoted 2 lines · Hans de Goede

Move the helpers to get irqs + gpios as well as the core code for instantiating all the devices missing from ACPI into a new core.c file.

...

drivers/platform/x86/x86-android-tablets/core.c line 29

Quoted 4 lines
drivers/platform/x86/x86-android-tablets/core.c new file +4 -0
+static int gpiochip_find_match_label(struct gpio_chip *gc, void *data)
+{
+	return gc->label && !strcmp(gc->label, data);
+}

Can we actually export find_chip_by_name() from GPIOLIB and reuse it here? (Perhaps it may require a separate patch(es) to be added)

...

Quoted 7 lines
drivers/platform/x86/x86-android-tablets/core.c new file +7 -0
+	case X86_ACPI_IRQ_TYPE_GPIOINT:
+		/* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */
+		ret = x86_android_tablet_get_gpiod(data->chip, data->index, &gpiod);
+		if (ret)
+			return ret;
+
+		irq = gpiod_to_irq(gpiod);

drivers/platform/x86/x86-android-tablets/core.c line 92

Quoted 10 lines
drivers/platform/x86/x86-android-tablets/core.c new file +10 -0
+		if (irq < 0) {
+			pr_err("error %d getting IRQ %s %d\n", irq, data->chip, data->index);
+			return irq;
+		}
+
+		irq_type = acpi_dev_get_irq_type(data->trigger, data->polarity);
+		if (irq_type != IRQ_TYPE_NONE && irq_type != irq_get_trigger_type(irq))
+			irq_set_irq_type(irq, irq_type);
+
+		return irq;

Similar Q here.

...

drivers/platform/x86/x86-android-tablets/core.c line 226

Quoted 3 lines
drivers/platform/x86/x86-android-tablets/core.c new file +3 -0
+static void x86_android_tablet_cleanup(void)
+{
+	int i;

unsigned?

drivers/platform/x86/x86-android-tablets/core.c line 229

Quoted 2 lines
drivers/platform/x86/x86-android-tablets/core.c new file +2 -0
+	for (i = 0; i < serdev_count; i++) {
+		if (serdevs[i])

Interesting that serdev requires this check in the callers.

Quoted 23 lines
drivers/platform/x86/x86-android-tablets/core.c new file +23 -0
+			serdev_device_remove(serdevs[i]);
+	}
+
+	kfree(serdevs);
+
+	for (i = 0; i < pdev_count; i++)
+		platform_device_unregister(pdevs[i]);
+
+	kfree(pdevs);
+
+	for (i = 0; i < i2c_client_count; i++)
+		i2c_unregister_device(i2c_clients[i]);
+
+	kfree(i2c_clients);
+
+	if (exit_handler)
+		exit_handler();
+
+	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
+		gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
+
+	software_node_unregister(bat_swnode);
+}

...

Quoted 1 line

+extern const struct dmi_system_id x86_android_tablet_ids[];

Why not in the header?

...

drivers/platform/x86/x86-android-tablets/core.c line 299

Quoted 3 lines
drivers/platform/x86/x86-android-tablets/core.c new file +3 -0
+	gpiod_lookup_tables = dev_info->gpiod_lookup_tables;
+	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
+		gpiod_add_lookup_table(gpiod_lookup_tables[i]);

gpiod_add_lookup_tables() ?

...

drivers/platform/x86/x86-android-tablets/x86-android-tablets.h line 14

Quoted 5 lines
drivers/platform/x86/x86-android-tablets/x86-android-tablets.h new file +4 -0
+#ifndef __X86_ANDROID_TABLETS_H
+#define __X86_ANDROID_TABLETS_H
 
+#include <linux/gpio/consumer.h>
+#include <linux/gpio/machine.h>

I don't see users of these headers here (forward declarations may do the job).

...

Quoted 1 line

+#include <linux/platform_device.h>

Ditto.

And seems missing other forward declaration(s?), like software_node.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

PATCH 3/9 platform/x86: x86-android-tablets: Move DMI match table into its own dmi.c file

In reply to Hans de Goede

In order to have a single MODULE_DEVICE_TABLE(dmi, ...), while allowing splitting the board descriptions into multiple files, add a new separate file for the DMI match table.

---
 .../platform/x86/x86-android-tablets/Makefile |   2 +-
 .../platform/x86/x86-android-tablets/dmi.c    | 166 ++++++++++++++++++
 .../x86-android-tablets-main.c                | 160 ++---------------
 3 files changed, 180 insertions(+), 148 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/dmi.c
drivers/platform/x86/x86-android-tablets/Makefile +1 -1
index 49c6bda1f817..ba16dc014e03 100644
@@ -5,4 +5,4 @@
 
 obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets.o
 
-x86-android-tablets-y := core.o x86-android-tablets-main.o
+x86-android-tablets-y := core.o dmi.o x86-android-tablets-main.o
drivers/platform/x86/x86-android-tablets/dmi.c new file +166 -0

166 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c +13 -147

247 lines not on this page · raw message

Signature · 1 line
2.39.1
#6 lore raw

Re: [PATCH 3/9] platform/x86: x86-android-tablets: Move DMI match table into its own dmi.c file

Quoted 3 lines · Hans de Goede

In order to have a single MODULE_DEVICE_TABLE(dmi, ...), while allowing splitting the board descriptions into multiple files, add a new separate file for the DMI match table.

...

Quoted 3 lines

+ * In order to have a single MODULE_DEVICE_TABLE(dmi, ...), while allowing
+ * splitting the board descriptions into multiple files, add extern declarations
+ * of the x86_dev_info structs here.

But why this can't be simply done in the local header? Does it not compile?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#7 lore raw

PATCH 4/9 platform/x86: x86-android-tablets: Move shared power-supply fw-nodes to a separate file

In reply to Hans de Goede

Move the shared power-supply fw-nodes and related files to a new separate shared-psy-info.c file.

---
 .../platform/x86/x86-android-tablets/Makefile |   2 +-
 .../x86/x86-android-tablets/shared-psy-info.c | 100 +++++++++++++++++
 .../x86/x86-android-tablets/shared-psy-info.h |  32 ++++++
 .../x86-android-tablets-main.c                | 101 ++----------------
 4 files changed, 142 insertions(+), 93 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/shared-psy-info.c
 create mode 100644 drivers/platform/x86/x86-android-tablets/shared-psy-info.h
drivers/platform/x86/x86-android-tablets/Makefile +1 -1
index ba16dc014e03..6383a1b26481 100644
@@ -5,4 +5,4 @@
 
 obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets.o
 
-x86-android-tablets-y := core.o dmi.o x86-android-tablets-main.o
+x86-android-tablets-y := core.o dmi.o shared-psy-info.o x86-android-tablets-main.o
drivers/platform/x86/x86-android-tablets/shared-psy-info.c new file +100 -0

100 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/shared-psy-info.h new file +32 -0
new file mode 100644
index 000000000000..bff3c82a16fb
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0+
+ *
+ * Shared psy info for X86 tablets which ship with Android as the factory image
+ * and which have broken DSDT tables. The factory kernels shipped on these
+ * devices typically have a bunch of things hardcoded, rather than specified
+ * in their DSDT.
+ *
+ * Copyright (C) 2021-2023 Hans de Goede <[email protected]>
+ */
+#ifndef __SHARED_PSY_INFO_H
+#define __SHARED_PSY_INFO_H
+
+#include <linux/power/bq24190_charger.h>
+#include <linux/gpio/machine.h>
+#include <linux/platform_device.h>
+#include <linux/property.h>
+
+extern const char * const tusb1211_chg_det_psy[];
+extern const char * const bq24190_psy[];
+extern const char * const bq25890_psy[];
+
+extern const struct software_node fg_bq24190_supply_node;
+extern const struct software_node fg_bq25890_supply_node;
+extern const struct software_node generic_lipo_hv_4v35_battery_node;
+
+extern struct bq24190_platform_data bq24190_pdata;
+extern const char * const bq24190_modules[];
+
+extern const struct platform_device_info int3496_pdevs[];
+extern struct gpiod_lookup_table int3496_reference_gpios;
+
+#endif
drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c +9 -92

167 lines not on this page · raw message

Signature · 1 line
2.39.1
#8 lore raw

Re: [PATCH 4/9] platform/x86: x86-android-tablets: Move shared power-supply fw-nodes to a separate file

Quoted 2 lines · Hans de Goede

Move the shared power-supply fw-nodes and related files to a new separate shared-psy-info.c file.

...

drivers/platform/x86/x86-android-tablets/shared-psy-info.h line 11

Quoted 2 lines
drivers/platform/x86/x86-android-tablets/shared-psy-info.h new file +2 -0
+#ifndef __SHARED_PSY_INFO_H
+#define __SHARED_PSY_INFO_H

For all headers in this folder. Can we have them prefixed with PDX86 or similar?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw

Re: [PATCH 4/9] platform/x86: x86-android-tablets: Move shared power-supply fw-nodes to a separate file

Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Hans de Goede

Move the shared power-supply fw-nodes and related files to a new separate shared-psy-info.c file.

...

Quoted 5 lines

drivers/platform/x86/x86-android-tablets/shared-psy-info.h line 11

Quoted 2 lines
drivers/platform/x86/x86-android-tablets/shared-psy-info.h new file +2 -0
+#ifndef __SHARED_PSY_INFO_H
+#define __SHARED_PSY_INFO_H

For all headers in this folder. Can we have them prefixed with PDX86 or similar?

I meant in the definitions like above.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#10 lore raw

PATCH 5/9 platform/x86: x86-android-tablets: Move Asus tablets to their own file

In reply to Hans de Goede

Move the info for the Asus tablets to their own asus.c file.

---
 .../platform/x86/x86-android-tablets/Makefile |   2 +-
 .../platform/x86/x86-android-tablets/asus.c   | 355 ++++++++++++++++++
 .../x86-android-tablets-main.c                | 340 -----------------
 3 files changed, 356 insertions(+), 341 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/asus.c
drivers/platform/x86/x86-android-tablets/Makefile +1 -1
index 6383a1b26481..a527f0a94034 100644
@@ -5,4 +5,4 @@
 
 obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets.o
 
-x86-android-tablets-y := core.o dmi.o shared-psy-info.o x86-android-tablets-main.o
+x86-android-tablets-y := core.o dmi.o shared-psy-info.o asus.o x86-android-tablets-main.o
drivers/platform/x86/x86-android-tablets/asus.c new file +355 -0

355 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c +0 -340

352 lines not on this page · raw message

Signature · 1 line
2.39.1
#11 lore raw

PATCH 6/9 platform/x86: x86-android-tablets: Move Lenovo tablets to their own file

In reply to Hans de Goede

Move the info for the Lenovo tablets to their own lenovo.c file.

---
 .../platform/x86/x86-android-tablets/Makefile |   3 +-
 .../platform/x86/x86-android-tablets/lenovo.c | 417 ++++++++++++++++++
 .../x86-android-tablets-main.c                | 405 -----------------
 3 files changed, 419 insertions(+), 406 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/lenovo.c
drivers/platform/x86/x86-android-tablets/Makefile +2 -1
index a527f0a94034..d0e4f0353a00 100644
@@ -5,4 +5,5 @@
 
 obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets.o
 
-x86-android-tablets-y := core.o dmi.o shared-psy-info.o asus.o x86-android-tablets-main.o
+x86-android-tablets-y := core.o dmi.o shared-psy-info.o \
+			 asus.o lenovo.o x86-android-tablets-main.o
drivers/platform/x86/x86-android-tablets/lenovo.c new file +417 -0

417 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c +0 -405

420 lines not on this page · raw message

Signature · 1 line
2.39.1
#12 lore raw

PATCH 7/9 platform/x86: x86-android-tablets: Move remaining tablets to other.c

In reply to Hans de Goede

All that remains now in x86-android-tablets-main.c is info for other (non Asus / Lenovo) tablets. Rename it to other.c to reflect this.

---
 drivers/platform/x86/x86-android-tablets/Makefile               | 2 +-
 .../x86-android-tablets/{x86-android-tablets-main.c => other.c} | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
 rename drivers/platform/x86/x86-android-tablets/{x86-android-tablets-main.c => other.c} (99%)
drivers/platform/x86/x86-android-tablets/Makefile +1 -1
index d0e4f0353a00..12f5eb2c9b84 100644
@@ -6,4 +6,4 @@
 obj-$(CONFIG_X86_ANDROID_TABLETS) += x86-android-tablets.o
 
 x86-android-tablets-y := core.o dmi.o shared-psy-info.o \
-			 asus.o lenovo.o x86-android-tablets-main.o
+			 asus.o lenovo.o other.o
drivers/platform/x86/x86-android-tablets/other.c renamed from drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c +1 -1
similarity index 99%
rename from drivers/platform/x86/x86-android-tablets/x86-android-tablets-main.c
rename to drivers/platform/x86/x86-android-tablets/other.c
index cb8d84983503..a0f8c4bb3237 100644
@@ -5,7 +5,7 @@
  * devices typically have a bunch of things hardcoded, rather than specified
  * in their DSDT.
  *
- * Copyright (C) 2021-2022 Hans de Goede <[email protected]>
+ * Copyright (C) 2021-2023 Hans de Goede <[email protected]>
  */
 
 #include <linux/acpi.h>
Signature · 1 line
2.39.1
#13 lore raw

PATCH 8/9 platform/x86: x86-android-tablets: Add gpio_keys support to x86_android_tablet_init()

In reply to Hans de Goede

Add gpio_keys instantation support to x86_android_tablet_init(), to avoid this having to be repeated in various x86_dev_info.init() functions.

---
 .../platform/x86/x86-android-tablets/asus.c   | 53 ++++---------------
 .../platform/x86/x86-android-tablets/core.c   | 30 ++++++++++-
 .../platform/x86/x86-android-tablets/other.c  | 37 ++-----------
 .../x86-android-tablets/x86-android-tablets.h |  4 ++
 4 files changed, 48 insertions(+), 76 deletions(-)
drivers/platform/x86/x86-android-tablets/asus.c +11 -42
index c7d3ca73ebd3..78e5d10eb803 100644
@@ -8,7 +8,6 @@
  * Copyright (C) 2021-2023 Hans de Goede <[email protected]>
  */
 
-#include <linux/gpio_keys.h>
 #include <linux/input.h>
 
 #include "shared-psy-info.h"
@@ -25,7 +24,7 @@ static struct gpiod_lookup_table int3496_gpo2_pin22_gpios = {
 
 static struct gpio_keys_button asus_me176c_tf103c_lid = {
 	.code = SW_LID,
-	/* .gpio gets filled in by asus_me176c_tf103c_init() */
+	/* .gpio gets filled in by x86_android_tablet_init() */
 	.active_low = true,
 	.desc = "lid_sw",
 	.type = EV_SW,
@@ -33,40 +32,6 @@ static struct gpio_keys_button asus_me176c_tf103c_lid = {
 	.debounce_interval = 50,
 };
 
-static const struct gpio_keys_platform_data asus_me176c_tf103c_lid_pdata __initconst = {
-	.buttons = &asus_me176c_tf103c_lid,
-	.nbuttons = 1,
-	.name = "lid_sw",
-};
-
-static const struct platform_device_info asus_me176c_tf103c_pdevs[] __initconst = {
-	{
-		.name = "gpio-keys",
-		.id = PLATFORM_DEVID_AUTO,
-		.data = &asus_me176c_tf103c_lid_pdata,
-		.size_data = sizeof(asus_me176c_tf103c_lid_pdata),
-	},
-	{
-		/* For micro USB ID pin handling */
-		.name = "intel-int3496",
-		.id = PLATFORM_DEVID_NONE,
-	},
-};
-
-static int __init asus_me176c_tf103c_init(void)
-{
-	struct gpio_desc *gpiod;
-	int ret;
-
-	ret = x86_android_tablet_get_gpiod("INT33FC:02", 12, &gpiod);
-	if (ret < 0)
-		return ret;
-	asus_me176c_tf103c_lid.gpio = desc_to_gpio(gpiod);
-
-	return 0;
-}
-
-
 /* Asus ME176C tablets have an Android factory img with everything hardcoded */
 static const char * const asus_me176c_accel_mount_matrix[] = {
 	"-1", "0", "0",
@@ -200,15 +165,17 @@ static struct gpiod_lookup_table * const asus_me176c_gpios[] = {
 const struct x86_dev_info asus_me176c_info __initconst = {
 	.i2c_client_info = asus_me176c_i2c_clients,
 	.i2c_client_count = ARRAY_SIZE(asus_me176c_i2c_clients),
-	.pdev_info = asus_me176c_tf103c_pdevs,
-	.pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs),
+	.pdev_info = int3496_pdevs,
+	.pdev_count = 1,
 	.serdev_info = asus_me176c_serdevs,
 	.serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
 	.gpiod_lookup_tables = asus_me176c_gpios,
 	.bat_swnode = &generic_lipo_hv_4v35_battery_node,
 	.modules = bq24190_modules,
 	.invalid_aei_gpiochip = "INT33FC:02",
-	.init = asus_me176c_tf103c_init,
+	.gpio_keys_button = &asus_me176c_tf103c_lid,
+	.gpio_keys_gpiochip = "INT33FC:02",
+	.gpio_keys_pin = 12,
 };
 
 /* Asus TF103C tablets have an Android factory img with everything hardcoded */
@@ -345,11 +312,13 @@ static struct gpiod_lookup_table * const asus_tf103c_gpios[] = {
 const struct x86_dev_info asus_tf103c_info __initconst = {
 	.i2c_client_info = asus_tf103c_i2c_clients,
 	.i2c_client_count = ARRAY_SIZE(asus_tf103c_i2c_clients),
-	.pdev_info = asus_me176c_tf103c_pdevs,
-	.pdev_count = ARRAY_SIZE(asus_me176c_tf103c_pdevs),
+	.pdev_info = int3496_pdevs,
+	.pdev_count = 1,
 	.gpiod_lookup_tables = asus_tf103c_gpios,
 	.bat_swnode = &asus_tf103c_battery_node,
 	.modules = bq24190_modules,
 	.invalid_aei_gpiochip = "INT33FC:02",
-	.init = asus_me176c_tf103c_init,
+	.gpio_keys_button = &asus_me176c_tf103c_lid,
+	.gpio_keys_gpiochip = "INT33FC:02",
+	.gpio_keys_pin = 12,
 };
drivers/platform/x86/x86-android-tablets/core.c +29 -1
index 5d04e63e1ebc..32819e7d4763 100644
@@ -322,7 +322,8 @@ static __init int x86_android_tablet_init(void)
 		}
 	}
 
-	pdevs = kcalloc(dev_info->pdev_count, sizeof(*pdevs), GFP_KERNEL);
+	/* + 1 to make space for (optional) gpio_keys_button pdev */
+	pdevs = kcalloc(dev_info->pdev_count + 1, sizeof(*pdevs), GFP_KERNEL);
 	if (!pdevs) {
 		x86_android_tablet_cleanup();
 		return -ENOMEM;
@@ -352,6 +353,33 @@ static __init int x86_android_tablet_init(void)
 		}
 	}
 
+	if (dev_info->gpio_keys_button) {
+		struct gpio_keys_platform_data pdata = {
+			.buttons = dev_info->gpio_keys_button,
+			.nbuttons = 1,
+		};
+		struct gpio_desc *gpiod;
+
+		/* Get GPIO for the gpio-button */
+		ret = x86_android_tablet_get_gpiod(dev_info->gpio_keys_gpiochip,
+						   dev_info->gpio_keys_pin, &gpiod);
+		if (ret < 0) {
+			x86_android_tablet_cleanup();
+			return ret;
+		}
+
+		dev_info->gpio_keys_button->gpio = desc_to_gpio(gpiod);
+
+		pdevs[pdev_count] = platform_device_register_data(NULL, "gpio-keys",
+								  PLATFORM_DEVID_AUTO,
+								  &pdata, sizeof(pdata));
+		if (IS_ERR(pdevs[pdev_count])) {
+			x86_android_tablet_cleanup();
+			return PTR_ERR(pdevs[pdev_count]);
+		}
+		pdev_count++;
+	}
+
 	return 0;
 }
 
drivers/platform/x86/x86-android-tablets/other.c +4 -33
index a0f8c4bb3237..e4b3ad2ce7c1 100644
@@ -9,7 +9,6 @@
  */
 
 #include <linux/acpi.h>
-#include <linux/gpio_keys.h>
 #include <linux/input.h>
 
 #include "shared-psy-info.h"
@@ -95,7 +94,7 @@ const struct x86_dev_info acer_b1_750_info __initconst = {
  */
 static struct gpio_keys_button advantech_mica_071_button = {
 	.code = KEY_PROG1,
-	/* .gpio gets filled in by advantech_mica_071_init() */
+	/* .gpio gets filled in by x86_android_tablet_init() */
 	.active_low = true,
 	.desc = "prog1_key",
 	.type = EV_KEY,
@@ -103,38 +102,10 @@ static struct gpio_keys_button advantech_mica_071_button = {
 	.debounce_interval = 50,
 };
 
-static const struct gpio_keys_platform_data advantech_mica_071_button_pdata __initconst = {
-	.buttons = &advantech_mica_071_button,
-	.nbuttons = 1,
-	.name = "prog1_key",
-};
-
-static const struct platform_device_info advantech_mica_071_pdevs[] __initconst = {
-	{
-		.name = "gpio-keys",
-		.id = PLATFORM_DEVID_AUTO,
-		.data = &advantech_mica_071_button_pdata,
-		.size_data = sizeof(advantech_mica_071_button_pdata),
-	},
-};
-
-static int __init advantech_mica_071_init(void)
-{
-	struct gpio_desc *gpiod;
-	int ret;
-
-	ret = x86_android_tablet_get_gpiod("INT33FC:00", 2, &gpiod);
-	if (ret < 0)
-		return ret;
-	advantech_mica_071_button.gpio = desc_to_gpio(gpiod);
-
-	return 0;
-}
-
 const struct x86_dev_info advantech_mica_071_info __initconst = {
-	.pdev_info = advantech_mica_071_pdevs,
-	.pdev_count = ARRAY_SIZE(advantech_mica_071_pdevs),
-	.init = advantech_mica_071_init,
+	.gpio_keys_button = &advantech_mica_071_button,
+	.gpio_keys_gpiochip = "INT33FC:00",
+	.gpio_keys_pin = 2,
 };
 
 /*
drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +4 -0
index 2023b53e0df2..f93d0fc61b7d 100644
@@ -10,6 +10,7 @@
 #ifndef __X86_ANDROID_TABLETS_H
 #define __X86_ANDROID_TABLETS_H
 
+#include <linux/gpio_keys.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
 #include <linux/i2c.h>
@@ -67,6 +68,9 @@ struct x86_dev_info {
 	int i2c_client_count;
 	int pdev_count;
 	int serdev_count;
+	int gpio_keys_pin;
+	const char *gpio_keys_gpiochip;
+	struct gpio_keys_button *gpio_keys_button;
 	int (*init)(void);
 	void (*exit)(void);
 };
Signature · 1 line
2.39.1
#14 lore raw

Re: [PATCH 8/9] platform/x86: x86-android-tablets: Add gpio_keys support to x86_android_tablet_init()

Quoted 2 lines · Hans de Goede

Add gpio_keys instantation support to x86_android_tablet_init(), to avoid this having to be repeated in various x86_dev_info.init() functions.

...

drivers/platform/x86/x86-android-tablets/asus.c static struct gpiod_lookup_table * const asus_me176c_gpios[] = { · line 178

Quoted 3 lines
drivers/platform/x86/x86-android-tablets/asus.c +3 -0
+	.gpio_keys_button = &asus_me176c_tf103c_lid,
+	.gpio_keys_gpiochip = "INT33FC:02",
+	.gpio_keys_pin = 12,

Maybe

struct x86_gpio_button {
	struct gpio_keys_button *button;
	const char *chip;
	int pin;
};
	.button = {
		.button = ,
		.chip = ,
		.pin = ,
	},

?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#15 lore raw

PATCH 9/9 platform/x86: x86-android-tablets: Add support for the Dolby button on Peaq C1010

In reply to Hans de Goede

The Peaq C1010 tablet has a special "Dolby" button. This button has a WMI interface, but this is broken in several ways:

1. It only supports polling
2. The value read on polling goes from 0 -> 1 for one poll on both edges of the button, with no way to tell which edge causes the poll to return 1.
3. It uses a non unique GUID (it uses the Microsoft docs WMI example GUID).

There currently is a WMI driver for this, but it uses several kludges to work around these issues and is not entirely reliable due to 2.

Replace the unreliable WMI driver by using the x86-android-tablets code to instantiate a gpio_keys device for this.

---
 MAINTAINERS                                   |   6 -
 drivers/platform/x86/Kconfig                  |   7 -
 drivers/platform/x86/Makefile                 |   1 -
 drivers/platform/x86/peaq-wmi.c               | 128 ------------------
 .../platform/x86/x86-android-tablets/dmi.c    |   9 ++
 .../platform/x86/x86-android-tablets/other.c  |  27 ++++
 6 files changed, 36 insertions(+), 142 deletions(-)
 delete mode 100644 drivers/platform/x86/peaq-wmi.c
MAINTAINERS +0 -6
index 87cc1e6b37c0..3c86814fc3ab 100644
@@ -16377,12 +16377,6 @@ S:	Maintained
 F:	crypto/pcrypt.c
 F:	include/crypto/pcrypt.h
 
-PEAQ WMI HOTKEYS DRIVER
-M:	Hans de Goede <[email protected]>
-L:	[email protected]
-S:	Maintained
-F:	drivers/platform/x86/peaq-wmi.c
-
 PECI HARDWARE MONITORING DRIVERS
 M:	Iwona Winiarska <[email protected]>
 L:	[email protected]
drivers/platform/x86/Kconfig +0 -7
index 8b4e03fe5bff..e7166812875a 100644
@@ -84,13 +84,6 @@ config MXM_WMI
           MXM is a standard for laptop graphics cards, the WMI interface
 	  is required for switchable nvidia graphics machines
 
-config PEAQ_WMI
-	tristate "PEAQ 2-in-1 WMI hotkey driver"
-	depends on ACPI_WMI
-	depends on INPUT
-	help
-	 Say Y here if you want to support WMI-based hotkeys on PEAQ 2-in-1s.
-
 config NVIDIA_WMI_EC_BACKLIGHT
 	tristate "EC Backlight Driver for Hybrid Graphics Notebook Systems"
 	depends on ACPI_VIDEO
drivers/platform/x86/Makefile +0 -1
index 0d9cc9af6ba7..12407f36d2be 100644
@@ -12,7 +12,6 @@ obj-$(CONFIG_WMI_BMOF)		+= wmi-bmof.o
 obj-$(CONFIG_HUAWEI_WMI)		+= huawei-wmi.o
 obj-$(CONFIG_MXM_WMI)			+= mxm-wmi.o
 obj-$(CONFIG_NVIDIA_WMI_EC_BACKLIGHT)	+= nvidia-wmi-ec-backlight.o
-obj-$(CONFIG_PEAQ_WMI)			+= peaq-wmi.o
 obj-$(CONFIG_XIAOMI_WMI)		+= xiaomi-wmi.o
 obj-$(CONFIG_GIGABYTE_WMI)		+= gigabyte-wmi.o
 obj-$(CONFIG_YOGABOOK_WMI)		+= lenovo-yogabook-wmi.o
drivers/platform/x86/peaq-wmi.c deleted +0 -128

128 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/dmi.c +9 -0
index ec7c0af8d73d..9a236bcd9728 100644
@@ -30,6 +30,7 @@ extern struct x86_dev_info lenovo_yoga_tab2_830_1050_info;
 extern const struct x86_dev_info lenovo_yt3_info;
 extern const struct x86_dev_info medion_lifetab_s10346_info;
 extern const struct x86_dev_info nextbook_ares8_info;
+extern const struct x86_dev_info peaq_c1010_info;
 extern const struct x86_dev_info whitelabel_tm800a550l_info;
 extern const struct x86_dev_info xiaomi_mipad2_info;
 
@@ -143,6 +144,14 @@ const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
 		},
 		.driver_data = (void *)&nextbook_ares8_info,
 	},
+	{
+		/* Peaq C1010 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "PEAQ"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "PEAQ PMM C1010 MD99187"),
+		},
+		.driver_data = (void *)&peaq_c1010_info,
+	},
 	{
 		/* Whitelabel (sold as various brands) TM800A550L */
 		.matches = {
drivers/platform/x86/x86-android-tablets/other.c +27 -0
index e4b3ad2ce7c1..e09d3baff677 100644
@@ -377,6 +377,33 @@ const struct x86_dev_info nextbook_ares8_info __initconst = {
 	.invalid_aei_gpiochip = "INT33FC:02",
 };
 
+/*
+ * Peaq C1010
+ * This is a standard Windows tablet, but it has a special Dolby button.
+ * This button has a WMI interface, but that is broken. Instead of trying to
+ * use the broken WMI interface, instantiate a gpio_keys device for this.
+ */
+static struct gpio_keys_button peaq_c1010_button = {
+	.code = KEY_SOUND,
+	/* .gpio gets filled in by x86_android_tablet_init() */
+	.active_low = true,
+	.desc = "dolby_key",
+	.type = EV_KEY,
+	.wakeup = false,
+	.debounce_interval = 50,
+};
+
+const struct x86_dev_info peaq_c1010_info __initconst = {
+	.gpio_keys_button = &peaq_c1010_button,
+	.gpio_keys_gpiochip = "INT33FC:00",
+	.gpio_keys_pin = 3,
+	/*
+	 * Move the ACPI event handler used by the broken WMI interface out of
+	 * the way. This is the only event handler on INT33FC:00.
+	 */
+	.invalid_aei_gpiochip = "INT33FC:00",
+};
+
 /*
  * Whitelabel (sold as various brands) TM800A550L tablets.
  * These tablet's DSDT contains a whole bunch of bogus ACPI I2C devices
Signature · 1 line
2.39.1