Skip to contentSkip to conversation

mfd: arizona-spi: Split Windows ACPI init code into its own function

PATCH Superseded Hans de Goede 3 participants 9 messages Feb 23, 2022 – Mar 8, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mfd: arizona-spi: Split Windows ACPI init code into its own function

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

The ACPI fwnode describing the codec differs depending on the factory OS, and the current arizona_spi_acpi_probe() function is tailored for use with the Windows board ACPI tables.

Split out the Windows board ACPI tables specific bits into a new arizona_spi_acpi_windows_probe() function in preparation for also adding support for the Android board ACPI tables.

---
 drivers/mfd/arizona-spi.c | 52 ++++++++++++++++++++++++---------------
 1 file changed, 32 insertions(+), 20 deletions(-)
drivers/mfd/arizona-spi.c +32 -20
index 9fe06dda3782..238355542ab1 100644
@@ -43,31 +43,13 @@ static const struct gpiod_lookup arizona_soc_gpios[] = {
 	{ "arizona", 4, "wlf,micd-pol", 0, GPIO_ACTIVE_LOW },
 };
 
-/*
- * The AOSP 3.5 mm Headset: Accessory Specification gives the following values:
- * Function A Play/Pause:           0 ohm
- * Function D Voice assistant:    135 ohm
- * Function B Volume Up           240 ohm
- * Function C Volume Down         470 ohm
- * Minimum Mic DC resistance     1000 ohm
- * Minimum Ear speaker impedance   16 ohm
- * Note the first max value below must be less then the min. speaker impedance,
- * to allow CTIA/OMTP detection to work. The other max values are the closest
- * value from extcon-arizona.c:arizona_micd_levels halfway 2 button resistances.
- */
-static const struct arizona_micd_range arizona_micd_aosp_ranges[] = {
-	{ .max =  11, .key = KEY_PLAYPAUSE },
-	{ .max = 186, .key = KEY_VOICECOMMAND },
-	{ .max = 348, .key = KEY_VOLUMEUP },
-	{ .max = 752, .key = KEY_VOLUMEDOWN },
-};
-
 static void arizona_spi_acpi_remove_lookup(void *lookup)
 {
 	gpiod_remove_lookup_table(lookup);
 }
 
-static int arizona_spi_acpi_probe(struct arizona *arizona)
+/* For ACPI tables from boards which ship with Windows as factory OS */
+static int arizona_spi_acpi_windows_probe(struct arizona *arizona)
 {
 	struct gpiod_lookup_table *lookup;
 	acpi_status status;
@@ -96,6 +78,36 @@ static int arizona_spi_acpi_probe(struct arizona *arizona)
 	if (ACPI_FAILURE(status))
 		dev_warn(arizona->dev, "Failed to enable 32KHz clk ACPI error %d\n", status);
 
+	return 0;
+}
+
+/*
+ * The AOSP 3.5 mm Headset: Accessory Specification gives the following values:
+ * Function A Play/Pause:           0 ohm
+ * Function D Voice assistant:    135 ohm
+ * Function B Volume Up           240 ohm
+ * Function C Volume Down         470 ohm
+ * Minimum Mic DC resistance     1000 ohm
+ * Minimum Ear speaker impedance   16 ohm
+ * Note the first max value below must be less then the min. speaker impedance,
+ * to allow CTIA/OMTP detection to work. The other max values are the closest
+ * value from extcon-arizona.c:arizona_micd_levels halfway 2 button resistances.
+ */
+static const struct arizona_micd_range arizona_micd_aosp_ranges[] = {
+	{ .max =  11, .key = KEY_PLAYPAUSE },
+	{ .max = 186, .key = KEY_VOICECOMMAND },
+	{ .max = 348, .key = KEY_VOLUMEUP },
+	{ .max = 752, .key = KEY_VOLUMEDOWN },
+};
+
+static int arizona_spi_acpi_probe(struct arizona *arizona)
+{
+	int ret;
+
+	ret = arizona_spi_acpi_windows_probe(arizona);
+	if (ret)
+		return ret;
+
 	/*
 	 * Some DSDTs wrongly declare the IRQ trigger-type as IRQF_TRIGGER_FALLING
 	 * The IRQ line will stay low when a new IRQ event happens between reading
Signature · 1 line
2.35.1
#1 lore raw

PATCH 2/2 mfd: arizona-spi: Add Android board ACPI table handling

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.

---
 drivers/mfd/arizona-spi.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/mfd/arizona-spi.c +33 -1
index 238355542ab1..2c686e71db21 100644
@@ -81,6 +81,29 @@ 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 +125,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 +170,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);
Signature · 1 line
2.35.1
Acked-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] mfd: arizona-spi: Add Android board ACPI table handling

Quoted 20 lines · Hans de Goede

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.

Quoted 6 lines

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.

---

Thanks,
Charles

#3 lore raw

Re: [PATCH 2/2] mfd: arizona-spi: Add Android board ACPI table handling

In reply to Hans de Goede
Quoted 42 lines · Hans de Goede

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.

---
 drivers/mfd/arizona-spi.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/mfd/arizona-spi.c +5 -0
index 238355542ab1..2c686e71db21 100644
@@ -81,6 +81,29 @@ 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;
+

drivers/mfd/arizona-spi.c static int arizona_spi_acpi_windows_probe(struct arizona *arizona) · line 98

Quoted 10 lines
drivers/mfd/arizona-spi.c +10 -0
+	/*
+	 * 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");

Nit: How many chars is this?

I thought we were drawing the line at 100 these days?

Does this patch pass checkpatch.pl?

Quoted 38 lines
drivers/mfd/arizona-spi.c +18 -1
+			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 +125,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 +170,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);
Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw

Re: [PATCH 2/2] mfd: arizona-spi: Add Android board ACPI table handling

Hi,

Quoted 48 lines · Lee Jones
Quoted 46 lines · Hans de Goede

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.

---
 drivers/mfd/arizona-spi.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/mfd/arizona-spi.c +9 -0
index 238355542ab1..2c686e71db21 100644
@@ -81,6 +81,29 @@ 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.
Quoted 8 lines

drivers/mfd/arizona-spi.c static int arizona_spi_acpi_windows_probe(struct arizona *arizona) · line 98

Quoted 6 lines
drivers/mfd/arizona-spi.c +6 -0
+	 */
+	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");

Nit: How many chars is this?

105.

Quoted 1 line

I thought we were drawing the line at 100 these days?

We have an exception for log lines, since we don't want to break them up because that makes grepping for them impossible.

Quoted 1 line

Does this patch pass checkpatch.pl?

Yes because of the exception for log lines:

[hans@x1 linux]$ scripts/checkpatch.pl 0001-mfd-arizona-spi-Add-Android-board-ACPI-table-handlin.patch
total: 0 errors, 0 warnings, 54 lines checked

0001-mfd-arizona-spi-Add-Android-board-ACPI-table-handlin.patch has no obvious style problems and is ready for submission.

Regards,

Hans

Quoted 40 lines
Quoted 39 lines
drivers/mfd/arizona-spi.c +18 -1
+			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 +125,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 +170,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);
#5 lore raw

Re: [PATCH 2/2] mfd: arizona-spi: Add Android board ACPI table handling

Quoted 67 lines · Hans de Goede

Hi,

Quoted 48 lines · Lee Jones
Quoted 46 lines · Hans de Goede

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.

---
 drivers/mfd/arizona-spi.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/mfd/arizona-spi.c +9 -0
index 238355542ab1..2c686e71db21 100644
@@ -81,6 +81,29 @@ 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.
Quoted 8 lines

drivers/mfd/arizona-spi.c static int arizona_spi_acpi_windows_probe(struct arizona *arizona) · line 98

Quoted 6 lines
drivers/mfd/arizona-spi.c +6 -0
+	 */
+	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");

Nit: How many chars is this?

105.

Quoted 1 line

I thought we were drawing the line at 100 these days?

We have an exception for log lines, since we don't want to break them up because that makes grepping for them impossible.

Quoted 8 lines
Quoted 1 line

Does this patch pass checkpatch.pl?

Yes because of the exception for log lines:

[hans@x1 linux]$ scripts/checkpatch.pl 0001-mfd-arizona-spi-Add-Android-board-ACPI-table-handlin.patch
total: 0 errors, 0 warnings, 54 lines checked

0001-mfd-arizona-spi-Add-Android-board-ACPI-table-handlin.patch has no obvious style problems and is ready for submission.

What do you mean by long lines?

I'm aware of the exception for long strings.

Not sure why anyone would grep for "dev_info_once(arizona->dev, ".

I would break this after the first comma.

Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw

Re: [PATCH 2/2] mfd: arizona-spi: Add Android board ACPI table handling

Hi,

Quoted 71 lines · Lee Jones
Quoted 69 lines · Hans de Goede

Hi,

Quoted 48 lines · Lee Jones
Quoted 46 lines · Hans de Goede

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.

---
 drivers/mfd/arizona-spi.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/mfd/arizona-spi.c +9 -0
index 238355542ab1..2c686e71db21 100644
@@ -81,6 +81,29 @@ 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.
Quoted 8 lines

drivers/mfd/arizona-spi.c static int arizona_spi_acpi_windows_probe(struct arizona *arizona) · line 98

Quoted 6 lines
drivers/mfd/arizona-spi.c +6 -0
+	 */
+	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");

Nit: How many chars is this?

105.

Quoted 1 line

I thought we were drawing the line at 100 these days?

We have an exception for log lines, since we don't want to break them up because that makes grepping for them impossible.

Quoted 1 line

Does this patch pass checkpatch.pl?

Quoted 8 lines
Quoted 6 lines

Yes because of the exception for log lines:

[hans@x1 linux]$ scripts/checkpatch.pl 0001-mfd-arizona-spi-Add-Android-board-ACPI-table-handlin.patch
total: 0 errors, 0 warnings, 54 lines checked

0001-mfd-arizona-spi-Add-Android-board-ACPI-table-handlin.patch has no obvious style problems and is ready for submission.

What do you mean by long lines?

Not long lines, log lines, as in lines logging a message, sorry if that was unclear.

Quoted 5 lines

I'm aware of the exception for long strings.

Not sure why anyone would grep for "dev_info_once(arizona->dev, ".

I would break this after the first comma.

Ok, I'll send a v2 with a break after the first comma.

Regards,

Hans

#7 lore raw

Re: [PATCH 2/2] mfd: arizona-spi: Add Android board ACPI table handling

Quoted 79 lines · Hans de Goede

Hi,

Quoted 76 lines · Lee Jones
Quoted 74 lines · Hans de Goede

Hi,

Quoted 48 lines · Lee Jones
Quoted 46 lines · Hans de Goede

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.

---
 drivers/mfd/arizona-spi.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)
drivers/mfd/arizona-spi.c +9 -0
index 238355542ab1..2c686e71db21 100644
@@ -81,6 +81,29 @@ 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.
Quoted 8 lines

drivers/mfd/arizona-spi.c static int arizona_spi_acpi_windows_probe(struct arizona *arizona) · line 98

Quoted 6 lines
drivers/mfd/arizona-spi.c +6 -0
+	 */
+	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");

Nit: How many chars is this?

105.

Quoted 1 line

I thought we were drawing the line at 100 these days?

We have an exception for log lines, since we don't want to break them up because that makes grepping for them impossible.

Quoted 1 line

Does this patch pass checkpatch.pl?

Yes because of the exception for log lines:

[hans@x1 linux]$ scripts/checkpatch.pl 0001-mfd-arizona-spi-Add-Android-board-ACPI-table-handlin.patch
total: 0 errors, 0 warnings, 54 lines checked

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

0001-mfd-arizona-spi-Add-Android-board-ACPI-table-handlin.patch has no obvious style problems and is ready for submission.

What do you mean by long lines?

Not long lines, log lines, as in lines logging a message, sorry if that was unclear.

My fault, I misread.

Quoted 7 lines
Quoted 5 lines

I'm aware of the exception for long strings.

Not sure why anyone would grep for "dev_info_once(arizona->dev, ".

I would break this after the first comma.

Ok, I'll send a v2 with a break after the first comma.

Thank you.

Signature · 4 lines
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
Acked-by on v1 1/2
#8 lore raw
In reply to Hans de Goede
Quoted 7 lines · Hans de Goede

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

The ACPI fwnode describing the codec differs depending on the factory OS, and the current arizona_spi_acpi_probe() function is tailored for use with the Windows board ACPI tables.

Quoted 6 lines

Split out the Windows board ACPI tables specific bits into a new arizona_spi_acpi_windows_probe() function in preparation for also adding support for the Android board ACPI tables.

---

Thanks,
Charles