Lines Matching full:dmic
3 // tegra210_dmic.c - Tegra210 DMIC driver
45 struct tegra210_dmic *dmic = dev_get_drvdata(dev); in tegra210_dmic_runtime_suspend() local
47 regcache_cache_only(dmic->regmap, true); in tegra210_dmic_runtime_suspend()
48 regcache_mark_dirty(dmic->regmap); in tegra210_dmic_runtime_suspend()
50 clk_disable_unprepare(dmic->clk_dmic); in tegra210_dmic_runtime_suspend()
57 struct tegra210_dmic *dmic = dev_get_drvdata(dev); in tegra210_dmic_runtime_resume() local
60 err = clk_prepare_enable(dmic->clk_dmic); in tegra210_dmic_runtime_resume()
62 dev_err(dev, "failed to enable DMIC clock, err: %d\n", err); in tegra210_dmic_runtime_resume()
66 regcache_cache_only(dmic->regmap, false); in tegra210_dmic_runtime_resume()
67 regcache_sync(dmic->regmap); in tegra210_dmic_runtime_resume()
76 struct tegra210_dmic *dmic = snd_soc_dai_get_drvdata(dai); in tegra210_dmic_hw_params() local
88 switch (dmic->ch_select) { in tegra210_dmic_hw_params()
97 dev_err(dai->dev, "invalid DMIC client channels\n"); in tegra210_dmic_hw_params()
104 * DMIC clock rate is a multiple of 'Over Sampling Ratio' and in tegra210_dmic_hw_params()
107 clk_rate = (DMIC_OSR_FACTOR << dmic->osr_val) * srate; in tegra210_dmic_hw_params()
109 err = clk_set_rate(dmic->clk_dmic, clk_rate); in tegra210_dmic_hw_params()
111 dev_err(dai->dev, "can't set DMIC clock rate %u, err: %d\n", in tegra210_dmic_hw_params()
116 regmap_update_bits(dmic->regmap, in tegra210_dmic_hw_params()
124 (dmic->lrsel << LRSEL_POL_SHIFT) | in tegra210_dmic_hw_params()
125 (dmic->osr_val << OSR_SHIFT) | in tegra210_dmic_hw_params()
126 ((dmic->ch_select + 1) << CH_SEL_SHIFT)); in tegra210_dmic_hw_params()
132 if (dmic->boost_gain) in tegra210_dmic_hw_params()
133 gain_q23 = div_u64(gain_q23 * dmic->boost_gain, 100); in tegra210_dmic_hw_params()
135 regmap_write(dmic->regmap, TEGRA210_DMIC_LP_FILTER_GAIN, in tegra210_dmic_hw_params()
151 cif_conf.mono_conv = dmic->mono_to_stereo; in tegra210_dmic_hw_params()
152 cif_conf.stereo_conv = dmic->stereo_to_mono; in tegra210_dmic_hw_params()
154 tegra_set_cif(dmic->regmap, TEGRA210_DMIC_TX_CIF_CTRL, &cif_conf); in tegra210_dmic_hw_params()
163 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_boost_gain() local
165 ucontrol->value.integer.value[0] = dmic->boost_gain; in tegra210_dmic_get_boost_gain()
174 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_boost_gain() local
177 if (value == dmic->boost_gain) in tegra210_dmic_put_boost_gain()
180 dmic->boost_gain = value; in tegra210_dmic_put_boost_gain()
189 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_ch_select() local
191 ucontrol->value.enumerated.item[0] = dmic->ch_select; in tegra210_dmic_get_ch_select()
200 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_ch_select() local
203 if (value == dmic->ch_select) in tegra210_dmic_put_ch_select()
206 dmic->ch_select = value; in tegra210_dmic_put_ch_select()
215 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_mono_to_stereo() local
217 ucontrol->value.enumerated.item[0] = dmic->mono_to_stereo; in tegra210_dmic_get_mono_to_stereo()
226 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_mono_to_stereo() local
229 if (value == dmic->mono_to_stereo) in tegra210_dmic_put_mono_to_stereo()
232 dmic->mono_to_stereo = value; in tegra210_dmic_put_mono_to_stereo()
241 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_stereo_to_mono() local
243 ucontrol->value.enumerated.item[0] = dmic->stereo_to_mono; in tegra210_dmic_get_stereo_to_mono()
252 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_stereo_to_mono() local
255 if (value == dmic->stereo_to_mono) in tegra210_dmic_put_stereo_to_mono()
258 dmic->stereo_to_mono = value; in tegra210_dmic_put_stereo_to_mono()
267 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_osr_val() local
269 ucontrol->value.enumerated.item[0] = dmic->osr_val; in tegra210_dmic_get_osr_val()
278 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_osr_val() local
281 if (value == dmic->osr_val) in tegra210_dmic_put_osr_val()
284 dmic->osr_val = value; in tegra210_dmic_put_osr_val()
293 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_get_pol_sel() local
295 ucontrol->value.enumerated.item[0] = dmic->lrsel; in tegra210_dmic_get_pol_sel()
304 struct tegra210_dmic *dmic = snd_soc_component_get_drvdata(comp); in tegra210_dmic_put_pol_sel() local
307 if (value == dmic->lrsel) in tegra210_dmic_put_pol_sel()
310 dmic->lrsel = value; in tegra210_dmic_put_pol_sel()
321 .name = "DMIC-CIF",
332 .name = "DMIC-DAP",
489 struct tegra210_dmic *dmic; in tegra210_dmic_probe() local
493 dmic = devm_kzalloc(dev, sizeof(*dmic), GFP_KERNEL); in tegra210_dmic_probe()
494 if (!dmic) in tegra210_dmic_probe()
497 dmic->osr_val = DMIC_OSR_64; in tegra210_dmic_probe()
498 dmic->ch_select = DMIC_CH_SELECT_STEREO; in tegra210_dmic_probe()
499 dmic->lrsel = DMIC_LRSEL_LEFT; in tegra210_dmic_probe()
500 dmic->boost_gain = 0; in tegra210_dmic_probe()
501 dmic->stereo_to_mono = 0; /* "CH0" */ in tegra210_dmic_probe()
503 dev_set_drvdata(dev, dmic); in tegra210_dmic_probe()
505 dmic->clk_dmic = devm_clk_get(dev, "dmic"); in tegra210_dmic_probe()
506 if (IS_ERR(dmic->clk_dmic)) { in tegra210_dmic_probe()
507 dev_err(dev, "can't retrieve DMIC clock\n"); in tegra210_dmic_probe()
508 return PTR_ERR(dmic->clk_dmic); in tegra210_dmic_probe()
515 dmic->regmap = devm_regmap_init_mmio(dev, regs, in tegra210_dmic_probe()
517 if (IS_ERR(dmic->regmap)) { in tegra210_dmic_probe()
519 return PTR_ERR(dmic->regmap); in tegra210_dmic_probe()
522 regcache_cache_only(dmic->regmap, true); in tegra210_dmic_probe()
528 dev_err(dev, "can't register DMIC component, err: %d\n", err); in tegra210_dmic_probe()
550 { .compatible = "nvidia,tegra210-dmic" },
557 .name = "tegra210-dmic",
567 MODULE_DESCRIPTION("Tegra210 ASoC DMIC driver");