linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Hans de Goede <hdegoede@redhat.com>,
	patches@opensource.cirrus.com, linux-kernel@vger.kernel.org,
	Charles Keepax <ckeepax@opensource.cirrus.com>
Subject: [PATCH v2 2/2] mfd: arizona-spi: Add Android board ACPI table handling
Date: Mon,  7 Mar 2022 18:38:44 +0100	[thread overview]
Message-ID: <20220307173844.199135-2-hdegoede@redhat.com> (raw)
In-Reply-To: <20220307173844.199135-1-hdegoede@redhat.com>

x86/ACPI boards with an arizona WM5102 codec ship with either Windows or
Android as factory installed OS.

The ACPI fwnode for the codec on Android boards misses 2 things compared
to the Windows boards (this is hardcoded in the Android board kernels):

1. There is no CLKE ACPI method to enabe the 32 KHz clock the codec needs
   for jack-detection.

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

The ACPI tables on x86/ACPI boards shipped with Android being incomplete
happens a lot. The special drivers/platform/x86/x86-android-tablets.c
module contains DMI based per model handling to compensate for this.

This module will enable the 32KHz clock through the pinctrl framework
to fix 1. and it will also register a gpio-lookup table for all GPIOs
needed by the codec + machine driver, including the GPIOs coming from
the codec itself.

Add an arizona_spi_acpi_android_probe() function which waits for the
x86-android-tablets to have set things up before continue with probing
the arizona WM5102 codec.

Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
- Wrap long dev_info_once() line
---
 drivers/mfd/arizona-spi.c | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/arizona-spi.c b/drivers/mfd/arizona-spi.c
index 238355542ab1..ada5664aadd1 100644
--- a/drivers/mfd/arizona-spi.c
+++ b/drivers/mfd/arizona-spi.c
@@ -81,6 +81,30 @@ static int arizona_spi_acpi_windows_probe(struct arizona *arizona)
 	return 0;
 }
 
+/* For ACPI tables from boards which ship with Android as factory OS */
+static int arizona_spi_acpi_android_probe(struct arizona *arizona)
+{
+	int ret;
+
+	/*
+	 * Get the reset GPIO, treating -ENOENT as -EPROBE_DEFER to wait for
+	 * the x86-android-tablets module to register the board specific GPIO
+	 * lookup table.
+	 */
+	arizona->pdata.reset = devm_gpiod_get(arizona->dev, "reset", GPIOD_OUT_LOW);
+	if (IS_ERR(arizona->pdata.reset)) {
+		ret = PTR_ERR(arizona->pdata.reset);
+		if (ret == -ENOENT) {
+			dev_info_once(arizona->dev,
+				      "Deferring probe till GPIO lookup is registered\n");
+			ret = -EPROBE_DEFER;
+		}
+		return dev_err_probe(arizona->dev, ret, "getting reset GPIO\n");
+	}
+
+	return 0;
+}
+
 /*
  * The AOSP 3.5 mm Headset: Accessory Specification gives the following values:
  * Function A Play/Pause:           0 ohm
@@ -102,9 +126,14 @@ static const struct arizona_micd_range arizona_micd_aosp_ranges[] = {
 
 static int arizona_spi_acpi_probe(struct arizona *arizona)
 {
+	struct acpi_device *adev = ACPI_COMPANION(arizona->dev);
 	int ret;
 
-	ret = arizona_spi_acpi_windows_probe(arizona);
+	if (acpi_dev_hid_uid_match(adev, "10WM5102", NULL))
+		ret = arizona_spi_acpi_android_probe(arizona);
+	else
+		ret = arizona_spi_acpi_windows_probe(arizona);
+
 	if (ret)
 		return ret;
 
@@ -142,6 +171,10 @@ static const struct acpi_device_id arizona_acpi_match[] = {
 		.id = "WM510205",
 		.driver_data = WM5102,
 	},
+	{
+		.id = "10WM5102",
+		.driver_data = WM5102,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(acpi, arizona_acpi_match);
-- 
2.35.1


  reply	other threads:[~2022-03-07 17:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 17:38 [PATCH v2 1/2] mfd: arizona-spi: Split Windows ACPI init code into its own function Hans de Goede
2022-03-07 17:38 ` Hans de Goede [this message]
2022-03-22  7:20   ` [PATCH v2 2/2] mfd: arizona-spi: Add Android board ACPI table handling Lee Jones
2022-03-22  7:19 ` [PATCH v2 1/2] mfd: arizona-spi: Split Windows ACPI init code into its own function Lee Jones

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=20220307173844.199135-2-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    /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).