Lines Matching +full:platform +full:- +full:pll
1 // SPDX-License-Identifier: GPL-2.0-only
3 * cht_bsw_rt5672.c - ASoc Machine driver for Intel Cherryview-based platforms
21 #include <sound/soc-acpi.h>
23 #include "../atom/sst-atom-controls.h"
24 #include "../common/soc-intel-quirks.h"
27 /* The platform clock #3 outputs 19.2Mhz clock to codec as I2S MCLK */
29 #define CHT_CODEC_DAI "rt5670-aif1"
53 struct snd_soc_dapm_context *dapm = w->dapm; in platform_clock_control()
54 struct snd_soc_card *card = dapm->card; in platform_clock_control()
61 dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); in platform_clock_control()
62 return -EIO; in platform_clock_control()
66 if (ctx->mclk) { in platform_clock_control()
67 ret = clk_prepare_enable(ctx->mclk); in platform_clock_control()
69 dev_err(card->dev, in platform_clock_control()
75 /* set codec PLL source to the 19.2MHz platform clock (MCLK) */ in platform_clock_control()
79 dev_err(card->dev, "can't set codec pll: %d\n", ret); in platform_clock_control()
83 /* set codec sysclk source to PLL */ in platform_clock_control()
87 dev_err(card->dev, "can't set codec sysclk: %d\n", ret); in platform_clock_control()
92 * PLL will be off when idle and MCLK will also be off by ACPI in platform_clock_control()
99 dev_err(card->dev, "failed to set codec sysclk: %d\n", ret); in platform_clock_control()
103 if (ctx->mclk) in platform_clock_control()
104 clk_disable_unprepare(ctx->mclk); in platform_clock_control()
114 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
130 {"Headphone", NULL, "Platform Clock"},
131 {"Headset Mic", NULL, "Platform Clock"},
132 {"Int Mic", NULL, "Platform Clock"},
133 {"Ext Spk", NULL, "Platform Clock"},
166 /* set codec PLL source to the 19.2MHz platform clock (MCLK) */ in cht_aif1_hw_params()
170 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); in cht_aif1_hw_params()
174 /* set codec sysclk source to PLL */ in cht_aif1_hw_params()
179 dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); in cht_aif1_hw_params()
188 { "headset-gpios", &headset_gpios, 1 },
196 struct snd_soc_component *component = codec_dai->component; in cht_codec_init()
197 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); in cht_codec_init()
199 if (devm_acpi_dev_add_driver_gpios(component->dev, cht_rt5672_gpios)) in cht_codec_init()
200 dev_warn(runtime->dev, "Unable to add GPIO mapping table\n"); in cht_codec_init()
216 if (ctx->use_ssp0) { in cht_codec_init()
217 ret = snd_soc_dapm_add_routes(&runtime->card->dapm, in cht_codec_init()
221 ret = snd_soc_dapm_add_routes(&runtime->card->dapm, in cht_codec_init()
228 ret = snd_soc_card_jack_new_pins(runtime->card, "Headset", in cht_codec_init()
231 &ctx->headset, in cht_codec_init()
237 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in cht_codec_init()
238 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_1, KEY_VOLUMEUP); in cht_codec_init()
239 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); in cht_codec_init()
241 rt5670_set_jack_detect(component, &ctx->headset); in cht_codec_init()
242 if (ctx->mclk) { in cht_codec_init()
253 ret = clk_prepare_enable(ctx->mclk); in cht_codec_init()
255 clk_disable_unprepare(ctx->mclk); in cht_codec_init()
257 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); in cht_codec_init()
260 dev_err(runtime->dev, "unable to set MCLK rate\n"); in cht_codec_init()
270 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(rtd->card); in cht_codec_fixup()
278 rate->min = rate->max = 48000; in cht_codec_fixup()
279 channels->min = channels->max = 2; in cht_codec_fixup()
281 if (ctx->use_ssp0) { in cht_codec_fixup()
282 /* set SSP0 to 16-bit */ in cht_codec_fixup()
286 /* set SSP2 to 24-bit */ in cht_codec_fixup()
292 * The default mode for the cpu-dai is TDM 4 slot. The default mode in cht_codec_fixup()
293 * for the codec-dai is I2S. So we need to either set the cpu-dai to in cht_codec_fixup()
294 * I2S mode to match the codec-dai, or set the codec-dai to TDM 4 slot in cht_codec_fixup()
297 * to SSP2. The second piggy-backed, output-only codec is inside the in cht_codec_fixup()
298 * keyboard-dock (which has extra speakers). Unlike the main rt5672 in cht_codec_fixup()
302 * for TDM on any cht-bsw-rt5672 designs. So we use I2S 2ch everywhere. in cht_codec_fixup()
309 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in cht_codec_fixup()
315 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); in cht_codec_fixup()
324 return snd_pcm_hw_constraint_single(substream->runtime, in cht_aif1_startup()
340 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
343 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
346 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
348 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5670:00",
349 "rt5670-aif1")));
351 SND_SOC_DAILINK_DEF(platform,
352 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
364 SND_SOC_DAILINK_REG(media, dummy, platform),
367 .name = "Deep-Buffer Audio Port",
368 .stream_name = "Deep-Buffer Audio",
373 SND_SOC_DAILINK_REG(deepbuffer, dummy, platform),
378 /* SSP2 - Codec */
379 .name = "SSP2-Codec",
387 SND_SOC_DAILINK_REG(ssp2_port, ssp2_codec, platform),
397 if (!strncmp(component->name, in cht_suspend_pre()
398 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_suspend_pre()
400 dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); in cht_suspend_pre()
414 if (!strncmp(component->name, in cht_resume_post()
415 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_resume_post()
417 dev_dbg(component->dev, "enabling jack detect for resume.\n"); in cht_resume_post()
427 #define SOF_CARD_NAME "bytcht rt5672" /* card name will be 'sof-bytcht rt5672' */
430 #define CARD_NAME "cht-bsw-rt5672"
448 #define RT5672_I2C_DEFAULT "i2c-10EC5670:00"
454 struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; in snd_cht_mc_probe()
461 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); in snd_cht_mc_probe()
463 return -ENOMEM; in snd_cht_mc_probe()
465 strcpy(drv->codec_name, RT5672_I2C_DEFAULT); in snd_cht_mc_probe()
470 !strcmp(cht_dailink[i].codecs->name, RT5672_I2C_DEFAULT)) { in snd_cht_mc_probe()
477 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_cht_mc_probe()
479 snprintf(drv->codec_name, sizeof(drv->codec_name), in snd_cht_mc_probe()
480 "i2c-%s", acpi_dev_name(adev)); in snd_cht_mc_probe()
481 cht_dailink[dai_index].codecs->name = drv->codec_name; in snd_cht_mc_probe()
483 dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); in snd_cht_mc_probe()
484 return -ENOENT; in snd_cht_mc_probe()
490 if (soc_intel_is_byt() && mach->mach_params.acpi_ipc_irq_index == 0) { in snd_cht_mc_probe()
491 cht_dailink[dai_index].cpus->dai_name = "ssp0-port"; in snd_cht_mc_probe()
492 drv->use_ssp0 = true; in snd_cht_mc_probe()
495 /* override platform name, if required */ in snd_cht_mc_probe()
496 snd_soc_card_cht.dev = &pdev->dev; in snd_cht_mc_probe()
497 platform_name = mach->mach_params.platform; in snd_cht_mc_probe()
506 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); in snd_cht_mc_probe()
507 if (IS_ERR(drv->mclk)) { in snd_cht_mc_probe()
508 dev_err(&pdev->dev, in snd_cht_mc_probe()
510 PTR_ERR(drv->mclk)); in snd_cht_mc_probe()
511 return PTR_ERR(drv->mclk); in snd_cht_mc_probe()
515 sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); in snd_cht_mc_probe()
528 pdev->dev.driver->pm = &snd_soc_pm_ops; in snd_cht_mc_probe()
531 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); in snd_cht_mc_probe()
533 dev_err(&pdev->dev, in snd_cht_mc_probe()
543 .name = "cht-bsw-rt5672",
553 MODULE_ALIAS("platform:cht-bsw-rt5672");