Skip to contentSkip to conversation

power: supply: axp288_charger: Use alt usb-id extcon on some x86 android tablets

PATCH In review Hans de Goede 1 participant 4 messages Apr 1, 2023 – May 10, 2023

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

cover power: supply: axp288_charger: Use alt usb-id extcon on some x86 android tablets

Hi Sebastian,

This patch used to be part of a patch set with 2 ACPI patches which introduce the acpi_quirk_skip_gpio_event_handlers() which this patch depends on.

Rafael has picked up the 2 ACPI patches and submitted them to Linus as fixes for this cycle:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5adc409340b1fc82bc1175e602d14ac82ac685e3

But this patch was not picked up.

So I'm resubmitting this patch hereby for direct inclusion into your linux-power-supply tree.

Note this relies on commit 5adc409340b1 ("ACPI: x86: Introduce an acpi_quirk_skip_gpio_event_handlers() helper") which is in Linus tree, but only in v6.3-rc3 and later.

Regards,

Hans

Hans de Goede (1):
power: supply: axp288_charger: Use alt usb-id extcon on some x86
android tablets

 drivers/power/supply/axp288_charger.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.1
#1 lore raw

PATCH 1/1 power: supply: axp288_charger: Use alt usb-id extcon on some x86 android tablets

x86 ACPI boards which ship with only Android as their factory image may have pretty broken ACPI tables. This includes broken _AEI ACPI GPIO event handlers, which are normally used to listen to the micro-USB ID pin and:

1. Switch the USB-mux to the host / device USB controllers
2. Disable Vbus path before enabling the 5V boost (AXP reg 0x30 bit 7)
3. Turn 5V Vboost on / off

On non broken systems where this is not done through an ACPI GPIO event handler, there is an ACPI INT3496 device describing the involved GPIOs which are handled by the extcon-intel-int3496 driver; and axp288-charger.ko listens to this extcon-device and disables the Vbus path when necessary.

On x86 Android boards, with broken ACPI GPIO event handlers, these are disabled by acpi_quirk_skip_gpio_event_handlers() and an intel-int3496 extcon device is manually instantiated by x86-android-tablets.ko .

Add support to the axp288-charger code for this setup, so that it properly disables the Vbus path when necessary. Note this uses acpi_quirk_skip_gpio_event_handlers() to identify these systems, to avoid the need to add a separate DMI match table for this.

---
 drivers/power/supply/axp288_charger.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/power/supply/axp288_charger.c +13 -2
index 15219ed43ce9..b5903193e2f9 100644
@@ -836,6 +836,7 @@ static int axp288_charger_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
 	struct power_supply_config charger_cfg = {};
+	const char *extcon_name = NULL;
 	unsigned int val;
 
 	/*
@@ -872,8 +873,18 @@ static int axp288_charger_probe(struct platform_device *pdev)
 		return PTR_ERR(info->cable.edev);
 	}
 
-	if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1)) {
-		info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_NAME);
+	/*
+	 * On devices with broken ACPI GPIO event handlers there also is no ACPI
+	 * "INT3496" (USB_HOST_EXTCON_HID) device. x86-android-tablets.ko
+	 * instantiates an "intel-int3496" extcon on these devs as a workaround.
+	 */
+	if (acpi_quirk_skip_gpio_event_handlers())
+		extcon_name = "intel-int3496";
+	else if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1))
+		extcon_name = USB_HOST_EXTCON_NAME;
+
+	if (extcon_name) {
+		info->otg.cable = extcon_get_extcon_dev(extcon_name);
 		if (IS_ERR(info->otg.cable)) {
 			dev_err_probe(dev, PTR_ERR(info->otg.cable),
 				      "extcon_get_extcon_dev(%s) failed\n",
Signature · 1 line
2.39.1
#2 lore raw
In reply to Hans de Goede

Hi Sebastian,

Quoted 10 lines · Hans de Goede

Hi Sebastian,

This patch used to be part of a patch set with 2 ACPI patches which introduce the acpi_quirk_skip_gpio_event_handlers() which this patch depends on.

Rafael has picked up the 2 ACPI patches and submitted them to Linus as fixes for this cycle:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5adc409340b1fc82bc1175e602d14ac82ac685e3

Quoted 8 lines

But this patch was not picked up.

So I'm resubmitting this patch hereby for direct inclusion into your linux-power-supply tree.

Note this relies on commit 5adc409340b1 ("ACPI: x86: Introduce an acpi_quirk_skip_gpio_event_handlers() helper") which is in Linus tree, but only in v6.3-rc3 and later.

Thank you for merging a bunch of my patches yesterday.

It looks like this one has fallen through the cracks though ?

Ideally this would go to 6.4 as a fix (as mentioned above the patch it depends on has landed in v6.3-rc3).

Regards,

Hans

Quoted 7 lines

Hans de Goede (1):
power: supply: axp288_charger: Use alt usb-id extcon on some x86
android tablets

 drivers/power/supply/axp288_charger.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
#3 lore raw

Hi,

Quoted 22 lines · Hans de Goede

Hi Sebastian,

Quoted 10 lines · Hans de Goede

Hi Sebastian,

This patch used to be part of a patch set with 2 ACPI patches which introduce the acpi_quirk_skip_gpio_event_handlers() which this patch depends on.

Rafael has picked up the 2 ACPI patches and submitted them to Linus as fixes for this cycle:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5adc409340b1fc82bc1175e602d14ac82ac685e3

Quoted 8 lines

But this patch was not picked up.

So I'm resubmitting this patch hereby for direct inclusion into your linux-power-supply tree.

Note this relies on commit 5adc409340b1 ("ACPI: x86: Introduce an acpi_quirk_skip_gpio_event_handlers() helper") which is in Linus tree, but only in v6.3-rc3 and later.

Quoted 6 lines

Thank you for merging a bunch of my patches yesterday.

It looks like this one has fallen through the cracks though ?

Ideally this would go to 6.4 as a fix (as mentioned above the patch it depends on has landed in v6.3-rc3).

Never mind I see that this patch has already found its way upstream. Sorry for the noise.

Regards,

Hans

Quoted 8 lines
Quoted 7 lines

Hans de Goede (1):
power: supply: axp288_charger: Use alt usb-id extcon on some x86
android tablets

 drivers/power/supply/axp288_charger.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)