1 // SPDX-License-Identifier: GPL-2.0-only
3 * tegra_asoc_machine.c - Universal ASoC machine driver for NVIDIA Tegra boards.
7 #include <linux/export.h>
8 #include <linux/gpio/consumer.h>
9 #include <linux/module.h>
11 #include <linux/of_device.h>
12 #include <linux/platform_device.h>
13 #include <linux/slab.h>
15 #include <sound/core.h>
16 #include <sound/jack.h>
17 #include <sound/pcm.h>
18 #include <sound/pcm_params.h>
19 #include <sound/soc.h>
21 #include "tegra_asoc_machine.h"
25 static struct snd_soc_jack tegra_machine_hp_jack;
27 static struct snd_soc_jack_pin tegra_machine_hp_jack_pins[] = {
28 { .pin = "Headphone", .mask = SND_JACK_HEADPHONE },
29 { .pin = "Headphones", .mask = SND_JACK_HEADPHONE },
32 static struct snd_soc_jack_gpio tegra_machine_hp_jack_gpio = {
33 .name = "Headphones detection",
34 .report = SND_JACK_HEADPHONE,
40 static struct snd_soc_jack tegra_machine_headset_jack;
42 static struct snd_soc_jack_pin tegra_machine_headset_jack_pins[] = {
43 { .pin = "Headset Mic", .mask = SND_JACK_MICROPHONE },
44 { .pin = "Headset Stereophone", .mask = SND_JACK_HEADPHONE },
47 static struct snd_soc_jack_gpio tegra_machine_headset_jack_gpio = {
48 .name = "Headset detection",
49 .report = SND_JACK_HEADSET,
55 static struct snd_soc_jack tegra_machine_mic_jack;
57 static struct snd_soc_jack_pin tegra_machine_mic_jack_pins[] = {
58 { .pin = "Mic Jack", .mask = SND_JACK_MICROPHONE },
59 { .pin = "Headset Mic", .mask = SND_JACK_MICROPHONE },
62 static struct snd_soc_jack_gpio tegra_machine_mic_jack_gpio = {
63 .name = "Mic detection",
64 .report = SND_JACK_MICROPHONE,
68 static int tegra_machine_event(struct snd_soc_dapm_widget *w,
69 struct snd_kcontrol *k, int event)
71 struct snd_soc_dapm_context *dapm = w->dapm;
72 struct tegra_machine *machine = snd_soc_card_get_drvdata(dapm->card);
74 if (!strcmp(w->name, "Int Spk") || !strcmp(w->name, "Speakers"))
75 gpiod_set_value_cansleep(machine->gpiod_spkr_en,
76 SND_SOC_DAPM_EVENT_ON(event));
78 if (!strcmp(w->name, "Mic Jack"))
79 gpiod_set_value_cansleep(machine->gpiod_ext_mic_en,
80 SND_SOC_DAPM_EVENT_ON(event));
82 if (!strcmp(w->name, "Int Mic"))
83 gpiod_set_value_cansleep(machine->gpiod_int_mic_en,
84 SND_SOC_DAPM_EVENT_ON(event));
86 if (!strcmp(w->name, "Headphone") || !strcmp(w->name, "Headphone Jack"))
87 gpiod_set_value_cansleep(machine->gpiod_hp_mute,
88 !SND_SOC_DAPM_EVENT_ON(event));
93 static const struct snd_soc_dapm_widget tegra_machine_dapm_widgets[] = {
94 SND_SOC_DAPM_HP("Headphone Jack", tegra_machine_event),
95 SND_SOC_DAPM_HP("Headphone", tegra_machine_event),
96 SND_SOC_DAPM_HP("Headset Stereophone", NULL),
97 SND_SOC_DAPM_HP("Headphones", NULL),
98 SND_SOC_DAPM_SPK("Speakers", tegra_machine_event),
99 SND_SOC_DAPM_SPK("Int Spk", tegra_machine_event),
100 SND_SOC_DAPM_MIC("Int Mic", tegra_machine_event),
101 SND_SOC_DAPM_MIC("Mic Jack", tegra_machine_event),
102 SND_SOC_DAPM_MIC("Internal Mic 1", NULL),
103 SND_SOC_DAPM_MIC("Internal Mic 2", NULL),
104 SND_SOC_DAPM_MIC("Headset Mic", NULL),
105 SND_SOC_DAPM_MIC("Digital Mic", NULL),
106 SND_SOC_DAPM_MIC("Mic", NULL),
107 SND_SOC_DAPM_LINE("Line In Jack", NULL),
108 SND_SOC_DAPM_LINE("Line In", NULL),
109 SND_SOC_DAPM_LINE("LineIn", NULL),
112 static const struct snd_kcontrol_new tegra_machine_controls[] = {
113 SOC_DAPM_PIN_SWITCH("Speakers"),
114 SOC_DAPM_PIN_SWITCH("Int Spk"),
115 SOC_DAPM_PIN_SWITCH("Int Mic"),
116 SOC_DAPM_PIN_SWITCH("Headset Mic"),
117 SOC_DAPM_PIN_SWITCH("Internal Mic 1"),
118 SOC_DAPM_PIN_SWITCH("Internal Mic 2"),
119 SOC_DAPM_PIN_SWITCH("Headphones"),
120 SOC_DAPM_PIN_SWITCH("Mic Jack"),
123 int tegra_asoc_machine_init(struct snd_soc_pcm_runtime *rtd)
125 struct snd_soc_card *card = rtd->card;
126 struct tegra_machine *machine = snd_soc_card_get_drvdata(card);
127 const char *jack_name;
130 if (machine->gpiod_hp_det && machine->asoc->add_hp_jack) {
131 if (machine->asoc->hp_jack_name)
132 jack_name = machine->asoc->hp_jack_name;
134 jack_name = "Headphones Jack";
136 err = snd_soc_card_jack_new_pins(card, jack_name,
138 &tegra_machine_hp_jack,
139 tegra_machine_hp_jack_pins,
140 ARRAY_SIZE(tegra_machine_hp_jack_pins));
143 "Headphones Jack creation failed: %d\n", err);
147 tegra_machine_hp_jack_gpio.desc = machine->gpiod_hp_det;
149 err = snd_soc_jack_add_gpios(&tegra_machine_hp_jack, 1,
150 &tegra_machine_hp_jack_gpio);
152 dev_err(rtd->dev, "HP GPIOs not added: %d\n", err);
155 if (machine->gpiod_hp_det && machine->asoc->add_headset_jack) {
156 err = snd_soc_card_jack_new_pins(card, "Headset Jack",
158 &tegra_machine_headset_jack,
159 tegra_machine_headset_jack_pins,
160 ARRAY_SIZE(tegra_machine_headset_jack_pins));
163 "Headset Jack creation failed: %d\n", err);
167 tegra_machine_headset_jack_gpio.desc = machine->gpiod_hp_det;
169 err = snd_soc_jack_add_gpios(&tegra_machine_headset_jack, 1,
170 &tegra_machine_headset_jack_gpio);
172 dev_err(rtd->dev, "Headset GPIOs not added: %d\n", err);
175 if (machine->gpiod_mic_det && machine->asoc->add_mic_jack) {
176 err = snd_soc_card_jack_new_pins(rtd->card, "Mic Jack",
178 &tegra_machine_mic_jack,
179 tegra_machine_mic_jack_pins,
180 ARRAY_SIZE(tegra_machine_mic_jack_pins));
182 dev_err(rtd->dev, "Mic Jack creation failed: %d\n", err);
186 tegra_machine_mic_jack_gpio.desc = machine->gpiod_mic_det;
188 err = snd_soc_jack_add_gpios(&tegra_machine_mic_jack, 1,
189 &tegra_machine_mic_jack_gpio);
191 dev_err(rtd->dev, "Mic GPIOs not added: %d\n", err);
196 EXPORT_SYMBOL_GPL(tegra_asoc_machine_init);
198 static unsigned int tegra_machine_mclk_rate_128(unsigned int srate)
203 static unsigned int tegra_machine_mclk_rate_256(unsigned int srate)
208 static unsigned int tegra_machine_mclk_rate_512(unsigned int srate)
213 static unsigned int tegra_machine_mclk_rate_12mhz(unsigned int srate)
241 static int tegra_machine_hw_params(struct snd_pcm_substream *substream,
242 struct snd_pcm_hw_params *params)
244 struct snd_soc_pcm_runtime *rtd = substream->private_data;
245 struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
246 struct snd_soc_card *card = rtd->card;
247 struct tegra_machine *machine = snd_soc_card_get_drvdata(card);
248 unsigned int srate = params_rate(params);
249 unsigned int mclk = machine->asoc->mclk_rate(srate);
250 unsigned int clk_id = machine->asoc->mclk_id;
251 unsigned int new_baseclock;
259 if (of_machine_is_compatible("nvidia,tegra20"))
260 new_baseclock = 56448000;
261 else if (of_machine_is_compatible("nvidia,tegra30"))
262 new_baseclock = 564480000;
264 new_baseclock = 282240000;
272 if (of_machine_is_compatible("nvidia,tegra20"))
273 new_baseclock = 73728000;
274 else if (of_machine_is_compatible("nvidia,tegra30"))
275 new_baseclock = 552960000;
277 new_baseclock = 368640000;
280 dev_err(card->dev, "Invalid sound rate: %u\n", srate);
284 if (new_baseclock != machine->set_baseclock ||
285 mclk != machine->set_mclk) {
286 machine->set_baseclock = 0;
287 machine->set_mclk = 0;
289 clk_disable_unprepare(machine->clk_cdev1);
291 err = clk_set_rate(machine->clk_pll_a, new_baseclock);
293 dev_err(card->dev, "Can't set pll_a rate: %d\n", err);
297 err = clk_set_rate(machine->clk_pll_a_out0, mclk);
299 dev_err(card->dev, "Can't set pll_a_out0 rate: %d\n", err);
303 /* Don't set cdev1/extern1 rate; it's locked to pll_a_out0 */
305 err = clk_prepare_enable(machine->clk_cdev1);
307 dev_err(card->dev, "Can't enable cdev1: %d\n", err);
311 machine->set_baseclock = new_baseclock;
312 machine->set_mclk = mclk;
315 err = snd_soc_dai_set_sysclk(codec_dai, clk_id, mclk, SND_SOC_CLOCK_IN);
317 dev_err(card->dev, "codec_dai clock not set: %d\n", err);
324 static const struct snd_soc_ops tegra_machine_snd_ops = {
325 .hw_params = tegra_machine_hw_params,
328 static void tegra_machine_node_release(void *of_node)
330 of_node_put(of_node);
333 static struct device_node *
334 tegra_machine_parse_phandle(struct device *dev, const char *name)
336 struct device_node *np;
339 np = of_parse_phandle(dev->of_node, name, 0);
341 dev_err(dev, "Property '%s' missing or invalid\n", name);
342 return ERR_PTR(-EINVAL);
345 err = devm_add_action_or_reset(dev, tegra_machine_node_release, np);
352 static void tegra_machine_unregister_codec(void *pdev)
354 platform_device_unregister(pdev);
357 static int tegra_machine_register_codec(struct device *dev, const char *name)
359 struct platform_device *pdev;
365 pdev = platform_device_register_simple(name, -1, NULL, 0);
367 return PTR_ERR(pdev);
369 err = devm_add_action_or_reset(dev, tegra_machine_unregister_codec,
377 int tegra_asoc_machine_probe(struct platform_device *pdev)
379 struct device_node *np_codec, *np_i2s, *np_ac97;
380 const struct tegra_asoc_data *asoc;
381 struct device *dev = &pdev->dev;
382 struct tegra_machine *machine;
383 struct snd_soc_card *card;
384 struct gpio_desc *gpiod;
387 machine = devm_kzalloc(dev, sizeof(*machine), GFP_KERNEL);
391 asoc = of_device_get_match_data(dev);
395 machine->asoc = asoc;
396 machine->mic_jack = &tegra_machine_mic_jack;
397 machine->hp_jack_gpio = &tegra_machine_hp_jack_gpio;
398 snd_soc_card_set_drvdata(card, machine);
400 gpiod = devm_gpiod_get_optional(dev, "nvidia,hp-mute", GPIOD_OUT_HIGH);
401 machine->gpiod_hp_mute = gpiod;
403 return PTR_ERR(gpiod);
405 gpiod = devm_gpiod_get_optional(dev, "nvidia,hp-det", GPIOD_IN);
406 machine->gpiod_hp_det = gpiod;
408 return PTR_ERR(gpiod);
410 gpiod = devm_gpiod_get_optional(dev, "nvidia,mic-det", GPIOD_IN);
411 machine->gpiod_mic_det = gpiod;
413 return PTR_ERR(gpiod);
415 gpiod = devm_gpiod_get_optional(dev, "nvidia,spkr-en", GPIOD_OUT_LOW);
416 machine->gpiod_spkr_en = gpiod;
418 return PTR_ERR(gpiod);
420 gpiod = devm_gpiod_get_optional(dev, "nvidia,int-mic-en", GPIOD_OUT_LOW);
421 machine->gpiod_int_mic_en = gpiod;
423 return PTR_ERR(gpiod);
425 gpiod = devm_gpiod_get_optional(dev, "nvidia,ext-mic-en", GPIOD_OUT_LOW);
426 machine->gpiod_ext_mic_en = gpiod;
428 return PTR_ERR(gpiod);
430 err = snd_soc_of_parse_card_name(card, "nvidia,model");
434 if (!card->dapm_routes) {
435 err = snd_soc_of_parse_audio_routing(card, "nvidia,audio-routing");
440 if (asoc->set_ac97) {
441 err = tegra_machine_register_codec(dev, asoc->codec_dev_name);
445 np_ac97 = tegra_machine_parse_phandle(dev, "nvidia,ac97-controller");
447 return PTR_ERR(np_ac97);
449 card->dai_link->cpus->of_node = np_ac97;
450 card->dai_link->platforms->of_node = np_ac97;
452 np_codec = tegra_machine_parse_phandle(dev, "nvidia,audio-codec");
453 if (IS_ERR(np_codec))
454 return PTR_ERR(np_codec);
456 np_i2s = tegra_machine_parse_phandle(dev, "nvidia,i2s-controller");
458 return PTR_ERR(np_i2s);
460 card->dai_link->cpus->of_node = np_i2s;
461 card->dai_link->codecs->of_node = np_codec;
462 card->dai_link->platforms->of_node = np_i2s;
465 if (asoc->add_common_controls) {
466 card->controls = tegra_machine_controls;
467 card->num_controls = ARRAY_SIZE(tegra_machine_controls);
470 if (asoc->add_common_dapm_widgets) {
471 card->dapm_widgets = tegra_machine_dapm_widgets;
472 card->num_dapm_widgets = ARRAY_SIZE(tegra_machine_dapm_widgets);
475 if (asoc->add_common_snd_ops)
476 card->dai_link->ops = &tegra_machine_snd_ops;
479 card->owner = THIS_MODULE;
480 if (!card->driver_name)
481 card->driver_name = "tegra";
483 machine->clk_pll_a = devm_clk_get(dev, "pll_a");
484 if (IS_ERR(machine->clk_pll_a)) {
485 dev_err(dev, "Can't retrieve clk pll_a\n");
486 return PTR_ERR(machine->clk_pll_a);
489 machine->clk_pll_a_out0 = devm_clk_get(dev, "pll_a_out0");
490 if (IS_ERR(machine->clk_pll_a_out0)) {
491 dev_err(dev, "Can't retrieve clk pll_a_out0\n");
492 return PTR_ERR(machine->clk_pll_a_out0);
495 machine->clk_cdev1 = devm_clk_get(dev, "mclk");
496 if (IS_ERR(machine->clk_cdev1)) {
497 dev_err(dev, "Can't retrieve clk cdev1\n");
498 return PTR_ERR(machine->clk_cdev1);
502 * If clock parents are not set in DT, configure here to use clk_out_1
503 * as mclk and extern1 as parent for Tegra30 and higher.
505 if (!of_find_property(dev->of_node, "assigned-clock-parents", NULL) &&
506 !of_machine_is_compatible("nvidia,tegra20")) {
507 struct clk *clk_out_1, *clk_extern1;
509 dev_warn(dev, "Configuring clocks for a legacy device-tree\n");
510 dev_warn(dev, "Please update DT to use assigned-clock-parents\n");
512 clk_extern1 = devm_clk_get(dev, "extern1");
513 if (IS_ERR(clk_extern1)) {
514 dev_err(dev, "Can't retrieve clk extern1\n");
515 return PTR_ERR(clk_extern1);
518 err = clk_set_parent(clk_extern1, machine->clk_pll_a_out0);
520 dev_err(dev, "Set parent failed for clk extern1\n");
524 clk_out_1 = devm_clk_get(dev, "pmc_clk_out_1");
525 if (IS_ERR(clk_out_1)) {
526 dev_err(dev, "Can't retrieve pmc_clk_out_1\n");
527 return PTR_ERR(clk_out_1);
530 err = clk_set_parent(clk_out_1, clk_extern1);
532 dev_err(dev, "Set parent failed for pmc_clk_out_1\n");
536 machine->clk_cdev1 = clk_out_1;
539 if (asoc->set_ac97) {
541 * AC97 rate is fixed at 24.576MHz and is used for both the
542 * host controller and the external codec
544 err = clk_set_rate(machine->clk_pll_a, 73728000);
546 dev_err(dev, "Can't set pll_a rate: %d\n", err);
550 err = clk_set_rate(machine->clk_pll_a_out0, 24576000);
552 dev_err(dev, "Can't set pll_a_out0 rate: %d\n", err);
556 machine->set_baseclock = 73728000;
557 machine->set_mclk = 24576000;
561 * FIXME: There is some unknown dependency between audio MCLK disable
562 * and suspend-resume functionality on Tegra30, although audio MCLK is
563 * only needed for audio.
565 err = clk_prepare_enable(machine->clk_cdev1);
567 dev_err(dev, "Can't enable cdev1: %d\n", err);
571 err = devm_snd_soc_register_card(dev, card);
577 EXPORT_SYMBOL_GPL(tegra_asoc_machine_probe);
581 SND_SOC_DAILINK_DEFS(wm8753_hifi,
582 DAILINK_COMP_ARRAY(COMP_EMPTY()),
583 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "wm8753-hifi")),
584 DAILINK_COMP_ARRAY(COMP_EMPTY()));
586 static struct snd_soc_dai_link tegra_wm8753_dai = {
588 .stream_name = "WM8753 PCM",
589 .dai_fmt = SND_SOC_DAIFMT_I2S |
590 SND_SOC_DAIFMT_NB_NF |
591 SND_SOC_DAIFMT_CBS_CFS,
592 SND_SOC_DAILINK_REG(wm8753_hifi),
595 static struct snd_soc_card snd_soc_tegra_wm8753 = {
596 .components = "codec:wm8753",
597 .dai_link = &tegra_wm8753_dai,
599 .fully_routed = true,
602 static const struct tegra_asoc_data tegra_wm8753_data = {
603 .mclk_rate = tegra_machine_mclk_rate_12mhz,
604 .card = &snd_soc_tegra_wm8753,
605 .add_common_dapm_widgets = true,
606 .add_common_snd_ops = true,
611 static int tegra_wm9712_init(struct snd_soc_pcm_runtime *rtd)
613 return snd_soc_dapm_force_enable_pin(&rtd->card->dapm, "Mic Bias");
616 SND_SOC_DAILINK_DEFS(wm9712_hifi,
617 DAILINK_COMP_ARRAY(COMP_EMPTY()),
618 DAILINK_COMP_ARRAY(COMP_CODEC("wm9712-codec", "wm9712-hifi")),
619 DAILINK_COMP_ARRAY(COMP_EMPTY()));
621 static struct snd_soc_dai_link tegra_wm9712_dai = {
623 .stream_name = "AC97 HiFi",
624 .init = tegra_wm9712_init,
625 SND_SOC_DAILINK_REG(wm9712_hifi),
628 static struct snd_soc_card snd_soc_tegra_wm9712 = {
629 .components = "codec:wm9712",
630 .dai_link = &tegra_wm9712_dai,
632 .fully_routed = true,
635 static const struct tegra_asoc_data tegra_wm9712_data = {
636 .card = &snd_soc_tegra_wm9712,
637 .add_common_dapm_widgets = true,
638 .codec_dev_name = "wm9712-codec",
642 /* MAX98090 machine */
644 SND_SOC_DAILINK_DEFS(max98090_hifi,
645 DAILINK_COMP_ARRAY(COMP_EMPTY()),
646 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "HiFi")),
647 DAILINK_COMP_ARRAY(COMP_EMPTY()));
649 static struct snd_soc_dai_link tegra_max98090_dai = {
651 .stream_name = "max98090 PCM",
652 .init = tegra_asoc_machine_init,
653 .dai_fmt = SND_SOC_DAIFMT_I2S |
654 SND_SOC_DAIFMT_NB_NF |
655 SND_SOC_DAIFMT_CBS_CFS,
656 SND_SOC_DAILINK_REG(max98090_hifi),
659 static struct snd_soc_card snd_soc_tegra_max98090 = {
660 .components = "codec:max98090",
661 .dai_link = &tegra_max98090_dai,
663 .fully_routed = true,
666 static const struct tegra_asoc_data tegra_max98090_data = {
667 .mclk_rate = tegra_machine_mclk_rate_12mhz,
668 .card = &snd_soc_tegra_max98090,
669 .hp_jack_name = "Headphones",
670 .add_common_dapm_widgets = true,
671 .add_common_controls = true,
672 .add_common_snd_ops = true,
673 .add_mic_jack = true,
677 /* SGTL5000 machine */
679 SND_SOC_DAILINK_DEFS(sgtl5000_hifi,
680 DAILINK_COMP_ARRAY(COMP_EMPTY()),
681 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "sgtl5000")),
682 DAILINK_COMP_ARRAY(COMP_EMPTY()));
684 static struct snd_soc_dai_link tegra_sgtl5000_dai = {
686 .stream_name = "HiFi",
687 .dai_fmt = SND_SOC_DAIFMT_I2S |
688 SND_SOC_DAIFMT_NB_NF |
689 SND_SOC_DAIFMT_CBS_CFS,
690 SND_SOC_DAILINK_REG(sgtl5000_hifi),
693 static struct snd_soc_card snd_soc_tegra_sgtl5000 = {
694 .components = "codec:sgtl5000",
695 .dai_link = &tegra_sgtl5000_dai,
697 .fully_routed = true,
700 static const struct tegra_asoc_data tegra_sgtl5000_data = {
701 .mclk_rate = tegra_machine_mclk_rate_12mhz,
702 .card = &snd_soc_tegra_sgtl5000,
703 .add_common_dapm_widgets = true,
704 .add_common_snd_ops = true,
707 /* TLV320AIC23 machine */
709 static const struct snd_soc_dapm_widget trimslice_dapm_widgets[] = {
710 SND_SOC_DAPM_HP("Line Out", NULL),
711 SND_SOC_DAPM_LINE("Line In", NULL),
714 static const struct snd_soc_dapm_route trimslice_audio_map[] = {
715 {"Line Out", NULL, "LOUT"},
716 {"Line Out", NULL, "ROUT"},
718 {"LLINEIN", NULL, "Line In"},
719 {"RLINEIN", NULL, "Line In"},
722 SND_SOC_DAILINK_DEFS(tlv320aic23_hifi,
723 DAILINK_COMP_ARRAY(COMP_EMPTY()),
724 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "tlv320aic23-hifi")),
725 DAILINK_COMP_ARRAY(COMP_EMPTY()));
727 static struct snd_soc_dai_link tegra_tlv320aic23_dai = {
728 .name = "TLV320AIC23",
729 .stream_name = "AIC23",
730 .dai_fmt = SND_SOC_DAIFMT_I2S |
731 SND_SOC_DAIFMT_NB_NF |
732 SND_SOC_DAIFMT_CBS_CFS,
733 SND_SOC_DAILINK_REG(tlv320aic23_hifi),
736 static struct snd_soc_card snd_soc_tegra_trimslice = {
737 .name = "tegra-trimslice",
738 .components = "codec:tlv320aic23",
739 .dai_link = &tegra_tlv320aic23_dai,
741 .dapm_widgets = trimslice_dapm_widgets,
742 .num_dapm_widgets = ARRAY_SIZE(trimslice_dapm_widgets),
743 .dapm_routes = trimslice_audio_map,
744 .num_dapm_routes = ARRAY_SIZE(trimslice_audio_map),
745 .fully_routed = true,
748 static const struct tegra_asoc_data tegra_trimslice_data = {
749 .mclk_rate = tegra_machine_mclk_rate_128,
750 .card = &snd_soc_tegra_trimslice,
751 .add_common_snd_ops = true,
756 static int tegra_rt5677_init(struct snd_soc_pcm_runtime *rtd)
758 struct snd_soc_card *card = rtd->card;
761 err = tegra_asoc_machine_init(rtd);
765 snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS1");
770 SND_SOC_DAILINK_DEFS(rt5677_aif1,
771 DAILINK_COMP_ARRAY(COMP_EMPTY()),
772 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5677-aif1")),
773 DAILINK_COMP_ARRAY(COMP_EMPTY()));
775 static struct snd_soc_dai_link tegra_rt5677_dai = {
777 .stream_name = "RT5677 PCM",
778 .init = tegra_rt5677_init,
779 .dai_fmt = SND_SOC_DAIFMT_I2S |
780 SND_SOC_DAIFMT_NB_NF |
781 SND_SOC_DAIFMT_CBS_CFS,
782 SND_SOC_DAILINK_REG(rt5677_aif1),
785 static struct snd_soc_card snd_soc_tegra_rt5677 = {
786 .components = "codec:rt5677",
787 .dai_link = &tegra_rt5677_dai,
789 .fully_routed = true,
792 static const struct tegra_asoc_data tegra_rt5677_data = {
793 .mclk_rate = tegra_machine_mclk_rate_256,
794 .card = &snd_soc_tegra_rt5677,
795 .add_common_dapm_widgets = true,
796 .add_common_controls = true,
797 .add_common_snd_ops = true,
798 .add_mic_jack = true,
804 SND_SOC_DAILINK_DEFS(rt5640_aif1,
805 DAILINK_COMP_ARRAY(COMP_EMPTY()),
806 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "rt5640-aif1")),
807 DAILINK_COMP_ARRAY(COMP_EMPTY()));
809 static struct snd_soc_dai_link tegra_rt5640_dai = {
811 .stream_name = "RT5640 PCM",
812 .init = tegra_asoc_machine_init,
813 .dai_fmt = SND_SOC_DAIFMT_I2S |
814 SND_SOC_DAIFMT_NB_NF |
815 SND_SOC_DAIFMT_CBS_CFS,
816 SND_SOC_DAILINK_REG(rt5640_aif1),
819 static struct snd_soc_card snd_soc_tegra_rt5640 = {
820 .components = "codec:rt5640",
821 .dai_link = &tegra_rt5640_dai,
823 .fully_routed = true,
826 static const struct tegra_asoc_data tegra_rt5640_data = {
827 .mclk_rate = tegra_machine_mclk_rate_256,
828 .card = &snd_soc_tegra_rt5640,
829 .add_common_dapm_widgets = true,
830 .add_common_controls = true,
831 .add_common_snd_ops = true,
837 SND_SOC_DAILINK_DEFS(rt5632_hifi,
838 DAILINK_COMP_ARRAY(COMP_EMPTY()),
839 DAILINK_COMP_ARRAY(COMP_CODEC(NULL, "alc5632-hifi")),
840 DAILINK_COMP_ARRAY(COMP_EMPTY()));
842 static struct snd_soc_dai_link tegra_rt5632_dai = {
844 .stream_name = "ALC5632 PCM",
845 .init = tegra_rt5677_init,
846 .dai_fmt = SND_SOC_DAIFMT_I2S |
847 SND_SOC_DAIFMT_NB_NF |
848 SND_SOC_DAIFMT_CBS_CFS,
849 SND_SOC_DAILINK_REG(rt5632_hifi),
852 static struct snd_soc_card snd_soc_tegra_rt5632 = {
853 .components = "codec:rt5632",
854 .dai_link = &tegra_rt5632_dai,
856 .fully_routed = true,
859 static const struct tegra_asoc_data tegra_rt5632_data = {
860 .mclk_rate = tegra_machine_mclk_rate_512,
861 .card = &snd_soc_tegra_rt5632,
862 .add_common_dapm_widgets = true,
863 .add_common_controls = true,
864 .add_common_snd_ops = true,
865 .add_headset_jack = true,
868 static const struct of_device_id tegra_machine_of_match[] = {
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 },
879 MODULE_DEVICE_TABLE(of, tegra_machine_of_match);
881 static struct platform_driver tegra_asoc_machine_driver = {
883 .name = "tegra-audio",
884 .of_match_table = tegra_machine_of_match,
885 .pm = &snd_soc_pm_ops,
887 .probe = tegra_asoc_machine_probe,
889 module_platform_driver(tegra_asoc_machine_driver);
891 MODULE_AUTHOR("Anatol Pomozov <anatol@google.com>");
892 MODULE_AUTHOR("Andrey Danin <danindrey@mail.ru>");
893 MODULE_AUTHOR("Dmitry Osipenko <digetx@gmail.com>");
894 MODULE_AUTHOR("Ion Agorria <ion@agorria.com>");
895 MODULE_AUTHOR("Leon Romanovsky <leon@leon.nu>");
896 MODULE_AUTHOR("Lucas Stach <dev@lynxeye.de>");
897 MODULE_AUTHOR("Marc Dietrich <marvin24@gmx.de>");
898 MODULE_AUTHOR("Marcel Ziswiler <marcel@ziswiler.com>");
899 MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
900 MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
901 MODULE_AUTHOR("Svyatoslav Ryhel <clamor95@gmail.com>");
902 MODULE_DESCRIPTION("Tegra machine ASoC driver");
903 MODULE_LICENSE("GPL");