Lines Matching +full:dmic +full:- +full:clkrate

1 // SPDX-License-Identifier: GPL-2.0-or-later
34 /* -54dB */
35 0x0, 0x11, TLV_DB_SCALE_ITEM(-5400, 0, 0),
36 /* -52.5dB to 15dB */
37 0x12, 0x3f, TLV_DB_SCALE_ITEM(-5250, 150, 0)
42 /* -78dB to 12dB */
43 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7800, 75, 0)
52 static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0);
53 static const DECLARE_TLV_DB_SCALE(mixin_gain_tlv, -450, 150, 0);
54 static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
55 static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -5700, 100, 0);
56 static const DECLARE_TLV_DB_SCALE(lineout_vol_tlv, -4800, 100, 0);
57 static const DECLARE_TLV_DB_SCALE(alc_threshold_tlv, -9450, 150, 0);
59 static const DECLARE_TLV_DB_SCALE(da7213_tonegen_gain_tlv, -4500, 300, 0);
221 mutex_lock(&da7213->ctrl_lock);
223 mutex_unlock(&da7213->ctrl_lock);
235 mutex_lock(&da7213->ctrl_lock);
237 mutex_unlock(&da7213->ctrl_lock);
249 mutex_lock(&da7213->ctrl_lock);
251 mutex_unlock(&da7213->ctrl_lock);
263 mutex_lock(&da7213->ctrl_lock);
265 mutex_unlock(&da7213->ctrl_lock);
312 offset_l = -avg_left_data;
313 offset_r = -avg_right_data;
344 dev_warn(component->dev,
402 if (da7213->alc_calib_auto)
430 if ((!ret) && (da7213->alc_en))
443 if (ucontrol->value.integer.value[0] ||
444 ucontrol->value.integer.value[1]) {
445 if (!da7213->alc_en) {
447 da7213->alc_en = true;
450 da7213->alc_en = false;
463 (struct soc_mixer_control *) kcontrol->private_value;
464 unsigned int reg = mixer_ctrl->reg;
468 mutex_lock(&da7213->ctrl_lock);
469 ret = regmap_raw_read(da7213->regmap, reg, &val, sizeof(val));
470 mutex_unlock(&da7213->ctrl_lock);
476 * Frequency value spans two 8-bit registers, lower then upper byte.
479 ucontrol->value.integer.value[0] = le16_to_cpu(val);
490 (struct soc_mixer_control *) kcontrol->private_value;
491 unsigned int reg = mixer_ctrl->reg;
496 * Frequency value spans two 8-bit registers, lower then upper byte.
500 val_new = cpu_to_le16(ucontrol->value.integer.value[0]);
502 mutex_lock(&da7213->ctrl_lock);
503 ret = regmap_raw_read(da7213->regmap, reg, &val_old, sizeof(val_old));
505 ret = regmap_raw_write(da7213->regmap, reg,
507 mutex_unlock(&da7213->ctrl_lock);
688 /* DMIC controls */
689 SOC_DOUBLE_R("DMIC Switch", DA7213_MIXIN_L_SELECT,
901 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
910 if (da7213->master)
943 dev_warn(component->dev, "SRM failed to lock\n");
955 /* PC free-running */
961 if (da7213->master)
966 return -EINVAL;
1324 struct snd_soc_component *component = dai->component;
1333 if (da7213->fmt != DA7213_DAI_FORMAT_DSP) {
1334 dev_err(component->dev, "Mono supported only in DSP mode\n");
1335 return -EINVAL;
1343 return -EINVAL;
1362 return -EINVAL;
1369 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000;
1373 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800;
1377 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000;
1381 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000;
1385 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800;
1389 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000;
1393 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800;
1397 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000;
1401 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800;
1405 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000;
1408 return -EINVAL;
1423 struct snd_soc_component *component = codec_dai->component;
1431 da7213->master = true;
1434 da7213->master = false;
1437 return -EINVAL;
1459 return -EINVAL;
1479 return -EINVAL;
1483 return -EINVAL;
1490 da7213->fmt = DA7213_DAI_FORMAT_I2S_MODE;
1494 da7213->fmt = DA7213_DAI_FORMAT_LEFT_J;
1498 da7213->fmt = DA7213_DAI_FORMAT_RIGHT_J;
1503 da7213->fmt = DA7213_DAI_FORMAT_DSP;
1507 da7213->fmt = DA7213_DAI_FORMAT_DSP;
1510 return -EINVAL;
1529 struct snd_soc_component *component = dai->component;
1556 if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq))
1563 if (((freq < da7213->fin_min_rate) && (freq != 32768)) || (freq > 54000000)) {
1564 dev_err(component->dev, "Unsupported MCLK value %d\n",
1566 return -EINVAL;
1580 dev_err(component->dev, "Unknown clock source %d\n", clk_id);
1581 return -EINVAL;
1584 da7213->clk_src = clk_id;
1586 if (da7213->mclk) {
1587 freq = clk_round_rate(da7213->mclk, freq);
1588 ret = clk_set_rate(da7213->mclk, freq);
1590 dev_err(component->dev, "Failed to set clock rate %d\n",
1596 da7213->mclk_rate = freq;
1601 /* Supported PLL input frequencies are 32KHz, 5MHz - 54MHz. */
1614 if (da7213->mclk_rate == 32768) {
1615 if (!da7213->master) {
1616 dev_err(component->dev,
1618 return -EINVAL;
1628 if (da7213->mclk_rate < 5000000) {
1629 dev_err(component->dev,
1631 da7213->mclk_rate);
1632 return -EINVAL;
1633 } else if (da7213->mclk_rate <= 9000000) {
1636 } else if (da7213->mclk_rate <= 18000000) {
1639 } else if (da7213->mclk_rate <= 36000000) {
1642 } else if (da7213->mclk_rate <= 54000000) {
1646 dev_err(component->dev,
1648 da7213->mclk_rate);
1649 return -EINVAL;
1651 freq_ref = (da7213->mclk_rate / indiv);
1670 if (da7213->mclk_rate != 32768) {
1671 dev_err(component->dev,
1673 return -EINVAL;
1680 dev_err(component->dev, "Invalid PLL config\n");
1681 return -EINVAL;
1718 da7213->fixed_clk_auto_pll = false;
1750 .name = "da7213-hifi",
1776 if (!da7213->fixed_clk_auto_pll)
1779 da7213->mclk_rate = clk_get_rate(da7213->mclk);
1782 /* Slave mode needs SRM for non-harmonic frequencies */
1783 if (da7213->master)
1789 switch (da7213->out_rate) {
1791 if (da7213->mclk_rate == 11289600 ||
1792 da7213->mclk_rate == 22579200 ||
1793 da7213->mclk_rate == 45158400)
1797 if (da7213->mclk_rate == 12288000 ||
1798 da7213->mclk_rate == 24576000 ||
1799 da7213->mclk_rate == 49152000)
1804 return -1;
1812 da7213->mclk_rate, da7213->out_rate);
1827 if (da7213->mclk) {
1828 ret = clk_prepare_enable(da7213->mclk);
1830 dev_err(component->dev,
1847 if (da7213->mclk) {
1849 clk_disable_unprepare(da7213->mclk);
1897 dev_warn(component->dev, "Invalid micbias level\n");
1910 dev_warn(component->dev, "Invalid DMIC data select type\n");
1923 dev_warn(component->dev, "Invalid DMIC sample phase\n");
1937 dev_warn(component->dev, "Invalid DMIC clock rate\n");
1945 struct device *dev = component->dev;
1950 pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL);
1954 if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0)
1955 pdata->micbias1_lvl = da7213_of_micbias_lvl(component, fw_val32);
1957 pdata->micbias1_lvl = DA7213_MICBIAS_2_2V;
1959 if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0)
1960 pdata->micbias2_lvl = da7213_of_micbias_lvl(component, fw_val32);
1962 pdata->micbias2_lvl = DA7213_MICBIAS_2_2V;
1964 if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str))
1965 pdata->dmic_data_sel = da7213_of_dmic_data_sel(component, fw_str);
1967 pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL;
1969 if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str))
1970 pdata->dmic_samplephase =
1973 pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE;
1975 if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0)
1976 pdata->dmic_clk_rate = da7213_of_dmic_clkrate(component, fw_val32);
1978 pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ;
1987 pm_runtime_get_sync(component->dev);
1992 da7213->alc_calib_auto = true;
1994 /* Default PC counter to free-running */
2049 da7213->pdata = dev_get_platdata(component->dev);
2050 if (!da7213->pdata)
2051 da7213->pdata = da7213_fw_to_pdata(component);
2054 if (da7213->pdata) {
2055 struct da7213_platform_data *pdata = da7213->pdata;
2059 switch (pdata->micbias1_lvl) {
2064 micbias_lvl |= (pdata->micbias1_lvl <<
2068 switch (pdata->micbias2_lvl) {
2073 micbias_lvl |= (pdata->micbias2_lvl <<
2081 /* Set DMIC configuration */
2082 switch (pdata->dmic_data_sel) {
2085 dmic_cfg |= (pdata->dmic_data_sel <<
2089 switch (pdata->dmic_samplephase) {
2092 dmic_cfg |= (pdata->dmic_samplephase <<
2096 switch (pdata->dmic_clk_rate) {
2099 dmic_cfg |= (pdata->dmic_clk_rate <<
2109 pm_runtime_put_sync(component->dev);
2112 da7213->mclk = devm_clk_get_optional(component->dev, "mclk");
2113 if (IS_ERR(da7213->mclk))
2114 return PTR_ERR(da7213->mclk);
2115 if (da7213->mclk)
2118 * with the simple-audio-card driver. */
2119 da7213->fixed_clk_auto_pll = true;
2157 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies);
2170 da7213 = devm_kzalloc(&i2c->dev, sizeof(*da7213), GFP_KERNEL);
2172 return -ENOMEM;
2174 da7213->fin_min_rate = (uintptr_t)i2c_get_match_data(i2c);
2175 if (!da7213->fin_min_rate)
2176 return -EINVAL;
2182 da7213->supplies[i].supply = da7213_supply_names[i];
2184 ret = devm_regulator_bulk_get(&i2c->dev, DA7213_NUM_SUPPLIES,
2185 da7213->supplies);
2187 dev_err(&i2c->dev, "Failed to get supplies: %d\n", ret);
2191 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies);
2195 ret = devm_add_action_or_reset(&i2c->dev, da7213_power_off, da7213);
2199 da7213->regmap = devm_regmap_init_i2c(i2c, &da7213_regmap_config);
2200 if (IS_ERR(da7213->regmap)) {
2201 ret = PTR_ERR(da7213->regmap);
2202 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret);
2206 mutex_init(&da7213->ctrl_lock);
2208 pm_runtime_set_autosuspend_delay(&i2c->dev, 100);
2209 pm_runtime_use_autosuspend(&i2c->dev);
2210 pm_runtime_set_active(&i2c->dev);
2211 pm_runtime_enable(&i2c->dev);
2213 ret = devm_snd_soc_register_component(&i2c->dev,
2216 dev_err(&i2c->dev, "Failed to register da7213 component: %d\n",
2224 pm_runtime_disable(&i2c->dev);
2231 regcache_cache_only(da7213->regmap, true);
2232 regcache_mark_dirty(da7213->regmap);
2233 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies);
2243 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies);
2246 regcache_cache_only(da7213->regmap, false);
2247 return regcache_sync(da7213->regmap);