Lines Matching +full:ext +full:- +full:clk +full:- +full:pin
1 // SPDX-License-Identifier: GPL-2.0-only
3 * cht-bsw-rt5645.c - ASoc Machine driver for Intel Cherryview-based platforms
18 #include <linux/clk.h>
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"
43 struct clk *mclk;
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()
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()
115 SND_SOC_DAPM_SPK("Ext Spk", NULL),
129 {"Ext Spk", NULL, "SPOL"},
130 {"Ext Spk", NULL, "SPOR"},
137 {"Ext Spk", NULL, "Platform Clock"},
147 {"Ext Spk", NULL, "SPOL"},
148 {"Ext Spk", NULL, "SPOR"},
152 {"Ext Spk", NULL, "Platform Clock"},
192 SOC_DAPM_PIN_SWITCH("Ext Spk"),
197 .pin = "Headphone",
201 .pin = "Headset Mic",
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")));
457 .name = "Deep-Buffer Audio Port",
458 .stream_name = "Deep-Buffer Audio",
465 /* CODEC<->CODEC link */
468 .name = "SSP2-Codec",
481 #define SOF_CARD_RT5645_NAME "bytcht rt5645" /* card name 'sof-bytcht rt5645' */
482 #define SOF_CARD_RT5650_NAME "bytcht rt5650" /* card name 'sof-bytcht rt5650' */
545 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); in snd_cht_mc_probe()
547 return -ENOMEM; in snd_cht_mc_probe()
549 mach = pdev->dev.platform_data; in snd_cht_mc_probe()
553 (!strncmp(snd_soc_cards[i].codec_id, mach->id, 8))) { in snd_cht_mc_probe()
554 dev_dbg(&pdev->dev, in snd_cht_mc_probe()
557 drv->acpi_card = &snd_soc_cards[i]; in snd_cht_mc_probe()
564 dev_err(&pdev->dev, "No matching HID found in supported list\n"); in snd_cht_mc_probe()
565 return -ENODEV; in snd_cht_mc_probe()
568 card->dev = &pdev->dev; in snd_cht_mc_probe()
573 !strcmp(cht_dailink[i].codecs->name, in snd_cht_mc_probe()
574 "i2c-10EC5645:00")) { in snd_cht_mc_probe()
580 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_cht_mc_probe()
583 "i2c-%s", acpi_dev_name(adev)); in snd_cht_mc_probe()
584 cht_dailink[dai_index].codecs->name = cht_rt5645_codec_name; in snd_cht_mc_probe()
586 dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); in snd_cht_mc_probe()
587 return -ENOENT; in snd_cht_mc_probe()
594 return -EPROBE_DEFER; in snd_cht_mc_probe()
604 if (mach->mach_params.acpi_ipc_irq_index == 0) in snd_cht_mc_probe()
614 * with the codec driver/pdata are non-existent in snd_cht_mc_probe()
619 /* format specified: 2 64-bit integers */ in snd_cht_mc_probe()
634 pkg_found = snd_soc_acpi_find_package_from_hid(mach->id, in snd_cht_mc_probe()
638 dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); in snd_cht_mc_probe()
641 dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n"); in snd_cht_mc_probe()
644 dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n"); in snd_cht_mc_probe()
650 /* no BIOS indications, assume SSP0-AIF2 connection */ in snd_cht_mc_probe()
657 log_quirks(&pdev->dev); in snd_cht_mc_probe()
661 cht_dailink[dai_index].codecs->dai_name = "rt5645-aif2"; in snd_cht_mc_probe()
665 cht_dailink[dai_index].cpus->dai_name = "ssp0-port"; in snd_cht_mc_probe()
668 platform_name = mach->mach_params.platform; in snd_cht_mc_probe()
680 drv->mclk = devm_clk_get(&pdev->dev, mclk_name); in snd_cht_mc_probe()
681 if (IS_ERR(drv->mclk)) { in snd_cht_mc_probe()
682 dev_err(&pdev->dev, "Failed to get MCLK from %s: %ld\n", in snd_cht_mc_probe()
683 mclk_name, PTR_ERR(drv->mclk)); in snd_cht_mc_probe()
684 return PTR_ERR(drv->mclk); in snd_cht_mc_probe()
689 sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); in snd_cht_mc_probe()
706 pdev->dev.driver->pm = &snd_soc_pm_ops; in snd_cht_mc_probe()
708 ret_val = devm_snd_soc_register_card(&pdev->dev, card); in snd_cht_mc_probe()
710 dev_err(&pdev->dev, in snd_cht_mc_probe()
720 .name = "cht-bsw-rt5645",
730 MODULE_ALIAS("platform:cht-bsw-rt5645");