Lines Matching +full:tegra +full:- +full:audio +full:- +full:trimslice
1 // SPDX-License-Identifier: GPL-2.0-only
3 * tegra_asoc_machine.c - Universal ASoC machine driver for NVIDIA Tegra boards.
71 struct snd_soc_dapm_context *dapm = w->dapm; in tegra_machine_event()
72 struct tegra_machine *machine = snd_soc_card_get_drvdata(dapm->card); in tegra_machine_event()
74 if (!strcmp(w->name, "Int Spk") || !strcmp(w->name, "Speakers")) in tegra_machine_event()
75 gpiod_set_value_cansleep(machine->gpiod_spkr_en, in tegra_machine_event()
78 if (!strcmp(w->name, "Mic Jack")) in tegra_machine_event()
79 gpiod_set_value_cansleep(machine->gpiod_ext_mic_en, in tegra_machine_event()
82 if (!strcmp(w->name, "Int Mic")) in tegra_machine_event()
83 gpiod_set_value_cansleep(machine->gpiod_int_mic_en, in tegra_machine_event()
86 if (!strcmp(w->name, "Headphone") || !strcmp(w->name, "Headphone Jack")) in tegra_machine_event()
87 gpiod_set_value_cansleep(machine->gpiod_hp_mute, in tegra_machine_event()
125 struct snd_soc_card *card = rtd->card; in tegra_asoc_machine_init()
130 if (machine->gpiod_hp_det && machine->asoc->add_hp_jack) { in tegra_asoc_machine_init()
131 if (machine->asoc->hp_jack_name) in tegra_asoc_machine_init()
132 jack_name = machine->asoc->hp_jack_name; in tegra_asoc_machine_init()
142 dev_err(rtd->dev, in tegra_asoc_machine_init()
147 tegra_machine_hp_jack_gpio.desc = machine->gpiod_hp_det; in tegra_asoc_machine_init()
152 dev_err(rtd->dev, "HP GPIOs not added: %d\n", err); in tegra_asoc_machine_init()
155 if (machine->gpiod_hp_det && machine->asoc->add_headset_jack) { in tegra_asoc_machine_init()
162 dev_err(rtd->dev, in tegra_asoc_machine_init()
167 tegra_machine_headset_jack_gpio.desc = machine->gpiod_hp_det; in tegra_asoc_machine_init()
172 dev_err(rtd->dev, "Headset GPIOs not added: %d\n", err); in tegra_asoc_machine_init()
175 if (machine->gpiod_mic_det && machine->asoc->add_mic_jack) { in tegra_asoc_machine_init()
176 err = snd_soc_card_jack_new_pins(rtd->card, "Mic Jack", in tegra_asoc_machine_init()
182 dev_err(rtd->dev, "Mic Jack creation failed: %d\n", err); in tegra_asoc_machine_init()
186 tegra_machine_mic_jack_gpio.desc = machine->gpiod_mic_det; in tegra_asoc_machine_init()
191 dev_err(rtd->dev, "Mic GPIOs not added: %d\n", err); in tegra_asoc_machine_init()
244 struct snd_soc_pcm_runtime *rtd = substream->private_data; in tegra_machine_hw_params()
246 struct snd_soc_card *card = rtd->card; in tegra_machine_hw_params()
249 unsigned int mclk = machine->asoc->mclk_rate(srate); in tegra_machine_hw_params()
250 unsigned int clk_id = machine->asoc->mclk_id; in tegra_machine_hw_params()
280 dev_err(card->dev, "Invalid sound rate: %u\n", srate); in tegra_machine_hw_params()
281 return -EINVAL; in tegra_machine_hw_params()
284 if (new_baseclock != machine->set_baseclock || in tegra_machine_hw_params()
285 mclk != machine->set_mclk) { in tegra_machine_hw_params()
286 machine->set_baseclock = 0; in tegra_machine_hw_params()
287 machine->set_mclk = 0; in tegra_machine_hw_params()
289 clk_disable_unprepare(machine->clk_cdev1); in tegra_machine_hw_params()
291 err = clk_set_rate(machine->clk_pll_a, new_baseclock); in tegra_machine_hw_params()
293 dev_err(card->dev, "Can't set pll_a rate: %d\n", err); in tegra_machine_hw_params()
297 err = clk_set_rate(machine->clk_pll_a_out0, mclk); in tegra_machine_hw_params()
299 dev_err(card->dev, "Can't set pll_a_out0 rate: %d\n", err); in tegra_machine_hw_params()
305 err = clk_prepare_enable(machine->clk_cdev1); in tegra_machine_hw_params()
307 dev_err(card->dev, "Can't enable cdev1: %d\n", err); in tegra_machine_hw_params()
311 machine->set_baseclock = new_baseclock; in tegra_machine_hw_params()
312 machine->set_mclk = mclk; in tegra_machine_hw_params()
317 dev_err(card->dev, "codec_dai clock not set: %d\n", err); in tegra_machine_hw_params()
339 np = of_parse_phandle(dev->of_node, name, 0); in tegra_machine_parse_phandle()
342 return ERR_PTR(-EINVAL); in tegra_machine_parse_phandle()
365 pdev = platform_device_register_simple(name, -1, NULL, 0); in tegra_machine_register_codec()
381 struct device *dev = &pdev->dev; in tegra_asoc_machine_probe()
389 return -ENOMEM; in tegra_asoc_machine_probe()
392 card = asoc->card; in tegra_asoc_machine_probe()
393 card->dev = dev; in tegra_asoc_machine_probe()
395 machine->asoc = asoc; in tegra_asoc_machine_probe()
396 machine->mic_jack = &tegra_machine_mic_jack; in tegra_asoc_machine_probe()
397 machine->hp_jack_gpio = &tegra_machine_hp_jack_gpio; in tegra_asoc_machine_probe()
400 gpiod = devm_gpiod_get_optional(dev, "nvidia,hp-mute", GPIOD_OUT_HIGH); in tegra_asoc_machine_probe()
401 machine->gpiod_hp_mute = gpiod; in tegra_asoc_machine_probe()
405 gpiod = devm_gpiod_get_optional(dev, "nvidia,hp-det", GPIOD_IN); in tegra_asoc_machine_probe()
406 machine->gpiod_hp_det = gpiod; in tegra_asoc_machine_probe()
410 gpiod = devm_gpiod_get_optional(dev, "nvidia,mic-det", GPIOD_IN); in tegra_asoc_machine_probe()
411 machine->gpiod_mic_det = gpiod; in tegra_asoc_machine_probe()
415 gpiod = devm_gpiod_get_optional(dev, "nvidia,spkr-en", GPIOD_OUT_LOW); in tegra_asoc_machine_probe()
416 machine->gpiod_spkr_en = gpiod; in tegra_asoc_machine_probe()
420 gpiod = devm_gpiod_get_optional(dev, "nvidia,int-mic-en", GPIOD_OUT_LOW); in tegra_asoc_machine_probe()
421 machine->gpiod_int_mic_en = gpiod; in tegra_asoc_machine_probe()
425 gpiod = devm_gpiod_get_optional(dev, "nvidia,ext-mic-en", GPIOD_OUT_LOW); in tegra_asoc_machine_probe()
426 machine->gpiod_ext_mic_en = gpiod; in tegra_asoc_machine_probe()
434 if (!card->dapm_routes) { in tegra_asoc_machine_probe()
435 err = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); in tegra_asoc_machine_probe()
440 if (asoc->set_ac97) { in tegra_asoc_machine_probe()
441 err = tegra_machine_register_codec(dev, asoc->codec_dev_name); in tegra_asoc_machine_probe()
445 np_ac97 = tegra_machine_parse_phandle(dev, "nvidia,ac97-controller"); in tegra_asoc_machine_probe()
449 card->dai_link->cpus->of_node = np_ac97; in tegra_asoc_machine_probe()
450 card->dai_link->platforms->of_node = np_ac97; in tegra_asoc_machine_probe()
452 np_codec = tegra_machine_parse_phandle(dev, "nvidia,audio-codec"); in tegra_asoc_machine_probe()
456 np_i2s = tegra_machine_parse_phandle(dev, "nvidia,i2s-controller"); in tegra_asoc_machine_probe()
460 card->dai_link->cpus->of_node = np_i2s; in tegra_asoc_machine_probe()
461 card->dai_link->codecs->of_node = np_codec; in tegra_asoc_machine_probe()
462 card->dai_link->platforms->of_node = np_i2s; in tegra_asoc_machine_probe()
465 if (asoc->add_common_controls) { in tegra_asoc_machine_probe()
466 card->controls = tegra_machine_controls; in tegra_asoc_machine_probe()
467 card->num_controls = ARRAY_SIZE(tegra_machine_controls); in tegra_asoc_machine_probe()
470 if (asoc->add_common_dapm_widgets) { in tegra_asoc_machine_probe()
471 card->dapm_widgets = tegra_machine_dapm_widgets; in tegra_asoc_machine_probe()
472 card->num_dapm_widgets = ARRAY_SIZE(tegra_machine_dapm_widgets); in tegra_asoc_machine_probe()
475 if (asoc->add_common_snd_ops) in tegra_asoc_machine_probe()
476 card->dai_link->ops = &tegra_machine_snd_ops; in tegra_asoc_machine_probe()
478 if (!card->owner) in tegra_asoc_machine_probe()
479 card->owner = THIS_MODULE; in tegra_asoc_machine_probe()
480 if (!card->driver_name) in tegra_asoc_machine_probe()
481 card->driver_name = "tegra"; in tegra_asoc_machine_probe()
483 machine->clk_pll_a = devm_clk_get(dev, "pll_a"); in tegra_asoc_machine_probe()
484 if (IS_ERR(machine->clk_pll_a)) { in tegra_asoc_machine_probe()
486 return PTR_ERR(machine->clk_pll_a); in tegra_asoc_machine_probe()
489 machine->clk_pll_a_out0 = devm_clk_get(dev, "pll_a_out0"); in tegra_asoc_machine_probe()
490 if (IS_ERR(machine->clk_pll_a_out0)) { in tegra_asoc_machine_probe()
492 return PTR_ERR(machine->clk_pll_a_out0); in tegra_asoc_machine_probe()
495 machine->clk_cdev1 = devm_clk_get(dev, "mclk"); in tegra_asoc_machine_probe()
496 if (IS_ERR(machine->clk_cdev1)) { in tegra_asoc_machine_probe()
498 return PTR_ERR(machine->clk_cdev1); in tegra_asoc_machine_probe()
505 if (!of_find_property(dev->of_node, "assigned-clock-parents", NULL) && in tegra_asoc_machine_probe()
509 dev_warn(dev, "Configuring clocks for a legacy device-tree\n"); in tegra_asoc_machine_probe()
510 dev_warn(dev, "Please update DT to use assigned-clock-parents\n"); in tegra_asoc_machine_probe()
518 err = clk_set_parent(clk_extern1, machine->clk_pll_a_out0); in tegra_asoc_machine_probe()
536 machine->clk_cdev1 = clk_out_1; in tegra_asoc_machine_probe()
539 if (asoc->set_ac97) { in tegra_asoc_machine_probe()
544 err = clk_set_rate(machine->clk_pll_a, 73728000); in tegra_asoc_machine_probe()
550 err = clk_set_rate(machine->clk_pll_a_out0, 24576000); in tegra_asoc_machine_probe()
556 machine->set_baseclock = 73728000; in tegra_asoc_machine_probe()
557 machine->set_mclk = 24576000; in tegra_asoc_machine_probe()
561 * FIXME: There is some unknown dependency between audio MCLK disable in tegra_asoc_machine_probe()
562 * and suspend-resume functionality on Tegra30, although audio MCLK is in tegra_asoc_machine_probe()
563 * only needed for audio. in tegra_asoc_machine_probe()
565 err = clk_prepare_enable(machine->clk_cdev1); in tegra_asoc_machine_probe()
583 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8753-hifi")),
613 return snd_soc_dapm_force_enable_pin(&rtd->card->dapm, "Mic Bias"); in tegra_wm9712_init()
618 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-hifi")),
638 .codec_dev_name = "wm9712-codec",
724 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "tlv320aic23-hifi")),
737 .name = "tegra-trimslice",
758 struct snd_soc_card *card = rtd->card; in tegra_rt5677_init()
765 snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS1"); in tegra_rt5677_init()
772 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5677-aif1")),
806 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5640-aif1")),
839 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "alc5632-hifi")),
869 { .compatible = "nvidia,tegra-audio-trimslice", .data = &tegra_trimslice_data },
870 { .compatible = "nvidia,tegra-audio-max98090", .data = &tegra_max98090_data },
871 { .compatible = "nvidia,tegra-audio-sgtl5000", .data = &tegra_sgtl5000_data },
872 { .compatible = "nvidia,tegra-audio-wm9712", .data = &tegra_wm9712_data },
873 { .compatible = "nvidia,tegra-audio-wm8753", .data = &tegra_wm8753_data },
874 { .compatible = "nvidia,tegra-audio-rt5677", .data = &tegra_rt5677_data },
875 { .compatible = "nvidia,tegra-audio-rt5640", .data = &tegra_rt5640_data },
876 { .compatible = "nvidia,tegra-audio-alc5632", .data = &tegra_rt5632_data },
883 .name = "tegra-audio",
902 MODULE_DESCRIPTION("Tegra machine ASoC driver");