linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Mark Gross <markgross@kernel.org>,
	Andy Shevchenko <andy@infradead.org>,
	Wolfram Sang <wsa@the-dreams.de>,
	Sebastian Reichel <sre@kernel.org>,
	MyungJoo Ham <myungjoo.ham@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Ard Biesheuvel <ardb@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>, Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, Yauhen Kharuzhy <jekhor@gmail.com>,
	Tsuchiya Yuto <kitakar@gmail.com>,
	platform-driver-x86@vger.kernel.org, linux-i2c@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-efi@vger.kernel.org
Subject: [RFC 1/5] ACPI / x86: Add 3 devices on the Xiaomi Mi Pad 2 to the always_present list
Date: Sun, 31 Oct 2021 17:24:24 +0100	[thread overview]
Message-ID: <20211031162428.22368-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20211031162428.22368-1-hdegoede@redhat.com>

The Xiaomi Mi Pad 2 ships in both Windows and Android variants and the BIOS
detects the OS by looking at the EFI executable the efibootmgr entry points
to. If this executable is not the original Android bootloader (signed with
Xiaomi's own keys) it detects the OS as Windows and sets the OSID variable
used in the DSDT to "1".

This causes the following problems when running Linux:

1. Like many other CHT based tablets the Xiaomi Mi Pad 2 does not have
   a properly working ACPI battery interface instead we need to load
   a native driver for the fuel-gauge, but the TXN27520 ACPI device for
   the fuel-gauge gets hidden when OSID == "1".

2. There are backlit LEDs behind the capacitive menu, home, back buttons
   below the screen which are controlled by the second PWM controller of
   the CHT SoC, this gets hidden when OSID == "1".

3. There is an I2C attached KTD2026 RGB LED controller for the notification
   LED, this gets hidden when OSID != "4".

Add always_present_ids table entries for these devices so that they are
always seen as present independent of the OSID value.

Note the TXN27520 ACPI device does not have a UID set, so add support for
matching devices with no UID.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/acpi/x86/utils.c | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/x86/utils.c b/drivers/acpi/x86/utils.c
index f22f23933063..831949fda492 100644
--- a/drivers/acpi/x86/utils.c
+++ b/drivers/acpi/x86/utils.c
@@ -58,6 +58,11 @@ static const struct always_present_id always_present_ids[] = {
 	ENTRY("80862289", "2", X86_MATCH(ATOM_AIRMONT), {
 			DMI_MATCH(DMI_PRODUCT_NAME, "Lenovo YB1-X9"),
 		}),
+	/* The Xiaomi Mi Pad 2 uses PWM2 for touchkeys backlight control */
+	ENTRY("80862289", "2", X86_MATCH(ATOM_AIRMONT), {
+		DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"),
+	      }),
 	/*
 	 * The INT0002 device is necessary to clear wakeup interrupt sources
 	 * on Cherry Trail devices, without it we get nobody cared IRQ msgs.
@@ -107,6 +112,24 @@ static const struct always_present_id always_present_ids[] = {
 		DMI_MATCH(DMI_PRODUCT_NAME, "Default string"),
 		DMI_MATCH(DMI_BIOS_DATE, "05/25/2017")
 	      }),
+	/*
+	 * The Xiaomi Mi Pad 2 does not use the ACPI battery interface
+	 * instead we need to load a native driver for the fuel-gauge,
+	 * but if the BIOS thinks we are Windows rather then Android,
+	 * the fuel-gauge ACPI device is hidden.
+	 */
+	ENTRY("TXN27520", NULL, X86_MATCH(ATOM_AIRMONT), {
+		DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"),
+	      }),
+	/*
+	 * The Xiaomi Mi Pad 2 has a RGB LED controller for its notifcation
+	 * LED which is hidden when the BIOS thinks we are Windows, unhide it.
+	 */
+	ENTRY("KTD20260", "1", X86_MATCH(ATOM_AIRMONT), {
+		DMI_MATCH(DMI_SYS_VENDOR, "Xiaomi Inc"),
+		DMI_MATCH(DMI_PRODUCT_NAME, "Mipad2"),
+	      }),
 };
 
 bool acpi_device_always_present(struct acpi_device *adev)
@@ -118,8 +141,8 @@ bool acpi_device_always_present(struct acpi_device *adev)
 		if (acpi_match_device_ids(adev, always_present_ids[i].hid))
 			continue;
 
-		if (!adev->pnp.unique_id ||
-		    strcmp(adev->pnp.unique_id, always_present_ids[i].uid))
+		if (always_present_ids[i].uid && (!adev->pnp.unique_id ||
+		    strcmp(adev->pnp.unique_id, always_present_ids[i].uid)))
 			continue;
 
 		if (!x86_match_cpu(always_present_ids[i].cpu_ids))
-- 
2.31.1


  reply	other threads:[~2021-10-31 16:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-31 16:24 [RFC 0/5] ACPI/power-suppy add fuel-gauge support on cht-wc PMIC without USB-PD support devs Hans de Goede
2021-10-31 16:24 ` Hans de Goede [this message]
2021-10-31 16:24 ` [RFC 2/5] gpiolib: acpi: Make acpi_gpio_in_ignore_list() more generic Hans de Goede
2021-10-31 16:24 ` [RFC 3/5] gpiolib: acpi: Add a new "ignore" module option Hans de Goede
2021-10-31 19:59   ` Andy Shevchenko
2021-10-31 20:01     ` Andy Shevchenko
2021-11-01 19:16     ` Hans de Goede
2021-10-31 16:24 ` [RFC 4/5] power: supply: bq27xxx: Add dev helper variable to bq27xxx_battery_i2c_probe() Hans de Goede
2021-10-31 16:24 ` [RFC 5/5] power: supply: bq27xxx: Add support for ACPI enumeration Hans de Goede
2021-10-31 19:49 ` [RFC 0/5] ACPI/power-suppy add fuel-gauge support on cht-wc PMIC without USB-PD support devs Andy Shevchenko
2021-11-01 19:13   ` Hans de Goede

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211031162428.22368-2-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andy@infradead.org \
    --cc=ardb@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=jekhor@gmail.com \
    --cc=kitakar@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=markgross@kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=myungjoo.ham@samsung.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=sre@kernel.org \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).