Lines Matching +full:codec +full:- +full:aif2
1 // SPDX-License-Identifier: GPL-2.0-only
3 // ALSA SoC Audio driver for CS47L92 codec
5 // Copyright (C) 2016-2019 Cirrus Logic, Inc. and
23 #include <linux/irqchip/irq-madera.h>
33 #define DRV_NAME "cs47l92-codec"
60 struct madera_priv *priv = &cs47l92->core; in cs47l92_put_demux()
61 struct madera *madera = priv->madera; in cs47l92_put_demux()
62 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in cs47l92_put_demux()
67 if (ucontrol->value.enumerated.item[0] > e->items - 1) in cs47l92_put_demux()
68 return -EINVAL; in cs47l92_put_demux()
70 mux = ucontrol->value.enumerated.item[0]; in cs47l92_put_demux()
74 ep_sel = mux << e->shift_l; in cs47l92_put_demux()
82 ret = regmap_read(madera->regmap, MADERA_OUTPUT_ENABLES_1, &cur); in cs47l92_put_demux()
84 dev_warn(madera->dev, "Failed to read outputs: %d\n", ret); in cs47l92_put_demux()
87 ret = regmap_update_bits(madera->regmap, MADERA_OUTPUT_ENABLES_1, in cs47l92_put_demux()
90 dev_warn(madera->dev, "Failed to disable outputs: %d\n", ret); in cs47l92_put_demux()
94 ret = regmap_update_bits(madera->regmap, MADERA_OUTPUT_ENABLES_1, in cs47l92_put_demux()
97 dev_err(madera->dev, "Failed to set OUT3 demux: %d\n", ret); in cs47l92_put_demux()
99 out_mono = madera->pdata.codec.out_mono[2 + mux]; in cs47l92_put_demux()
103 dev_warn(madera->dev, in cs47l92_put_demux()
107 ret = regmap_update_bits(madera->regmap, MADERA_OUTPUT_ENABLES_1, in cs47l92_put_demux()
110 dev_warn(madera->dev, "Failed to restore outputs: %d\n", ret); in cs47l92_put_demux()
124 dev_err(madera->dev, "Failed to update demux power state: %d\n", ret); in cs47l92_put_demux()
145 snd_soc_dapm_to_component(w->dapm); in cs47l92_adsp_power_ev()
147 struct madera_priv *priv = &cs47l92->core; in cs47l92_adsp_power_ev()
148 struct madera *madera = priv->madera; in cs47l92_adsp_power_ev()
152 ret = regmap_read(madera->regmap, MADERA_DSP_CLOCK_2, &freq); in cs47l92_adsp_power_ev()
154 dev_err(madera->dev, in cs47l92_adsp_power_ev()
161 ret = madera_set_adsp_clk(&cs47l92->core, w->shift, freq); in cs47l92_adsp_power_ev()
177 snd_soc_dapm_to_component(w->dapm); in cs47l92_outclk_ev()
179 struct madera_priv *priv = &cs47l92->core; in cs47l92_outclk_ev()
180 struct madera *madera = priv->madera; in cs47l92_outclk_ev()
184 ret = regmap_read(madera->regmap, MADERA_OUTPUT_RATE_1, &val); in cs47l92_outclk_ev()
186 dev_err(madera->dev, "Failed to read OUTCLK source: %d\n", ret); in cs47l92_outclk_ev()
196 val -= (MADERA_OUTCLK_MCLK1 - MADERA_MCLK1); in cs47l92_outclk_ev()
200 ret = clk_prepare_enable(madera->mclk[val].clk); in cs47l92_outclk_ev()
205 clk_disable_unprepare(madera->mclk[val].clk); in cs47l92_outclk_ev()
1430 { "AIF2 Capture", NULL, "AIF2TX1" },
1431 { "AIF2 Capture", NULL, "AIF2TX2" },
1432 { "AIF2 Capture", NULL, "AIF2TX3" },
1433 { "AIF2 Capture", NULL, "AIF2TX4" },
1434 { "AIF2 Capture", NULL, "AIF2TX5" },
1435 { "AIF2 Capture", NULL, "AIF2TX6" },
1436 { "AIF2 Capture", NULL, "AIF2TX7" },
1437 { "AIF2 Capture", NULL, "AIF2TX8" },
1439 { "AIF2RX1", NULL, "AIF2 Playback" },
1440 { "AIF2RX2", NULL, "AIF2 Playback" },
1441 { "AIF2RX3", NULL, "AIF2 Playback" },
1442 { "AIF2RX4", NULL, "AIF2 Playback" },
1443 { "AIF2RX5", NULL, "AIF2 Playback" },
1444 { "AIF2RX6", NULL, "AIF2 Playback" },
1445 { "AIF2RX7", NULL, "AIF2 Playback" },
1446 { "AIF2RX8", NULL, "AIF2 Playback" },
1481 { "AIF2 Playback", NULL, "SYSCLK" },
1488 { "AIF2 Capture", NULL, "SYSCLK" },
1683 return madera_fllhj_set_refclk(&cs47l92->fll[0], source, fref, in cs47l92_set_fll()
1686 return madera_fllhj_set_refclk(&cs47l92->fll[1], source, fref, in cs47l92_set_fll()
1689 return -EINVAL; in cs47l92_set_fll()
1699 .name = "cs47l92-aif1",
1721 .name = "cs47l92-aif2",
1725 .stream_name = "AIF2 Playback",
1732 .stream_name = "AIF2 Capture",
1743 .name = "cs47l92-aif3",
1765 .name = "cs47l92-slim1",
1784 .name = "cs47l92-slim2",
1803 .name = "cs47l92-slim3",
1822 .name = "cs47l92-cpu-trace",
1833 .name = "cs47l92-dsp-trace",
1847 struct snd_soc_pcm_runtime *rtd = stream->private_data; in cs47l92_open()
1849 struct madera_priv *priv = &cs47l92->core; in cs47l92_open()
1850 struct madera *madera = priv->madera; in cs47l92_open()
1853 if (strcmp(snd_soc_rtd_to_codec(rtd, 0)->name, "cs47l92-dsp-trace") == 0) { in cs47l92_open()
1856 dev_err(madera->dev, in cs47l92_open()
1858 snd_soc_rtd_to_codec(rtd, 0)->name); in cs47l92_open()
1859 return -EINVAL; in cs47l92_open()
1862 return wm_adsp_compr_open(&priv->adsp[n_adsp], stream); in cs47l92_open()
1868 struct madera_priv *priv = &cs47l92->core; in cs47l92_adsp2_irq()
1869 struct madera *madera = priv->madera; in cs47l92_adsp2_irq()
1872 ret = wm_adsp_compr_handle_irq(&priv->adsp[0]); in cs47l92_adsp2_irq()
1873 if (ret == -ENODEV) { in cs47l92_adsp2_irq()
1874 dev_err(madera->dev, "Spurious compressed data IRQ\n"); in cs47l92_adsp2_irq()
1891 struct madera *madera = cs47l92->core.madera; in cs47l92_component_probe()
1894 snd_soc_component_init_regmap(component, madera->regmap); in cs47l92_component_probe()
1896 mutex_lock(&madera->dapm_ptr_lock); in cs47l92_component_probe()
1897 madera->dapm = snd_soc_component_get_dapm(component); in cs47l92_component_probe()
1898 mutex_unlock(&madera->dapm_ptr_lock); in cs47l92_component_probe()
1918 return wm_adsp2_component_probe(&cs47l92->core.adsp[0], component); in cs47l92_component_probe()
1924 struct madera *madera = cs47l92->core.madera; in cs47l92_component_remove()
1926 mutex_lock(&madera->dapm_ptr_lock); in cs47l92_component_remove()
1927 madera->dapm = NULL; in cs47l92_component_remove()
1928 mutex_unlock(&madera->dapm_ptr_lock); in cs47l92_component_remove()
1930 wm_adsp2_component_remove(&cs47l92->core.adsp[0], component); in cs47l92_component_remove()
1975 struct madera *madera = dev_get_drvdata(pdev->dev.parent); in cs47l92_probe()
1982 if (!madera->irq_dev) { in cs47l92_probe()
1983 dev_dbg(&pdev->dev, "irqchip driver not ready\n"); in cs47l92_probe()
1984 return -EPROBE_DEFER; in cs47l92_probe()
1987 cs47l92 = devm_kzalloc(&pdev->dev, sizeof(struct cs47l92), GFP_KERNEL); in cs47l92_probe()
1989 return -ENOMEM; in cs47l92_probe()
1993 cs47l92->core.madera = madera; in cs47l92_probe()
1994 cs47l92->core.dev = &pdev->dev; in cs47l92_probe()
1995 cs47l92->core.num_inputs = 8; in cs47l92_probe()
1997 ret = madera_core_init(&cs47l92->core); in cs47l92_probe()
2005 dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret); in cs47l92_probe()
2011 dev_warn(&pdev->dev, "Failed to set DSP IRQ wake: %d\n", ret); in cs47l92_probe()
2013 cs47l92->core.adsp[0].part = "cs47l92"; in cs47l92_probe()
2014 cs47l92->core.adsp[0].cs_dsp.num = 1; in cs47l92_probe()
2015 cs47l92->core.adsp[0].cs_dsp.type = WMFW_ADSP2; in cs47l92_probe()
2016 cs47l92->core.adsp[0].cs_dsp.rev = 2; in cs47l92_probe()
2017 cs47l92->core.adsp[0].cs_dsp.dev = madera->dev; in cs47l92_probe()
2018 cs47l92->core.adsp[0].cs_dsp.regmap = madera->regmap_32bit; in cs47l92_probe()
2020 cs47l92->core.adsp[0].cs_dsp.base = MADERA_DSP1_CONFIG_1; in cs47l92_probe()
2021 cs47l92->core.adsp[0].cs_dsp.mem = cs47l92_dsp1_regions; in cs47l92_probe()
2022 cs47l92->core.adsp[0].cs_dsp.num_mems = ARRAY_SIZE(cs47l92_dsp1_regions); in cs47l92_probe()
2024 cs47l92->core.adsp[0].cs_dsp.lock_regions = CS_ADSP2_REGION_1_9; in cs47l92_probe()
2026 ret = wm_adsp2_init(&cs47l92->core.adsp[0]); in cs47l92_probe()
2030 ret = madera_init_bus_error_irq(&cs47l92->core, 0, wm_adsp2_bus_error); in cs47l92_probe()
2034 madera_init_fll(madera, 1, MADERA_FLL1_CONTROL_1 - 1, in cs47l92_probe()
2035 &cs47l92->fll[0]); in cs47l92_probe()
2036 madera_init_fll(madera, 2, MADERA_FLL2_CONTROL_1 - 1, in cs47l92_probe()
2037 &cs47l92->fll[1]); in cs47l92_probe()
2040 madera_init_dai(&cs47l92->core, i); in cs47l92_probe()
2044 regmap_update_bits(madera->regmap, cs47l92_digital_vu[i], in cs47l92_probe()
2047 pm_runtime_enable(&pdev->dev); in cs47l92_probe()
2048 pm_runtime_idle(&pdev->dev); in cs47l92_probe()
2050 ret = devm_snd_soc_register_component(&pdev->dev, in cs47l92_probe()
2055 dev_err(&pdev->dev, "Failed to register component: %d\n", ret); in cs47l92_probe()
2062 pm_runtime_disable(&pdev->dev); in cs47l92_probe()
2063 madera_free_bus_error_irq(&cs47l92->core, 0); in cs47l92_probe()
2065 wm_adsp2_remove(&cs47l92->core.adsp[0]); in cs47l92_probe()
2070 madera_core_free(&cs47l92->core); in cs47l92_probe()
2079 pm_runtime_disable(&pdev->dev); in cs47l92_remove()
2081 madera_free_bus_error_irq(&cs47l92->core, 0); in cs47l92_remove()
2082 wm_adsp2_remove(&cs47l92->core.adsp[0]); in cs47l92_remove()
2084 madera_set_irq_wake(cs47l92->core.madera, MADERA_IRQ_DSP_IRQ1, 0); in cs47l92_remove()
2085 madera_free_irq(cs47l92->core.madera, MADERA_IRQ_DSP_IRQ1, cs47l92); in cs47l92_remove()
2087 madera_core_free(&cs47l92->core); in cs47l92_remove()
2092 .name = "cs47l92-codec",
2100 MODULE_SOFTDEP("pre: madera irq-madera arizona-micsupp");
2104 MODULE_ALIAS("platform:cs47l92-codec");