All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs
@ 2021-12-29 23:14 Hans de Goede
  2021-12-29 23:14 ` [PATCH 01/12] ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration() helpers Hans de Goede
                   ` (13 more replies)
  0 siblings, 14 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

Hi All,

As a small(ish) hoppy project over the holidays I've been looking into
getting some (somewhat older) x86 tablets which ship with Android as the
only OS on their factory image working with the mainline kernel.

These typically have pretty broken DSDTs since the Android image kernel
just has everything hardcoded.

This patch-series makes most things on 3 of these tablets work with the
mainline kernel and lays the groundwork for adding support for similar
tablets.

Since the ACPI tables on these devices clearly are buggy this series is
written so as to add minimal changes to the ACPI core code, leaving all
of the heavy lifting to the recently introduced (in linux-next)
drivers/platform/x86/x86-android-tablets.c module, which when built as
a module only autoloads on affected devices based on DMI matching.

And when this module is disabled the added acpi_quirk_skip_*_enumeration()
helpers are replaced by inline stubs and even the minimally added core
code will be optimized away.

The ACPI core changes are in patches 1-3 of this series. Since the
i2c and serdev ACPI enumeration changes are very small and depend on
patch 1, I believe it would be best for patches 1-3 to all be merged
through Rafael's ACPI tree.

Greg and Wolfram, may we have your acks for this please?

I will take care of merging the rest of the series through the pdx86
tree (these 2 parts of this series can be merged independenly without
issues).

Regards,

Hans


Hans de Goede (12):
  ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration()
    helpers
  i2c: acpi: Do not instantiate I2C-clients on boards with known bogus
    DSDT entries
  serdev: Do not instantiate serdevs on boards with known bogus DSDT
    entries
  platform/x86: x86-android-tablets: Don't return -EPROBE_DEFER from a
    non probe() function
  platform/x86: x86-android-tablets: Add support for PMIC interrupts
  platform/x86: x86-android-tablets: Add support for instantiating
    platform-devs
  platform/x86: x86-android-tablets: Add support for instantiating
    serdevs
  platform/x86: x86-android-tablets: Add support for registering GPIO
    lookup tables
  platform/x86: x86-android-tablets: Add support for preloading modules
  platform/x86: x86-android-tablets: Add Asus TF103C data
  platform/x86: x86-android-tablets: Add Asus MeMO Pad 7 ME176C data
  platform/x86: x86-android-tablets: Add TM800A550L data

 drivers/acpi/x86/utils.c                   |  96 ++++
 drivers/i2c/i2c-core-acpi.c                |  17 +
 drivers/platform/x86/Kconfig               |   2 +-
 drivers/platform/x86/x86-android-tablets.c | 562 ++++++++++++++++++++-
 drivers/tty/serdev/core.c                  |  14 +
 include/acpi/acpi_bus.h                    |  16 +
 6 files changed, 698 insertions(+), 9 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 01/12] ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration() helpers
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries Hans de Goede
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

x86 ACPI boards which ship with only Android as their factory image usually
declare a whole bunch of bogus I2C devs in their ACPI tables and sometimes
there are issues with serdev devices on these boards too, e.g. the resource
points to the wrong serdev_controller.

Instantiating I2C / serdev devs for these bogus devs causes various issues,
e.g. GPIO/IRQ resource conflicts because sometimes drivers do bind to them.
The Android x86 kernel fork shipped on these devices has some special code
to remove the bogus I2C clients (and serdevs are ignored completely).

Introduce acpi_quirk_skip_i2c_client_enumeration() and
acpi_quirk_skip_serdev_enumeration() helpers. Which can be used by the I2C/
serdev code to skip instantiating any I2C or serdev devs on broken boards.

These 2 helpers are added to drivers/acpi/x86/utils.c so that the DMI table
can be shared between the I2C and serdev code.

Note these boards typically do actually have I2C and serdev devices, just
different ones then the ones described in their DSDT. The devices which
are actually present are manually instantiated by the
drivers/platform/x86/x86-android-tablets.c kernel module.

The new helpers are only build if CONFIG_X86_ANDROID_TABLETS is enabled,
otherwise they are empty stubs to not unnecessarily grow the kernel size.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/x86/utils.c | 96 ++++++++++++++++++++++++++++++++++++++++
 include/acpi/acpi_bus.h  | 16 +++++++
 2 files changed, 112 insertions(+)

diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
index a2ae1ac41319..3ac7b477f2e8 100644
--- a/drivers/acpi/x86/utils.c
+++ b/drivers/acpi/x86/utils.c
@@ -10,6 +10,7 @@
 
 #include <linux/acpi.h>
 #include <linux/dmi.h>
+#include <linux/platform_device.h>
 #include <asm/cpu_device_id.h>
 #include <asm/intel-family.h>
 #include "../internal.h"
@@ -208,3 +209,98 @@ bool force_storage_d3(void)
 {
 	return x86_match_cpu(storage_d3_cpu_ids);
 }
+
+#if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS)
+/*
+ * x86 ACPI boards which ship with only Android as their factory image usually
+ * declare a whole bunch of bogus I2C devices in their ACPI tables and sometimes
+ * there are issues with serdev devices on these boards too, e.g. the resource
+ * points to the wrong serdev_controller.
+ *
+ * Instantiating I2C / serdev devs for these bogus devs causes various issues,
+ * e.g. GPIO/IRQ resource conflicts because sometimes drivers do bind to them.
+ * The Android x86 kernel fork shipped on these devices has some special code
+ * to remove the bogus I2C clients (and AFAICT serdevs are ignored completely).
+ *
+ * The acpi_quirk_skip_*_enumeration() functions below are used by the I2C or
+ * serdev code to skip instantiating any I2C or serdev devs on broken boards.
+ *
+ * Note these boards typically do actually have I2C and serdev devices,
+ * just different ones then the ones described in their DSDT. The devices
+ * which are actually present are manually instantiated by the
+ * drivers/platform/x86/x86-android-tablets.c kernel module.
+ */
+#define ACPI_QUIRK_SKIP_I2C_CLIENTS				BIT(0)
+#define ACPI_QUIRK_UART1_TTY_UART2_SKIP				BIT(1)
+
+static const struct dmi_system_id acpi_skip_serial_bus_enumeration_ids[] = {
+	{
+		.matches = {
+			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"),
+		},
+		.driver_data = (void *)(ACPI_QUIRK_SKIP_I2C_CLIENTS |
+					ACPI_QUIRK_UART1_TTY_UART2_SKIP),
+	},
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"),
+		},
+		.driver_data = (void *)ACPI_QUIRK_SKIP_I2C_CLIENTS,
+	},
+	{
+		/* Whitelabel (sold as various brands) TM800A550L */
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
+			DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
+			/* Above strings are too generic, also match on BIOS version */
+			DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"),
+		},
+		.driver_data = (void *)ACPI_QUIRK_SKIP_I2C_CLIENTS,
+	},
+	{}
+};
+
+bool acpi_quirk_skip_i2c_client_enumeration(void)
+{
+	const struct dmi_system_id *dmi_id;
+	long quirks = 0;
+
+	dmi_id = dmi_first_match(acpi_skip_serial_bus_enumeration_ids);
+	if (dmi_id)
+		quirks = (unsigned long)dmi_id->driver_data;
+
+	return (quirks & ACPI_QUIRK_SKIP_I2C_CLIENTS);
+}
+EXPORT_SYMBOL_GPL(acpi_quirk_skip_i2c_client_enumeration);
+
+int acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *skip)
+{
+	struct acpi_device *adev = ACPI_COMPANION(controller_parent);
+	const struct dmi_system_id *dmi_id;
+	long quirks = 0;
+
+	*skip = false;
+
+	/* !dev_is_platform() to not match on PNP enumerated debug UARTs */
+	if (!adev || !adev->pnp.unique_id || !dev_is_platform(controller_parent))
+		return 0;
+
+	dmi_id = dmi_first_match(acpi_skip_serial_bus_enumeration_ids);
+	if (dmi_id)
+		quirks = (unsigned long)dmi_id->driver_data;
+
+	if (quirks & ACPI_QUIRK_UART1_TTY_UART2_SKIP) {
+		if (!strcmp(adev->pnp.unique_id, "1"))
+			return -ENODEV; /* Create tty cdev instead of serdev */
+
+		if (!strcmp(adev->pnp.unique_id, "2"))
+			*skip = true;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(acpi_quirk_skip_serdev_enumeration);
+
+#endif
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index 5895f6c7f6db..54652dc4ee74 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -624,6 +624,22 @@ static inline bool acpi_device_override_status(struct acpi_device *adev,
 }
 #endif
 
+#if IS_ENABLED(CONFIG_X86_ANDROID_TABLETS)
+bool acpi_quirk_skip_i2c_client_enumeration(void);
+int acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *skip);
+#else
+static inline bool acpi_quirk_skip_i2c_client_enumeration(void)
+{
+	return false;
+}
+static inline int
+acpi_quirk_skip_serdev_enumeration(struct device *controller_parent, bool *skip)
+{
+	*skip = false;
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_PM
 void acpi_pm_wakeup_event(struct device *dev);
 acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
  2021-12-29 23:14 ` [PATCH 01/12] ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration() helpers Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-30 12:03   ` Mika Westerberg
  2021-12-30 12:21   ` Wolfram Sang
  2021-12-29 23:14 ` [PATCH 03/12] serdev: Do not instantiate serdevs " Hans de Goede
                   ` (11 subsequent siblings)
  13 siblings, 2 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

x86 ACPI devices which ship with only Android as their factory image
usually declare a whole bunch of bogus I2C devices in their ACPI tables.

Instantiating I2C clients for these bogus devices causes various issues,
e.g. GPIO/IRQ resource conflicts because sometimes drivers do bind to them.
The Android x86 kernel fork shipped on these devices has some special code
to remove these bogus devices, instead of just fixing the DSDT <sigh>.

Use the new acpi_quirk_skip_i2c_client_enumeration() helper to
identify known boards with this issue, and on these boards ignore I2C
devices described in ACPI, with a few exceptions which are known to
always be correct (and in case of the audio-codecs where the drivers
heavily rely on the codec being enumerated through ACPI).

Note these boards typically do actually have I2C devices, just
different ones then the ones described in their DSDT. The devices
which are actually present are manually instantiated by the
drivers/platform/x86/x86-android-tablets.c kernel module.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/i2c/i2c-core-acpi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/i2c/i2c-core-acpi.c b/drivers/i2c/i2c-core-acpi.c
index c87ce2276007..8b5b0161d3b2 100644
--- a/drivers/i2c/i2c-core-acpi.c
+++ b/drivers/i2c/i2c-core-acpi.c
@@ -253,10 +253,27 @@ static int i2c_acpi_get_info(struct acpi_device *adev,
 	return 0;
 }
 
+static const struct acpi_device_id i2c_acpi_known_good_ids[] = {
+	{ "10EC5640", 0 }, /* RealTek ALC5640 audio codec */
+	{ "INT33F4", 0 },  /* X-Powers AXP288 PMIC */
+	{ "INT33FD", 0 },  /* Intel Crystal Cove PMIC */
+	{ "NPCE69A", 0 },  /* Asus Transformer keyboard dock */
+	{}
+};
+
 static void i2c_acpi_register_device(struct i2c_adapter *adapter,
 				     struct acpi_device *adev,
 				     struct i2c_board_info *info)
 {
+	/*
+	 * Skip registration on boards where the ACPI tables are known
+	 * to contain bogus I2C devices, with the exception of devices
+	 * on the known good list.
+	 */
+	if (acpi_quirk_skip_i2c_client_enumeration() &&
+	    acpi_match_device_ids(adev, i2c_acpi_known_good_ids) != 0)
+		return;
+
 	adev->power.flags.ignore_parent = true;
 	acpi_device_set_enumerated(adev);
 
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 03/12] serdev: Do not instantiate serdevs on boards with known bogus DSDT entries
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
  2021-12-29 23:14 ` [PATCH 01/12] ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration() helpers Hans de Goede
  2021-12-29 23:14 ` [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-30 12:44   ` Greg Kroah-Hartman
  2021-12-29 23:14 ` [PATCH 04/12] platform/x86: x86-android-tablets: Don't return -EPROBE_DEFER from a non probe() function Hans de Goede
                   ` (10 subsequent siblings)
  13 siblings, 1 reply; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

x86 ACPI devices which ship with only Android as their factory image use
older kernels which do not yet support ACPI serdev enumeration, as such
the serdev information in their ACPI tables is not reliable.

For example on the Asus ME176C tablet the serdev describing the Bluetooth
HCI points to the serdev_controller connected to the GPS and the other way
around.

Use the new acpi_quirk_skip_serdev_enumeration() helper to identify
known boards with this issue and then either abort adding the serdev
controller (creating a tty cdev instead) or only create the controller
leaving the instantation of the serdev itself up to platform code.

In the case where only the serdev controller is created the necessary
serdevs will instead be instantiated by the
drivers/platform/x86/x86-android-tablets.c kernel module.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/tty/serdev/core.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index f1324fe99378..92e3433276f8 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -727,10 +727,24 @@ static acpi_status acpi_serdev_add_device(acpi_handle handle, u32 level,
 static int acpi_serdev_register_devices(struct serdev_controller *ctrl)
 {
 	acpi_status status;
+	bool skip;
+	int ret;
 
 	if (!has_acpi_companion(ctrl->dev.parent))
 		return -ENODEV;
 
+	/*
+	 * Skip registration on boards where the ACPI tables are known to
+	 * contain buggy devices. Note serdev_controller_add() must still
+	 * succeed in this case, so that the proper serdev devices can be
+	 * added "manually" later.
+	 */
+	ret = acpi_quirk_skip_serdev_enumeration(ctrl->dev.parent, &skip);
+	if (ret)
+		return ret;
+	if (skip)
+		return 0;
+
 	status = acpi_walk_namespace(ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
 				     SERDEV_ACPI_MAX_SCAN_DEPTH,
 				     acpi_serdev_add_device, NULL, ctrl, NULL);
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 04/12] platform/x86: x86-android-tablets: Don't return -EPROBE_DEFER from a non probe() function
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (2 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 03/12] serdev: Do not instantiate serdevs " Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 05/12] platform/x86: x86-android-tablets: Add support for PMIC interrupts Hans de Goede
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

The x86-android-tablets code all runs from module_init, so returning
-EPROBE_DEFER is not appropriate. Instead log an error and bail.

This path should never get hit since PINCTRL_BAYTRAIL is a bool.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 4a04da27a3f4..ea033d7f4439 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -63,8 +63,10 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
 	case X86_ACPI_IRQ_TYPE_GPIOINT:
 		/* Like acpi_dev_gpio_irq_get(), but without parsing ACPI resources */
 		chip = gpiochip_find(data->chip, x86_acpi_irq_helper_gpiochip_find);
-		if (!chip)
-			return -EPROBE_DEFER;
+		if (!chip) {
+			pr_err("error cannot find GPIO chip %s\n", data->chip);
+			return -ENODEV;
+		}
 
 		gpiod = gpiochip_get_desc(chip, data->index);
 		if (IS_ERR(gpiod)) {
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 05/12] platform/x86: x86-android-tablets: Add support for PMIC interrupts
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (3 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 04/12] platform/x86: x86-android-tablets: Don't return -EPROBE_DEFER from a non probe() function Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 06/12] platform/x86: x86-android-tablets: Add support for instantiating platform-devs Hans de Goede
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

The Crystal Cove PMIC has a pin which can be used to connect the IRQ of
an external charger IC. On some boards this is used so we need a way to
look this up.

Note that the Intel PMICs have 2 levels of interrupts and thus
2 levels of IRQ domains all tied to a single fwnode.

Level 1 is the irqchip which demultiplexes the actual PMIC interrupt into
interrupts for the various MFD cells. Level 2 are the irqchips used in the
cell drivers which themselves export IRQs, such as the crystal_cove_gpio
driver, which de-multiplexes the level 2 interrupts for the GPIOs into
individual per GPIO IRQs.

The crystal_cove_charger driver registers an irqchip with a single IRQ for
the charger driver to consume. Note the MFD cell IRQ cannot be consumed
directly because the level 2 interrupts must be explicitly acked.

To allow finding the right IRQ domain when looking up the IRQ for
the charger, the crystal_cove_charger driver sets a DOMAIN_BUS_WIRED token
on its IRQ domain.

Add support for looking up the IRQ from the crystal_cove_charger driver.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 31 +++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index ea033d7f4439..44138882bc9f 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -17,6 +17,7 @@
 #include <linux/gpio/machine.h>
 #include <linux/i2c.h>
 #include <linux/irq.h>
+#include <linux/irqdomain.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/string.h>
@@ -31,11 +32,13 @@ enum x86_acpi_irq_type {
 	X86_ACPI_IRQ_TYPE_NONE,
 	X86_ACPI_IRQ_TYPE_APIC,
 	X86_ACPI_IRQ_TYPE_GPIOINT,
+	X86_ACPI_IRQ_TYPE_PMIC,
 };
 
 struct x86_acpi_irq_data {
-	char *chip;   /* GPIO chip label (GPIOINT) */
+	char *chip;   /* GPIO chip label (GPIOINT) or PMIC ACPI path (PMIC) */
 	enum x86_acpi_irq_type type;
+	enum irq_domain_bus_token domain;
 	int index;
 	int trigger;  /* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */
 	int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */
@@ -48,9 +51,14 @@ static int x86_acpi_irq_helper_gpiochip_find(struct gpio_chip *gc, void *data)
 
 static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
 {
+	struct irq_fwspec fwspec = { };
+	struct irq_domain *domain;
+	struct acpi_device *adev;
 	struct gpio_desc *gpiod;
 	struct gpio_chip *chip;
 	unsigned int irq_type;
+	acpi_handle handle;
+	acpi_status status;
 	int irq, ret;
 
 	switch (data->type) {
@@ -86,6 +94,27 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
 			irq_set_irq_type(irq, irq_type);
 
 		return irq;
+	case X86_ACPI_IRQ_TYPE_PMIC:
+		status = acpi_get_handle(NULL, data->chip, &handle);
+		if (ACPI_FAILURE(status)) {
+			pr_err("error could not get %s handle\n", data->chip);
+			return -ENODEV;
+		}
+
+		acpi_bus_get_device(handle, &adev);
+		if (!adev) {
+			pr_err("error could not get %s adev\n", data->chip);
+			return -ENODEV;
+		}
+
+		fwspec.fwnode = acpi_fwnode_handle(adev);
+		domain = irq_find_matching_fwspec(&fwspec, data->domain);
+		if (!domain) {
+			pr_err("error could not find IRQ domain for %s\n", data->chip);
+			return -ENODEV;
+		}
+
+		return irq_create_mapping(domain, data->index);
 	default:
 		return 0;
 	}
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 06/12] platform/x86: x86-android-tablets: Add support for instantiating platform-devs
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (4 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 05/12] platform/x86: x86-android-tablets: Add support for PMIC interrupts Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 07/12] platform/x86: x86-android-tablets: Add support for instantiating serdevs Hans de Goede
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

Add support for instantiating platform-devs, note this also makes some
small changes to the i2c_client instantiating code to make the 2 flows
identical.

Specifically for the pdevs flow pdev_count must only be set after
allocating the pdevs array, to avoid a NULL ptr deref in
x86_android_tablet_cleanup() and the i2c_clients flow is updated
to work the same way.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 36 ++++++++++++++++++----
 1 file changed, 30 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 44138882bc9f..4bcad05d4039 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -20,6 +20,7 @@
 #include <linux/irqdomain.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/platform_device.h>
 #include <linux/string.h>
 /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
 #include "../../gpio/gpiolib.h"
@@ -128,7 +129,9 @@ struct x86_i2c_client_info {
 
 struct x86_dev_info {
 	const struct x86_i2c_client_info *i2c_client_info;
+	const struct platform_device_info *pdev_info;
 	int i2c_client_count;
+	int pdev_count;
 };
 
 /*
@@ -269,7 +272,9 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
 MODULE_DEVICE_TABLE(dmi, x86_android_tablet_ids);
 
 static int i2c_client_count;
+static int pdev_count;
 static struct i2c_client **i2c_clients;
+static struct platform_device **pdevs;
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
 					     int idx)
@@ -309,6 +314,11 @@ static void x86_android_tablet_cleanup(void)
 {
 	int i;
 
+	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]);
 
@@ -327,21 +337,35 @@ static __init int x86_android_tablet_init(void)
 
 	dev_info = id->driver_data;
 
-	i2c_client_count = dev_info->i2c_client_count;
-
-	i2c_clients = kcalloc(i2c_client_count, sizeof(*i2c_clients), GFP_KERNEL);
+	i2c_clients = kcalloc(dev_info->i2c_client_count, sizeof(*i2c_clients), GFP_KERNEL);
 	if (!i2c_clients)
 		return -ENOMEM;
 
-	for (i = 0; i < dev_info->i2c_client_count; i++) {
+	i2c_client_count = dev_info->i2c_client_count;
+	for (i = 0; i < i2c_client_count; i++) {
 		ret = x86_instantiate_i2c_client(dev_info, i);
 		if (ret < 0) {
 			x86_android_tablet_cleanup();
-			break;
+			return ret;
+		}
+	}
+
+	pdevs = kcalloc(dev_info->pdev_count, sizeof(*pdevs), GFP_KERNEL);
+	if (!pdevs) {
+		x86_android_tablet_cleanup();
+		return -ENOMEM;
+	}
+
+	pdev_count = dev_info->pdev_count;
+	for (i = 0; i < pdev_count; i++) {
+		pdevs[i] = platform_device_register_full(&dev_info->pdev_info[i]);
+		if (IS_ERR(pdevs[i])) {
+			x86_android_tablet_cleanup();
+			return PTR_ERR(pdevs[i]);
 		}
 	}
 
-	return ret;
+	return 0;
 }
 
 module_init(x86_android_tablet_init);
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 07/12] platform/x86: x86-android-tablets: Add support for instantiating serdevs
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (5 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 06/12] platform/x86: x86-android-tablets: Add support for instantiating platform-devs Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 08/12] platform/x86: x86-android-tablets: Add support for registering GPIO lookup tables Hans de Goede
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

Add support for instantiating serdevs, this is necessary on some boards
where the serdev info in the DSDT has issues.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/Kconfig               |   2 +-
 drivers/platform/x86/x86-android-tablets.c | 101 +++++++++++++++++++++
 2 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 56efe336a690..8e55529f285c 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1027,7 +1027,7 @@ config TOUCHSCREEN_DMI
 
 config X86_ANDROID_TABLETS
 	tristate "X86 Android tablet support"
-	depends on I2C && ACPI && GPIOLIB
+	depends on I2C && SERIAL_DEV_BUS && ACPI && GPIOLIB
 	help
 	  X86 tablets which ship with Android as (part of) the factory image
 	  typically have various problems with their DSDTs. The factory kernels
diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 4bcad05d4039..5267e57c4fea 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/serdev.h>
 #include <linux/string.h>
 /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
 #include "../../gpio/gpiolib.h"
@@ -127,11 +128,26 @@ struct x86_i2c_client_info {
 	struct x86_acpi_irq_data irq_data;
 };
 
+struct x86_serdev_info {
+	const char *ctrl_hid;
+	const char *ctrl_uid;
+	const char *ctrl_devname;
+	/*
+	 * ATM the serdev core only supports of or ACPI matching; and sofar all
+	 * Android x86 tablets DSDTs have usable serdev nodes, but sometimes
+	 * under the wrong controller. So we just tie the existing serdev ACPI
+	 * node to the right controller.
+	 */
+	const char *serdev_hid;
+};
+
 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;
 	int i2c_client_count;
 	int pdev_count;
+	int serdev_count;
 };
 
 /*
@@ -273,8 +289,10 @@ MODULE_DEVICE_TABLE(dmi, x86_android_tablet_ids);
 
 static int i2c_client_count;
 static int pdev_count;
+static int serdev_count;
 static struct i2c_client **i2c_clients;
 static struct platform_device **pdevs;
+static struct serdev_device **serdevs;
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
 					     int idx)
@@ -310,10 +328,78 @@ static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info
 	return 0;
 }
 
+static __init int x86_instantiate_serdev(const struct x86_serdev_info *info, int idx)
+{
+	struct acpi_device *ctrl_adev, *serdev_adev;
+	struct serdev_device *serdev;
+	struct device *ctrl_dev;
+	int ret = -ENODEV;
+
+	ctrl_adev = acpi_dev_get_first_match_dev(info->ctrl_hid, info->ctrl_uid, -1);
+	if (!ctrl_adev) {
+		pr_err("error could not get %s/%s ctrl adev\n",
+		       info->ctrl_hid, info->ctrl_uid);
+		return -ENODEV;
+	}
+
+	serdev_adev = acpi_dev_get_first_match_dev(info->serdev_hid, NULL, -1);
+	if (!serdev_adev) {
+		pr_err("error could not get %s serdev adev\n", info->serdev_hid);
+		goto put_ctrl_adev;
+	}
+
+	/* get_first_physical_node() returns a weak ref, no need to put() it */
+	ctrl_dev = acpi_get_first_physical_node(ctrl_adev);
+	if (!ctrl_dev)	{
+		pr_err("error could not get %s/%s ctrl physical dev\n",
+		       info->ctrl_hid, info->ctrl_uid);
+		goto put_serdev_adev;
+	}
+
+	/* ctrl_dev now points to the controller's parent, get the controller */
+	ctrl_dev = device_find_child_by_name(ctrl_dev, info->ctrl_devname);
+	if (!ctrl_dev) {
+		pr_err("error could not get %s/%s %s ctrl dev\n",
+		       info->ctrl_hid, info->ctrl_uid, info->ctrl_devname);
+		goto put_serdev_adev;
+	}
+
+	serdev = serdev_device_alloc(to_serdev_controller(ctrl_dev));
+	if (!serdev) {
+		ret = -ENOMEM;
+		goto put_serdev_adev;
+	}
+
+	ACPI_COMPANION_SET(&serdev->dev, serdev_adev);
+	acpi_device_set_enumerated(serdev_adev);
+
+	ret = serdev_device_add(serdev);
+	if (ret) {
+		dev_err(&serdev->dev, "error %d adding serdev\n", ret);
+		serdev_device_put(serdev);
+		goto put_serdev_adev;
+	}
+
+	serdevs[idx] = serdev;
+
+put_serdev_adev:
+	acpi_dev_put(serdev_adev);
+put_ctrl_adev:
+	acpi_dev_put(ctrl_adev);
+	return ret;
+}
+
 static void x86_android_tablet_cleanup(void)
 {
 	int i;
 
+	for (i = 0; i < serdev_count; i++) {
+		if (serdevs[i])
+			serdev_device_remove(serdevs[i]);
+	}
+
+	kfree(serdevs);
+
 	for (i = 0; i < pdev_count; i++)
 		platform_device_unregister(pdevs[i]);
 
@@ -365,6 +451,21 @@ static __init int x86_android_tablet_init(void)
 		}
 	}
 
+	serdevs = kcalloc(dev_info->serdev_count, sizeof(*serdevs), GFP_KERNEL);
+	if (!serdevs) {
+		x86_android_tablet_cleanup();
+		return -ENOMEM;
+	}
+
+	serdev_count = dev_info->serdev_count;
+	for (i = 0; i < serdev_count; i++) {
+		ret = x86_instantiate_serdev(&dev_info->serdev_info[i], i);
+		if (ret < 0) {
+			x86_android_tablet_cleanup();
+			return ret;
+		}
+	}
+
 	return 0;
 }
 
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 08/12] platform/x86: x86-android-tablets: Add support for registering GPIO lookup tables
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (6 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 07/12] platform/x86: x86-android-tablets: Add support for instantiating serdevs Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 09/12] platform/x86: x86-android-tablets: Add support for preloading modules Hans de Goede
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

Add support for registering GPIO lookup tables.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 5267e57c4fea..0b521e4671aa 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -142,6 +142,7 @@ struct x86_serdev_info {
 };
 
 struct x86_dev_info {
+	struct gpiod_lookup_table **gpiod_lookup_tables;
 	const struct x86_i2c_client_info *i2c_client_info;
 	const struct platform_device_info *pdev_info;
 	const struct x86_serdev_info *serdev_info;
@@ -293,6 +294,7 @@ static int serdev_count;
 static struct i2c_client **i2c_clients;
 static struct platform_device **pdevs;
 static struct serdev_device **serdevs;
+static struct gpiod_lookup_table **gpiod_lookup_tables;
 
 static __init int x86_instantiate_i2c_client(const struct x86_dev_info *dev_info,
 					     int idx)
@@ -409,6 +411,9 @@ static void x86_android_tablet_cleanup(void)
 		i2c_unregister_device(i2c_clients[i]);
 
 	kfree(i2c_clients);
+
+	for (i = 0; gpiod_lookup_tables && gpiod_lookup_tables[i]; i++)
+		gpiod_remove_lookup_table(gpiod_lookup_tables[i]);
 }
 
 static __init int x86_android_tablet_init(void)
@@ -423,6 +428,10 @@ static __init int x86_android_tablet_init(void)
 
 	dev_info = id->driver_data;
 
+	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]);
+
 	i2c_clients = kcalloc(dev_info->i2c_client_count, sizeof(*i2c_clients), GFP_KERNEL);
 	if (!i2c_clients)
 		return -ENOMEM;
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 09/12] platform/x86: x86-android-tablets: Add support for preloading modules
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (7 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 08/12] platform/x86: x86-android-tablets: Add support for registering GPIO lookup tables Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 10/12] platform/x86: x86-android-tablets: Add Asus TF103C data Hans de Goede
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

Since the x86-android-tablets code does all it work from module_init() it
cannot use -EPROBE_DEFER to wait for e.g. interrupt providing GPIO-chips
or PMIC-cells to show up.

To make sure things will still work when some necessary resource providers
are build as module allow the per board info to specify a list of modules
to pre-load before instantiating the I2C clients.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 0b521e4671aa..3c01c8607c26 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -142,6 +142,7 @@ struct x86_serdev_info {
 };
 
 struct x86_dev_info {
+	const char * const *modules;
 	struct gpiod_lookup_table **gpiod_lookup_tables;
 	const struct x86_i2c_client_info *i2c_client_info;
 	const struct platform_device_info *pdev_info;
@@ -428,6 +429,13 @@ static __init int x86_android_tablet_init(void)
 
 	dev_info = id->driver_data;
 
+	/*
+	 * Since this runs from module_init() it cannot use -EPROBE_DEFER,
+	 * instead pre-load any modules which are listed as requirements.
+	 */
+	for (i = 0; dev_info->modules && dev_info->modules[i]; i++)
+		request_module(dev_info->modules[i]);
+
 	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]);
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 10/12] platform/x86: x86-android-tablets: Add Asus TF103C data
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (8 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 09/12] platform/x86: x86-android-tablets: Add support for preloading modules Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 11/12] platform/x86: x86-android-tablets: Add Asus MeMO Pad 7 ME176C data Hans de Goede
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

Asus TF103C tablets have an Android factory img with everything hardcoded
in the kernel instead of properly described in the DSDT.

Add support for manually instantiating all the missing I2C devices by
adding the necessary device info to the x86-android-tablets module.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 165 +++++++++++++++++++++
 1 file changed, 165 insertions(+)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 3c01c8607c26..1f4300e837c6 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -21,6 +21,7 @@
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/power/bq24190_charger.h>
 #include <linux/serdev.h>
 #include <linux/string.h>
 /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
@@ -152,6 +153,162 @@ struct x86_dev_info {
 	int serdev_count;
 };
 
+/* Generic / shared bq24190 settings */
+static const char * const bq24190_suppliers[] = { "tusb1210-psy" };
+
+static const struct property_entry bq24190_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_suppliers),
+	PROPERTY_ENTRY_BOOL("omit-battery-class"),
+	PROPERTY_ENTRY_BOOL("disable-reset"),
+	{ }
+};
+
+static const struct software_node bq24190_node = {
+	.properties = bq24190_props,
+};
+
+/* For enableing the bq24190 5V boost based on id-pin */
+static struct regulator_consumer_supply intel_int3496_consumer = {
+	.supply = "vbus",
+	.dev_name = "intel-int3496",
+};
+
+static const struct regulator_init_data bq24190_vbus_init_data = {
+	.constraints = {
+		.name = "bq24190_vbus",
+		.valid_ops_mask = REGULATOR_CHANGE_STATUS,
+	},
+	.consumer_supplies = &intel_int3496_consumer,
+	.num_consumer_supplies = 1,
+};
+
+static struct bq24190_platform_data bq24190_pdata = {
+	.regulator_init_data = &bq24190_vbus_init_data,
+};
+
+static const char * const bq24190_modules[] __initconst = {
+	"crystal_cove_charger", /* For the bq24190 IRQ */
+	"bq24190_charger",      /* For the Vbus regulator for intel-int3496 */
+	NULL
+};
+
+/* Generic pdevs array and gpio-lookups for micro USB ID pin handling */
+static const struct platform_device_info int3496_pdevs[] __initconst = {
+	{
+		/* For micro USB ID pin handling */
+		.name = "intel-int3496",
+		.id = PLATFORM_DEVID_NONE,
+	},
+};
+
+static struct gpiod_lookup_table int3496_gpo2_pin22_gpios = {
+	.dev_id = "intel-int3496",
+	.table = {
+		GPIO_LOOKUP("INT33FC:02", 22, "id", GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+/* Asus TF103C tablets have an Android factory img with everything hardcoded */
+static const char * const asus_tf103c_accel_mount_matrix[] = {
+	"0", "-1", "0",
+	"-1", "0", "0",
+	"0", "0", "1"
+};
+
+static const struct property_entry asus_tf103c_accel_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", asus_tf103c_accel_mount_matrix),
+	{ }
+};
+
+static const struct software_node asus_tf103c_accel_node = {
+	.properties = asus_tf103c_accel_props,
+};
+
+static const struct property_entry asus_tf103c_touchscreen_props[] = {
+	PROPERTY_ENTRY_STRING("compatible", "atmel,atmel_mxt_ts"),
+	{ }
+};
+
+static const struct software_node asus_tf103c_touchscreen_node = {
+	.properties = asus_tf103c_touchscreen_props,
+};
+
+static const struct x86_i2c_client_info asus_tf103c_i2c_clients[] __initconst = {
+	{
+		/* bq24190 battery charger */
+		.board_info = {
+			.type = "bq24190",
+			.addr = 0x6b,
+			.dev_name = "bq24190",
+			.swnode = &bq24190_node,
+			.platform_data = &bq24190_pdata,
+		},
+		.adapter_path = "\\_SB_.I2C1",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_PMIC,
+			.chip = "\\_SB_.I2C7.PMIC",
+			.domain = DOMAIN_BUS_WAKEUP,
+			.index = 0,
+		},
+	}, {
+		/* ug3105 battery monitor */
+		.board_info = {
+			.type = "ug3105",
+			.addr = 0x70,
+			.dev_name = "ug3105",
+		},
+		.adapter_path = "\\_SB_.I2C1",
+	}, {
+		/* ak09911 compass */
+		.board_info = {
+			.type = "ak09911",
+			.addr = 0x0c,
+			.dev_name = "ak09911",
+		},
+		.adapter_path = "\\_SB_.I2C5",
+	}, {
+		/* kxtj21009 accel */
+		.board_info = {
+			.type = "kxtj21009",
+			.addr = 0x0f,
+			.dev_name = "kxtj21009",
+			.swnode = &asus_tf103c_accel_node,
+		},
+		.adapter_path = "\\_SB_.I2C5",
+	}, {
+		/* atmel touchscreen */
+		.board_info = {
+			.type = "atmel_mxt_ts",
+			.addr = 0x4a,
+			.dev_name = "atmel_mxt_ts",
+			.swnode = &asus_tf103c_touchscreen_node,
+		},
+		.adapter_path = "\\_SB_.I2C6",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
+			.chip = "INT33FC:02",
+			.index = 28,
+			.trigger = ACPI_EDGE_SENSITIVE,
+			.polarity = ACPI_ACTIVE_LOW,
+		},
+	},
+};
+
+static struct gpiod_lookup_table *asus_tf103c_gpios[] = {
+	&int3496_gpo2_pin22_gpios,
+	NULL
+};
+
+static 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 = int3496_pdevs,
+	.pdev_count = ARRAY_SIZE(int3496_pdevs),
+	.gpiod_lookup_tables = asus_tf103c_gpios,
+	.modules = bq24190_modules,
+};
+
 /*
  * When booted with the BIOS set to Android mode the Chuwi Hi8 (CWI509) DSDT
  * contains a whole bunch of bogus ACPI I2C devices and is missing entries
@@ -268,6 +425,14 @@ static const struct x86_dev_info xiaomi_mipad2_info __initconst = {
 };
 
 static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
+	{
+		/* Asus TF103C */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "TF103C"),
+		},
+		.driver_data = (void *)&asus_tf103c_info,
+	},
 	{
 		/* Chuwi Hi8 (CWI509) */
 		.matches = {
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 11/12] platform/x86: x86-android-tablets: Add Asus MeMO Pad 7 ME176C data
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (9 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 10/12] platform/x86: x86-android-tablets: Add Asus TF103C data Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-29 23:14 ` [PATCH 12/12] platform/x86: x86-android-tablets: Add TM800A550L data Hans de Goede
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

Asus MeMO Pad 7 ME176C tablets have an Android factory img with everything
hardcoded in the kernel instead of properly described in the DSDT.

Add support for manually instantiating all the missing I2C devices by
adding the necessary device info to the x86-android-tablets module.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 118 +++++++++++++++++++++
 1 file changed, 118 insertions(+)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 1f4300e837c6..fb257b5811d3 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -209,6 +209,116 @@ static struct gpiod_lookup_table int3496_gpo2_pin22_gpios = {
 	},
 };
 
+/* Asus ME176C tablets have an Android factory img with everything hardcoded */
+static const char * const asus_me176c_accel_mount_matrix[] = {
+	"-1", "0", "0",
+	"0", "1", "0",
+	"0", "0", "1"
+};
+
+static const struct property_entry asus_me176c_accel_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", asus_me176c_accel_mount_matrix),
+	{ }
+};
+
+static const struct software_node asus_me176c_accel_node = {
+	.properties = asus_me176c_accel_props,
+};
+
+static const struct x86_i2c_client_info asus_me176c_i2c_clients[] __initconst = {
+	{
+		/* bq24190 battery charger */
+		.board_info = {
+			.type = "bq24190",
+			.addr = 0x6b,
+			.dev_name = "bq24190",
+			.swnode = &bq24190_node,
+			.platform_data = &bq24190_pdata,
+		},
+		.adapter_path = "\\_SB_.I2C1",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_PMIC,
+			.chip = "\\_SB_.I2C7.PMIC",
+			.domain = DOMAIN_BUS_WAKEUP,
+			.index = 0,
+		},
+	}, {
+		/* ug3105 battery monitor */
+		.board_info = {
+			.type = "ug3105",
+			.addr = 0x70,
+			.dev_name = "ug3105",
+		},
+		.adapter_path = "\\_SB_.I2C1",
+	}, {
+		/* ak09911 compass */
+		.board_info = {
+			.type = "ak09911",
+			.addr = 0x0c,
+			.dev_name = "ak09911",
+		},
+		.adapter_path = "\\_SB_.I2C5",
+	}, {
+		/* kxtj21009 accel */
+		.board_info = {
+			.type = "kxtj21009",
+			.addr = 0x0f,
+			.dev_name = "kxtj21009",
+			.swnode = &asus_me176c_accel_node,
+		},
+		.adapter_path = "\\_SB_.I2C5",
+	}, {
+		/* goodix touchscreen */
+		.board_info = {
+			.type = "GDIX1001:00",
+			.addr = 0x14,
+			.dev_name = "goodix_ts",
+		},
+		.adapter_path = "\\_SB_.I2C6",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_APIC,
+			.index = 0x45,
+			.trigger = ACPI_EDGE_SENSITIVE,
+			.polarity = ACPI_ACTIVE_LOW,
+		},
+	},
+};
+
+static const struct x86_serdev_info asus_me176c_serdevs[] __initconst = {
+	{
+		.ctrl_hid = "80860F0A",
+		.ctrl_uid = "2",
+		.ctrl_devname = "serial0",
+		.serdev_hid = "BCM2E3A",
+	},
+};
+
+static struct gpiod_lookup_table asus_me176c_goodix_gpios = {
+	.dev_id = "i2c-goodix_ts",
+	.table = {
+		GPIO_LOOKUP("INT33FC:00", 60, "reset", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("INT33FC:02", 28, "irq", GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+static struct gpiod_lookup_table *asus_me176c_gpios[] = {
+	&int3496_gpo2_pin22_gpios,
+	&asus_me176c_goodix_gpios,
+	NULL
+};
+
+static 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 = int3496_pdevs,
+	.pdev_count = ARRAY_SIZE(int3496_pdevs),
+	.serdev_info = asus_me176c_serdevs,
+	.serdev_count = ARRAY_SIZE(asus_me176c_serdevs),
+	.gpiod_lookup_tables = asus_me176c_gpios,
+	.modules = bq24190_modules,
+};
+
 /* Asus TF103C tablets have an Android factory img with everything hardcoded */
 static const char * const asus_tf103c_accel_mount_matrix[] = {
 	"0", "-1", "0",
@@ -425,6 +535,14 @@ static const struct x86_dev_info xiaomi_mipad2_info __initconst = {
 };
 
 static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
+	{
+		/* Asus MeMO Pad 7 ME176C */
+		.matches = {
+			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ME176C"),
+		},
+		.driver_data = (void *)&asus_me176c_info,
+	},
 	{
 		/* Asus TF103C */
 		.matches = {
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 12/12] platform/x86: x86-android-tablets: Add TM800A550L data
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (10 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 11/12] platform/x86: x86-android-tablets: Add Asus MeMO Pad 7 ME176C data Hans de Goede
@ 2021-12-29 23:14 ` Hans de Goede
  2021-12-30 11:57 ` [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Wolfram Sang
  2022-01-03 11:42 ` Hans de Goede
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-29 23:14 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Hans de Goede, Len Brown, linux-acpi, platform-driver-x86,
	linux-i2c, Stephan Gerhold, linux-serial

The whitelabel (sold as various brands) TM800A550L tablets's DSDT contains
a whole bunch of bogus ACPI I2C devices and the ACPI node describing
the touchscreen is bad (the IRQ is missing). Enumeration of these is
skipped through the acpi_quirk_skip_i2c_client_enumeration().

Add support for manually instantiating the (now) missing I2C devices by
adding the necessary device info to the x86-android-tablets module,
including instantiating an actually working i2c-client for
the touchscreen.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/platform/x86/x86-android-tablets.c | 90 ++++++++++++++++++++++
 1 file changed, 90 insertions(+)

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index fb257b5811d3..5f66fab6100e 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -534,6 +534,86 @@ static const struct x86_dev_info xiaomi_mipad2_info __initconst = {
 	.i2c_client_count = ARRAY_SIZE(xiaomi_mipad2_i2c_clients),
 };
 
+/*
+ * Whitelabel (sold as various brands) TM800A550L tablets.
+ * These tablet's DSDT contains a whole bunch of bogus ACPI I2C devices
+ * (removed through acpi_quirk_skip_i2c_client_enumeration()) and
+ * the touchscreen fwnode has the wrong GPIOs.
+ */
+static const char * const whitelabel_tm800a550l_accel_mount_matrix[] = {
+	"-1", "0", "0",
+	"0", "1", "0",
+	"0", "0", "1"
+};
+
+static const struct property_entry whitelabel_tm800a550l_accel_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("mount-matrix", whitelabel_tm800a550l_accel_mount_matrix),
+	{ }
+};
+
+static const struct software_node whitelabel_tm800a550l_accel_node = {
+	.properties = whitelabel_tm800a550l_accel_props,
+};
+
+static const struct property_entry whitelabel_tm800a550l_goodix_props[] = {
+	PROPERTY_ENTRY_STRING("firmware-name", "gt912-tm800a550l.fw"),
+	PROPERTY_ENTRY_STRING("goodix,config-name", "gt912-tm800a550l.cfg"),
+	PROPERTY_ENTRY_U32("goodix,main-clk", 54),
+	{ }
+};
+
+static const struct software_node whitelabel_tm800a550l_goodix_node = {
+	.properties = whitelabel_tm800a550l_goodix_props,
+};
+
+static const struct x86_i2c_client_info whitelabel_tm800a550l_i2c_clients[] __initconst = {
+	{
+		/* goodix touchscreen */
+		.board_info = {
+			.type = "GDIX1001:00",
+			.addr = 0x14,
+			.dev_name = "goodix_ts",
+			.swnode = &whitelabel_tm800a550l_goodix_node,
+		},
+		.adapter_path = "\\_SB_.I2C2",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_APIC,
+			.index = 0x44,
+			.trigger = ACPI_EDGE_SENSITIVE,
+			.polarity = ACPI_ACTIVE_HIGH,
+		},
+	}, {
+		/* kxcj91008 accel */
+		.board_info = {
+			.type = "kxcj91008",
+			.addr = 0x0f,
+			.dev_name = "kxcj91008",
+			.swnode = &whitelabel_tm800a550l_accel_node,
+		},
+		.adapter_path = "\\_SB_.I2C3",
+	},
+};
+
+static struct gpiod_lookup_table whitelabel_tm800a550l_goodix_gpios = {
+	.dev_id = "i2c-goodix_ts",
+	.table = {
+		GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("INT33FC:02", 3, "irq", GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+static struct gpiod_lookup_table *whitelabel_tm800a550l_gpios[] = {
+	&whitelabel_tm800a550l_goodix_gpios,
+	NULL
+};
+
+static const struct x86_dev_info whitelabel_tm800a550l_info __initconst = {
+	.i2c_client_info = whitelabel_tm800a550l_i2c_clients,
+	.i2c_client_count = ARRAY_SIZE(whitelabel_tm800a550l_i2c_clients),
+	.gpiod_lookup_tables = whitelabel_tm800a550l_gpios,
+};
+
 static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
 	{
 		/* Asus MeMO Pad 7 ME176C */
@@ -568,6 +648,16 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
 		},
 		.driver_data = (void *)&xiaomi_mipad2_info,
 	},
+	{
+		/* Whitelabel (sold as various brands) TM800A550L */
+		.matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
+			DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
+			/* Above strings are too generic, also match on BIOS version */
+			DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"),
+		},
+		.driver_data = (void *)&whitelabel_tm800a550l_info,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(dmi, x86_android_tablet_ids);
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (11 preceding siblings ...)
  2021-12-29 23:14 ` [PATCH 12/12] platform/x86: x86-android-tablets: Add TM800A550L data Hans de Goede
@ 2021-12-30 11:57 ` Wolfram Sang
  2022-01-03 11:42 ` Hans de Goede
  13 siblings, 0 replies; 19+ messages in thread
From: Wolfram Sang @ 2021-12-30 11:57 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Mika Westerberg,
	Rob Herring, Greg Kroah-Hartman, Jiri Slaby, Len Brown,
	linux-acpi, platform-driver-x86, linux-i2c, Stephan Gerhold,
	linux-serial

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

Hi Hans,

> The ACPI core changes are in patches 1-3 of this series. Since the
> i2c and serdev ACPI enumeration changes are very small and depend on
> patch 1, I believe it would be best for patches 1-3 to all be merged
> through Rafael's ACPI tree.

OK.

> Greg and Wolfram, may we have your acks for this please?

I don't know the gory details of ACPI, that's why we thankfully have I2C
ACPI maintainers. If they are happy, I am, too.

Kind regards,

   Wolfram

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries
  2021-12-29 23:14 ` [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries Hans de Goede
@ 2021-12-30 12:03   ` Mika Westerberg
  2021-12-30 12:21   ` Wolfram Sang
  1 sibling, 0 replies; 19+ messages in thread
From: Mika Westerberg @ 2021-12-30 12:03 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Rob Herring, Greg Kroah-Hartman, Jiri Slaby, Len Brown,
	linux-acpi, platform-driver-x86, linux-i2c, Stephan Gerhold,
	linux-serial

On Thu, Dec 30, 2021 at 12:14:21AM +0100, Hans de Goede wrote:
> x86 ACPI devices which ship with only Android as their factory image
> usually declare a whole bunch of bogus I2C devices in their ACPI tables.
> 
> Instantiating I2C clients for these bogus devices causes various issues,
> e.g. GPIO/IRQ resource conflicts because sometimes drivers do bind to them.
> The Android x86 kernel fork shipped on these devices has some special code
> to remove these bogus devices, instead of just fixing the DSDT <sigh>.
> 
> Use the new acpi_quirk_skip_i2c_client_enumeration() helper to
> identify known boards with this issue, and on these boards ignore I2C
> devices described in ACPI, with a few exceptions which are known to
> always be correct (and in case of the audio-codecs where the drivers
> heavily rely on the codec being enumerated through ACPI).
> 
> Note these boards typically do actually have I2C devices, just
> different ones then the ones described in their DSDT. The devices
> which are actually present are manually instantiated by the
> drivers/platform/x86/x86-android-tablets.c kernel module.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries
  2021-12-29 23:14 ` [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries Hans de Goede
  2021-12-30 12:03   ` Mika Westerberg
@ 2021-12-30 12:21   ` Wolfram Sang
  2021-12-30 12:34     ` Hans de Goede
  1 sibling, 1 reply; 19+ messages in thread
From: Wolfram Sang @ 2021-12-30 12:21 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Mika Westerberg,
	Rob Herring, Greg Kroah-Hartman, Jiri Slaby, Len Brown,
	linux-acpi, platform-driver-x86, linux-i2c, Stephan Gerhold,
	linux-serial

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]


Okay, I have a question, after all :)

> +static const struct acpi_device_id i2c_acpi_known_good_ids[] = {
> +	{ "10EC5640", 0 }, /* RealTek ALC5640 audio codec */
> +	{ "INT33F4", 0 },  /* X-Powers AXP288 PMIC */
> +	{ "INT33FD", 0 },  /* Intel Crystal Cove PMIC */
> +	{ "NPCE69A", 0 },  /* Asus Transformer keyboard dock */
> +	{}
> +};

Can't we add this table to patch 1 and check it within a
acpi_quirk_skip_i2c_client_enumeration(adev)?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries
  2021-12-30 12:21   ` Wolfram Sang
@ 2021-12-30 12:34     ` Hans de Goede
  0 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2021-12-30 12:34 UTC (permalink / raw)
  To: Wolfram Sang, Rafael J . Wysocki, Mark Gross, Andy Shevchenko,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby,
	Len Brown, linux-acpi, platform-driver-x86, linux-i2c,
	Stephan Gerhold, linux-serial

Hi,

On 12/30/21 13:21, Wolfram Sang wrote:
> 
> Okay, I have a question, after all :)
> 
>> +static const struct acpi_device_id i2c_acpi_known_good_ids[] = {
>> +	{ "10EC5640", 0 }, /* RealTek ALC5640 audio codec */
>> +	{ "INT33F4", 0 },  /* X-Powers AXP288 PMIC */
>> +	{ "INT33FD", 0 },  /* Intel Crystal Cove PMIC */
>> +	{ "NPCE69A", 0 },  /* Asus Transformer keyboard dock */
>> +	{}
>> +};
> 
> Can't we add this table to patch 1 and check it within a
> acpi_quirk_skip_i2c_client_enumeration(adev)?

Yes that will keep all the quirk-handling / ugliness together in
a single place, so that is good idea.

I will change this for v2 of the series.

Regards,

Hans


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 03/12] serdev: Do not instantiate serdevs on boards with known bogus DSDT entries
  2021-12-29 23:14 ` [PATCH 03/12] serdev: Do not instantiate serdevs " Hans de Goede
@ 2021-12-30 12:44   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 19+ messages in thread
From: Greg Kroah-Hartman @ 2021-12-30 12:44 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Jiri Slaby, Len Brown, linux-acpi,
	platform-driver-x86, linux-i2c, Stephan Gerhold, linux-serial

On Thu, Dec 30, 2021 at 12:14:22AM +0100, Hans de Goede wrote:
> x86 ACPI devices which ship with only Android as their factory image use
> older kernels which do not yet support ACPI serdev enumeration, as such
> the serdev information in their ACPI tables is not reliable.
> 
> For example on the Asus ME176C tablet the serdev describing the Bluetooth
> HCI points to the serdev_controller connected to the GPS and the other way
> around.
> 
> Use the new acpi_quirk_skip_serdev_enumeration() helper to identify
> known boards with this issue and then either abort adding the serdev
> controller (creating a tty cdev instead) or only create the controller
> leaving the instantation of the serdev itself up to platform code.
> 
> In the case where only the serdev controller is created the necessary
> serdevs will instead be instantiated by the
> drivers/platform/x86/x86-android-tablets.c kernel module.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/tty/serdev/core.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)


Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs
  2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
                   ` (12 preceding siblings ...)
  2021-12-30 11:57 ` [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Wolfram Sang
@ 2022-01-03 11:42 ` Hans de Goede
  13 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2022-01-03 11:42 UTC (permalink / raw)
  To: Rafael J . Wysocki, Mark Gross, Andy Shevchenko, Wolfram Sang,
	Mika Westerberg, Rob Herring, Greg Kroah-Hartman, Jiri Slaby
  Cc: Len Brown, linux-acpi, platform-driver-x86, linux-i2c,
	Stephan Gerhold, linux-serial

Hi All,

On 12/30/21 00:14, Hans de Goede wrote:
> Hi All,
> 
> As a small(ish) hoppy project over the holidays I've been looking into
> getting some (somewhat older) x86 tablets which ship with Android as the
> only OS on their factory image working with the mainline kernel.
> 
> These typically have pretty broken DSDTs since the Android image kernel
> just has everything hardcoded.
> 
> This patch-series makes most things on 3 of these tablets work with the
> mainline kernel and lays the groundwork for adding support for similar
> tablets.
> 
> Since the ACPI tables on these devices clearly are buggy this series is
> written so as to add minimal changes to the ACPI core code, leaving all
> of the heavy lifting to the recently introduced (in linux-next)
> drivers/platform/x86/x86-android-tablets.c module, which when built as
> a module only autoloads on affected devices based on DMI matching.
> 
> And when this module is disabled the added acpi_quirk_skip_*_enumeration()
> helpers are replaced by inline stubs and even the minimally added core
> code will be optimized away.
> 
> The ACPI core changes are in patches 1-3 of this series. Since the
> i2c and serdev ACPI enumeration changes are very small and depend on
> patch 1, I believe it would be best for patches 1-3 to all be merged
> through Rafael's ACPI tree.

I've added patches 4-12 to my pdx86/review-hans (soon to be for-next)
branch now.

Regards,

Hans


> Hans de Goede (12):
>   ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration()
>     helpers
>   i2c: acpi: Do not instantiate I2C-clients on boards with known bogus
>     DSDT entries
>   serdev: Do not instantiate serdevs on boards with known bogus DSDT
>     entries
>   platform/x86: x86-android-tablets: Don't return -EPROBE_DEFER from a
>     non probe() function
>   platform/x86: x86-android-tablets: Add support for PMIC interrupts
>   platform/x86: x86-android-tablets: Add support for instantiating
>     platform-devs
>   platform/x86: x86-android-tablets: Add support for instantiating
>     serdevs
>   platform/x86: x86-android-tablets: Add support for registering GPIO
>     lookup tables
>   platform/x86: x86-android-tablets: Add support for preloading modules
>   platform/x86: x86-android-tablets: Add Asus TF103C data
>   platform/x86: x86-android-tablets: Add Asus MeMO Pad 7 ME176C data
>   platform/x86: x86-android-tablets: Add TM800A550L data
> 
>  drivers/acpi/x86/utils.c                   |  96 ++++
>  drivers/i2c/i2c-core-acpi.c                |  17 +
>  drivers/platform/x86/Kconfig               |   2 +-
>  drivers/platform/x86/x86-android-tablets.c | 562 ++++++++++++++++++++-
>  drivers/tty/serdev/core.c                  |  14 +
>  include/acpi/acpi_bus.h                    |  16 +
>  6 files changed, 698 insertions(+), 9 deletions(-)
> 


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-01-03 11:42 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-29 23:14 [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Hans de Goede
2021-12-29 23:14 ` [PATCH 01/12] ACPI / x86: Add acpi_quirk_skip_[i2c_client|serdev]_enumeration() helpers Hans de Goede
2021-12-29 23:14 ` [PATCH 02/12] i2c: acpi: Do not instantiate I2C-clients on boards with known bogus DSDT entries Hans de Goede
2021-12-30 12:03   ` Mika Westerberg
2021-12-30 12:21   ` Wolfram Sang
2021-12-30 12:34     ` Hans de Goede
2021-12-29 23:14 ` [PATCH 03/12] serdev: Do not instantiate serdevs " Hans de Goede
2021-12-30 12:44   ` Greg Kroah-Hartman
2021-12-29 23:14 ` [PATCH 04/12] platform/x86: x86-android-tablets: Don't return -EPROBE_DEFER from a non probe() function Hans de Goede
2021-12-29 23:14 ` [PATCH 05/12] platform/x86: x86-android-tablets: Add support for PMIC interrupts Hans de Goede
2021-12-29 23:14 ` [PATCH 06/12] platform/x86: x86-android-tablets: Add support for instantiating platform-devs Hans de Goede
2021-12-29 23:14 ` [PATCH 07/12] platform/x86: x86-android-tablets: Add support for instantiating serdevs Hans de Goede
2021-12-29 23:14 ` [PATCH 08/12] platform/x86: x86-android-tablets: Add support for registering GPIO lookup tables Hans de Goede
2021-12-29 23:14 ` [PATCH 09/12] platform/x86: x86-android-tablets: Add support for preloading modules Hans de Goede
2021-12-29 23:14 ` [PATCH 10/12] platform/x86: x86-android-tablets: Add Asus TF103C data Hans de Goede
2021-12-29 23:14 ` [PATCH 11/12] platform/x86: x86-android-tablets: Add Asus MeMO Pad 7 ME176C data Hans de Goede
2021-12-29 23:14 ` [PATCH 12/12] platform/x86: x86-android-tablets: Add TM800A550L data Hans de Goede
2021-12-30 11:57 ` [PATCH 00/12] ACPI / pdx86: Add support for x86 Android tablets with broken DSDTs Wolfram Sang
2022-01-03 11:42 ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.