Lines Matching +full:dsp +full:- +full:aif1

1 // SPDX-License-Identifier: GPL-2.0-only
3 * bytcr_wm5102.c - ASoc Machine driver for Intel Baytrail platforms with a
8 * Copyright (C) 2014-2020 Intel Corp
27 #include <sound/soc-acpi.h>
29 #include "../atom/sst-atom-controls.h"
51 /* Note these values are pre-shifted for easy use of setting quirks */
59 static int quirk_override = -1;
61 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
102 struct snd_soc_card *card = w->dapm->card; in byt_wm5102_spkvdd_power_event()
105 gpiod_set_value_cansleep(priv->spkvdd_en_gpio, in byt_wm5102_spkvdd_power_event()
113 struct snd_soc_component *codec_component = codec_dai->component; in byt_wm5102_prepare_and_enable_pll1()
114 struct byt_wm5102_private *priv = snd_soc_card_get_drvdata(codec_component->card); in byt_wm5102_prepare_and_enable_pll1()
126 priv->mclk_freq, rate * sr_mult); in byt_wm5102_prepare_and_enable_pll1()
128 dev_err(codec_component->dev, "Error setting PLL: %d\n", ret); in byt_wm5102_prepare_and_enable_pll1()
136 dev_err(codec_component->dev, "Error setting SYSCLK: %d\n", ret); in byt_wm5102_prepare_and_enable_pll1()
143 dev_err(codec_component->dev, "Error setting clock: %d\n", ret); in byt_wm5102_prepare_and_enable_pll1()
153 struct snd_soc_dapm_context *dapm = w->dapm; in platform_clock_control()
154 struct snd_soc_card *card = dapm->card; in platform_clock_control()
159 codec_dai = snd_soc_card_get_codec_dai(card, "wm5102-aif1"); in platform_clock_control()
161 dev_err(card->dev, "Error codec DAI not found\n"); in platform_clock_control()
162 return -EIO; in platform_clock_control()
166 ret = clk_prepare_enable(priv->mclk); in platform_clock_control()
168 dev_err(card->dev, "Error enabling MCLK: %d\n", ret); in platform_clock_control()
173 dev_err(card->dev, "Error setting codec sysclk: %d\n", ret); in platform_clock_control()
178 * The WM5102 has a separate 32KHz clock for jack-detect in platform_clock_control()
180 * platform clock which is the source-clock for the PLL. in platform_clock_control()
183 clk_disable_unprepare(priv->mclk); in platform_clock_control()
215 * is connected, as the MICBIAS is applied after the CTIA/OMTP cross-switch.
223 {"AIF1 Playback", NULL, "ssp0 Tx"},
226 {"ssp0 Rx", NULL, "AIF1 Capture"},
230 {"AIF1 Playback", NULL, "ssp2 Tx"},
235 {"ssp2 Rx", NULL, "AIF1 Capture"},
285 struct snd_soc_card *card = runtime->card; in byt_wm5102_init()
287 struct snd_soc_component *component = snd_soc_rtd_to_codec(runtime, 0)->component; in byt_wm5102_init()
291 card->dapm.idle_bias_off = true; in byt_wm5102_init()
296 dev_err(card->dev, "Error adding card controls: %d\n", ret); in byt_wm5102_init()
310 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_wm5102_init()
324 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_wm5102_init()
335 ret = snd_soc_dapm_add_routes(&card->dapm, custom_map, num_routes); in byt_wm5102_init()
340 priv->mclk_freq = 19200000; in byt_wm5102_init()
342 priv->mclk_freq = 25000000; in byt_wm5102_init()
352 ret = clk_prepare_enable(priv->mclk); in byt_wm5102_init()
354 clk_disable_unprepare(priv->mclk); in byt_wm5102_init()
356 ret = clk_set_rate(priv->mclk, priv->mclk_freq); in byt_wm5102_init()
358 dev_err(card->dev, "Error setting MCLK rate: %d\n", ret); in byt_wm5102_init()
365 &priv->jack, byt_wm5102_pins, in byt_wm5102_init()
368 dev_err(card->dev, "Error creating jack: %d\n", ret); in byt_wm5102_init()
372 snd_soc_component_set_jack(component, &priv->jack, NULL); in byt_wm5102_init()
386 /* The DSP will convert the FE rate to 48k, stereo */ in byt_wm5102_codec_fixup()
387 rate->min = 48000; in byt_wm5102_codec_fixup()
388 rate->max = 48000; in byt_wm5102_codec_fixup()
389 channels->min = 2; in byt_wm5102_codec_fixup()
390 channels->max = 2; in byt_wm5102_codec_fixup()
393 /* set SSP2 to 24-bit */ in byt_wm5102_codec_fixup()
397 /* set SSP0 to 16-bit */ in byt_wm5102_codec_fixup()
404 * with explicit setting to I2S 2ch 16-bit. The word length is set with in byt_wm5102_codec_fixup()
412 dev_err(rtd->dev, "Error setting format to I2S: %d\n", ret); in byt_wm5102_codec_fixup()
418 dev_err(rtd->dev, "Error setting I2S config: %d\n", ret); in byt_wm5102_codec_fixup()
427 return snd_pcm_hw_constraint_single(substream->runtime, in byt_wm5102_aif1_startup()
439 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
442 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
445 DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
450 * Note there is no need to overwrite the codec-name as is done in
451 * other bytcr machine drivers, because the codec is a MFD child-dev.
453 "wm5102-codec",
454 "wm5102-aif1")));
457 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
470 .name = "Deep-Buffer Audio Port",
471 .stream_name = "Deep-Buffer Audio",
482 * Yet its name is always kept as "SSP2-Codec" because the SOF
483 * tplg files hardcode "SSP2-Codec" even in byt-foo-ssp0.tplg.
485 .name = "SSP2-Codec",
497 #define SOF_CARD_NAME "bytcht wm5102" /* card name will be 'sof-bytcht wm5102' */
500 #define CARD_NAME "bytcr-wm5102"
515 static char byt_wm5102_components[64]; /* = "cfg-spk:* cfg-int-mic:* cfg-hs-mic:* ..." */
523 struct device *dev = &pdev->dev; in snd_byt_wm5102_mc_probe()
535 return -ENOMEM; in snd_byt_wm5102_mc_probe()
538 priv->mclk = devm_clk_get(dev, "pmc_plt_clk_3"); in snd_byt_wm5102_mc_probe()
539 if (IS_ERR(priv->mclk)) in snd_byt_wm5102_mc_probe()
540 return dev_err_probe(dev, PTR_ERR(priv->mclk), "getting pmc_plt_clk_3\n"); in snd_byt_wm5102_mc_probe()
544 * 1. Get codec-device-name in snd_byt_wm5102_mc_probe()
545 * 2. Get codec-device in snd_byt_wm5102_mc_probe()
546 * 3. Get GPIO from codec-device in snd_byt_wm5102_mc_probe()
548 mach = dev->platform_data; in snd_byt_wm5102_mc_probe()
549 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_byt_wm5102_mc_probe()
551 snprintf(codec_name, sizeof(codec_name), "spi-%s", acpi_dev_name(adev)); in snd_byt_wm5102_mc_probe()
560 return -EPROBE_DEFER; in snd_byt_wm5102_mc_probe()
563 priv->spkvdd_en_gpio = gpiod_get(codec_dev, "wlf,spkvdd-ena", GPIOD_OUT_LOW); in snd_byt_wm5102_mc_probe()
566 if (IS_ERR(priv->spkvdd_en_gpio)) { in snd_byt_wm5102_mc_probe()
567 ret = PTR_ERR(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_probe()
569 * The spkvdd gpio-lookup is registered by: drivers/mfd/arizona-spi.c, in snd_byt_wm5102_mc_probe()
570 * so -ENOENT means that arizona-spi hasn't probed yet. in snd_byt_wm5102_mc_probe()
572 if (ret == -ENOENT) in snd_byt_wm5102_mc_probe()
573 ret = -EPROBE_DEFER; in snd_byt_wm5102_mc_probe()
575 return dev_err_probe(dev, ret, "getting spkvdd-GPIO\n"); in snd_byt_wm5102_mc_probe()
588 if (quirk_override != -1) { in snd_byt_wm5102_mc_probe()
596 "cfg-spk:%s cfg-intmic:%s cfg-hsmic:%s", in snd_byt_wm5102_mc_probe()
605 !strcmp(byt_wm5102_dais[i].codecs->name, in snd_byt_wm5102_mc_probe()
606 "wm5102-codec")) { in snd_byt_wm5102_mc_probe()
614 platform_name = mach->mach_params.platform; in snd_byt_wm5102_mc_probe()
621 byt_wm5102_dais[dai_index].cpus->dai_name = "ssp2-port"; in snd_byt_wm5102_mc_probe()
623 /* set card and driver name and pm-ops */ in snd_byt_wm5102_mc_probe()
628 dev->driver->pm = &snd_soc_pm_ops; in snd_byt_wm5102_mc_probe()
645 gpiod_put(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_probe()
654 gpiod_put(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_remove()