Lines Matching +full:i2c +full:- +full:topology
1 // SPDX-License-Identifier: GPL-2.0-only
12 #include <linux/i2c.h>
21 #include <sound/soc-acpi.h>
24 /* jd-inv + terminating entry */
56 static int quirk_override = -1;
58 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
79 { "speakers-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
84 { "speakers-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
88 { "speakers-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
89 { "headphone-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
94 { "speakers-enable-gpios", &enable_gpio1, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
95 { "headphone-enable-gpios", &enable_gpio0, 1, ACPI_GPIO_QUIRK_ONLY_GPIOIO },
120 gpiod_set_value_cansleep(priv->gpio_speakers, priv->speaker_en); in pcm_pop_work_events()
123 gpiod_set_value_cansleep(priv->gpio_headphone, priv->speaker_en); in pcm_pop_work_events()
130 struct snd_soc_card *card = rtd->card; in sof_8336_trigger()
142 if (priv->speaker_en == false) in sof_8336_trigger()
143 if (substream->stream == 0) { in sof_8336_trigger()
144 cancel_delayed_work(&priv->pcm_pop_work); in sof_8336_trigger()
145 gpiod_set_value_cansleep(priv->gpio_speakers, true); in sof_8336_trigger()
149 return -EINVAL; in sof_8336_trigger()
158 struct snd_soc_card *card = w->dapm->card; in sof_es8316_speaker_power_event()
161 if (priv->speaker_en == !SND_SOC_DAPM_EVENT_ON(event)) in sof_es8316_speaker_power_event()
164 priv->speaker_en = !SND_SOC_DAPM_EVENT_ON(event); in sof_es8316_speaker_power_event()
166 queue_delayed_work(system_wq, &priv->pcm_pop_work, msecs_to_jiffies(70)); in sof_es8316_speaker_power_event()
233 struct snd_soc_card *card = runtime->card; in dmic_init()
236 ret = snd_soc_dapm_new_controls(&card->dapm, dmic_widgets, in dmic_init()
239 dev_err(card->dev, "DMic widget addition failed: %d\n", ret); in dmic_init()
243 ret = snd_soc_dapm_add_routes(&card->dapm, dmic_map, in dmic_init()
246 dev_err(card->dev, "DMic map addition failed: %d\n", ret); in dmic_init()
253 struct sof_es8336_private *priv = snd_soc_card_get_drvdata(runtime->card); in sof_hdmi_init()
257 pcm = devm_kzalloc(runtime->card->dev, sizeof(*pcm), GFP_KERNEL); in sof_hdmi_init()
259 return -ENOMEM; in sof_hdmi_init()
262 pcm->device = runtime->dai_link->id; in sof_hdmi_init()
263 pcm->codec_dai = dai; in sof_hdmi_init()
265 list_add_tail(&pcm->head, &priv->hdmi_pcm_list); in sof_hdmi_init()
272 struct snd_soc_component *codec = snd_soc_rtd_to_codec(runtime, 0)->component; in sof_es8316_init()
273 struct snd_soc_card *card = runtime->card; in sof_es8316_init()
279 card->dapm.idle_bias_off = true; in sof_es8316_init()
289 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in sof_es8316_init()
295 &priv->jack, sof_es8316_jack_pins, in sof_es8316_init()
298 dev_err(card->dev, "jack creation failed %d\n", ret); in sof_es8316_init()
302 snd_jack_set_key(priv->jack.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in sof_es8316_init()
304 snd_soc_component_set_jack(codec, &priv->jack, NULL); in sof_es8316_init()
311 struct snd_soc_component *component = snd_soc_rtd_to_codec(rtd, 0)->component; in sof_es8316_exit()
318 quirk = (unsigned long)id->driver_data; in sof_es8336_quirk_cb()
324 * this table should only be used to add GPIO or jack-detection quirks
327 * with the topology used.
332 * if the topology file is modified as well.
347 DMI_MATCH(DMI_BOARD_NAME, "BOHB-WAX9-PCB-B2"),
365 dev_err(rtd->dev, "%s, Failed to set ES8336 SYSCLK: %d\n", in sof_es8336_hw_params()
387 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-ESSX8336:00", "ES8316 HiFi")));
391 .name = "dmic-codec",
392 .dai_name = "dmic-hifi",
401 if (list_empty(&priv->hdmi_pcm_list)) in sof_es8336_late_probe()
402 return -ENOENT; in sof_es8336_late_probe()
404 pcm = list_first_entry(&priv->hdmi_pcm_list, struct sof_hdmi_pcm, head); in sof_es8336_late_probe()
406 return hda_dsp_hdmi_build_controls(card, pcm->codec_dai->component); in sof_es8336_late_probe()
411 .name = "essx8336", /* sof- prefix added automatically */
445 "SSP%d-Codec", ssp_codec); in sof_card_dai_links_create()
464 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, in sof_card_dai_links_create()
467 if (!links[id].cpus->dai_name) in sof_card_dai_links_create()
477 links[id].cpus->dai_name = "DMIC01 Pin"; in sof_card_dai_links_create()
483 links[id + 1].cpus->dai_name = "DMIC16k Pin"; in sof_card_dai_links_create()
487 /* HDMI dai link starts at 3 according to current topology settings */ in sof_card_dai_links_create()
524 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, in sof_card_dai_links_create()
526 if (!links[id].cpus->dai_name) in sof_card_dai_links_create()
529 idisp_components[i - 1].name = "ehdaudio0D2"; in sof_card_dai_links_create()
530 idisp_components[i - 1].dai_name = devm_kasprintf(dev, in sof_card_dai_links_create()
532 "intel-hdmi-hifi%d", in sof_card_dai_links_create()
534 if (!idisp_components[i - 1].dai_name) in sof_card_dai_links_create()
537 links[id].codecs = &idisp_components[i - 1]; in sof_card_dai_links_create()
548 /* HDMI-In SSP */ in sof_card_dai_links_create()
560 links[id].cpus->dai_name = devm_kasprintf(dev, GFP_KERNEL, in sof_card_dai_links_create()
562 if (!links[id].cpus->dai_name) in sof_card_dai_links_create()
564 links[id].name = devm_kasprintf(dev, GFP_KERNEL, "SSP%d-HDMI", port); in sof_card_dai_links_create()
587 /* i2c-<HID>:00 with HID being 8 chars */
592 struct device *dev = &pdev->dev; in sof_es8336_probe()
594 struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; in sof_es8336_probe()
609 return -ENOMEM; in sof_es8336_probe()
612 card->dev = dev; in sof_es8336_probe()
614 if (pdev->id_entry && pdev->id_entry->driver_data) in sof_es8336_probe()
615 quirk = (unsigned long)pdev->id_entry->driver_data; in sof_es8336_probe()
620 /* Use NHLT configuration only for Non-HDMI capture use case. in sof_es8336_probe()
624 if (mach->tplg_quirk_mask & SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER) { in sof_es8336_probe()
625 if (!mach->mach_params.i2s_link_mask) { in sof_es8336_probe()
632 * In some cases multiple SSPs can be reported by NHLT, starting MSB-first in sof_es8336_probe()
637 /* fls returns 1-based results, SSPs indices are 0-based */ in sof_es8336_probe()
638 ssp = fls(mach->mach_params.i2s_link_mask) - 1; in sof_es8336_probe()
644 if (mach->mach_params.dmic_num) in sof_es8336_probe()
647 if (quirk_override != -1) { in sof_es8336_probe()
668 return -ENOMEM; in sof_es8336_probe()
673 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in sof_es8336_probe()
676 "i2c-%s", acpi_dev_name(adev)); in sof_es8336_probe()
677 dai_links[0].codecs->name = codec_name; in sof_es8336_probe()
680 if (!strncmp(mach->id, "ESSX8326", SND_ACPI_I2C_ID_LEN)) in sof_es8336_probe()
681 dai_links[0].codecs->dai_name = "ES8326 HiFi"; in sof_es8336_probe()
683 dev_err(dev, "Error cannot find '%s' dev\n", mach->id); in sof_es8336_probe()
684 return -ENOENT; in sof_es8336_probe()
690 return -EPROBE_DEFER; in sof_es8336_probe()
691 priv->codec_dev = get_device(codec_dev); in sof_es8336_probe()
694 mach->mach_params.platform); in sof_es8336_probe()
701 props[cnt++] = PROPERTY_ENTRY_BOOL("everest,jack-detect-inverted"); in sof_es8336_probe()
736 priv->gpio_speakers = gpiod_get_optional(codec_dev, "speakers-enable", GPIOD_OUT_LOW); in sof_es8336_probe()
737 if (IS_ERR(priv->gpio_speakers)) { in sof_es8336_probe()
738 ret = dev_err_probe(dev, PTR_ERR(priv->gpio_speakers), in sof_es8336_probe()
739 "could not get speakers-enable GPIO\n"); in sof_es8336_probe()
743 priv->gpio_headphone = gpiod_get_optional(codec_dev, "headphone-enable", GPIOD_OUT_LOW); in sof_es8336_probe()
744 if (IS_ERR(priv->gpio_headphone)) { in sof_es8336_probe()
745 ret = dev_err_probe(dev, PTR_ERR(priv->gpio_headphone), in sof_es8336_probe()
746 "could not get headphone-enable GPIO\n"); in sof_es8336_probe()
750 INIT_LIST_HEAD(&priv->hdmi_pcm_list); in sof_es8336_probe()
751 INIT_DELAYED_WORK(&priv->pcm_pop_work, in sof_es8336_probe()
755 if (mach->mach_params.dmic_num > 0) { in sof_es8336_probe()
757 "cfg-dmics:%d", mach->mach_params.dmic_num); in sof_es8336_probe()
758 card->components = soc_components; in sof_es8336_probe()
763 gpiod_put(priv->gpio_speakers); in sof_es8336_probe()
771 device_remove_software_node(priv->codec_dev); in sof_es8336_probe()
781 cancel_delayed_work_sync(&priv->pcm_pop_work); in sof_es8336_remove()
782 gpiod_put(priv->gpio_speakers); in sof_es8336_remove()
783 device_remove_software_node(priv->codec_dev); in sof_es8336_remove()
784 put_device(priv->codec_dev); in sof_es8336_remove()
789 .name = "sof-essx8336", /* default quirk == 0 */
837 .name = "sof-essx8336",