Skip to contentSkip to conversation

platform/x86: x86-android-tablets: Split in multiple files + misc additions

PATCH In review Hans de Goede 2 participants 27 messages Mar 1, 2023

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

v2 cover platform/x86: x86-android-tablets: Split in multiple files + misc additions

Hi All,

Here is version 2 of my series to move the x86-android-tablets driver into its own subdir and to split it into multiple-files.

Changes in v2:
-Gather all outstanding x86-android-tablets changes in 1 series. -Address all Andy's review remarks, see individual commit messages
for details. Thank you for all the reviews Andy!
-New patches:
-Add LID switch support to Yoga Tablet 2 1050/830 series -Lenovo Yoga Book match is for YB1-X91 models only

Regards,

Hans

Hans de Goede (14):
platform/x86: x86-android-tablets: Add Acer Iconia One 7 B1-750 data 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
  platform/x86: x86-android-tablets: Add touchscreen support for Lenovo
    Yoga Tab 3 Pro YT3-X90F
  platform/x86: x86-android-tablets: Add backlight ctrl for Lenovo Yoga
    Tab 3 Pro YT3-X90F
  platform/x86: x86-android-tablets: Add LID switch support for Yoga
    Tablet 2 1050/830 series

platform/x86: x86-android-tablets: Lenovo Yoga Book match is for
YB1-X91 models only

 MAINTAINERS                                   |    8 +-
 drivers/platform/x86/Kconfig                  |   24 +-
 drivers/platform/x86/Makefile                 |    3 +-
 drivers/platform/x86/peaq-wmi.c               |  128 --
 drivers/platform/x86/x86-android-tablets.c    | 1803 -----------------
 .../platform/x86/x86-android-tablets/Kconfig  |   21 +
 .../platform/x86/x86-android-tablets/Makefile |    9 +
 .../platform/x86/x86-android-tablets/asus.c   |  325 +++
 .../platform/x86/x86-android-tablets/core.c   |  391 ++++
 .../platform/x86/x86-android-tablets/dmi.c    |  154 ++
 .../platform/x86/x86-android-tablets/lenovo.c |  502 +++++
 .../platform/x86/x86-android-tablets/other.c  |  522 +++++
 .../x86/x86-android-tablets/shared-psy-info.c |  101 +
 .../x86/x86-android-tablets/shared-psy-info.h |   32 +
 .../x86-android-tablets/x86-android-tablets.h |  108 +
 15 files changed, 2168 insertions(+), 1963 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 v2 1/14 platform/x86: x86-android-tablets: Add Acer Iconia One 7 B1-750 data

The Acer Iconia One 7 B1-750 is a x86 ACPI tablet which ships with Android x86 as factory OS. Its DSDT contains a bunch of I2C devices which are not actually there, causing various resource conflicts. Enumeration of these is skipped through the acpi_quirk_skip_i2c_client_enumeration().

Add support for manually instantiating the I2C + other devices which are actually present on this tablet by adding the necessary device info to the x86-android-tablets module.

---
 drivers/platform/x86/x86-android-tablets.c | 101 +++++++++++++++++++--
 1 file changed, 91 insertions(+), 10 deletions(-)
drivers/platform/x86/x86-android-tablets.c +91 -10
index 111b007656fc..8405e1c58d52 100644
@@ -265,6 +265,88 @@ static struct gpiod_lookup_table int3496_gpo2_pin22_gpios = {
 	},
 };
 
+static struct gpiod_lookup_table int3496_reference_gpios = {
+	.dev_id = "intel-int3496",
+	.table = {
+		GPIO_LOOKUP("INT33FC:01", 15, "vbus", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("INT33FC:02", 1, "mux", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("INT33FC:02", 18, "id", GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+/* Acer Iconia One 7 B1-750 has an Android factory img with everything hardcoded */
+static const char * const acer_b1_750_mount_matrix[] = {
+	"-1", "0", "0",
+	"0", "1", "0",
+	"0", "0", "1"
+};
+
+static const struct property_entry acer_b1_750_bma250e_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", acer_b1_750_mount_matrix),
+	{ }
+};
+
+static const struct software_node acer_b1_750_bma250e_node = {
+	.properties = acer_b1_750_bma250e_props,
+};
+
+static const struct x86_i2c_client_info acer_b1_750_i2c_clients[] __initconst = {
+	{
+		/* Novatek NVT-ts touchscreen */
+		.board_info = {
+			.type = "NVT-ts",
+			.addr = 0x34,
+			.dev_name = "NVT-ts",
+		},
+		.adapter_path = "\\_SB_.I2C4",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
+			.chip = "INT33FC:02",
+			.index = 3,
+			.trigger = ACPI_EDGE_SENSITIVE,
+			.polarity = ACPI_ACTIVE_LOW,
+		},
+	}, {
+		/* BMA250E accelerometer */
+		.board_info = {
+			.type = "bma250e",
+			.addr = 0x18,
+			.swnode = &acer_b1_750_bma250e_node,
+		},
+		.adapter_path = "\\_SB_.I2C3",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
+			.chip = "INT33FC:02",
+			.index = 25,
+			.trigger = ACPI_LEVEL_SENSITIVE,
+			.polarity = ACPI_ACTIVE_HIGH,
+		},
+	},
+};
+
+static struct gpiod_lookup_table acer_b1_750_goodix_gpios = {
+	.dev_id = "i2c-NVT-ts",
+	.table = {
+		GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_LOW),
+		{ }
+	},
+};
+
+static struct gpiod_lookup_table * const acer_b1_750_gpios[] = {
+	&acer_b1_750_goodix_gpios,
+	&int3496_reference_gpios,
+	NULL
+};
+
+static const struct x86_dev_info acer_b1_750_info __initconst = {
+	.i2c_client_info = acer_b1_750_i2c_clients,
+	.i2c_client_count = ARRAY_SIZE(acer_b1_750_i2c_clients),
+	.pdev_info = int3496_pdevs,
+	.pdev_count = ARRAY_SIZE(int3496_pdevs),
+	.gpiod_lookup_tables = acer_b1_750_gpios,
+};
+
 /*
  * Advantech MICA-071
  * This is a standard Windows tablet, but it has an extra "quick launch" button
@@ -1298,17 +1380,8 @@ static const struct x86_i2c_client_info nextbook_ares8_i2c_clients[] __initconst
 	},
 };
 
-static struct gpiod_lookup_table nextbook_ares8_int3496_gpios = {
-	.dev_id = "intel-int3496",
-	.table = {
-		GPIO_LOOKUP("INT33FC:02", 1, "mux", GPIO_ACTIVE_HIGH),
-		GPIO_LOOKUP("INT33FC:02", 18, "id", GPIO_ACTIVE_HIGH),
-		{ }
-	},
-};
-
 static struct gpiod_lookup_table * const nextbook_ares8_gpios[] = {
-	&nextbook_ares8_int3496_gpios,
+	&int3496_reference_gpios,
 	NULL
 };
 
@@ -1435,6 +1508,14 @@ static const struct x86_dev_info xiaomi_mipad2_info __initconst = {
 };
 
 static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
+	{
+		/* Acer Iconia One 7 B1-750 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "VESPA2"),
+		},
+		.driver_data = (void *)&acer_b1_750_info,
+	},
 	{
 		/* Advantech MICA-071 */
 		.matches = {
Signature · 1 line
2.39.1
#2 lore raw

PATCH v2 2/14 platform/x86: x86-android-tablets: Move into its own subdir

In reply to 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.

---
Changes in v2:
- Use GPL-2.0-or-later for SPDX identifier

---
 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 931a34371e93..2537fe542231 100644
@@ -22631,7 +22631,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..2b3daca5380b
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# 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..52a0d6de5fcb
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# 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
#3 lore raw

PATCH v2 3/14 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.

---
Changes in v2:
- Use GPL-2.0-or-later for SPDX identifier
- Use struct forward declarations in x86-android-tablets.h instead of bringing in a bunch of headers
- Prefix the define guarding against multiple inclusions with PDX86_

---
 .../platform/x86/x86-android-tablets/Makefile |   2 +-
 .../platform/x86/x86-android-tablets/core.c   | 365 ++++++++++++++++
 .../x86-android-tablets-main.c                | 404 +-----------------
 .../x86-android-tablets/x86-android-tablets.h |  79 ++++
 4 files changed, 447 insertions(+), 403 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 52a0d6de5fcb..34016df3e54a 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 +365 -0

365 lines not on this page · raw message

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

429 lines not on this page · raw message

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

79 lines not on this page · raw message

Signature · 1 line
2.39.1
#4 lore raw

Re: [PATCH v2 03/14] 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

IRQs
GPIOs

Quoted 1 line

instantiating all the devices missing from ACPI into a new core.c file.

...

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

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

Do we have an API to remove a bunch of tables at once?

...

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

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]);

This seems like open coded gpiod_add_lookup_tables().

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

Re: [PATCH v2 03/14] platform/x86: x86-android-tablets: Move core code into new core.c file

Hi,

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

Move the helpers to get irqs + gpios as well as the core code for

IRQs
GPIOs

Ack I'll amend the commit msg.

Quoted 10 lines
Quoted 2 lines

instantiating all the devices missing from ACPI into a new core.c file.

...

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

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

Do we have an API to remove a bunch of tables at once?

Quoted 7 lines

...

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

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]);

This seems like open coded gpiod_add_lookup_tables().

This is just moving code, not refactoring it. The intend is very much to NOT make any code changes here.

Regards,

Hans

#6 lore raw

Re: [PATCH v2 03/14] platform/x86: x86-android-tablets: Move core code into new core.c file

Quoted 22 lines · Hans de Goede
Quoted 6 lines · Andy Shevchenko
Quoted 2 lines · Hans de Goede

Move the helpers to get irqs + gpios as well as the core code for

IRQs
GPIOs

Ack I'll amend the commit msg.

Quoted 12 lines
Quoted 2 lines

instantiating all the devices missing from ACPI into a new core.c file.

...

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

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

Do we have an API to remove a bunch of tables at once?

...

Quoted 8 lines
Quoted 5 lines

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

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]);

This seems like open coded gpiod_add_lookup_tables().

This is just moving code, not refactoring it. The intend is very much to NOT make any code changes here.

OK!

Then it might be a new patch in the future :-)

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

PATCH v2 4/14 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.

---
Changes in v2:
- Use GPL-2.0-or-later for SPDX identifier
- Move extern declarations for x86_dev_info structs to .h file

---
 .../platform/x86/x86-android-tablets/Makefile |   2 +-
 .../platform/x86/x86-android-tablets/core.c   |   2 -
 .../platform/x86/x86-android-tablets/dmi.c    | 146 ++++++++++++++++
 .../x86-android-tablets-main.c                | 160 ++----------------
 .../x86-android-tablets/x86-android-tablets.h |  20 +++
 5 files changed, 180 insertions(+), 150 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/dmi.c
drivers/platform/x86/x86-android-tablets/Makefile +1 -1
index 34016df3e54a..230683cdd5be 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/core.c +0 -2
index ddd24881f392..779d49c66987 100644
@@ -253,8 +253,6 @@ static void x86_android_tablet_cleanup(void)
 	software_node_unregister(bat_swnode);
 }
 
-extern const struct dmi_system_id x86_android_tablet_ids[];
-
 static __init int x86_android_tablet_init(void)
 {
 	const struct x86_dev_info *dev_info;
drivers/platform/x86/x86-android-tablets/dmi.c new file +146 -0

146 lines not on this page · raw message

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

248 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +20 -0
index 434353572096..19994b501903 100644
@@ -76,4 +76,24 @@ struct x86_dev_info {
 int x86_android_tablet_get_gpiod(const char *label, int pin, struct gpio_desc **desc);
 int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data);
 
+/*
+ * Extern declarations of x86_dev_info structs so there can be a single
+ * MODULE_DEVICE_TABLE(dmi, ...), while splitting the board descriptions.
+ */
+extern const struct x86_dev_info acer_b1_750_info;
+extern const struct x86_dev_info advantech_mica_071_info;
+extern const struct x86_dev_info asus_me176c_info;
+extern const struct x86_dev_info asus_tf103c_info;
+extern const struct x86_dev_info chuwi_hi8_info;
+extern const struct x86_dev_info czc_p10t;
+extern const struct x86_dev_info lenovo_yogabook_x9x_info;
+/* Not const as this gets modified by its init callback */
+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 whitelabel_tm800a550l_info;
+extern const struct x86_dev_info xiaomi_mipad2_info;
+extern const struct dmi_system_id x86_android_tablet_ids[];
+
 #endif
Signature · 1 line
2.39.1
#8 lore raw

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

Quoted 4 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.

...

drivers/platform/x86/x86-android-tablets/dmi.c line 12

Quoted 2 lines
drivers/platform/x86/x86-android-tablets/dmi.c new file +2 -0
+#include <linux/dmi.h>
+#include <linux/mod_devicetable.h>

+ init.h for __initconst

+ module.h for MODULE_DEVICE_TABLE()

Quoted 1 line

+#include "x86-android-tablets.h"

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

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

Hi,

Quoted 6 lines · Andy Shevchenko
Quoted 4 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 8 lines

...

drivers/platform/x86/x86-android-tablets/dmi.c line 12

Quoted 2 lines
drivers/platform/x86/x86-android-tablets/dmi.c new file +2 -0
+#include <linux/dmi.h>
+#include <linux/mod_devicetable.h>

+ init.h for __initconst

+ module.h for MODULE_DEVICE_TABLE()

Ack I'll amend this before merging this series.

Weird that MODULE_DEVICE_TABLE() is inside module.h though and not actually in mod_devicetable.h as the name of both would suggest.

Regards,

Hans

#10 lore raw

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

Quoted 1 line · Hans de Goede

On 3/1/23 11:21, Andy Shevchenko wrote:

...

Quoted 3 lines

Weird that MODULE_DEVICE_TABLE() is inside module.h though and not actually in mod_devicetable.h as the name of both would suggest.

Yep, but I can speculate that the edge is on user space vs. kernel, as the latter is used in the tooling for modules which is user space code.

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

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

Quoted 6 lines · Andy Shevchenko
Quoted 1 line · Hans de Goede

On 3/1/23 11:21, Andy Shevchenko wrote:

...

Quoted 7 lines
Quoted 3 lines

Weird that MODULE_DEVICE_TABLE() is inside module.h though and not actually in mod_devicetable.h as the name of both would suggest.

Yep, but I can speculate that the edge is on user space vs. kernel, as the latter is used in the tooling for modules which is user space code.

*) latter == mod_devicetable.h.

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

PATCH v2 5/14 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.

---
Changes in v2:
- Use GPL-2.0-or-later for SPDX identifier
- Use struct forward declarations in shared-psy-info.h instead of bringing in a bunch of headers
- Prefix the define guarding against multiple inclusions with PDX86_

---
 .../platform/x86/x86-android-tablets/Makefile |   2 +-
 .../x86/x86-android-tablets/shared-psy-info.c | 101 ++++++++++++++++++
 .../x86/x86-android-tablets/shared-psy-info.h |  32 ++++++
 .../x86-android-tablets-main.c                | 101 ++----------------
 4 files changed, 143 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 230683cdd5be..d4e0da886790 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 +101 -0

101 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..c2d2968cddc2
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * 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 __PDX86_SHARED_PSY_INFO_H
+#define __PDX86_SHARED_PSY_INFO_H
+
+struct bq24190_platform_data;
+struct gpiod_lookup_table;
+struct platform_device_info;
+struct software_node;
+
+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
#13 lore raw

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

Quoted 3 lines · Hans de Goede

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

...

Quoted 1 line

+#include <linux/kernel.h>

Hmm... What's for?

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

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

Hi,

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

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

...

Quoted 1 line

+#include <linux/kernel.h>

Hmm... What's for?

I think I added this for ARRAY_SIZE, but I see that is not used in this file, I'll drop it before merging this series.

Regards,

Hans

#15 lore raw

PATCH v2 6/14 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.

---
Changes in v2:
- Use GPL-2.0-or-later for SPDX identifier

---
 .../platform/x86/x86-android-tablets/Makefile |   2 +-
 .../platform/x86/x86-android-tablets/asus.c   | 358 ++++++++++++++++++
 .../x86-android-tablets-main.c                | 340 -----------------
 3 files changed, 359 insertions(+), 341 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/asus.c
drivers/platform/x86/x86-android-tablets/Makefile +1 -1
index d4e0da886790..76f94831bf97 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 +358 -0

358 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
#16 lore raw

Re: [PATCH v2 06/14] platform/x86: x86-android-tablets: Move Asus tablets to their own file

Quoted 2 lines · Hans de Goede

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

...

drivers/platform/x86/x86-android-tablets/asus.c line 68

Quoted 11 lines
drivers/platform/x86/x86-android-tablets/asus.c new file +10 -0
+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);
 
+

I would expect this blank line to be after return ret;, but it's not a big deal.

Quoted 2 lines
drivers/platform/x86/x86-android-tablets/asus.c new file +2 -0
+       return 0;
+}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#17 lore raw

Re: [PATCH v2 06/14] platform/x86: x86-android-tablets: Move Asus tablets to their own file

Hi,

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

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

...

Quoted 9 lines
drivers/platform/x86/x86-android-tablets/asus.c new file +9 -0
+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);
Quoted 3 lines
Quoted 1 line

+

I would expect this blank line to be after return ret;, but it's not a big deal.

I think it was this way before moving it around and more importantly
the "platform/x86: x86-android-tablets: Add gpio_keys support to x86_android_tablet_init()" patch completely removes this function.

Talking about "platform/x86: x86-android-tablets: Add gpio_keys support to x86_android_tablet_init()"

I did implement your suggestions to put all the info for a button into a separate struct, but I forgot to add a Changes section to the commit msg for this.

Regards,

Hans

Quoted 4 lines
Quoted 3 lines
drivers/platform/x86/x86-android-tablets/asus.c new file +2 -0
+       return 0;
+}
#18 lore raw

PATCH v2 7/14 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.

---
Changes in v2:
- Use GPL-2.0-or-later for SPDX identifier

---
 .../platform/x86/x86-android-tablets/Makefile |   3 +-
 .../platform/x86/x86-android-tablets/lenovo.c | 419 ++++++++++++++++++
 .../x86-android-tablets-main.c                | 406 +----------------
 3 files changed, 422 insertions(+), 406 deletions(-)
 create mode 100644 drivers/platform/x86/x86-android-tablets/lenovo.c
drivers/platform/x86/x86-android-tablets/Makefile +2 -1
index 76f94831bf97..d881a824fa3d 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 +419 -0

419 lines not on this page · raw message

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

423 lines not on this page · raw message

Signature · 1 line
2.39.1
#19 lore raw

PATCH v2 8/14 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.

---
Changes in v2:
- Use GPL-2.0-or-later for SPDX identifier

---
 drivers/platform/x86/x86-android-tablets/Makefile             | 2 +-
 .../{x86-android-tablets-main.c => other.c}                   | 4 ++--
 2 files changed, 3 insertions(+), 3 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 d881a824fa3d..41ece5a37137 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 +2 -2
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 0362194e225c..83b30b24d57f 100644
@@ -1,11 +1,11 @@
-// SPDX-License-Identifier: GPL-2.0+
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * DMI based code to deal with broken DSDTs on X86 tablets which ship with
  * Android as (part of) the factory image. The factory kernels shipped on these
  * 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
#20 lore raw

PATCH v2 9/14 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   | 65 +++++--------------
 .../platform/x86/x86-android-tablets/core.c   | 30 ++++++++-
 .../platform/x86/x86-android-tablets/other.c  | 51 ++++-----------
 .../x86-android-tablets/x86-android-tablets.h |  8 +++
 4 files changed, 64 insertions(+), 90 deletions(-)
drivers/platform/x86/x86-android-tablets/asus.c +16 -49
index 74c3b10e9ca7..cfa038b44b43 100644
@@ -8,8 +8,6 @@
  * Copyright (C) 2021-2023 Hans de Goede <[email protected]>
  */
 
-#include <linux/gpio_keys.h>
-#include <linux/gpio/consumer.h>
 #include <linux/gpio/machine.h>
 #include <linux/input.h>
 #include <linux/platform_device.h>
@@ -26,50 +24,19 @@ 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() */
-	.active_low = true,
-	.desc = "lid_sw",
-	.type = EV_SW,
-	.wakeup = true,
-	.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 struct x86_gpio_button asus_me176c_tf103c_lid = {
+	.button = {
+		.code = SW_LID,
+		.active_low = true,
+		.desc = "lid_sw",
+		.type = EV_SW,
+		.wakeup = true,
+		.debounce_interval = 50,
 	},
+	.chip = "INT33FC:02",
+	.pin = 12,
 };
 
-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",
@@ -203,15 +170,15 @@ 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),
+	.gpio_button = &asus_me176c_tf103c_lid,
 	.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,
 };
 
 /* Asus TF103C tablets have an Android factory img with everything hardcoded */
@@ -348,11 +315,11 @@ 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,
+	.gpio_button = &asus_me176c_tf103c_lid,
 	.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,
 };
drivers/platform/x86/x86-android-tablets/core.c +29 -1
index 779d49c66987..245167674aa2 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_button) {
+		struct gpio_keys_platform_data pdata = {
+			.buttons = &dev_info->gpio_button->button,
+			.nbuttons = 1,
+		};
+		struct gpio_desc *gpiod;
+
+		/* Get GPIO for the gpio-button */
+		ret = x86_android_tablet_get_gpiod(dev_info->gpio_button->chip,
+						   dev_info->gpio_button->pin, &gpiod);
+		if (ret < 0) {
+			x86_android_tablet_cleanup();
+			return ret;
+		}
+
+		dev_info->gpio_button->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 +11 -40

67 lines not on this page · raw message

drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +8 -0
index 19994b501903..fb499a2c42d9 100644
@@ -10,6 +10,7 @@
 #ifndef __PDX86_X86_ANDROID_TABLETS_H
 #define __PDX86_X86_ANDROID_TABLETS_H
 
+#include <linux/gpio_keys.h>
 #include <linux/i2c.h>
 #include <linux/irqdomain_defs.h>
 
@@ -58,6 +59,12 @@ struct x86_serdev_info {
 	const char *serdev_hid;
 };
 
+struct x86_gpio_button {
+	struct gpio_keys_button button;
+	const char *chip;
+	int pin;
+};
+
 struct x86_dev_info {
 	char *invalid_aei_gpiochip;
 	const char * const *modules;
@@ -66,6 +73,7 @@ struct x86_dev_info {
 	const struct x86_i2c_client_info *i2c_client_info;
 	const struct platform_device_info *pdev_info;
 	const struct x86_serdev_info *serdev_info;
+	struct x86_gpio_button *gpio_button;
 	int i2c_client_count;
 	int pdev_count;
 	int serdev_count;
Signature · 1 line
2.39.1
#21 lore raw

PATCH v2 10/14 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    |   8 ++
 .../platform/x86/x86-android-tablets/other.c  |  28 ++++
 .../x86-android-tablets/x86-android-tablets.h |   1 +
 7 files changed, 37 insertions(+), 142 deletions(-)
 delete mode 100644 drivers/platform/x86/peaq-wmi.c
MAINTAINERS +0 -6
index 2537fe542231..ee9ce2377bfc 100644
@@ -16376,12 +16376,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 +8 -0
index 716b285f0afd..1e9ad22b259c 100644
@@ -123,6 +123,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 +28 -0
index c1bde42315c4..83cd7e16c84c 100644
@@ -380,6 +380,34 @@ 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 x86_gpio_button peaq_c1010_button = {
+	.button = {
+		.code = KEY_SOUND,
+		.active_low = true,
+		.desc = "dolby_key",
+		.type = EV_KEY,
+		.wakeup = false,
+		.debounce_interval = 50,
+	},
+	.chip = "INT33FC:00",
+	.pin = 3,
+};
+
+const struct x86_dev_info peaq_c1010_info __initconst = {
+	.gpio_button = &peaq_c1010_button,
+	/*
+	 * 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
drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +1 -0
index fb499a2c42d9..f7ee36a30a91 100644
@@ -100,6 +100,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;
 extern const struct dmi_system_id x86_android_tablet_ids[];
Signature · 1 line
2.39.1
#22 lore raw

PATCH v2 11/14 platform/x86: x86-android-tablets: Add touchscreen support for Lenovo Yoga Tab 3 Pro YT3-X90F

In reply to Hans de Goede

Add the necessaty info to instantiate the I2C device for the touchscreen on Lenovo Yoga Tab 3 Pro YT3-X90F tablets.

---
 .../platform/x86/x86-android-tablets/lenovo.c | 46 +++++++++++++++++++
 1 file changed, 46 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +46 -0
index 290de07d8aa0..10121fde42da 100644
@@ -12,6 +12,7 @@
 
 #include <linux/efi.h>
 #include <linux/gpio/machine.h>
+#include <linux/mfd/intel_soc_pmic.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/pinctrl/machine.h>
 #include <linux/platform_data/lp855x.h>
@@ -334,6 +335,17 @@ static const struct software_node lenovo_yt3_bq25892_0_node = {
 	.properties = lenovo_yt3_bq25892_0_props,
 };
 
+static const struct property_entry lenovo_yt3_hideep_ts_props[] = {
+	PROPERTY_ENTRY_U32("touchscreen-size-x", 1600),
+	PROPERTY_ENTRY_U32("touchscreen-size-y", 2560),
+	PROPERTY_ENTRY_U32("touchscreen-max-pressure", 255),
+	{ }
+};
+
+static const struct software_node lenovo_yt3_hideep_ts_node = {
+	.properties = lenovo_yt3_hideep_ts_props,
+};
+
 static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = {
 	{
 		/* bq27500 fuel-gauge for the flat lipo battery behind the screen */
@@ -369,6 +381,22 @@ static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = {
 			.swnode = &fg_bq25890_1_supply_node,
 		},
 		.adapter_path = "\\_SB_.PCI0.I2C2",
+	}, {
+		/* HiDeep Touchscreen */
+		.board_info = {
+			.type = "hideep_ts",
+			.addr = 0x6c,
+			.dev_name = "hideep_ts",
+			.swnode = &lenovo_yt3_hideep_ts_node,
+		},
+		.adapter_path = "\\_SB_.PCI0.I2C6",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
+			.chip = "INT33FF:03",
+			.index = 77,
+			.trigger = ACPI_LEVEL_SENSITIVE,
+			.polarity = ACPI_ACTIVE_LOW,
+		},
 	}
 };
 
@@ -409,11 +437,29 @@ static int __init lenovo_yt3_init(void)
 
 	gpiod_set_value(gpiod, 0);
 
+	/* Enable the regulators used by the touchscreen */
+	intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0x9b, 0x02, 0xff);
+	intel_soc_pmic_exec_mipi_pmic_seq_element(0x6e, 0xa0, 0x02, 0xff);
+
 	return 0;
 }
 
+static struct gpiod_lookup_table lenovo_yt3_hideep_gpios = {
+	.dev_id = "i2c-hideep_ts",
+	.table = {
+		GPIO_LOOKUP("INT33FF:00", 7, "reset", GPIO_ACTIVE_LOW),
+		{ }
+	},
+};
+
+static struct gpiod_lookup_table * const lenovo_yt3_gpios[] = {
+	&lenovo_yt3_hideep_gpios,
+	NULL
+};
+
 const struct x86_dev_info lenovo_yt3_info __initconst = {
 	.i2c_client_info = lenovo_yt3_i2c_clients,
 	.i2c_client_count = ARRAY_SIZE(lenovo_yt3_i2c_clients),
+	.gpiod_lookup_tables = lenovo_yt3_gpios,
 	.init = lenovo_yt3_init,
 };
Signature · 1 line
2.39.1
#23 lore raw

PATCH v2 12/14 platform/x86: x86-android-tablets: Add backlight ctrl for Lenovo Yoga Tab 3 Pro YT3-X90F

In reply to Hans de Goede

The YT3 uses an TI LP8557 LED backlight controller, the LP8557's PWM input is connected to a PWM output coming from the LCD panel's controller.

The Android kernel has a hack in the i915 driver to write the non-standard DSI reg 0x51 with the desired level to set the duty-cycle of the LCD's PWM.

To avoid having to have a similar hack in the mainline kernel program instantiate an i2c-client for the LP8557 with platform-data to have the LP8557 to directly set the level (ignoring its PWM input), this allows backlight brightness control through a backlight device registered by the lp855x_bl driver.

---
 .../platform/x86/x86-android-tablets/lenovo.c | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +23 -0
index 10121fde42da..f8544a4e807d 100644
@@ -346,6 +346,20 @@ static const struct software_node lenovo_yt3_hideep_ts_node = {
 	.properties = lenovo_yt3_hideep_ts_props,
 };
 
+/*
+ * The YT3 uses an TI LP8557 LED backlight controller, the LP8557's PWM input is
+ * connected to a PWM output coming from the LCD panel's controller. The Android
+ * kernel has a hack in the i915 driver to write the non-standard DSI reg 0x51
+ * with the desired level to set the duty-cycle of the LCD's PWM output.
+ *
+ * To avoid having to have a similar hack in the mainline kernel program the
+ * LP8557 to directly set the level and use the lp855x_bl driver for control.
+ */
+static struct lp855x_platform_data lenovo_yt3_lp8557_pdata = {
+	.device_control = 0x86,
+	.initial_brightness = 128,
+};
+
 static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = {
 	{
 		/* bq27500 fuel-gauge for the flat lipo battery behind the screen */
@@ -397,6 +411,15 @@ static const struct x86_i2c_client_info lenovo_yt3_i2c_clients[] __initconst = {
 			.trigger = ACPI_LEVEL_SENSITIVE,
 			.polarity = ACPI_ACTIVE_LOW,
 		},
+	}, {
+		/* LP8557 Backlight controller */
+		.board_info = {
+			.type = "lp8557",
+			.addr = 0x2c,
+			.dev_name = "lp8557",
+			.platform_data = &lenovo_yt3_lp8557_pdata,
+		},
+		.adapter_path = "\\_SB_.PCI0.I2C1",
 	}
 };
 
Signature · 1 line
2.39.1
#24 lore raw

PATCH v2 13/14 platform/x86: x86-android-tablets: Add LID switch support for Yoga Tablet 2 1050/830 series

In reply to Hans de Goede

The Yoga Tablet 2 1050/830 series have a HALL sensor for detecting when their (optional) case/cover is closed over the screen.

Their Windows counterparts (alsmost the same HW, different BIOS) model this as a LID switch. Add support for reporting this as a LID switch on the Android models too.

---
 drivers/platform/x86/x86-android-tablets/lenovo.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/platform/x86/x86-android-tablets/lenovo.c +14 -0
index f8544a4e807d..e140fa401301 100644
@@ -56,6 +56,19 @@ static const struct software_node lenovo_yoga_tab2_830_1050_bq24190_node = {
 	.properties = lenovo_yoga_tab2_830_1050_bq24190_props,
 };
 
+static struct x86_gpio_button lenovo_yoga_tab2_830_1050_lid = {
+	.button = {
+		.code = SW_LID,
+		.active_low = true,
+		.desc = "lid_sw",
+		.type = EV_SW,
+		.wakeup = true,
+		.debounce_interval = 50,
+	},
+	.chip = "INT33FC:02",
+	.pin = 26,
+};
+
 /* This gets filled by lenovo_yoga_tab2_830_1050_init() */
 static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { };
 
@@ -154,6 +167,7 @@ struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initdata = {
 	/* i2c_client_count gets set by lenovo_yoga_tab2_830_1050_init() */
 	.pdev_info = int3496_pdevs,
 	.pdev_count = 1,
+	.gpio_button = &lenovo_yoga_tab2_830_1050_lid,
 	.gpiod_lookup_tables = lenovo_yoga_tab2_830_1050_gpios,
 	.bat_swnode = &generic_lipo_hv_4v35_battery_node,
 	.modules = bq24190_modules,
Signature · 1 line
2.39.1
#25 lore raw

PATCH v2 14/14 platform/x86: x86-android-tablets: Lenovo Yoga Book match is for YB1-X91 models only

In reply to Hans de Goede

When support for instantiating an i2c-client for the fuel-gauge was added for the Windows based Yoga Book YB1-X91F/L models, the assumption was made that this would apply to the Android based YB1-X90F/L models too.

But these have a completely different BIOS with completely different DMI strings. Update the existing YB1-X91 support to reflect that it only applies to the YB1-X91F/L models.

Cc Yauhen Kharuzhy <[email protected]>
---
 drivers/platform/x86/x86-android-tablets/dmi.c         |  8 ++++----
 drivers/platform/x86/x86-android-tablets/lenovo.c      | 10 +++++-----
 .../x86/x86-android-tablets/x86-android-tablets.h      |  2 +-
 3 files changed, 10 insertions(+), 10 deletions(-)
drivers/platform/x86/x86-android-tablets/dmi.c +4 -4
index 1e9ad22b259c..332a65685458 100644
@@ -75,12 +75,12 @@ const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
 		.driver_data = (void *)&czc_p10t,
 	},
 	{
-		/* Lenovo Yoga Book X90F / X91F / X91L */
+		/* Lenovo Yoga Book X91F / X91L */
 		.matches = {
-			/* Non exact match to match all versions */
-			DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9"),
+			/* Non exact match to match F + L versions */
+			DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X91"),
 		},
-		.driver_data = (void *)&lenovo_yogabook_x9x_info,
+		.driver_data = (void *)&lenovo_yogabook_x91_info,
 	},
 	{
 		/*
drivers/platform/x86/x86-android-tablets/lenovo.c +5 -5
index e140fa401301..da73e634fe9f 100644
@@ -24,8 +24,8 @@
 #include "shared-psy-info.h"
 #include "x86-android-tablets.h"
 
-/* Lenovo Yoga Book X90F / X91F / X91L need manual instantiation of the fg client */
-static const struct x86_i2c_client_info lenovo_yogabook_x9x_i2c_clients[] __initconst = {
+/* Lenovo Yoga Book X91F/L Windows tablet needs manual instantiation of the fg client */
+static const struct x86_i2c_client_info lenovo_yogabook_x91_i2c_clients[] __initconst = {
 	{
 		/* BQ27542 fuel-gauge */
 		.board_info = {
@@ -38,9 +38,9 @@ static const struct x86_i2c_client_info lenovo_yogabook_x9x_i2c_clients[] __init
 	},
 };
 
-const struct x86_dev_info lenovo_yogabook_x9x_info __initconst = {
-	.i2c_client_info = lenovo_yogabook_x9x_i2c_clients,
-	.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x9x_i2c_clients),
+const struct x86_dev_info lenovo_yogabook_x91_info __initconst = {
+	.i2c_client_info = lenovo_yogabook_x91_i2c_clients,
+	.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x91_i2c_clients),
 };
 
 /* Lenovo Yoga Tablet 2 1050F/L's Android factory img has everything hardcoded */
drivers/platform/x86/x86-android-tablets/x86-android-tablets.h +1 -1
index f7ee36a30a91..cf8566b3fd9c 100644
@@ -94,7 +94,7 @@ extern const struct x86_dev_info asus_me176c_info;
 extern const struct x86_dev_info asus_tf103c_info;
 extern const struct x86_dev_info chuwi_hi8_info;
 extern const struct x86_dev_info czc_p10t;
-extern const struct x86_dev_info lenovo_yogabook_x9x_info;
+extern const struct x86_dev_info lenovo_yogabook_x91_info;
 /* Not const as this gets modified by its init callback */
 extern struct x86_dev_info lenovo_yoga_tab2_830_1050_info;
 extern const struct x86_dev_info lenovo_yt3_info;
Signature · 1 line
2.39.1
Reviewed-by on the v2 series
#26 lore raw
In reply to Hans de Goede
Quoted 5 lines · Hans de Goede

Hi All,

Here is version 2 of my series to move the x86-android-tablets driver into its own subdir and to split it into multiple-files.

There are a few remarks, but overall it's in a good shape, so

for the next version of the series where I believe you will make a few amendments.

Quoted 7 lines

Changes in v2:

(quoted diff) +0 -3
-Gather all outstanding x86-android-tablets changes in 1 series.
-Address all Andy's review remarks, see individual commit messages
 for details. Thank you for all the reviews Andy!
-New patches:
 -Add LID switch support to Yoga Tablet 2 1050/830 series
 -Lenovo Yoga Book match is for YB1-X91 models only
Signature · 2 lines
With Best Regards,
Andy Shevchenko