Lines Matching +full:tegra +full:- +full:audio +full:- +full:rt5631

1 // SPDX-License-Identifier: GPL-2.0-only
3 * tegra_asoc_machine.c - Universal ASoC machine driver for NVIDIA Tegra boards.
58 if (gpiod_get_value_cansleep(machine->gpiod_hp_det) && in coupled_mic_hp_check()
59 gpiod_get_value_cansleep(machine->gpiod_mic_det)) in coupled_mic_hp_check()
81 struct snd_soc_dapm_context *dapm = w->dapm; in tegra_machine_event()
82 struct tegra_machine *machine = snd_soc_card_get_drvdata(dapm->card); in tegra_machine_event()
86 gpiod_set_value_cansleep(machine->gpiod_spkr_en, in tegra_machine_event()
91 gpiod_set_value_cansleep(machine->gpiod_ext_mic_en, in tegra_machine_event()
96 gpiod_set_value_cansleep(machine->gpiod_int_mic_en, in tegra_machine_event()
101 gpiod_set_value_cansleep(machine->gpiod_hp_mute, in tegra_machine_event()
141 struct snd_soc_card *card = rtd->card; in tegra_asoc_machine_init()
146 if (machine->gpiod_hp_det && machine->asoc->add_hp_jack) { in tegra_asoc_machine_init()
147 if (machine->asoc->hp_jack_name) in tegra_asoc_machine_init()
148 jack_name = machine->asoc->hp_jack_name; in tegra_asoc_machine_init()
158 dev_err(rtd->dev, in tegra_asoc_machine_init()
163 tegra_machine_hp_jack_gpio.desc = machine->gpiod_hp_det; in tegra_asoc_machine_init()
168 dev_err(rtd->dev, "HP GPIOs not added: %d\n", err); in tegra_asoc_machine_init()
171 if (machine->gpiod_hp_det && machine->asoc->add_headset_jack) { in tegra_asoc_machine_init()
178 dev_err(rtd->dev, in tegra_asoc_machine_init()
183 tegra_machine_headset_jack_gpio.desc = machine->gpiod_hp_det; in tegra_asoc_machine_init()
188 dev_err(rtd->dev, "Headset GPIOs not added: %d\n", err); in tegra_asoc_machine_init()
191 if (machine->gpiod_mic_det && machine->asoc->add_mic_jack) { in tegra_asoc_machine_init()
192 err = snd_soc_card_jack_new_pins(rtd->card, "Mic Jack", in tegra_asoc_machine_init()
198 dev_err(rtd->dev, "Mic Jack creation failed: %d\n", err); in tegra_asoc_machine_init()
203 tegra_machine_mic_jack_gpio.desc = machine->gpiod_mic_det; in tegra_asoc_machine_init()
205 if (of_property_read_bool(card->dev->of_node, in tegra_asoc_machine_init()
206 "nvidia,coupled-mic-hp-det")) { in tegra_asoc_machine_init()
207 tegra_machine_mic_jack_gpio.desc = machine->gpiod_hp_det; in tegra_asoc_machine_init()
214 dev_err(rtd->dev, "Mic GPIOs not added: %d\n", err); in tegra_asoc_machine_init()
295 struct snd_soc_card *card = rtd->card; in tegra_machine_hw_params()
298 unsigned int mclk = machine->asoc->mclk_rate(srate); in tegra_machine_hw_params()
299 unsigned int clk_id = machine->asoc->mclk_id; in tegra_machine_hw_params()
329 dev_err(card->dev, "Invalid sound rate: %u\n", srate); in tegra_machine_hw_params()
330 return -EINVAL; in tegra_machine_hw_params()
333 if (new_baseclock != machine->set_baseclock || in tegra_machine_hw_params()
334 mclk != machine->set_mclk) { in tegra_machine_hw_params()
335 machine->set_baseclock = 0; in tegra_machine_hw_params()
336 machine->set_mclk = 0; in tegra_machine_hw_params()
338 clk_disable_unprepare(machine->clk_cdev1); in tegra_machine_hw_params()
340 err = clk_set_rate(machine->clk_pll_a, new_baseclock); in tegra_machine_hw_params()
342 dev_err(card->dev, "Can't set pll_a rate: %d\n", err); in tegra_machine_hw_params()
346 err = clk_set_rate(machine->clk_pll_a_out0, mclk); in tegra_machine_hw_params()
348 dev_err(card->dev, "Can't set pll_a_out0 rate: %d\n", err); in tegra_machine_hw_params()
354 err = clk_prepare_enable(machine->clk_cdev1); in tegra_machine_hw_params()
356 dev_err(card->dev, "Can't enable cdev1: %d\n", err); in tegra_machine_hw_params()
360 machine->set_baseclock = new_baseclock; in tegra_machine_hw_params()
361 machine->set_mclk = mclk; in tegra_machine_hw_params()
366 dev_err(card->dev, "codec_dai clock not set: %d\n", err); in tegra_machine_hw_params()
388 np = of_parse_phandle(dev->of_node, name, 0); in tegra_machine_parse_phandle()
391 return ERR_PTR(-EINVAL); in tegra_machine_parse_phandle()
414 pdev = platform_device_register_simple(name, -1, NULL, 0); in tegra_machine_register_codec()
430 struct device *dev = &pdev->dev; in tegra_asoc_machine_probe()
438 return -ENOMEM; in tegra_asoc_machine_probe()
441 card = asoc->card; in tegra_asoc_machine_probe()
442 card->dev = dev; in tegra_asoc_machine_probe()
444 machine->asoc = asoc; in tegra_asoc_machine_probe()
445 machine->mic_jack = &tegra_machine_mic_jack; in tegra_asoc_machine_probe()
446 machine->hp_jack_gpio = &tegra_machine_hp_jack_gpio; in tegra_asoc_machine_probe()
449 gpiod = devm_gpiod_get_optional(dev, "nvidia,hp-mute", GPIOD_OUT_HIGH); in tegra_asoc_machine_probe()
450 machine->gpiod_hp_mute = gpiod; in tegra_asoc_machine_probe()
454 gpiod = devm_gpiod_get_optional(dev, "nvidia,hp-det", GPIOD_IN); in tegra_asoc_machine_probe()
455 machine->gpiod_hp_det = gpiod; in tegra_asoc_machine_probe()
459 gpiod = devm_gpiod_get_optional(dev, "nvidia,mic-det", GPIOD_IN); in tegra_asoc_machine_probe()
460 machine->gpiod_mic_det = gpiod; in tegra_asoc_machine_probe()
464 gpiod = devm_gpiod_get_optional(dev, "nvidia,spkr-en", GPIOD_OUT_LOW); in tegra_asoc_machine_probe()
465 machine->gpiod_spkr_en = gpiod; in tegra_asoc_machine_probe()
469 gpiod = devm_gpiod_get_optional(dev, "nvidia,int-mic-en", GPIOD_OUT_LOW); in tegra_asoc_machine_probe()
470 machine->gpiod_int_mic_en = gpiod; in tegra_asoc_machine_probe()
474 gpiod = devm_gpiod_get_optional(dev, "nvidia,ext-mic-en", GPIOD_OUT_LOW); in tegra_asoc_machine_probe()
475 machine->gpiod_ext_mic_en = gpiod; in tegra_asoc_machine_probe()
483 if (!card->dapm_routes) { in tegra_asoc_machine_probe()
484 err = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing"); in tegra_asoc_machine_probe()
489 if (asoc->set_ac97) { in tegra_asoc_machine_probe()
490 err = tegra_machine_register_codec(dev, asoc->codec_dev_name); in tegra_asoc_machine_probe()
494 np_ac97 = tegra_machine_parse_phandle(dev, "nvidia,ac97-controller"); in tegra_asoc_machine_probe()
498 card->dai_link->cpus->of_node = np_ac97; in tegra_asoc_machine_probe()
499 card->dai_link->platforms->of_node = np_ac97; in tegra_asoc_machine_probe()
501 np_codec = tegra_machine_parse_phandle(dev, "nvidia,audio-codec"); in tegra_asoc_machine_probe()
505 np_i2s = tegra_machine_parse_phandle(dev, "nvidia,i2s-controller"); in tegra_asoc_machine_probe()
509 card->dai_link->cpus->of_node = np_i2s; in tegra_asoc_machine_probe()
510 card->dai_link->codecs->of_node = np_codec; in tegra_asoc_machine_probe()
511 card->dai_link->platforms->of_node = np_i2s; in tegra_asoc_machine_probe()
514 if (asoc->add_common_controls) { in tegra_asoc_machine_probe()
515 card->controls = tegra_machine_controls; in tegra_asoc_machine_probe()
516 card->num_controls = ARRAY_SIZE(tegra_machine_controls); in tegra_asoc_machine_probe()
519 if (asoc->add_common_dapm_widgets) { in tegra_asoc_machine_probe()
520 card->dapm_widgets = tegra_machine_dapm_widgets; in tegra_asoc_machine_probe()
521 card->num_dapm_widgets = ARRAY_SIZE(tegra_machine_dapm_widgets); in tegra_asoc_machine_probe()
524 if (asoc->add_common_snd_ops) in tegra_asoc_machine_probe()
525 card->dai_link->ops = &tegra_machine_snd_ops; in tegra_asoc_machine_probe()
527 if (!card->owner) in tegra_asoc_machine_probe()
528 card->owner = THIS_MODULE; in tegra_asoc_machine_probe()
529 if (!card->driver_name) in tegra_asoc_machine_probe()
530 card->driver_name = "tegra"; in tegra_asoc_machine_probe()
532 machine->clk_pll_a = devm_clk_get(dev, "pll_a"); in tegra_asoc_machine_probe()
533 if (IS_ERR(machine->clk_pll_a)) { in tegra_asoc_machine_probe()
535 return PTR_ERR(machine->clk_pll_a); in tegra_asoc_machine_probe()
538 machine->clk_pll_a_out0 = devm_clk_get(dev, "pll_a_out0"); in tegra_asoc_machine_probe()
539 if (IS_ERR(machine->clk_pll_a_out0)) { in tegra_asoc_machine_probe()
541 return PTR_ERR(machine->clk_pll_a_out0); in tegra_asoc_machine_probe()
544 machine->clk_cdev1 = devm_clk_get(dev, "mclk"); in tegra_asoc_machine_probe()
545 if (IS_ERR(machine->clk_cdev1)) { in tegra_asoc_machine_probe()
547 return PTR_ERR(machine->clk_cdev1); in tegra_asoc_machine_probe()
554 if (!of_property_present(dev->of_node, "assigned-clock-parents") && in tegra_asoc_machine_probe()
558 dev_warn(dev, "Configuring clocks for a legacy device-tree\n"); in tegra_asoc_machine_probe()
559 dev_warn(dev, "Please update DT to use assigned-clock-parents\n"); in tegra_asoc_machine_probe()
567 err = clk_set_parent(clk_extern1, machine->clk_pll_a_out0); in tegra_asoc_machine_probe()
585 machine->clk_cdev1 = clk_out_1; in tegra_asoc_machine_probe()
588 if (asoc->set_ac97) { in tegra_asoc_machine_probe()
593 err = clk_set_rate(machine->clk_pll_a, 73728000); in tegra_asoc_machine_probe()
599 err = clk_set_rate(machine->clk_pll_a_out0, 24576000); in tegra_asoc_machine_probe()
605 machine->set_baseclock = 73728000; in tegra_asoc_machine_probe()
606 machine->set_mclk = 24576000; in tegra_asoc_machine_probe()
610 * FIXME: There is some unknown dependency between audio MCLK disable in tegra_asoc_machine_probe()
611 * and suspend-resume functionality on Tegra30, although audio MCLK is in tegra_asoc_machine_probe()
612 * only needed for audio. in tegra_asoc_machine_probe()
614 err = clk_prepare_enable(machine->clk_cdev1); in tegra_asoc_machine_probe()
632 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8753-hifi")),
662 return snd_soc_dapm_force_enable_pin(&rtd->card->dapm, "Mic Bias"); in tegra_wm9712_init()
667 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-hifi")),
687 .codec_dev_name = "wm9712-codec",
807 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "tlv320aic23-hifi")),
820 .name = "tegra-trimslice",
841 struct snd_soc_card *card = rtd->card; in tegra_rt5677_init()
848 snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS1"); in tegra_rt5677_init()
855 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5677-aif1")),
889 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5640-aif1")),
922 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "alc5632-hifi")),
951 /* RT5631 machine */
955 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5631-hifi")),
959 .name = "RT5631",
960 .stream_name = "RT5631 PCM",
969 .components = "codec:rt5631",
986 { .compatible = "nvidia,tegra-audio-trimslice", .data = &tegra_trimslice_data },
987 { .compatible = "nvidia,tegra-audio-max98090", .data = &tegra_max98090_data },
988 { .compatible = "nvidia,tegra-audio-max98088", .data = &tegra_max98088_data },
989 { .compatible = "nvidia,tegra-audio-max98089", .data = &tegra_max98088_data },
990 { .compatible = "nvidia,tegra-audio-sgtl5000", .data = &tegra_sgtl5000_data },
991 { .compatible = "nvidia,tegra-audio-wm9712", .data = &tegra_wm9712_data },
992 { .compatible = "nvidia,tegra-audio-wm8753", .data = &tegra_wm8753_data },
993 { .compatible = "nvidia,tegra-audio-rt5677", .data = &tegra_rt5677_data },
994 { .compatible = "nvidia,tegra-audio-rt5640", .data = &tegra_rt5640_data },
995 { .compatible = "nvidia,tegra-audio-alc5632", .data = &tegra_rt5632_data },
996 { .compatible = "nvidia,tegra-audio-rt5631", .data = &tegra_rt5631_data },
1003 .name = "tegra-audio",
1022 MODULE_DESCRIPTION("Tegra machine ASoC driver");