Skip to content

Commit 3cf2b43

Browse files
jwrdegoedeLee Jones
authored andcommitted
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. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20220307173844.199135-1-hdegoede@redhat.com
1 parent e84ee1a commit 3cf2b43

1 file changed

Lines changed: 32 additions & 20 deletions

File tree

drivers/mfd/arizona-spi.c

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,13 @@ static const struct gpiod_lookup arizona_soc_gpios[] = {
4343
{ "arizona", 4, "wlf,micd-pol", 0, GPIO_ACTIVE_LOW },
4444
};
4545

46-
/*
47-
* The AOSP 3.5 mm Headset: Accessory Specification gives the following values:
48-
* Function A Play/Pause: 0 ohm
49-
* Function D Voice assistant: 135 ohm
50-
* Function B Volume Up 240 ohm
51-
* Function C Volume Down 470 ohm
52-
* Minimum Mic DC resistance 1000 ohm
53-
* Minimum Ear speaker impedance 16 ohm
54-
* Note the first max value below must be less then the min. speaker impedance,
55-
* to allow CTIA/OMTP detection to work. The other max values are the closest
56-
* value from extcon-arizona.c:arizona_micd_levels halfway 2 button resistances.
57-
*/
58-
static const struct arizona_micd_range arizona_micd_aosp_ranges[] = {
59-
{ .max = 11, .key = KEY_PLAYPAUSE },
60-
{ .max = 186, .key = KEY_VOICECOMMAND },
61-
{ .max = 348, .key = KEY_VOLUMEUP },
62-
{ .max = 752, .key = KEY_VOLUMEDOWN },
63-
};
64-
6546
static void arizona_spi_acpi_remove_lookup(void *lookup)
6647
{
6748
gpiod_remove_lookup_table(lookup);
6849
}
6950

70-
static int arizona_spi_acpi_probe(struct arizona *arizona)
51+
/* For ACPI tables from boards which ship with Windows as factory OS */
52+
static int arizona_spi_acpi_windows_probe(struct arizona *arizona)
7153
{
7254
struct gpiod_lookup_table *lookup;
7355
acpi_status status;
@@ -96,6 +78,36 @@ static int arizona_spi_acpi_probe(struct arizona *arizona)
9678
if (ACPI_FAILURE(status))
9779
dev_warn(arizona->dev, "Failed to enable 32KHz clk ACPI error %d\n", status);
9880

81+
return 0;
82+
}
83+
84+
/*
85+
* The AOSP 3.5 mm Headset: Accessory Specification gives the following values:
86+
* Function A Play/Pause: 0 ohm
87+
* Function D Voice assistant: 135 ohm
88+
* Function B Volume Up 240 ohm
89+
* Function C Volume Down 470 ohm
90+
* Minimum Mic DC resistance 1000 ohm
91+
* Minimum Ear speaker impedance 16 ohm
92+
* Note the first max value below must be less then the min. speaker impedance,
93+
* to allow CTIA/OMTP detection to work. The other max values are the closest
94+
* value from extcon-arizona.c:arizona_micd_levels halfway 2 button resistances.
95+
*/
96+
static const struct arizona_micd_range arizona_micd_aosp_ranges[] = {
97+
{ .max = 11, .key = KEY_PLAYPAUSE },
98+
{ .max = 186, .key = KEY_VOICECOMMAND },
99+
{ .max = 348, .key = KEY_VOLUMEUP },
100+
{ .max = 752, .key = KEY_VOLUMEDOWN },
101+
};
102+
103+
static int arizona_spi_acpi_probe(struct arizona *arizona)
104+
{
105+
int ret;
106+
107+
ret = arizona_spi_acpi_windows_probe(arizona);
108+
if (ret)
109+
return ret;
110+
99111
/*
100112
* Some DSDTs wrongly declare the IRQ trigger-type as IRQF_TRIGGER_FALLING
101113
* The IRQ line will stay low when a new IRQ event happens between reading

0 commit comments

Comments
 (0)