Lines Matching +full:event +full:- +full:deep
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
25 #include <sound/soc-acpi.h>
27 #include "../atom/sst-atom-controls.h"
41 struct snd_kcontrol *kcontrol, int event) in byt_wm5102_spkvdd_power_event() argument
43 struct snd_soc_card *card = w->dapm->card; in byt_wm5102_spkvdd_power_event()
46 gpiod_set_value_cansleep(priv->spkvdd_en_gpio, in byt_wm5102_spkvdd_power_event()
47 !!SND_SOC_DAPM_EVENT_ON(event)); in byt_wm5102_spkvdd_power_event()
54 struct snd_soc_component *codec_component = codec_dai->component; in byt_wm5102_prepare_and_enable_pll1()
68 dev_err(codec_component->dev, "Error setting PLL: %d\n", ret); in byt_wm5102_prepare_and_enable_pll1()
76 dev_err(codec_component->dev, "Error setting SYSCLK: %d\n", ret); in byt_wm5102_prepare_and_enable_pll1()
83 dev_err(codec_component->dev, "Error setting clock: %d\n", ret); in byt_wm5102_prepare_and_enable_pll1()
91 struct snd_kcontrol *k, int event) in platform_clock_control() argument
93 struct snd_soc_dapm_context *dapm = w->dapm; in platform_clock_control()
94 struct snd_soc_card *card = dapm->card; in platform_clock_control()
99 codec_dai = snd_soc_card_get_codec_dai(card, "wm5102-aif1"); in platform_clock_control()
101 dev_err(card->dev, "Error codec DAI not found\n"); in platform_clock_control()
102 return -EIO; in platform_clock_control()
105 if (SND_SOC_DAPM_EVENT_ON(event)) { in platform_clock_control()
106 ret = clk_prepare_enable(priv->mclk); in platform_clock_control()
108 dev_err(card->dev, "Error enabling MCLK: %d\n", ret); in platform_clock_control()
113 dev_err(card->dev, "Error setting codec sysclk: %d\n", ret); in platform_clock_control()
118 * The WM5102 has a separate 32KHz clock for jack-detect in platform_clock_control()
120 * platform clock which is the source-clock for the PLL. in platform_clock_control()
123 clk_disable_unprepare(priv->mclk); in platform_clock_control()
162 * is connected, as the MICBIAS is applied after the CTIA/OMTP cross-switch.
195 struct snd_soc_card *card = runtime->card; in byt_wm5102_init()
197 struct snd_soc_component *component = asoc_rtd_to_codec(runtime, 0)->component; in byt_wm5102_init()
200 card->dapm.idle_bias_off = true; in byt_wm5102_init()
205 dev_err(card->dev, "Error adding card controls: %d\n", ret); in byt_wm5102_init()
217 ret = clk_prepare_enable(priv->mclk); in byt_wm5102_init()
219 clk_disable_unprepare(priv->mclk); in byt_wm5102_init()
221 ret = clk_set_rate(priv->mclk, MCLK_FREQ); in byt_wm5102_init()
223 dev_err(card->dev, "Error setting MCLK rate: %d\n", ret); in byt_wm5102_init()
230 &priv->jack, byt_wm5102_pins, in byt_wm5102_init()
233 dev_err(card->dev, "Error creating jack: %d\n", ret); in byt_wm5102_init()
237 snd_soc_component_set_jack(component, &priv->jack, NULL); in byt_wm5102_init()
252 rate->min = 48000; in byt_wm5102_codec_fixup()
253 rate->max = 48000; in byt_wm5102_codec_fixup()
254 channels->min = 2; in byt_wm5102_codec_fixup()
255 channels->max = 2; in byt_wm5102_codec_fixup()
257 /* set SSP0 to 16-bit */ in byt_wm5102_codec_fixup()
262 * with explicit setting to I2S 2ch 16-bit. The word length is set with in byt_wm5102_codec_fixup()
270 dev_err(rtd->dev, "Error setting format to I2S: %d\n", ret); in byt_wm5102_codec_fixup()
276 dev_err(rtd->dev, "Error setting I2S config: %d\n", ret); in byt_wm5102_codec_fixup()
285 return snd_pcm_hw_constraint_single(substream->runtime, in byt_wm5102_aif1_startup()
297 DAILINK_COMP_ARRAY(COMP_CPU("media-cpu-dai")));
300 DAILINK_COMP_ARRAY(COMP_CPU("deepbuffer-cpu-dai")));
303 DAILINK_COMP_ARRAY(COMP_CPU("ssp0-port")));
308 * Note there is no need to overwrite the codec-name as is done in
309 * other bytcr machine drivers, because the codec is a MFD child-dev.
311 "wm5102-codec",
312 "wm5102-aif1")));
315 DAILINK_COMP_ARRAY(COMP_PLATFORM("sst-mfld-platform")));
330 .name = "Deep-Buffer Audio Port",
331 .stream_name = "Deep-Buffer Audio",
341 * This must be named SSP2-Codec even though this machine driver
344 * as "SSP2-Codec". The SOF tplg files hardcode the "SSP2-Codec" even
345 * in the byt-foo-ssp0.tplg versions because the other machine-drivers
346 * use "SSP2-Codec" even when SSP0 is used.
348 .name = "SSP2-Codec",
362 #define SOF_CARD_NAME "bytcht wm5102" /* card name will be 'sof-bytcht wm5102' */
365 #define CARD_NAME "bytcr-wm5102"
383 struct device *dev = &pdev->dev; in snd_byt_wm5102_mc_probe()
394 return -ENOMEM; in snd_byt_wm5102_mc_probe()
397 priv->mclk = devm_clk_get(dev, "pmc_plt_clk_3"); in snd_byt_wm5102_mc_probe()
398 if (IS_ERR(priv->mclk)) in snd_byt_wm5102_mc_probe()
399 return dev_err_probe(dev, PTR_ERR(priv->mclk), "getting pmc_plt_clk_3\n"); in snd_byt_wm5102_mc_probe()
403 * 1. Get codec-device-name in snd_byt_wm5102_mc_probe()
404 * 2. Get codec-device in snd_byt_wm5102_mc_probe()
405 * 3. Get GPIO from codec-device in snd_byt_wm5102_mc_probe()
407 mach = dev->platform_data; in snd_byt_wm5102_mc_probe()
408 adev = acpi_dev_get_first_match_dev(mach->id, NULL, -1); in snd_byt_wm5102_mc_probe()
410 dev_err(dev, "Error cannot find acpi-dev for codec\n"); in snd_byt_wm5102_mc_probe()
411 return -ENOENT; in snd_byt_wm5102_mc_probe()
413 snprintf(codec_name, sizeof(codec_name), "spi-%s", acpi_dev_name(adev)); in snd_byt_wm5102_mc_probe()
414 put_device(&adev->dev); in snd_byt_wm5102_mc_probe()
418 return -EPROBE_DEFER; in snd_byt_wm5102_mc_probe()
421 priv->spkvdd_en_gpio = gpiod_get(codec_dev, "wlf,spkvdd-ena", GPIOD_OUT_LOW); in snd_byt_wm5102_mc_probe()
424 if (IS_ERR(priv->spkvdd_en_gpio)) { in snd_byt_wm5102_mc_probe()
425 ret = PTR_ERR(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_probe()
427 * The spkvdd gpio-lookup is registered by: drivers/mfd/arizona-spi.c, in snd_byt_wm5102_mc_probe()
428 * so -ENOENT means that arizona-spi hasn't probed yet. in snd_byt_wm5102_mc_probe()
430 if (ret == -ENOENT) in snd_byt_wm5102_mc_probe()
431 ret = -EPROBE_DEFER; in snd_byt_wm5102_mc_probe()
433 return dev_err_probe(dev, ret, "getting spkvdd-GPIO\n"); in snd_byt_wm5102_mc_probe()
438 platform_name = mach->mach_params.platform; in snd_byt_wm5102_mc_probe()
443 /* set card and driver name and pm-ops */ in snd_byt_wm5102_mc_probe()
448 dev->driver->pm = &snd_soc_pm_ops; in snd_byt_wm5102_mc_probe()
465 gpiod_put(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_probe()
474 gpiod_put(priv->spkvdd_en_gpio); in snd_byt_wm5102_mc_remove()