Skip to content

Commit 3285a0b

Browse files
committed
ASoC: Intel: sof_es8336: always use 2 GPIOs
There are always two GPIOS used, the first one controls the speaker and the second one the headset. This first simplification assumes the GPIOs are active high, in a future enhancement the level will be adjusted base on _DSM information. Signed-off-by: Pierre-Louis Bossart <[email protected]>
1 parent 6904df2 commit 3285a0b

File tree

1 file changed

+4
-45
lines changed

1 file changed

+4
-45
lines changed

sound/soc/intel/boards/sof_es8336.c

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#define SOF_ES8336_SSP_CODEC(quirk) ((quirk) & GENMASK(3, 0))
2828
#define SOF_ES8336_SSP_CODEC_MASK (GENMASK(3, 0))
2929

30-
#define SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK BIT(4)
31-
3230
/* HDMI capture*/
3331
#define SOF_SSP_HDMI_CAPTURE_PRESENT BIT(14)
3432
#define SOF_NO_OF_HDMI_CAPTURE_SSP_SHIFT 15
@@ -48,7 +46,6 @@
4846

4947
#define SOF_ES8336_ENABLE_DMIC BIT(5)
5048
#define SOF_ES8336_JD_INVERTED BIT(6)
51-
#define SOF_ES8336_HEADPHONE_GPIO BIT(7)
5249
#define SOC_ES8336_HEADSET_MIC1 BIT(8)
5350

5451
static unsigned long quirk;
@@ -75,37 +72,18 @@ struct sof_hdmi_pcm {
7572
static const struct acpi_gpio_params enable_gpio0 = { 0, 0, true };
7673
static const struct acpi_gpio_params enable_gpio1 = { 1, 0, true };
7774

78-
static const struct acpi_gpio_mapping acpi_speakers_enable_gpio0[] = {
79-
{ "speakers-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
80-
{ }
81-
};
82-
83-
static const struct acpi_gpio_mapping acpi_speakers_enable_gpio1[] = {
84-
{ "speakers-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
85-
};
86-
8775
static const struct acpi_gpio_mapping acpi_enable_both_gpios[] = {
8876
{ "speakers-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
8977
{ "headphone-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
9078
{ }
9179
};
9280

93-
static const struct acpi_gpio_mapping acpi_enable_both_gpios_rev_order[] = {
94-
{ "speakers-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
95-
{ "headphone-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
96-
{ }
97-
};
98-
9981
static void log_quirks(struct device *dev)
10082
{
10183
dev_info(dev, "quirk mask %#lx\n", quirk);
10284
dev_info(dev, "quirk SSP%ld\n", SOF_ES8336_SSP_CODEC(quirk));
10385
if (quirk & SOF_ES8336_ENABLE_DMIC)
10486
dev_info(dev, "quirk DMIC enabled\n");
105-
if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK)
106-
dev_info(dev, "Speakers GPIO1 quirk enabled\n");
107-
if (quirk & SOF_ES8336_HEADPHONE_GPIO)
108-
dev_info(dev, "quirk headphone GPIO enabled\n");
10987
if (quirk & SOF_ES8336_JD_INVERTED)
11088
dev_info(dev, "quirk JD inverted enabled\n");
11189
if (quirk & SOC_ES8336_HEADSET_MIC1)
@@ -119,8 +97,7 @@ static void pcm_pop_work_events(struct work_struct *work)
11997

12098
gpiod_set_value_cansleep(priv->gpio_speakers, priv->speaker_en);
12199

122-
if (quirk & SOF_ES8336_HEADPHONE_GPIO)
123-
gpiod_set_value_cansleep(priv->gpio_headphone, priv->speaker_en);
100+
gpiod_set_value_cansleep(priv->gpio_headphone, !priv->speaker_en);
124101

125102
}
126103

@@ -143,6 +120,7 @@ static int sof_8336_trigger(struct snd_pcm_substream *substream, int cmd)
143120
if (substream->stream == 0) {
144121
cancel_delayed_work(&priv->pcm_pop_work);
145122
gpiod_set_value_cansleep(priv->gpio_speakers, true);
123+
gpiod_set_value_cansleep(priv->gpio_headphone, false);
146124
}
147125
break;
148126
default:
@@ -332,22 +310,13 @@ static int sof_es8336_quirk_cb(const struct dmi_system_id *id)
332310
* if the topology file is modified as well.
333311
*/
334312
static const struct dmi_system_id sof_es8336_quirk_table[] = {
335-
{
336-
.callback = sof_es8336_quirk_cb,
337-
.matches = {
338-
DMI_MATCH(DMI_SYS_VENDOR, "IP3 tech"),
339-
DMI_MATCH(DMI_BOARD_NAME, "WN1"),
340-
},
341-
.driver_data = (void *)(SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK)
342-
},
343313
{
344314
.callback = sof_es8336_quirk_cb,
345315
.matches = {
346316
DMI_MATCH(DMI_SYS_VENDOR, "HUAWEI"),
347317
DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"),
348318
},
349-
.driver_data = (void *)(SOF_ES8336_HEADPHONE_GPIO |
350-
SOC_ES8336_HEADSET_MIC1)
319+
.driver_data = (void *)(SOC_ES8336_HEADSET_MIC1)
351320
},
352321
{}
353322
};
@@ -723,16 +692,7 @@ static int sof_es8336_probe(struct platform_device *pdev)
723692
}
724693

725694
/* get speaker enable GPIO */
726-
if (quirk & SOF_ES8336_HEADPHONE_GPIO) {
727-
if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK)
728-
gpio_mapping = acpi_enable_both_gpios;
729-
else
730-
gpio_mapping = acpi_enable_both_gpios_rev_order;
731-
} else if (quirk & SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK) {
732-
gpio_mapping = acpi_speakers_enable_gpio1;
733-
} else {
734-
gpio_mapping = acpi_speakers_enable_gpio0;
735-
}
695+
gpio_mapping = acpi_enable_both_gpios;
736696

737697
ret = devm_acpi_dev_add_driver_gpios(codec_dev, gpio_mapping);
738698
if (ret)
@@ -802,7 +762,6 @@ static const struct platform_device_id board_ids[] = {
802762
SOF_HDMI_CAPTURE_1_SSP(0) |
803763
SOF_HDMI_CAPTURE_2_SSP(2) |
804764
SOF_SSP_HDMI_CAPTURE_PRESENT |
805-
SOF_ES8336_SPEAKERS_EN_GPIO1_QUIRK |
806765
SOF_ES8336_JD_INVERTED),
807766
},
808767
{ }

0 commit comments

Comments
 (0)