Lines Matching +full:platform +full:- +full:pll
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()
124 /* Configure the FLL1 PLL before selecting it */ 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()
179 * so we can disable the PLL, followed by disabling the 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()
195 SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
204 {"Headphone", NULL, "Platform Clock"},
205 {"Headset Mic", NULL, "Platform Clock"},
206 {"Internal Mic", NULL, "Platform Clock"},
207 {"Speaker", NULL, "Platform Clock"},
215 * is connected, as the MICBIAS is applied after the CTIA/OMTP cross-switch.
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()
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")));
456 SND_SOC_DAILINK_DEF(platform,
457 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
468 SND_SOC_DAILINK_REG(media, dummy, platform),
472 .name = "Deep-Buffer Audio Port",
473 .stream_name = "Deep-Buffer Audio",
478 SND_SOC_DAILINK_REG(deepbuffer, dummy, platform),
484 * Yet its name is always kept as "SSP2-Codec" because the SOF
485 * tplg files hardcode "SSP2-Codec" even in byt-foo-ssp0.tplg.
487 .name = "SSP2-Codec",
496 SND_SOC_DAILINK_REG(ssp0_port, ssp0_codec, platform),
501 #define SOF_CARD_NAME "bytcht wm5102" /* card name will be 'sof-bytcht wm5102' */
504 #define CARD_NAME "bytcr-wm5102"
519 static char byt_wm5102_components[64]; /* = "cfg-spk:* cfg-int-mic:* cfg-hs-mic:* ..." */
527 struct device *dev = &pdev->dev; in snd_byt_wm5102_mc_probe()
539 return -ENOMEM; in snd_byt_wm5102_mc_probe()
542 priv->mclk = devm_clk_get(dev, "pmc_plt_clk_3"); in snd_byt_wm5102_mc_probe()
543 if (IS_ERR(priv->mclk)) in snd_byt_wm5102_mc_probe()
544 return dev_err_probe(dev, PTR_ERR(priv->mclk), "getting pmc_plt_clk_3\n"); in snd_byt_wm5102_mc_probe()
548 * 1. Get codec-device-name in snd_byt_wm5102_mc_probe()
549 * 2. Get codec-device in snd_byt_wm5102_mc_probe()
550 * 3. Get GPIO from codec-device in snd_byt_wm5102_mc_probe()
552 mach = dev->platform_data; in snd_byt_wm5102_mc_probe()
553 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_byt_wm5102_mc_probe()
555 snprintf(codec_name, sizeof(codec_name), "spi-%s", acpi_dev_name(adev)); in snd_byt_wm5102_mc_probe()
564 return -EPROBE_DEFER; in snd_byt_wm5102_mc_probe()
567 priv->spkvdd_en_gpio = gpiod_get(codec_dev, "wlf,spkvdd-ena", GPIOD_OUT_LOW); in snd_byt_wm5102_mc_probe()
570 if (IS_ERR(priv->spkvdd_en_gpio)) { in snd_byt_wm5102_mc_probe()
571 ret = PTR_ERR(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_probe()
573 * The spkvdd gpio-lookup is registered by: drivers/mfd/arizona-spi.c, in snd_byt_wm5102_mc_probe()
574 * so -ENOENT means that arizona-spi hasn't probed yet. in snd_byt_wm5102_mc_probe()
576 if (ret == -ENOENT) in snd_byt_wm5102_mc_probe()
577 ret = -EPROBE_DEFER; in snd_byt_wm5102_mc_probe()
579 return dev_err_probe(dev, ret, "getting spkvdd-GPIO\n"); in snd_byt_wm5102_mc_probe()
592 if (quirk_override != -1) { in snd_byt_wm5102_mc_probe()
600 "cfg-spk:%s cfg-intmic:%s cfg-hsmic:%s", in snd_byt_wm5102_mc_probe()
609 !strcmp(byt_wm5102_dais[i].codecs->name, in snd_byt_wm5102_mc_probe()
610 "wm5102-codec")) { in snd_byt_wm5102_mc_probe()
616 /* override platform name, if required */ in snd_byt_wm5102_mc_probe()
618 platform_name = mach->mach_params.platform; in snd_byt_wm5102_mc_probe()
625 byt_wm5102_dais[dai_index].cpus->dai_name = "ssp2-port"; in snd_byt_wm5102_mc_probe()
627 /* set card and driver name and pm-ops */ in snd_byt_wm5102_mc_probe()
632 dev->driver->pm = &snd_soc_pm_ops; in snd_byt_wm5102_mc_probe()
649 gpiod_put(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_probe()
658 gpiod_put(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_remove()
674 MODULE_ALIAS("platform:bytcr_wm5102");