All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support
@ 2022-02-23 13:31 Hans de Goede
  2022-02-23 13:31 ` [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk Hans de Goede
                   ` (5 more replies)
  0 siblings, 6 replies; 19+ messages in thread
From: Hans de Goede @ 2022-02-23 13:31 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij
  Cc: Hans de Goede, platform-driver-x86, linux-gpio

Hi All,

This series consists of 2 parts:

Patch 1   : pinctrl: baytrail: Add pinconf group + function for the pmu_clk
Patch 2-5 : platform/x86: x86-android-tablets: Add Lenovo Yoga Tab2 support

Patch 5 has a runtime dependency on patch 1, but this is only  runtime and
there are some other patches in flight to other subsystems which are also
needed for the Lenovo Yoga Tab2 support.

As such I believe that patch 1 can be merged independently through the
pinctrl-intel tree and then I'll merge patches 2-5 through the pdx86 tree.

The only reason for sending this out as a series is because patch 5
uses the new pmu_clk pinconf added by patch 1.

Regards,

Hans


Hans de Goede (5):
  pinctrl: baytrail: Add pinconf group + function for the pmu_clk
  platform/x86: x86-android-tablets: Fix EBUSY error when requesting
    IOAPIC IRQs
  platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050
    data
  platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2
    830/1050 poweroff hang
  platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound
    support

 drivers/pinctrl/intel/pinctrl-baytrail.c   |   9 +
 drivers/platform/x86/x86-android-tablets.c | 280 +++++++++++++++++++++
 2 files changed, 289 insertions(+)

-- 
2.35.1


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

* [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk
  2022-02-23 13:31 [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Hans de Goede
@ 2022-02-23 13:31 ` Hans de Goede
  2022-02-23 14:54   ` Andy Shevchenko
  2022-02-23 13:31 ` [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs Hans de Goede
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: Hans de Goede @ 2022-02-23 13:31 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij
  Cc: Hans de Goede, platform-driver-x86, linux-gpio

On the Lenovo Yoga Tablet 2 830 / 1050 / 1051 models the 32KHz PMU clk,
which can be muxed externally to SUS pin 5 and/or 6 is used as a clock
for the audio codec.

On the 830 and 1050 models, with ship with Android as factory OS the
pin-muxing for this is not setup by the BIOS.

Add a pinconf group + function for the pmu_clk on SUS pin 5 and 6 to
allow setting the pinmux up from within the x86-android-tablets
platform code.

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

diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
index 7ae71152b480..fec888c1cd05 100644
--- a/drivers/pinctrl/intel/pinctrl-baytrail.c
+++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
@@ -444,6 +444,9 @@ static const unsigned int byt_sus_pcu_spi_pins[] = { 21 };
 static const unsigned int byt_sus_pcu_spi_mode_values[] = { 0 };
 static const unsigned int byt_sus_pcu_spi_gpio_mode_values[] = { 1 };
 
+static const unsigned int byt_sus_pmu_clk1_pins[] = { 5 };
+static const unsigned int byt_sus_pmu_clk2_pins[] = { 6 };
+
 static const struct intel_pingroup byt_sus_groups[] = {
 	PIN_GROUP("usb_oc_grp", byt_sus_usb_over_current_pins, byt_sus_usb_over_current_mode_values),
 	PIN_GROUP("usb_ulpi_grp", byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_mode_values),
@@ -451,20 +454,26 @@ static const struct intel_pingroup byt_sus_groups[] = {
 	PIN_GROUP("usb_oc_grp_gpio", byt_sus_usb_over_current_pins, byt_sus_usb_over_current_gpio_mode_values),
 	PIN_GROUP("usb_ulpi_grp_gpio", byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_gpio_mode_values),
 	PIN_GROUP("pcu_spi_grp_gpio", byt_sus_pcu_spi_pins, byt_sus_pcu_spi_gpio_mode_values),
+	PIN_GROUP("pmu_clk1_grp", byt_sus_pmu_clk1_pins, 1),
+	PIN_GROUP("pmu_clk2_grp", byt_sus_pmu_clk2_pins, 1),
 };
 
 static const char * const byt_sus_usb_groups[] = {
 	"usb_oc_grp", "usb_ulpi_grp",
 };
 static const char * const byt_sus_spi_groups[] = { "pcu_spi_grp" };
+static const char * const byt_sus_pmu_clk_groups[] = {
+	"pmu_clk1_grp", "pmu_clk2_grp" };
 static const char * const byt_sus_gpio_groups[] = {
 	"usb_oc_grp_gpio", "usb_ulpi_grp_gpio", "pcu_spi_grp_gpio",
+	"pmu_clk1_grp", "pmu_clk2_grp",
 };
 
 static const struct intel_function byt_sus_functions[] = {
 	FUNCTION("usb", byt_sus_usb_groups),
 	FUNCTION("spi", byt_sus_spi_groups),
 	FUNCTION("gpio", byt_sus_gpio_groups),
+	FUNCTION("pmu_clk", byt_sus_pmu_clk_groups),
 };
 
 static const struct intel_community byt_sus_communities[] = {
-- 
2.35.1


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

* [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
  2022-02-23 13:31 [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Hans de Goede
  2022-02-23 13:31 ` [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk Hans de Goede
@ 2022-02-23 13:31 ` Hans de Goede
  2022-02-23 14:56   ` Andy Shevchenko
  2022-02-23 13:31 ` [PATCH 3/5] platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data Hans de Goede
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: Hans de Goede @ 2022-02-23 13:31 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij
  Cc: Hans de Goede, platform-driver-x86, linux-gpio

Sometimes IRQs used by GPIOs in direct-IRQ mode are already registered
because they are used as ACPI "Interrupt () {}" resource for one of the
many bogus I2C devices present in the broken DSDTs of Android x86 tablets.

This is an issue if the existing (bogus) ACPI resource uses different
trigger settings then what is being requested, leading to an -EBUSY
error return of acpi_register_gsi().

Fix this by calling acpi_unregister_gsi() first, so that
the acpi_register_gsi() is allowed to change the trigger settings.

In cases where the GSI has not been registered yet
the acpi_unregister_gsi() is a no-op.

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

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index f280c82d5ba5..61e526e048c3 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -89,6 +89,12 @@ static int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
 
 	switch (data->type) {
 	case X86_ACPI_IRQ_TYPE_APIC:
+		/*
+		 * The DSDT may already reference the GSI in a device skipped by
+		 * acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI
+		 * to avoid EBUSY errors in this case.
+		 */
+		acpi_unregister_gsi(data->index);
 		irq = acpi_register_gsi(NULL, data->index, data->trigger, data->polarity);
 		if (irq < 0)
 			pr_err("error %d getting APIC IRQ %d\n", irq, data->index);
-- 
2.35.1


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

* [PATCH 3/5] platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data
  2022-02-23 13:31 [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Hans de Goede
  2022-02-23 13:31 ` [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk Hans de Goede
  2022-02-23 13:31 ` [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs Hans de Goede
@ 2022-02-23 13:31 ` Hans de Goede
  2022-02-23 15:04   ` Andy Shevchenko
  2022-02-23 13:31 ` [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang Hans de Goede
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 19+ messages in thread
From: Hans de Goede @ 2022-02-23 13:31 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij
  Cc: Hans de Goede, platform-driver-x86, linux-gpio

The Lenovo Yoga Tablet 2 series comes in 4 versions: 830F, 830L, 1050F and
1050L. The F postfix indicates a wifi only version and the L postfix
indicates a LTE version. The 830 models are 8" and the 1050 models are 10".

Despite there being 8" and 10" versions all models use the same mainboard,
with an identical BIOS and thus identical DMI strings, so support for all
4 models is added through a single DMI table entry.

As all devices dealt with in the x86-android-tablets modules, these are
x86 ACPI tablets which ships with Android x86 as factory OS.
The mainboard's DSDT contain 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 devices which are
actually present on this tablet by adding the necessary device info to
the x86-android-tablets module.

This has been tested on a 830F and a 1050L tablet.

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

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 61e526e048c3..89972723f546 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -22,8 +22,10 @@
 #include <linux/irqdomain.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/platform_data/lp855x.h>
 #include <linux/platform_device.h>
 #include <linux/power/bq24190_charger.h>
+#include <linux/rmi.h>
 #include <linux/serdev.h>
 #include <linux/string.h>
 /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
@@ -182,6 +184,15 @@ static const char * const tusb1211_chg_det_psy[] = { "tusb1211-charger-detect" }
 static const char * const bq24190_psy[] = { "bq24190-charger" };
 static const char * const bq25890_psy[] = { "bq25890-charger" };
 
+static const struct property_entry fg_bq24190_supply_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_psy),
+	{ }
+};
+
+static const struct software_node fg_bq24190_supply_node = {
+	.properties = fg_bq24190_supply_props,
+};
+
 static const struct property_entry fg_bq25890_supply_props[] = {
 	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq25890_psy),
 	{ }
@@ -704,6 +715,165 @@ static const struct x86_dev_info lenovo_yogabook_x9x_info __initconst = {
 	.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x9x_i2c_clients),
 };
 
+/* Lenovo Yoga Tablet 2 1050F/L's Android factory img has everything hardcoded */
+static const struct property_entry lenovo_yoga_tab2_830_1050_bq24190_props[] = {
+	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", tusb1211_chg_det_psy),
+	PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node),
+	PROPERTY_ENTRY_BOOL("omit-battery-class"),
+	PROPERTY_ENTRY_BOOL("disable-reset"),
+	{ }
+};
+
+static const struct software_node lenovo_yoga_tab2_830_1050_bq24190_node = {
+	.properties = lenovo_yoga_tab2_830_1050_bq24190_props,
+};
+
+/* This gets filled by lenovo_yoga_tab2_830_1050_init() */
+static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { };
+
+static struct lp855x_platform_data lenovo_yoga_tab2_830_1050_lp8557_pdata = {
+	.device_control = 0x86,
+	.initial_brightness = 128,
+};
+
+static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initconst = {
+	{
+		/* bq24292i battery charger */
+		.board_info = {
+			.type = "bq24190",
+			.addr = 0x6b,
+			.dev_name = "bq24292i",
+			.swnode = &lenovo_yoga_tab2_830_1050_bq24190_node,
+			.platform_data = &bq24190_pdata,
+		},
+		.adapter_path = "\\_SB_.I2C1",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
+			.chip = "INT33FC:02",
+			.index = 2,
+			.trigger = ACPI_EDGE_SENSITIVE,
+			.polarity = ACPI_ACTIVE_HIGH,
+		},
+	}, {
+		/* BQ27541 fuel-gauge */
+		.board_info = {
+			.type = "bq27541",
+			.addr = 0x55,
+			.dev_name = "bq27541",
+			.swnode = &fg_bq24190_supply_node,
+		},
+		.adapter_path = "\\_SB_.I2C1",
+	}, {
+		/* Synaptics RMI touchscreen */
+		.board_info = {
+			.type = "rmi4_i2c",
+			.addr = 0x38,
+			.dev_name = "rmi4_i2c",
+			.platform_data = &lenovo_yoga_tab2_830_1050_rmi_pdata,
+		},
+		.adapter_path = "\\_SB_.I2C6",
+		.irq_data = {
+			.type = X86_ACPI_IRQ_TYPE_APIC,
+			.index = 0x45,
+			.trigger = ACPI_EDGE_SENSITIVE,
+			.polarity = ACPI_ACTIVE_HIGH,
+		},
+	}, {
+		/* LP8557 Backlight controller */
+		.board_info = {
+			.type = "lp8557",
+			.addr = 0x2c,
+			.dev_name = "lp8557",
+			.platform_data = &lenovo_yoga_tab2_830_1050_lp8557_pdata,
+		},
+		.adapter_path = "\\_SB_.I2C3",
+	},
+};
+
+static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_int3496_gpios = {
+	.dev_id = "intel-int3496",
+	.table = {
+		GPIO_LOOKUP("INT33FC:02", 1, "mux", GPIO_ACTIVE_LOW),
+		GPIO_LOOKUP("INT33FC:02", 24, "id", GPIO_ACTIVE_HIGH),
+		{ }
+	},
+};
+
+static struct gpiod_lookup_table * const lenovo_yoga_tab2_830_1050_gpios[] = {
+	&lenovo_yoga_tab2_830_1050_int3496_gpios,
+	NULL
+};
+
+static int __init lenovo_yoga_tab2_830_1050_init(void);
+static void lenovo_yoga_tab2_830_1050_exit(void);
+
+static struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initdata = {
+	.i2c_client_info = lenovo_yoga_tab2_830_1050_i2c_clients,
+	/* i2c_client_count gets set by lenovo_yoga_tab2_830_1050_init() */
+	.pdev_info = int3496_pdevs,
+	.pdev_count = ARRAY_SIZE(int3496_pdevs),
+	.gpiod_lookup_tables = lenovo_yoga_tab2_830_1050_gpios,
+	.bat_swnode = &generic_lipo_hv_4v35_battery_node,
+	.modules = bq24190_modules,
+	.invalid_aei_gpiochip = "INT33FC:02",
+	.init = lenovo_yoga_tab2_830_1050_init,
+};
+
+/*
+ * The Lenovo Yoga Tablet 2 830 and 1050 (8" vs 10") versions use the same
+ * mainboard, but they need some different treatment related to the display:
+ * 1. The 830 uses a portrait LCD panel with a landscape touchscreen, requiring
+ *    the touchscreen driver to adjust the touch-coords to match the LCD.
+ * 2. Both use an TI LP8557 LED backlight controller. On the 1050 the LP8557's
+ *    PWM input is connected to the PMIC's PWM output and everything works fine
+ *    with the defaults programmed into the LP8557 by the BIOS.
+ *    But on the 830 the LP8557's PWM input is connected to a PWM output coming
+ *    from the LCD panel's controller. The Android code has a hack in the i915
+ *    driver to write the non-standard DSI reg 0x9f with the desired backlight
+ *    level to set the duty-cycle of the LCD's PWM output.
+ *
+ *    To avoid having to have a similar hack in the mainline kernel the LP8557
+ *    entry in lenovo_yoga_tab2_830_1050_i2c_clients instead just programs the
+ *    LP8557 to directly set the level, ignoring the PWM input. This means that
+ *    the LP8557 i2c_client should only be instantiated on the 830.
+ */
+static int __init lenovo_yoga_tab2_830_1050_init_display(void)
+{
+	struct gpio_desc *gpiod;
+	int ret;
+
+	/* Use PMIC GPIO 10 bootstrap pin to differentiate 830 vs 1050 */
+	ret = x86_android_tablet_get_gpiod("gpio_crystalcove", 10, &gpiod);
+	if (ret)
+		return ret;
+
+	ret = gpiod_get_value_cansleep(gpiod);
+	if (ret) {
+		pr_info("detected Lenovo Yoga Tablet 2 1050F/L\n");
+		lenovo_yoga_tab2_830_1050_info.i2c_client_count =
+			ARRAY_SIZE(lenovo_yoga_tab2_830_1050_i2c_clients) - 1;
+	} else {
+		pr_info("detected Lenovo Yoga Tablet 2 830F/L\n");
+		lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.swap_axes = true;
+		lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.flip_y = true;
+		lenovo_yoga_tab2_830_1050_info.i2c_client_count =
+			ARRAY_SIZE(lenovo_yoga_tab2_830_1050_i2c_clients);
+	}
+
+	return 0;
+}
+
+static int __init lenovo_yoga_tab2_830_1050_init(void)
+{
+	int ret;
+
+	ret = lenovo_yoga_tab2_830_1050_init_display();
+	if (ret)
+		return ret;
+
+	return 0;
+}
+
 /* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
 static const char * const nextbook_ares8_accel_mount_matrix[] = {
 	"0", "-1", "0",
@@ -948,6 +1118,20 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
 		},
 		.driver_data = (void *)&lenovo_yogabook_x9x_info,
 	},
+	{
+		/*
+		 * Lenovo Yoga Tablet 2 830F/L or 1050F/L (The 8" and 10"
+		 * Lenovo Yoga Tablet 2 use the same mainboard)
+		 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"),
+			DMI_MATCH(DMI_BOARD_NAME, "BYT-T FFD8"),
+			/* Partial match on beginning of BIOS version */
+			DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"),
+		},
+		.driver_data = (void *)&lenovo_yoga_tab2_830_1050_info,
+	},
 	{
 		/* Nextbook Ares 8 */
 		.matches = {
-- 
2.35.1


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

* [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang
  2022-02-23 13:31 [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Hans de Goede
                   ` (2 preceding siblings ...)
  2022-02-23 13:31 ` [PATCH 3/5] platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data Hans de Goede
@ 2022-02-23 13:31 ` Hans de Goede
  2022-02-23 14:58   ` Andy Shevchenko
  2022-02-23 13:31 ` [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support Hans de Goede
  2022-02-23 14:55 ` [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Andy Shevchenko
  5 siblings, 1 reply; 19+ messages in thread
From: Hans de Goede @ 2022-02-23 13:31 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij
  Cc: Hans de Goede, platform-driver-x86, linux-gpio

These tablets' DSDT does not set acpi_gbl_reduced_hardware, so
acpi_power_off gets used as pm_power_off handler. This causes "poweroff"
on these tablets to hang hard. Requiring pressing the powerbutton for
30 seconds *twice* followed by a normal 3 second press to recover.

Avoid this by overriding the global pm_power_off handler to do
an EFI poweroff instead.

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

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index 89972723f546..c3d2b30dbe26 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -12,6 +12,7 @@
 
 #include <linux/acpi.h>
 #include <linux/dmi.h>
+#include <linux/efi.h>
 #include <linux/gpio_keys.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
@@ -24,6 +25,7 @@
 #include <linux/mod_devicetable.h>
 #include <linux/platform_data/lp855x.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
 #include <linux/power/bq24190_charger.h>
 #include <linux/rmi.h>
 #include <linux/serdev.h>
@@ -817,6 +819,7 @@ static struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initdata = {
 	.modules = bq24190_modules,
 	.invalid_aei_gpiochip = "INT33FC:02",
 	.init = lenovo_yoga_tab2_830_1050_init,
+	.exit = lenovo_yoga_tab2_830_1050_exit,
 };
 
 /*
@@ -863,6 +866,18 @@ static int __init lenovo_yoga_tab2_830_1050_init_display(void)
 	return 0;
 }
 
+/*
+ * These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off
+ * gets used as pm_power_off handler. This causes "poweroff" on these tablets
+ * to hang hard. Requiring pressing the powerbutton for 30 seconds *twice*
+ * followed by a normal 3 second press to recover. Avoid this by doing an EFI
+ * poweroff instead.
+ */
+static void lenovo_yoga_tab2_830_1050_power_off(void)
+{
+	efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
+}
+
 static int __init lenovo_yoga_tab2_830_1050_init(void)
 {
 	int ret;
@@ -871,9 +886,15 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)
 	if (ret)
 		return ret;
 
+	pm_power_off = lenovo_yoga_tab2_830_1050_power_off;
 	return 0;
 }
 
+static void lenovo_yoga_tab2_830_1050_exit(void)
+{
+	pm_power_off = NULL; /* Just turn poweroff into halt on module unload */
+}
+
 /* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
 static const char * const nextbook_ares8_accel_mount_matrix[] = {
 	"0", "-1", "0",
-- 
2.35.1


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

* [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support
  2022-02-23 13:31 [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Hans de Goede
                   ` (3 preceding siblings ...)
  2022-02-23 13:31 ` [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang Hans de Goede
@ 2022-02-23 13:31 ` Hans de Goede
  2022-02-23 15:04   ` Andy Shevchenko
  2022-02-23 14:55 ` [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Andy Shevchenko
  5 siblings, 1 reply; 19+ messages in thread
From: Hans de Goede @ 2022-02-23 13:31 UTC (permalink / raw)
  To: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij
  Cc: Hans de Goede, platform-driver-x86, linux-gpio

The ACPI tables for the codec setup on the Lenovo Yoga Tablet 2 830/1050
miss 2 things compared to their Windows (Lenovo Yoga Tablet 2 1051)
counterparts:

1. There is no CLKE ACPI method to enable output of the 32KHz PMU clock on
   pin 6 of the SUS GPIO controller

2. The GPIOs used by the codec are not listed in the fwnode for the codec

Add pinctrl code to set the SUS6 pin mux manually and a gpio-lookup table
for the GPIOs to work around both issues.

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

diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
index c3d2b30dbe26..f446be72e539 100644
--- a/drivers/platform/x86/x86-android-tablets.c
+++ b/drivers/platform/x86/x86-android-tablets.c
@@ -23,12 +23,15 @@
 #include <linux/irqdomain.h>
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/pinctrl/machine.h>
 #include <linux/platform_data/lp855x.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/power/bq24190_charger.h>
 #include <linux/rmi.h>
 #include <linux/serdev.h>
+#include <linux/spi/spi.h>
 #include <linux/string.h>
 /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
 #include "../../gpio/gpiolib.h"
@@ -801,8 +804,22 @@ static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_int3496_gpios = {
 	},
 };
 
+#define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00"
+
+static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_codec_gpios = {
+	.dev_id = LENOVO_YOGA_TAB2_830_1050_CODEC_NAME,
+	.table = {
+		GPIO_LOOKUP("gpio_crystalcove", 3, "reset", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("INT33FC:01", 23, "wlf,ldoena", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("arizona", 2, "wlf,spkvdd-ena", GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP("arizona", 4, "wlf,micd-pol", GPIO_ACTIVE_LOW),
+		{ }
+	},
+};
+
 static struct gpiod_lookup_table * const lenovo_yoga_tab2_830_1050_gpios[] = {
 	&lenovo_yoga_tab2_830_1050_int3496_gpios,
+	&lenovo_yoga_tab2_830_1050_codec_gpios,
 	NULL
 };
 
@@ -866,6 +883,49 @@ static int __init lenovo_yoga_tab2_830_1050_init_display(void)
 	return 0;
 }
 
+/* SUS (INT33FC:02) pin 6 needs to be configured as pmu_clk for the audio codec */
+static const struct pinctrl_map lenovo_yoga_tab2_830_1050_codec_pinctrl_map =
+	PIN_MAP_MUX_GROUP(LENOVO_YOGA_TAB2_830_1050_CODEC_NAME, "codec_32khz_clk",
+			  "INT33FC:02", "pmu_clk2_grp", "pmu_clk");
+
+static struct pinctrl *lenovo_yoga_tab2_830_1050_codec_pinctrl;
+
+static int __init lenovo_yoga_tab2_830_1050_init_codec(void)
+{
+	struct device *codec_dev;
+	struct pinctrl *pinctrl;
+	int ret;
+
+	codec_dev = bus_find_device_by_name(&spi_bus_type, NULL,
+					    LENOVO_YOGA_TAB2_830_1050_CODEC_NAME);
+	if (!codec_dev) {
+		pr_err("error cannot find %s device\n", LENOVO_YOGA_TAB2_830_1050_CODEC_NAME);
+		return -ENODEV;
+	}
+
+	ret = pinctrl_register_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map, 1);
+	if (ret)
+		goto err_put_device;
+
+	pinctrl = pinctrl_get_select(codec_dev, "codec_32khz_clk");
+	if (IS_ERR(pinctrl)) {
+		ret = dev_err_probe(codec_dev, PTR_ERR(pinctrl), "selecting codec_32khz_clk\n");
+		goto err_unregister_mappings;
+	}
+
+	/* We're done with the codec_dev now */
+	put_device(codec_dev);
+
+	lenovo_yoga_tab2_830_1050_codec_pinctrl = pinctrl;
+	return 0;
+
+err_unregister_mappings:
+	pinctrl_unregister_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map);
+err_put_device:
+	put_device(codec_dev);
+	return ret;
+}
+
 /*
  * These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off
  * gets used as pm_power_off handler. This causes "poweroff" on these tablets
@@ -886,6 +946,10 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)
 	if (ret)
 		return ret;
 
+	ret = lenovo_yoga_tab2_830_1050_init_codec();
+	if (ret)
+		return ret;
+
 	pm_power_off = lenovo_yoga_tab2_830_1050_power_off;
 	return 0;
 }
@@ -893,6 +957,11 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)
 static void lenovo_yoga_tab2_830_1050_exit(void)
 {
 	pm_power_off = NULL; /* Just turn poweroff into halt on module unload */
+
+	if (lenovo_yoga_tab2_830_1050_codec_pinctrl) {
+		pinctrl_put(lenovo_yoga_tab2_830_1050_codec_pinctrl);
+		pinctrl_unregister_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map);
+	}
 }
 
 /* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
-- 
2.35.1


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

* Re: [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk
  2022-02-23 13:31 ` [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk Hans de Goede
@ 2022-02-23 14:54   ` Andy Shevchenko
  2022-02-23 15:27     ` Andy Shevchenko
  0 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-23 14:54 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Wed, Feb 23, 2022 at 02:31:49PM +0100, Hans de Goede wrote:
> On the Lenovo Yoga Tablet 2 830 / 1050 / 1051 models the 32KHz PMU clk,
> which can be muxed externally to SUS pin 5 and/or 6 is used as a clock
> for the audio codec.
> 
> On the 830 and 1050 models, with ship with Android as factory OS the
> pin-muxing for this is not setup by the BIOS.
> 
> Add a pinconf group + function for the pmu_clk on SUS pin 5 and 6 to
> allow setting the pinmux up from within the x86-android-tablets
> platform code.

With nit-pick addressed,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/pinctrl/intel/pinctrl-baytrail.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c
> index 7ae71152b480..fec888c1cd05 100644
> --- a/drivers/pinctrl/intel/pinctrl-baytrail.c
> +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c
> @@ -444,6 +444,9 @@ static const unsigned int byt_sus_pcu_spi_pins[] = { 21 };
>  static const unsigned int byt_sus_pcu_spi_mode_values[] = { 0 };
>  static const unsigned int byt_sus_pcu_spi_gpio_mode_values[] = { 1 };
>  
> +static const unsigned int byt_sus_pmu_clk1_pins[] = { 5 };
> +static const unsigned int byt_sus_pmu_clk2_pins[] = { 6 };
> +
>  static const struct intel_pingroup byt_sus_groups[] = {
>  	PIN_GROUP("usb_oc_grp", byt_sus_usb_over_current_pins, byt_sus_usb_over_current_mode_values),
>  	PIN_GROUP("usb_ulpi_grp", byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_mode_values),
> @@ -451,20 +454,26 @@ static const struct intel_pingroup byt_sus_groups[] = {
>  	PIN_GROUP("usb_oc_grp_gpio", byt_sus_usb_over_current_pins, byt_sus_usb_over_current_gpio_mode_values),
>  	PIN_GROUP("usb_ulpi_grp_gpio", byt_sus_usb_ulpi_pins, byt_sus_usb_ulpi_gpio_mode_values),
>  	PIN_GROUP("pcu_spi_grp_gpio", byt_sus_pcu_spi_pins, byt_sus_pcu_spi_gpio_mode_values),
> +	PIN_GROUP("pmu_clk1_grp", byt_sus_pmu_clk1_pins, 1),
> +	PIN_GROUP("pmu_clk2_grp", byt_sus_pmu_clk2_pins, 1),
>  };
>  
>  static const char * const byt_sus_usb_groups[] = {
>  	"usb_oc_grp", "usb_ulpi_grp",
>  };
>  static const char * const byt_sus_spi_groups[] = { "pcu_spi_grp" };
> +static const char * const byt_sus_pmu_clk_groups[] = {
> +	"pmu_clk1_grp", "pmu_clk2_grp" };

}; on new line.

>  static const char * const byt_sus_gpio_groups[] = {
>  	"usb_oc_grp_gpio", "usb_ulpi_grp_gpio", "pcu_spi_grp_gpio",
> +	"pmu_clk1_grp", "pmu_clk2_grp",
>  };
>  
>  static const struct intel_function byt_sus_functions[] = {
>  	FUNCTION("usb", byt_sus_usb_groups),
>  	FUNCTION("spi", byt_sus_spi_groups),
>  	FUNCTION("gpio", byt_sus_gpio_groups),
> +	FUNCTION("pmu_clk", byt_sus_pmu_clk_groups),
>  };
>  
>  static const struct intel_community byt_sus_communities[] = {
> -- 
> 2.35.1
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support
  2022-02-23 13:31 [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Hans de Goede
                   ` (4 preceding siblings ...)
  2022-02-23 13:31 ` [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support Hans de Goede
@ 2022-02-23 14:55 ` Andy Shevchenko
  2022-02-24 16:43   ` Hans de Goede
  5 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-23 14:55 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Wed, Feb 23, 2022 at 02:31:48PM +0100, Hans de Goede wrote:
> Hi All,
> 
> This series consists of 2 parts:
> 
> Patch 1   : pinctrl: baytrail: Add pinconf group + function for the pmu_clk
> Patch 2-5 : platform/x86: x86-android-tablets: Add Lenovo Yoga Tab2 support
> 
> Patch 5 has a runtime dependency on patch 1, but this is only  runtime and
> there are some other patches in flight to other subsystems which are also
> needed for the Lenovo Yoga Tab2 support.
> 
> As such I believe that patch 1 can be merged independently through the
> pinctrl-intel tree and then I'll merge patches 2-5 through the pdx86 tree.
> 
> The only reason for sending this out as a series is because patch 5
> uses the new pmu_clk pinconf added by patch 1.

You may route via PDx86 and provide an IB to me, thanks!

> Regards,
> 
> Hans
> 
> 
> Hans de Goede (5):
>   pinctrl: baytrail: Add pinconf group + function for the pmu_clk
>   platform/x86: x86-android-tablets: Fix EBUSY error when requesting
>     IOAPIC IRQs
>   platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050
>     data
>   platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2
>     830/1050 poweroff hang
>   platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound
>     support
> 
>  drivers/pinctrl/intel/pinctrl-baytrail.c   |   9 +
>  drivers/platform/x86/x86-android-tablets.c | 280 +++++++++++++++++++++
>  2 files changed, 289 insertions(+)
> 
> -- 
> 2.35.1
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
  2022-02-23 13:31 ` [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs Hans de Goede
@ 2022-02-23 14:56   ` Andy Shevchenko
  2022-02-23 15:16     ` Hans de Goede
  0 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-23 14:56 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Wed, Feb 23, 2022 at 02:31:50PM +0100, Hans de Goede wrote:
> Sometimes IRQs used by GPIOs in direct-IRQ mode are already registered
> because they are used as ACPI "Interrupt () {}" resource for one of the
> many bogus I2C devices present in the broken DSDTs of Android x86 tablets.
> 
> This is an issue if the existing (bogus) ACPI resource uses different
> trigger settings then what is being requested, leading to an -EBUSY
> error return of acpi_register_gsi().
> 
> Fix this by calling acpi_unregister_gsi() first, so that
> the acpi_register_gsi() is allowed to change the trigger settings.
> 
> In cases where the GSI has not been registered yet
> the acpi_unregister_gsi() is a no-op.

...

>  	case X86_ACPI_IRQ_TYPE_APIC:
> +		/*
> +		 * The DSDT may already reference the GSI in a device skipped by
> +		 * acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI
> +		 * to avoid EBUSY errors in this case.
> +		 */
> +		acpi_unregister_gsi(data->index);

Perhaps a warning (or at least debug) message?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang
  2022-02-23 13:31 ` [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang Hans de Goede
@ 2022-02-23 14:58   ` Andy Shevchenko
  2022-02-24 16:57     ` Hans de Goede
  0 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-23 14:58 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Wed, Feb 23, 2022 at 02:31:52PM +0100, Hans de Goede wrote:
> These tablets' DSDT does not set acpi_gbl_reduced_hardware, so
> acpi_power_off gets used as pm_power_off handler. This causes "poweroff"
> on these tablets to hang hard. Requiring pressing the powerbutton for
> 30 seconds *twice* followed by a normal 3 second press to recover.
> 
> Avoid this by overriding the global pm_power_off handler to do
> an EFI poweroff instead.

Oh, you eventually found the root cause (reduced HW bit)?
Perhaps we need to enforce it based on a quirk?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support
  2022-02-23 13:31 ` [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support Hans de Goede
@ 2022-02-23 15:04   ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-23 15:04 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Wed, Feb 23, 2022 at 02:31:53PM +0100, Hans de Goede wrote:
> The ACPI tables for the codec setup on the Lenovo Yoga Tablet 2 830/1050
> miss 2 things compared to their Windows (Lenovo Yoga Tablet 2 1051)
> counterparts:
> 
> 1. There is no CLKE ACPI method to enable output of the 32KHz PMU clock on
>    pin 6 of the SUS GPIO controller
> 
> 2. The GPIOs used by the codec are not listed in the fwnode for the codec
> 
> Add pinctrl code to set the SUS6 pin mux manually and a gpio-lookup table
> for the GPIOs to work around both issues.

With or without an addressed nit-pick,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/x86-android-tablets.c | 69 ++++++++++++++++++++++
>  1 file changed, 69 insertions(+)
> 
> diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
> index c3d2b30dbe26..f446be72e539 100644
> --- a/drivers/platform/x86/x86-android-tablets.c
> +++ b/drivers/platform/x86/x86-android-tablets.c
> @@ -23,12 +23,15 @@
>  #include <linux/irqdomain.h>
>  #include <linux/module.h>
>  #include <linux/mod_devicetable.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/pinctrl/machine.h>
>  #include <linux/platform_data/lp855x.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm.h>
>  #include <linux/power/bq24190_charger.h>
>  #include <linux/rmi.h>
>  #include <linux/serdev.h>
> +#include <linux/spi/spi.h>
>  #include <linux/string.h>
>  /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
>  #include "../../gpio/gpiolib.h"
> @@ -801,8 +804,22 @@ static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_int3496_gpios = {
>  	},
>  };
>  
> +#define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00"
> +
> +static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_codec_gpios = {
> +	.dev_id = LENOVO_YOGA_TAB2_830_1050_CODEC_NAME,
> +	.table = {
> +		GPIO_LOOKUP("gpio_crystalcove", 3, "reset", GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP("INT33FC:01", 23, "wlf,ldoena", GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP("arizona", 2, "wlf,spkvdd-ena", GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP("arizona", 4, "wlf,micd-pol", GPIO_ACTIVE_LOW),
> +		{ }
> +	},
> +};
> +
>  static struct gpiod_lookup_table * const lenovo_yoga_tab2_830_1050_gpios[] = {
>  	&lenovo_yoga_tab2_830_1050_int3496_gpios,
> +	&lenovo_yoga_tab2_830_1050_codec_gpios,
>  	NULL
>  };
>  
> @@ -866,6 +883,49 @@ static int __init lenovo_yoga_tab2_830_1050_init_display(void)
>  	return 0;
>  }
>  
> +/* SUS (INT33FC:02) pin 6 needs to be configured as pmu_clk for the audio codec */
> +static const struct pinctrl_map lenovo_yoga_tab2_830_1050_codec_pinctrl_map =

> +	PIN_MAP_MUX_GROUP(LENOVO_YOGA_TAB2_830_1050_CODEC_NAME, "codec_32khz_clk",
> +			  "INT33FC:02", "pmu_clk2_grp", "pmu_clk");

To avoid typos in messages you may define "codec_32khz_clk" and reuse in all (three?)
cases.

> +static struct pinctrl *lenovo_yoga_tab2_830_1050_codec_pinctrl;
> +
> +static int __init lenovo_yoga_tab2_830_1050_init_codec(void)
> +{
> +	struct device *codec_dev;
> +	struct pinctrl *pinctrl;
> +	int ret;
> +
> +	codec_dev = bus_find_device_by_name(&spi_bus_type, NULL,
> +					    LENOVO_YOGA_TAB2_830_1050_CODEC_NAME);
> +	if (!codec_dev) {
> +		pr_err("error cannot find %s device\n", LENOVO_YOGA_TAB2_830_1050_CODEC_NAME);
> +		return -ENODEV;
> +	}
> +
> +	ret = pinctrl_register_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map, 1);
> +	if (ret)
> +		goto err_put_device;
> +
> +	pinctrl = pinctrl_get_select(codec_dev, "codec_32khz_clk");
> +	if (IS_ERR(pinctrl)) {
> +		ret = dev_err_probe(codec_dev, PTR_ERR(pinctrl), "selecting codec_32khz_clk\n");
> +		goto err_unregister_mappings;
> +	}
> +
> +	/* We're done with the codec_dev now */
> +	put_device(codec_dev);
> +
> +	lenovo_yoga_tab2_830_1050_codec_pinctrl = pinctrl;
> +	return 0;
> +
> +err_unregister_mappings:
> +	pinctrl_unregister_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map);
> +err_put_device:
> +	put_device(codec_dev);
> +	return ret;
> +}
> +
>  /*
>   * These tablet's DSDT does not set acpi_gbl_reduced_hardware, so acpi_power_off
>   * gets used as pm_power_off handler. This causes "poweroff" on these tablets
> @@ -886,6 +946,10 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)
>  	if (ret)
>  		return ret;
>  
> +	ret = lenovo_yoga_tab2_830_1050_init_codec();
> +	if (ret)
> +		return ret;
> +
>  	pm_power_off = lenovo_yoga_tab2_830_1050_power_off;
>  	return 0;
>  }
> @@ -893,6 +957,11 @@ static int __init lenovo_yoga_tab2_830_1050_init(void)
>  static void lenovo_yoga_tab2_830_1050_exit(void)
>  {
>  	pm_power_off = NULL; /* Just turn poweroff into halt on module unload */
> +
> +	if (lenovo_yoga_tab2_830_1050_codec_pinctrl) {
> +		pinctrl_put(lenovo_yoga_tab2_830_1050_codec_pinctrl);
> +		pinctrl_unregister_mappings(&lenovo_yoga_tab2_830_1050_codec_pinctrl_map);
> +	}
>  }
>  
>  /* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
> -- 
> 2.35.1
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 3/5] platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data
  2022-02-23 13:31 ` [PATCH 3/5] platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data Hans de Goede
@ 2022-02-23 15:04   ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-23 15:04 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Wed, Feb 23, 2022 at 02:31:51PM +0100, Hans de Goede wrote:
> The Lenovo Yoga Tablet 2 series comes in 4 versions: 830F, 830L, 1050F and
> 1050L. The F postfix indicates a wifi only version and the L postfix
> indicates a LTE version. The 830 models are 8" and the 1050 models are 10".
> 
> Despite there being 8" and 10" versions all models use the same mainboard,
> with an identical BIOS and thus identical DMI strings, so support for all
> 4 models is added through a single DMI table entry.
> 
> As all devices dealt with in the x86-android-tablets modules, these are
> x86 ACPI tablets which ships with Android x86 as factory OS.
> The mainboard's DSDT contain 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 devices which are
> actually present on this tablet by adding the necessary device info to
> the x86-android-tablets module.
> 
> This has been tested on a 830F and a 1050L tablet.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/platform/x86/x86-android-tablets.c | 184 +++++++++++++++++++++
>  1 file changed, 184 insertions(+)
> 
> diff --git a/drivers/platform/x86/x86-android-tablets.c b/drivers/platform/x86/x86-android-tablets.c
> index 61e526e048c3..89972723f546 100644
> --- a/drivers/platform/x86/x86-android-tablets.c
> +++ b/drivers/platform/x86/x86-android-tablets.c
> @@ -22,8 +22,10 @@
>  #include <linux/irqdomain.h>
>  #include <linux/module.h>
>  #include <linux/mod_devicetable.h>
> +#include <linux/platform_data/lp855x.h>
>  #include <linux/platform_device.h>
>  #include <linux/power/bq24190_charger.h>
> +#include <linux/rmi.h>
>  #include <linux/serdev.h>
>  #include <linux/string.h>
>  /* For gpio_get_desc() which is EXPORT_SYMBOL_GPL() */
> @@ -182,6 +184,15 @@ static const char * const tusb1211_chg_det_psy[] = { "tusb1211-charger-detect" }
>  static const char * const bq24190_psy[] = { "bq24190-charger" };
>  static const char * const bq25890_psy[] = { "bq25890-charger" };
>  
> +static const struct property_entry fg_bq24190_supply_props[] = {
> +	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq24190_psy),
> +	{ }
> +};
> +
> +static const struct software_node fg_bq24190_supply_node = {
> +	.properties = fg_bq24190_supply_props,
> +};
> +
>  static const struct property_entry fg_bq25890_supply_props[] = {
>  	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", bq25890_psy),
>  	{ }
> @@ -704,6 +715,165 @@ static const struct x86_dev_info lenovo_yogabook_x9x_info __initconst = {
>  	.i2c_client_count = ARRAY_SIZE(lenovo_yogabook_x9x_i2c_clients),
>  };
>  
> +/* Lenovo Yoga Tablet 2 1050F/L's Android factory img has everything hardcoded */
> +static const struct property_entry lenovo_yoga_tab2_830_1050_bq24190_props[] = {
> +	PROPERTY_ENTRY_STRING_ARRAY("supplied-from", tusb1211_chg_det_psy),
> +	PROPERTY_ENTRY_REF("monitored-battery", &generic_lipo_hv_4v35_battery_node),
> +	PROPERTY_ENTRY_BOOL("omit-battery-class"),
> +	PROPERTY_ENTRY_BOOL("disable-reset"),
> +	{ }
> +};
> +
> +static const struct software_node lenovo_yoga_tab2_830_1050_bq24190_node = {
> +	.properties = lenovo_yoga_tab2_830_1050_bq24190_props,
> +};
> +
> +/* This gets filled by lenovo_yoga_tab2_830_1050_init() */
> +static struct rmi_device_platform_data lenovo_yoga_tab2_830_1050_rmi_pdata = { };
> +
> +static struct lp855x_platform_data lenovo_yoga_tab2_830_1050_lp8557_pdata = {
> +	.device_control = 0x86,
> +	.initial_brightness = 128,
> +};
> +
> +static const struct x86_i2c_client_info lenovo_yoga_tab2_830_1050_i2c_clients[] __initconst = {
> +	{
> +		/* bq24292i battery charger */
> +		.board_info = {
> +			.type = "bq24190",
> +			.addr = 0x6b,
> +			.dev_name = "bq24292i",
> +			.swnode = &lenovo_yoga_tab2_830_1050_bq24190_node,
> +			.platform_data = &bq24190_pdata,
> +		},
> +		.adapter_path = "\\_SB_.I2C1",
> +		.irq_data = {
> +			.type = X86_ACPI_IRQ_TYPE_GPIOINT,
> +			.chip = "INT33FC:02",
> +			.index = 2,
> +			.trigger = ACPI_EDGE_SENSITIVE,
> +			.polarity = ACPI_ACTIVE_HIGH,
> +		},
> +	}, {
> +		/* BQ27541 fuel-gauge */
> +		.board_info = {
> +			.type = "bq27541",
> +			.addr = 0x55,
> +			.dev_name = "bq27541",
> +			.swnode = &fg_bq24190_supply_node,
> +		},
> +		.adapter_path = "\\_SB_.I2C1",
> +	}, {
> +		/* Synaptics RMI touchscreen */
> +		.board_info = {
> +			.type = "rmi4_i2c",
> +			.addr = 0x38,
> +			.dev_name = "rmi4_i2c",
> +			.platform_data = &lenovo_yoga_tab2_830_1050_rmi_pdata,
> +		},
> +		.adapter_path = "\\_SB_.I2C6",
> +		.irq_data = {
> +			.type = X86_ACPI_IRQ_TYPE_APIC,
> +			.index = 0x45,
> +			.trigger = ACPI_EDGE_SENSITIVE,
> +			.polarity = ACPI_ACTIVE_HIGH,
> +		},
> +	}, {
> +		/* LP8557 Backlight controller */
> +		.board_info = {
> +			.type = "lp8557",
> +			.addr = 0x2c,
> +			.dev_name = "lp8557",
> +			.platform_data = &lenovo_yoga_tab2_830_1050_lp8557_pdata,
> +		},
> +		.adapter_path = "\\_SB_.I2C3",
> +	},
> +};
> +
> +static struct gpiod_lookup_table lenovo_yoga_tab2_830_1050_int3496_gpios = {
> +	.dev_id = "intel-int3496",
> +	.table = {
> +		GPIO_LOOKUP("INT33FC:02", 1, "mux", GPIO_ACTIVE_LOW),
> +		GPIO_LOOKUP("INT33FC:02", 24, "id", GPIO_ACTIVE_HIGH),
> +		{ }
> +	},
> +};
> +
> +static struct gpiod_lookup_table * const lenovo_yoga_tab2_830_1050_gpios[] = {
> +	&lenovo_yoga_tab2_830_1050_int3496_gpios,
> +	NULL
> +};
> +
> +static int __init lenovo_yoga_tab2_830_1050_init(void);
> +static void lenovo_yoga_tab2_830_1050_exit(void);
> +
> +static struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initdata = {
> +	.i2c_client_info = lenovo_yoga_tab2_830_1050_i2c_clients,
> +	/* i2c_client_count gets set by lenovo_yoga_tab2_830_1050_init() */
> +	.pdev_info = int3496_pdevs,
> +	.pdev_count = ARRAY_SIZE(int3496_pdevs),
> +	.gpiod_lookup_tables = lenovo_yoga_tab2_830_1050_gpios,
> +	.bat_swnode = &generic_lipo_hv_4v35_battery_node,
> +	.modules = bq24190_modules,
> +	.invalid_aei_gpiochip = "INT33FC:02",
> +	.init = lenovo_yoga_tab2_830_1050_init,
> +};
> +
> +/*
> + * The Lenovo Yoga Tablet 2 830 and 1050 (8" vs 10") versions use the same
> + * mainboard, but they need some different treatment related to the display:
> + * 1. The 830 uses a portrait LCD panel with a landscape touchscreen, requiring
> + *    the touchscreen driver to adjust the touch-coords to match the LCD.
> + * 2. Both use an TI LP8557 LED backlight controller. On the 1050 the LP8557's
> + *    PWM input is connected to the PMIC's PWM output and everything works fine
> + *    with the defaults programmed into the LP8557 by the BIOS.
> + *    But on the 830 the LP8557's PWM input is connected to a PWM output coming
> + *    from the LCD panel's controller. The Android code has a hack in the i915
> + *    driver to write the non-standard DSI reg 0x9f with the desired backlight
> + *    level to set the duty-cycle of the LCD's PWM output.
> + *
> + *    To avoid having to have a similar hack in the mainline kernel the LP8557
> + *    entry in lenovo_yoga_tab2_830_1050_i2c_clients instead just programs the
> + *    LP8557 to directly set the level, ignoring the PWM input. This means that
> + *    the LP8557 i2c_client should only be instantiated on the 830.
> + */
> +static int __init lenovo_yoga_tab2_830_1050_init_display(void)
> +{
> +	struct gpio_desc *gpiod;
> +	int ret;
> +
> +	/* Use PMIC GPIO 10 bootstrap pin to differentiate 830 vs 1050 */
> +	ret = x86_android_tablet_get_gpiod("gpio_crystalcove", 10, &gpiod);
> +	if (ret)
> +		return ret;
> +
> +	ret = gpiod_get_value_cansleep(gpiod);
> +	if (ret) {
> +		pr_info("detected Lenovo Yoga Tablet 2 1050F/L\n");
> +		lenovo_yoga_tab2_830_1050_info.i2c_client_count =
> +			ARRAY_SIZE(lenovo_yoga_tab2_830_1050_i2c_clients) - 1;
> +	} else {
> +		pr_info("detected Lenovo Yoga Tablet 2 830F/L\n");
> +		lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.swap_axes = true;
> +		lenovo_yoga_tab2_830_1050_rmi_pdata.sensor_pdata.axis_align.flip_y = true;
> +		lenovo_yoga_tab2_830_1050_info.i2c_client_count =
> +			ARRAY_SIZE(lenovo_yoga_tab2_830_1050_i2c_clients);
> +	}
> +
> +	return 0;
> +}
> +
> +static int __init lenovo_yoga_tab2_830_1050_init(void)
> +{
> +	int ret;
> +
> +	ret = lenovo_yoga_tab2_830_1050_init_display();
> +	if (ret)
> +		return ret;
> +
> +	return 0;
> +}
> +
>  /* Nextbook Ares 8 tablets have an Android factory img with everything hardcoded */
>  static const char * const nextbook_ares8_accel_mount_matrix[] = {
>  	"0", "-1", "0",
> @@ -948,6 +1118,20 @@ static const struct dmi_system_id x86_android_tablet_ids[] __initconst = {
>  		},
>  		.driver_data = (void *)&lenovo_yogabook_x9x_info,
>  	},
> +	{
> +		/*
> +		 * Lenovo Yoga Tablet 2 830F/L or 1050F/L (The 8" and 10"
> +		 * Lenovo Yoga Tablet 2 use the same mainboard)
> +		 */
> +		.matches = {
> +			DMI_MATCH(DMI_SYS_VENDOR, "Intel Corp."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "VALLEYVIEW C0 PLATFORM"),
> +			DMI_MATCH(DMI_BOARD_NAME, "BYT-T FFD8"),
> +			/* Partial match on beginning of BIOS version */
> +			DMI_MATCH(DMI_BIOS_VERSION, "BLADE_21"),
> +		},
> +		.driver_data = (void *)&lenovo_yoga_tab2_830_1050_info,
> +	},
>  	{
>  		/* Nextbook Ares 8 */
>  		.matches = {
> -- 
> 2.35.1
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
  2022-02-23 14:56   ` Andy Shevchenko
@ 2022-02-23 15:16     ` Hans de Goede
  2022-02-23 15:38       ` Andy Shevchenko
  0 siblings, 1 reply; 19+ messages in thread
From: Hans de Goede @ 2022-02-23 15:16 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

Hi,

On 2/23/22 15:56, Andy Shevchenko wrote:
> On Wed, Feb 23, 2022 at 02:31:50PM +0100, Hans de Goede wrote:
>> Sometimes IRQs used by GPIOs in direct-IRQ mode are already registered
>> because they are used as ACPI "Interrupt () {}" resource for one of the
>> many bogus I2C devices present in the broken DSDTs of Android x86 tablets.
>>
>> This is an issue if the existing (bogus) ACPI resource uses different
>> trigger settings then what is being requested, leading to an -EBUSY
>> error return of acpi_register_gsi().
>>
>> Fix this by calling acpi_unregister_gsi() first, so that
>> the acpi_register_gsi() is allowed to change the trigger settings.
>>
>> In cases where the GSI has not been registered yet
>> the acpi_unregister_gsi() is a no-op.
> 
> ...
> 
>>  	case X86_ACPI_IRQ_TYPE_APIC:
>> +		/*
>> +		 * The DSDT may already reference the GSI in a device skipped by
>> +		 * acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI
>> +		 * to avoid EBUSY errors in this case.
>> +		 */
>> +		acpi_unregister_gsi(data->index);
> 
> Perhaps a warning (or at least debug) message?

The function returns void, so we cannot check if it did anything or not.

Regards,

Hans


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

* Re: [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk
  2022-02-23 14:54   ` Andy Shevchenko
@ 2022-02-23 15:27     ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-23 15:27 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Wed, Feb 23, 2022 at 04:54:31PM +0200, Andy Shevchenko wrote:
> On Wed, Feb 23, 2022 at 02:31:49PM +0100, Hans de Goede wrote:

...

> >  static const char * const byt_sus_usb_groups[] = {
> >  	"usb_oc_grp", "usb_ulpi_grp",
> >  };
> >  static const char * const byt_sus_spi_groups[] = { "pcu_spi_grp" };
> > +static const char * const byt_sus_pmu_clk_groups[] = {
> > +	"pmu_clk1_grp", "pmu_clk2_grp" };
> 
> }; on new line.

And add a comma in that case.
See how USB is written above.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
  2022-02-23 15:16     ` Hans de Goede
@ 2022-02-23 15:38       ` Andy Shevchenko
  2022-02-24 16:49         ` Hans de Goede
  0 siblings, 1 reply; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-23 15:38 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Wed, Feb 23, 2022 at 04:16:42PM +0100, Hans de Goede wrote:
> On 2/23/22 15:56, Andy Shevchenko wrote:
> > On Wed, Feb 23, 2022 at 02:31:50PM +0100, Hans de Goede wrote:

...

> >>  	case X86_ACPI_IRQ_TYPE_APIC:
> >> +		/*
> >> +		 * The DSDT may already reference the GSI in a device skipped by
> >> +		 * acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI
> >> +		 * to avoid EBUSY errors in this case.
> >> +		 */
> >> +		acpi_unregister_gsi(data->index);
> > 
> > Perhaps a warning (or at least debug) message?
> 
> The function returns void, so we cannot check if it did anything or not.

Another approach may be to try to register GSI and if fail, try unregister
and register again?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support
  2022-02-23 14:55 ` [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Andy Shevchenko
@ 2022-02-24 16:43   ` Hans de Goede
  0 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2022-02-24 16:43 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

Hi,

On 2/23/22 15:55, Andy Shevchenko wrote:
> On Wed, Feb 23, 2022 at 02:31:48PM +0100, Hans de Goede wrote:
>> Hi All,
>>
>> This series consists of 2 parts:
>>
>> Patch 1   : pinctrl: baytrail: Add pinconf group + function for the pmu_clk
>> Patch 2-5 : platform/x86: x86-android-tablets: Add Lenovo Yoga Tab2 support
>>
>> Patch 5 has a runtime dependency on patch 1, but this is only  runtime and
>> there are some other patches in flight to other subsystems which are also
>> needed for the Lenovo Yoga Tab2 support.
>>
>> As such I believe that patch 1 can be merged independently through the
>> pinctrl-intel tree and then I'll merge patches 2-5 through the pdx86 tree.
>>
>> The only reason for sending this out as a series is because patch 5
>> uses the new pmu_clk pinconf added by patch 1.
> 
> You may route via PDx86 and provide an IB to me, thanks!

Ok, I've just created an immutable-branch + signed tag for this,
with your 2 small nitpicks fixed.

I'll send you a pull-req for this right away.

Regards,

Hans


> 
>> Regards,
>>
>> Hans
>>
>>
>> Hans de Goede (5):
>>   pinctrl: baytrail: Add pinconf group + function for the pmu_clk
>>   platform/x86: x86-android-tablets: Fix EBUSY error when requesting
>>     IOAPIC IRQs
>>   platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050
>>     data
>>   platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2
>>     830/1050 poweroff hang
>>   platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound
>>     support
>>
>>  drivers/pinctrl/intel/pinctrl-baytrail.c   |   9 +
>>  drivers/platform/x86/x86-android-tablets.c | 280 +++++++++++++++++++++
>>  2 files changed, 289 insertions(+)
>>
>> -- 
>> 2.35.1
>>
> 


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

* Re: [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs
  2022-02-23 15:38       ` Andy Shevchenko
@ 2022-02-24 16:49         ` Hans de Goede
  0 siblings, 0 replies; 19+ messages in thread
From: Hans de Goede @ 2022-02-24 16:49 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

Hi,

On 2/23/22 16:38, Andy Shevchenko wrote:
> On Wed, Feb 23, 2022 at 04:16:42PM +0100, Hans de Goede wrote:
>> On 2/23/22 15:56, Andy Shevchenko wrote:
>>> On Wed, Feb 23, 2022 at 02:31:50PM +0100, Hans de Goede wrote:
> 
> ...
> 
>>>>  	case X86_ACPI_IRQ_TYPE_APIC:
>>>> +		/*
>>>> +		 * The DSDT may already reference the GSI in a device skipped by
>>>> +		 * acpi_quirk_skip_i2c_client_enumeration(). Unregister the GSI
>>>> +		 * to avoid EBUSY errors in this case.
>>>> +		 */
>>>> +		acpi_unregister_gsi(data->index);
>>>
>>> Perhaps a warning (or at least debug) message?
>>
>> The function returns void, so we cannot check if it did anything or not.
> 
> Another approach may be to try to register GSI and if fail, try unregister
> and register again?

Since we only run this on boards where it is specifically enabled and it
thus has been tested to be safe I believe that that needlessly complicates
things, so I'm just going to merge this as is.

Regards,

Hans


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

* Re: [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang
  2022-02-23 14:58   ` Andy Shevchenko
@ 2022-02-24 16:57     ` Hans de Goede
  2022-02-25 16:35       ` Andy Shevchenko
  0 siblings, 1 reply; 19+ messages in thread
From: Hans de Goede @ 2022-02-24 16:57 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

Hi,

On 2/23/22 15:58, Andy Shevchenko wrote:
> On Wed, Feb 23, 2022 at 02:31:52PM +0100, Hans de Goede wrote:
>> These tablets' DSDT does not set acpi_gbl_reduced_hardware, so
>> acpi_power_off gets used as pm_power_off handler. This causes "poweroff"
>> on these tablets to hang hard. Requiring pressing the powerbutton for
>> 30 seconds *twice* followed by a normal 3 second press to recover.
>>
>> Avoid this by overriding the global pm_power_off handler to do
>> an EFI poweroff instead.
> 
> Oh, you eventually found the root cause (reduced HW bit)?

I'm not sure, it is possible that not setting the reduced HW bit
is actually correct for this hw, but that does lead to using
acpi_power_off which seems broken on this system.

I've updated the commit message while merging this to reflect
that using acpi_power_off is the problem, rather then not setting
the reduced HW bit.

Also note that the issue of reboot being the same as poweroff once
the system has been rebooted at least once is still unresolved.

Regards,

Hans


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

* Re: [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang
  2022-02-24 16:57     ` Hans de Goede
@ 2022-02-25 16:35       ` Andy Shevchenko
  0 siblings, 0 replies; 19+ messages in thread
From: Andy Shevchenko @ 2022-02-25 16:35 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Mark Gross, Andy Shevchenko, Mika Westerberg, Linus Walleij,
	platform-driver-x86, linux-gpio

On Thu, Feb 24, 2022 at 05:57:11PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 2/23/22 15:58, Andy Shevchenko wrote:
> > On Wed, Feb 23, 2022 at 02:31:52PM +0100, Hans de Goede wrote:
> >> These tablets' DSDT does not set acpi_gbl_reduced_hardware, so
> >> acpi_power_off gets used as pm_power_off handler. This causes "poweroff"
> >> on these tablets to hang hard. Requiring pressing the powerbutton for
> >> 30 seconds *twice* followed by a normal 3 second press to recover.
> >>
> >> Avoid this by overriding the global pm_power_off handler to do
> >> an EFI poweroff instead.
> > 
> > Oh, you eventually found the root cause (reduced HW bit)?
> 
> I'm not sure, it is possible that not setting the reduced HW bit
> is actually correct for this hw, but that does lead to using
> acpi_power_off which seems broken on this system.
> 
> I've updated the commit message while merging this to reflect
> that using acpi_power_off is the problem, rather then not setting
> the reduced HW bit.

Understood. Thanks!

> Also note that the issue of reboot being the same as poweroff once
> the system has been rebooted at least once is still unresolved.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2022-02-25 16:36 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 13:31 [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Hans de Goede
2022-02-23 13:31 ` [PATCH 1/5] pinctrl: baytrail: Add pinconf group + function for the pmu_clk Hans de Goede
2022-02-23 14:54   ` Andy Shevchenko
2022-02-23 15:27     ` Andy Shevchenko
2022-02-23 13:31 ` [PATCH 2/5] platform/x86: x86-android-tablets: Fix EBUSY error when requesting IOAPIC IRQs Hans de Goede
2022-02-23 14:56   ` Andy Shevchenko
2022-02-23 15:16     ` Hans de Goede
2022-02-23 15:38       ` Andy Shevchenko
2022-02-24 16:49         ` Hans de Goede
2022-02-23 13:31 ` [PATCH 3/5] platform/x86: x86-android-tablets: Add Lenovo Yoga Tablet 2 830 / 1050 data Hans de Goede
2022-02-23 15:04   ` Andy Shevchenko
2022-02-23 13:31 ` [PATCH 4/5] platform/x86: x86-android-tablets: Workaround Lenovo Yoga Tablet 2 830/1050 poweroff hang Hans de Goede
2022-02-23 14:58   ` Andy Shevchenko
2022-02-24 16:57     ` Hans de Goede
2022-02-25 16:35       ` Andy Shevchenko
2022-02-23 13:31 ` [PATCH 5/5] platform/x86: x86-android-tablets: Lenovo Yoga Tablet 2 830/1050 sound support Hans de Goede
2022-02-23 15:04   ` Andy Shevchenko
2022-02-23 14:55 ` [PATCH 0/5] pinctrl/baytrail platform/x86: SUS6 mux / Lenovo Yoga Tablet 2 support Andy Shevchenko
2022-02-24 16:43   ` 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.