Lines Matching +full:codec +full:- +full:aif1
1 // SPDX-License-Identifier: GPL-2.0-only
3 * cht-bsw-rt5645.c - ASoc Machine driver for Intel Cherryview-based platforms
4 * Cherrytrail and Braswell, with RT5645 codec.
25 #include <sound/soc-acpi.h>
27 #include "../atom/sst-atom-controls.h"
28 #include "../common/soc-intel-quirks.h"
31 #define CHT_CODEC_DAI1 "rt5645-aif1"
32 #define CHT_CODEC_DAI2 "rt5645-aif2"
47 #define CHT_RT5645_SSP2_AIF2 BIT(16) /* default is using AIF1 */
69 struct snd_soc_dapm_context *dapm = w->dapm; in platform_clock_control()
70 struct snd_soc_card *card = dapm->card; in platform_clock_control()
80 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); in platform_clock_control()
81 return -EIO; in platform_clock_control()
85 ret = clk_prepare_enable(ctx->mclk); in platform_clock_control()
87 dev_err(card->dev, in platform_clock_control()
92 /* Set codec sysclk source to its internal clock because codec PLL will in platform_clock_control()
93 * be off when idle and MCLK will also be off when codec is in platform_clock_control()
94 * runtime suspended. Codec needs clock for jack detection and button in platform_clock_control()
100 dev_err(card->dev, "can't set codec sysclk: %d\n", ret); in platform_clock_control()
104 clk_disable_unprepare(ctx->mclk); in platform_clock_control()
156 {"AIF1 Playback", NULL, "ssp2 Tx"},
161 {"ssp2 Rx", NULL, "AIF1 Capture"},
174 {"AIF1 Playback", NULL, "ssp0 Tx"},
177 {"ssp0 Rx", NULL, "AIF1 Capture"},
213 /* set codec PLL source to the 19.2MHz platform clock (MCLK) */ in cht_aif1_hw_params()
217 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); in cht_aif1_hw_params()
224 dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); in cht_aif1_hw_params()
233 cht_rt5645_quirk = (unsigned long)id->driver_data; in cht_rt5645_quirk_cb()
252 struct snd_soc_card *card = runtime->card; in cht_codec_init()
253 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); in cht_codec_init()
254 struct snd_soc_component *component = snd_soc_rtd_to_codec(runtime, 0)->component; in cht_codec_init()
278 ret = snd_soc_dapm_add_routes(&card->dapm, in cht_codec_init()
282 ret = snd_soc_dapm_add_routes(&card->dapm, in cht_codec_init()
286 ret = snd_soc_dapm_add_routes(&card->dapm, in cht_codec_init()
290 ret = snd_soc_dapm_add_routes(&card->dapm, in cht_codec_init()
297 if (ctx->acpi_card->codec_type == CODEC_TYPE_RT5650) in cht_codec_init()
304 ret = snd_soc_card_jack_new_pins(runtime->card, "Headset", jack_type, in cht_codec_init()
305 &ctx->jack, cht_bsw_jack_pins, in cht_codec_init()
308 dev_err(runtime->dev, "Headset jack creation failed %d\n", ret); in cht_codec_init()
312 rt5645_set_jack_detect(component, &ctx->jack, &ctx->jack, &ctx->jack); in cht_codec_init()
325 ret = clk_prepare_enable(ctx->mclk); in cht_codec_init()
327 clk_disable_unprepare(ctx->mclk); in cht_codec_init()
329 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); in cht_codec_init()
332 dev_err(runtime->dev, "unable to set MCLK rate\n"); in cht_codec_init()
347 rate->min = rate->max = 48000; in cht_codec_fixup()
348 channels->min = channels->max = 2; in cht_codec_fixup()
353 /* set SSP0 to 16-bit */ in cht_codec_fixup()
358 * with explicit setting to I2S 2ch 16-bit. The word length is set with in cht_codec_fixup()
367 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in cht_codec_fixup()
377 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in cht_codec_fixup()
383 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); in cht_codec_fixup()
389 /* set SSP2 to 24-bit */ in cht_codec_fixup()
400 dev_err(rtd->dev, "can't set format to TDM %d\n", ret); in cht_codec_fixup()
407 dev_err(rtd->dev, "can't set codec TDM slot %d\n", ret); in cht_codec_fixup()
416 return snd_pcm_hw_constraint_single(substream->runtime, in cht_aif1_startup()
432 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
435 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
438 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
440 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5645:00", "rt5645-aif1")));
443 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
455 .name = "Deep-Buffer Audio Port",
456 .stream_name = "Deep-Buffer Audio",
463 /* CODEC<->CODEC link */
466 .name = "SSP2-Codec",
476 /* use space before codec name to simplify card ID, and simplify driver name */
477 #define SOF_CARD_RT5645_NAME "bytcht rt5645" /* card name 'sof-bytcht rt5645' */
478 #define SOF_CARD_RT5650_NAME "bytcht rt5650" /* card name 'sof-bytcht rt5650' */
521 u64 aif_value; /* 1: AIF1, 2: AIF2 */
541 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); in snd_cht_mc_probe()
543 return -ENOMEM; in snd_cht_mc_probe()
545 mach = pdev->dev.platform_data; in snd_cht_mc_probe()
549 (!strncmp(snd_soc_cards[i].codec_id, mach->id, 8))) { in snd_cht_mc_probe()
550 dev_dbg(&pdev->dev, in snd_cht_mc_probe()
551 "found codec %s\n", snd_soc_cards[i].codec_id); in snd_cht_mc_probe()
553 drv->acpi_card = &snd_soc_cards[i]; in snd_cht_mc_probe()
560 dev_err(&pdev->dev, "No matching HID found in supported list\n"); in snd_cht_mc_probe()
561 return -ENODEV; in snd_cht_mc_probe()
564 card->dev = &pdev->dev; in snd_cht_mc_probe()
566 /* set correct codec name */ in snd_cht_mc_probe()
569 !strcmp(cht_dailink[i].codecs->name, in snd_cht_mc_probe()
570 "i2c-10EC5645:00")) { in snd_cht_mc_probe()
575 /* fixup codec name based on HID */ in snd_cht_mc_probe()
576 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_cht_mc_probe()
579 "i2c-%s", acpi_dev_name(adev)); in snd_cht_mc_probe()
580 cht_dailink[dai_index].codecs->name = cht_rt5645_codec_name; in snd_cht_mc_probe()
582 dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); in snd_cht_mc_probe()
583 return -ENOENT; in snd_cht_mc_probe()
590 return -EPROBE_DEFER; in snd_cht_mc_probe()
600 if (mach->mach_params.acpi_ipc_irq_index == 0) in snd_cht_mc_probe()
610 * with the codec driver/pdata are non-existent in snd_cht_mc_probe()
615 /* format specified: 2 64-bit integers */ in snd_cht_mc_probe()
630 pkg_found = snd_soc_acpi_find_package_from_hid(mach->id, in snd_cht_mc_probe()
634 dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); in snd_cht_mc_probe()
637 dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n"); in snd_cht_mc_probe()
640 dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n"); in snd_cht_mc_probe()
646 /* no BIOS indications, assume SSP0-AIF2 connection */ in snd_cht_mc_probe()
653 log_quirks(&pdev->dev); in snd_cht_mc_probe()
657 cht_dailink[dai_index].codecs->dai_name = "rt5645-aif2"; in snd_cht_mc_probe()
661 cht_dailink[dai_index].cpus->dai_name = "ssp0-port"; in snd_cht_mc_probe()
664 platform_name = mach->mach_params.platform; in snd_cht_mc_probe()
676 drv->mclk = devm_clk_get(&pdev->dev, mclk_name); in snd_cht_mc_probe()
677 if (IS_ERR(drv->mclk)) { in snd_cht_mc_probe()
678 dev_err(&pdev->dev, "Failed to get MCLK from %s: %ld\n", in snd_cht_mc_probe()
679 mclk_name, PTR_ERR(drv->mclk)); in snd_cht_mc_probe()
680 return PTR_ERR(drv->mclk); in snd_cht_mc_probe()
685 sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); in snd_cht_mc_probe()
702 pdev->dev.driver->pm = &snd_soc_pm_ops; in snd_cht_mc_probe()
704 ret_val = devm_snd_soc_register_card(&pdev->dev, card); in snd_cht_mc_probe()
706 dev_err(&pdev->dev, in snd_cht_mc_probe()
716 .name = "cht-bsw-rt5645",
726 MODULE_ALIAS("platform:cht-bsw-rt5645");