Lines Matching +full:aif1 +full:- +full:pins

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"
29 #define CHT_CODEC_DAI "rt5670-aif1"
38 /* Headset jack detection DAPM pins */
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()
79 dev_err(card->dev, "can't set codec pll: %d\n", ret); in platform_clock_control()
87 dev_err(card->dev, "can't set codec sysclk: %d\n", ret); in platform_clock_control()
99 if (ctx->mclk) in platform_clock_control()
100 clk_disable_unprepare(ctx->mclk); in platform_clock_control()
133 {"AIF1 Playback", NULL, "ssp0 Tx"},
136 {"ssp0 Rx", NULL, "AIF1 Capture"},
140 {"AIF1 Playback", NULL, "ssp2 Tx"},
145 {"ssp2 Rx", NULL, "AIF1 Capture"},
166 dev_err(rtd->dev, "can't set codec pll: %d\n", ret); in cht_aif1_hw_params()
175 dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); in cht_aif1_hw_params()
184 { "headset-gpios", &headset_gpios, 1 },
192 struct snd_soc_component *component = codec_dai->component; in cht_codec_init()
193 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); in cht_codec_init()
195 if (devm_acpi_dev_add_driver_gpios(component->dev, cht_rt5672_gpios)) in cht_codec_init()
196 dev_warn(runtime->dev, "Unable to add GPIO mapping table\n"); in cht_codec_init()
212 if (ctx->use_ssp0) { in cht_codec_init()
213 ret = snd_soc_dapm_add_routes(&runtime->card->dapm, in cht_codec_init()
217 ret = snd_soc_dapm_add_routes(&runtime->card->dapm, in cht_codec_init()
224 ret = snd_soc_card_jack_new_pins(runtime->card, "Headset", in cht_codec_init()
227 &ctx->headset, in cht_codec_init()
233 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_0, KEY_PLAYPAUSE); in cht_codec_init()
234 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_1, KEY_VOLUMEUP); in cht_codec_init()
235 snd_jack_set_key(ctx->headset.jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); in cht_codec_init()
237 rt5670_set_jack_detect(component, &ctx->headset); in cht_codec_init()
238 if (ctx->mclk) { in cht_codec_init()
249 ret = clk_prepare_enable(ctx->mclk); in cht_codec_init()
251 clk_disable_unprepare(ctx->mclk); in cht_codec_init()
253 ret = clk_set_rate(ctx->mclk, CHT_PLAT_CLK_3_HZ); in cht_codec_init()
256 dev_err(runtime->dev, "unable to set MCLK rate\n"); in cht_codec_init()
266 struct cht_mc_private *ctx = snd_soc_card_get_drvdata(rtd->card); in cht_codec_fixup()
274 rate->min = rate->max = 48000; in cht_codec_fixup()
275 channels->min = channels->max = 2; in cht_codec_fixup()
277 if (ctx->use_ssp0) { in cht_codec_fixup()
278 /* set SSP0 to 16-bit */ in cht_codec_fixup()
282 /* set SSP2 to 24-bit */ in cht_codec_fixup()
288 * The default mode for the cpu-dai is TDM 4 slot. The default mode in cht_codec_fixup()
289 * for the codec-dai is I2S. So we need to either set the cpu-dai to in cht_codec_fixup()
290 * I2S mode to match the codec-dai, or set the codec-dai to TDM 4 slot in cht_codec_fixup()
293 * to SSP2. The second piggy-backed, output-only codec is inside the in cht_codec_fixup()
294 * keyboard-dock (which has extra speakers). Unlike the main rt5672 in cht_codec_fixup()
298 * for TDM on any cht-bsw-rt5672 designs. So we use I2S 2ch everywhere. in cht_codec_fixup()
305 dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret); in cht_codec_fixup()
311 dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); in cht_codec_fixup()
320 return snd_pcm_hw_constraint_single(substream->runtime, in cht_aif1_startup()
336 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
339 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
342 DAILINK_COMP_ARRAY(COMP_CPU("ssp2-port")));
344 DAILINK_COMP_ARRAY(COMP_CODEC("i2c-10EC5670:00",
345 "rt5670-aif1")));
348 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
363 .name = "Deep-Buffer Audio Port",
364 .stream_name = "Deep-Buffer Audio",
374 /* SSP2 - Codec */
375 .name = "SSP2-Codec",
393 if (!strncmp(component->name, in cht_suspend_pre()
394 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_suspend_pre()
396 dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); in cht_suspend_pre()
410 if (!strncmp(component->name, in cht_resume_post()
411 ctx->codec_name, sizeof(ctx->codec_name))) { in cht_resume_post()
413 dev_dbg(component->dev, "enabling jack detect for resume.\n"); in cht_resume_post()
423 #define SOF_CARD_NAME "bytcht rt5672" /* card name will be 'sof-bytcht rt5672' */
426 #define CARD_NAME "cht-bsw-rt5672"
444 #define RT5672_I2C_DEFAULT "i2c-10EC5670:00"
450 struct snd_soc_acpi_mach *mach = pdev->dev.platform_data; in snd_cht_mc_probe()
457 drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); in snd_cht_mc_probe()
459 return -ENOMEM; in snd_cht_mc_probe()
461 strcpy(drv->codec_name, RT5672_I2C_DEFAULT); in snd_cht_mc_probe()
465 if (!strcmp(cht_dailink[i].codecs->name, RT5672_I2C_DEFAULT)) { in snd_cht_mc_probe()
472 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_cht_mc_probe()
474 snprintf(drv->codec_name, sizeof(drv->codec_name), in snd_cht_mc_probe()
475 "i2c-%s", acpi_dev_name(adev)); in snd_cht_mc_probe()
476 put_device(&adev->dev); in snd_cht_mc_probe()
477 cht_dailink[dai_index].codecs->name = drv->codec_name; in snd_cht_mc_probe()
481 if (soc_intel_is_byt() && mach->mach_params.acpi_ipc_irq_index == 0) { in snd_cht_mc_probe()
482 cht_dailink[dai_index].cpus->dai_name = "ssp0-port"; in snd_cht_mc_probe()
483 drv->use_ssp0 = true; in snd_cht_mc_probe()
487 snd_soc_card_cht.dev = &pdev->dev; in snd_cht_mc_probe()
488 platform_name = mach->mach_params.platform; in snd_cht_mc_probe()
497 drv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); in snd_cht_mc_probe()
498 if (IS_ERR(drv->mclk)) { in snd_cht_mc_probe()
499 dev_err(&pdev->dev, in snd_cht_mc_probe()
501 PTR_ERR(drv->mclk)); in snd_cht_mc_probe()
502 return PTR_ERR(drv->mclk); in snd_cht_mc_probe()
506 sof_parent = snd_soc_acpi_sof_parent(&pdev->dev); in snd_cht_mc_probe()
519 pdev->dev.driver->pm = &snd_soc_pm_ops; in snd_cht_mc_probe()
522 ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); in snd_cht_mc_probe()
524 dev_err(&pdev->dev, in snd_cht_mc_probe()
534 .name = "cht-bsw-rt5672",
544 MODULE_ALIAS("platform:cht-bsw-rt5672");