Lines Matching +full:vddmic +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-or-later
33 /* -54dB */
34 0x0, 0x11, TLV_DB_SCALE_ITEM(-5400, 0, 0),
35 /* -52.5dB to 15dB */
36 0x12, 0x3f, TLV_DB_SCALE_ITEM(-5250, 150, 0)
41 /* -78dB to 12dB */
42 0x08, 0x7f, TLV_DB_SCALE_ITEM(-7800, 75, 0)
51 static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, -600, 600, 0);
52 static const DECLARE_TLV_DB_SCALE(mixin_gain_tlv, -450, 150, 0);
53 static const DECLARE_TLV_DB_SCALE(eq_gain_tlv, -1050, 150, 0);
54 static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -5700, 100, 0);
55 static const DECLARE_TLV_DB_SCALE(lineout_vol_tlv, -4800, 100, 0);
56 static const DECLARE_TLV_DB_SCALE(alc_threshold_tlv, -9450, 150, 0);
58 static const DECLARE_TLV_DB_SCALE(da7213_tonegen_gain_tlv, -4500, 300, 0);
220 mutex_lock(&da7213->ctrl_lock); in da7213_volsw_locked_get()
222 mutex_unlock(&da7213->ctrl_lock); in da7213_volsw_locked_get()
234 mutex_lock(&da7213->ctrl_lock); in da7213_volsw_locked_put()
236 mutex_unlock(&da7213->ctrl_lock); in da7213_volsw_locked_put()
248 mutex_lock(&da7213->ctrl_lock); in da7213_enum_locked_get()
250 mutex_unlock(&da7213->ctrl_lock); in da7213_enum_locked_get()
262 mutex_lock(&da7213->ctrl_lock); in da7213_enum_locked_put()
264 mutex_unlock(&da7213->ctrl_lock); in da7213_enum_locked_put()
311 offset_l = -avg_left_data; in da7213_alc_calib_man()
312 offset_r = -avg_right_data; in da7213_alc_calib_man()
343 dev_warn(component->dev, in da7213_alc_calib_auto()
401 if (da7213->alc_calib_auto) in da7213_alc_calib()
429 if ((!ret) && (da7213->alc_en)) in da7213_put_mixin_gain()
442 if (ucontrol->value.integer.value[0] || in da7213_put_alc_sw()
443 ucontrol->value.integer.value[1]) { in da7213_put_alc_sw()
444 if (!da7213->alc_en) { in da7213_put_alc_sw()
446 da7213->alc_en = true; in da7213_put_alc_sw()
449 da7213->alc_en = false; in da7213_put_alc_sw()
462 (struct soc_mixer_control *) kcontrol->private_value; in da7213_tonegen_freq_get()
463 unsigned int reg = mixer_ctrl->reg; in da7213_tonegen_freq_get()
467 mutex_lock(&da7213->ctrl_lock); in da7213_tonegen_freq_get()
468 ret = regmap_raw_read(da7213->regmap, reg, &val, sizeof(val)); in da7213_tonegen_freq_get()
469 mutex_unlock(&da7213->ctrl_lock); in da7213_tonegen_freq_get()
475 * Frequency value spans two 8-bit registers, lower then upper byte. in da7213_tonegen_freq_get()
478 ucontrol->value.integer.value[0] = le16_to_cpu(val); in da7213_tonegen_freq_get()
489 (struct soc_mixer_control *) kcontrol->private_value; in da7213_tonegen_freq_put()
490 unsigned int reg = mixer_ctrl->reg; in da7213_tonegen_freq_put()
495 * Frequency value spans two 8-bit registers, lower then upper byte. in da7213_tonegen_freq_put()
499 val_new = cpu_to_le16(ucontrol->value.integer.value[0]); in da7213_tonegen_freq_put()
501 mutex_lock(&da7213->ctrl_lock); in da7213_tonegen_freq_put()
502 ret = regmap_raw_read(da7213->regmap, reg, &val_old, sizeof(val_old)); in da7213_tonegen_freq_put()
504 ret = regmap_raw_write(da7213->regmap, reg, in da7213_tonegen_freq_put()
506 mutex_unlock(&da7213->ctrl_lock); in da7213_tonegen_freq_put()
900 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in da7213_dai_event()
909 if (da7213->master) in da7213_dai_event()
942 dev_warn(component->dev, "SRM failed to lock\n"); in da7213_dai_event()
954 /* PC free-running */ in da7213_dai_event()
960 if (da7213->master) in da7213_dai_event()
965 return -EINVAL; in da7213_dai_event()
976 * Power Supply
978 SND_SOC_DAPM_REGULATOR_SUPPLY("VDDMIC", 0, 0),
984 /* Use a supply here as this controls both input & output DAIs */
1106 {"Mic Bias 1", NULL, "VDDMIC"},
1107 {"Mic Bias 2", NULL, "VDDMIC"},
1323 struct snd_soc_component *component = dai->component; in da7213_hw_params()
1332 if (da7213->fmt != DA7213_DAI_FORMAT_DSP) { in da7213_hw_params()
1333 dev_err(component->dev, "Mono supported only in DSP mode\n"); in da7213_hw_params()
1334 return -EINVAL; in da7213_hw_params()
1342 return -EINVAL; in da7213_hw_params()
1361 return -EINVAL; in da7213_hw_params()
1368 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1372 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1376 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1380 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1384 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1388 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1392 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1396 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1400 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1404 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1407 return -EINVAL; in da7213_hw_params()
1422 struct snd_soc_component *component = codec_dai->component; in da7213_set_dai_fmt()
1430 da7213->master = true; in da7213_set_dai_fmt()
1433 da7213->master = false; in da7213_set_dai_fmt()
1436 return -EINVAL; in da7213_set_dai_fmt()
1458 return -EINVAL; in da7213_set_dai_fmt()
1478 return -EINVAL; in da7213_set_dai_fmt()
1482 return -EINVAL; in da7213_set_dai_fmt()
1489 da7213->fmt = DA7213_DAI_FORMAT_I2S_MODE; in da7213_set_dai_fmt()
1493 da7213->fmt = DA7213_DAI_FORMAT_LEFT_J; in da7213_set_dai_fmt()
1497 da7213->fmt = DA7213_DAI_FORMAT_RIGHT_J; in da7213_set_dai_fmt()
1502 da7213->fmt = DA7213_DAI_FORMAT_DSP; in da7213_set_dai_fmt()
1506 da7213->fmt = DA7213_DAI_FORMAT_DSP; in da7213_set_dai_fmt()
1509 return -EINVAL; in da7213_set_dai_fmt()
1528 struct snd_soc_component *component = dai->component; in da7213_mute()
1555 if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) in da7213_set_component_sysclk()
1559 dev_err(component->dev, "Unsupported MCLK value %d\n", in da7213_set_component_sysclk()
1561 return -EINVAL; in da7213_set_component_sysclk()
1575 dev_err(component->dev, "Unknown clock source %d\n", clk_id); in da7213_set_component_sysclk()
1576 return -EINVAL; in da7213_set_component_sysclk()
1579 da7213->clk_src = clk_id; in da7213_set_component_sysclk()
1581 if (da7213->mclk) { in da7213_set_component_sysclk()
1582 freq = clk_round_rate(da7213->mclk, freq); in da7213_set_component_sysclk()
1583 ret = clk_set_rate(da7213->mclk, freq); in da7213_set_component_sysclk()
1585 dev_err(component->dev, "Failed to set clock rate %d\n", in da7213_set_component_sysclk()
1591 da7213->mclk_rate = freq; in da7213_set_component_sysclk()
1596 /* Supported PLL input frequencies are 32KHz, 5MHz - 54MHz. */
1609 if (da7213->mclk_rate == 32768) { in _da7213_set_component_pll()
1610 if (!da7213->master) { in _da7213_set_component_pll()
1611 dev_err(component->dev, in _da7213_set_component_pll()
1613 return -EINVAL; in _da7213_set_component_pll()
1623 if (da7213->mclk_rate < 5000000) { in _da7213_set_component_pll()
1624 dev_err(component->dev, in _da7213_set_component_pll()
1626 da7213->mclk_rate); in _da7213_set_component_pll()
1627 return -EINVAL; in _da7213_set_component_pll()
1628 } else if (da7213->mclk_rate <= 9000000) { in _da7213_set_component_pll()
1631 } else if (da7213->mclk_rate <= 18000000) { in _da7213_set_component_pll()
1634 } else if (da7213->mclk_rate <= 36000000) { in _da7213_set_component_pll()
1637 } else if (da7213->mclk_rate <= 54000000) { in _da7213_set_component_pll()
1641 dev_err(component->dev, in _da7213_set_component_pll()
1643 da7213->mclk_rate); in _da7213_set_component_pll()
1644 return -EINVAL; in _da7213_set_component_pll()
1646 freq_ref = (da7213->mclk_rate / indiv); in _da7213_set_component_pll()
1665 if (da7213->mclk_rate != 32768) { in _da7213_set_component_pll()
1666 dev_err(component->dev, in _da7213_set_component_pll()
1668 return -EINVAL; in _da7213_set_component_pll()
1675 dev_err(component->dev, "Invalid PLL config\n"); in _da7213_set_component_pll()
1676 return -EINVAL; in _da7213_set_component_pll()
1713 da7213->fixed_clk_auto_pll = false; in da7213_set_component_pll()
1745 .name = "da7213-hifi",
1771 if (!da7213->fixed_clk_auto_pll) in da7213_set_auto_pll()
1774 da7213->mclk_rate = clk_get_rate(da7213->mclk); in da7213_set_auto_pll()
1777 /* Slave mode needs SRM for non-harmonic frequencies */ in da7213_set_auto_pll()
1778 if (da7213->master) in da7213_set_auto_pll()
1784 switch (da7213->out_rate) { in da7213_set_auto_pll()
1786 if (da7213->mclk_rate == 11289600 || in da7213_set_auto_pll()
1787 da7213->mclk_rate == 22579200 || in da7213_set_auto_pll()
1788 da7213->mclk_rate == 45158400) in da7213_set_auto_pll()
1792 if (da7213->mclk_rate == 12288000 || in da7213_set_auto_pll()
1793 da7213->mclk_rate == 24576000 || in da7213_set_auto_pll()
1794 da7213->mclk_rate == 49152000) in da7213_set_auto_pll()
1799 return -1; in da7213_set_auto_pll()
1807 da7213->mclk_rate, da7213->out_rate); in da7213_set_auto_pll()
1822 if (da7213->mclk) { in da7213_set_bias_level()
1823 ret = clk_prepare_enable(da7213->mclk); in da7213_set_bias_level()
1825 dev_err(component->dev, in da7213_set_bias_level()
1842 if (da7213->mclk) { in da7213_set_bias_level()
1844 clk_disable_unprepare(da7213->mclk); in da7213_set_bias_level()
1889 dev_warn(component->dev, "Invalid micbias level\n"); in da7213_of_micbias_lvl()
1902 dev_warn(component->dev, "Invalid DMIC data select type\n"); in da7213_of_dmic_data_sel()
1915 dev_warn(component->dev, "Invalid DMIC sample phase\n"); in da7213_of_dmic_samplephase()
1929 dev_warn(component->dev, "Invalid DMIC clock rate\n"); in da7213_of_dmic_clkrate()
1937 struct device *dev = component->dev; in da7213_fw_to_pdata()
1942 pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); in da7213_fw_to_pdata()
1946 if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) in da7213_fw_to_pdata()
1947 pdata->micbias1_lvl = da7213_of_micbias_lvl(component, fw_val32); in da7213_fw_to_pdata()
1949 pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; in da7213_fw_to_pdata()
1951 if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) in da7213_fw_to_pdata()
1952 pdata->micbias2_lvl = da7213_of_micbias_lvl(component, fw_val32); in da7213_fw_to_pdata()
1954 pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; in da7213_fw_to_pdata()
1956 if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) in da7213_fw_to_pdata()
1957 pdata->dmic_data_sel = da7213_of_dmic_data_sel(component, fw_str); in da7213_fw_to_pdata()
1959 pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; in da7213_fw_to_pdata()
1961 if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) in da7213_fw_to_pdata()
1962 pdata->dmic_samplephase = in da7213_fw_to_pdata()
1965 pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; in da7213_fw_to_pdata()
1967 if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) in da7213_fw_to_pdata()
1968 pdata->dmic_clk_rate = da7213_of_dmic_clkrate(component, fw_val32); in da7213_fw_to_pdata()
1970 pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; in da7213_fw_to_pdata()
1979 pm_runtime_get_sync(component->dev); in da7213_probe()
1984 da7213->alc_calib_auto = true; in da7213_probe()
1986 /* Default PC counter to free-running */ in da7213_probe()
2041 da7213->pdata = dev_get_platdata(component->dev); in da7213_probe()
2042 if (!da7213->pdata) in da7213_probe()
2043 da7213->pdata = da7213_fw_to_pdata(component); in da7213_probe()
2046 if (da7213->pdata) { in da7213_probe()
2047 struct da7213_platform_data *pdata = da7213->pdata; in da7213_probe()
2051 switch (pdata->micbias1_lvl) { in da7213_probe()
2056 micbias_lvl |= (pdata->micbias1_lvl << in da7213_probe()
2060 switch (pdata->micbias2_lvl) { in da7213_probe()
2065 micbias_lvl |= (pdata->micbias2_lvl << in da7213_probe()
2074 switch (pdata->dmic_data_sel) { in da7213_probe()
2077 dmic_cfg |= (pdata->dmic_data_sel << in da7213_probe()
2081 switch (pdata->dmic_samplephase) { in da7213_probe()
2084 dmic_cfg |= (pdata->dmic_samplephase << in da7213_probe()
2088 switch (pdata->dmic_clk_rate) { in da7213_probe()
2091 dmic_cfg |= (pdata->dmic_clk_rate << in da7213_probe()
2101 pm_runtime_put_sync(component->dev); in da7213_probe()
2104 da7213->mclk = devm_clk_get_optional(component->dev, "mclk"); in da7213_probe()
2105 if (IS_ERR(da7213->mclk)) in da7213_probe()
2106 return PTR_ERR(da7213->mclk); in da7213_probe()
2107 if (da7213->mclk) in da7213_probe()
2110 * with the simple-audio-card driver. */ in da7213_probe()
2111 da7213->fixed_clk_auto_pll = true; in da7213_probe()
2148 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_power_off()
2161 da7213 = devm_kzalloc(&i2c->dev, sizeof(*da7213), GFP_KERNEL); in da7213_i2c_probe()
2163 return -ENOMEM; in da7213_i2c_probe()
2169 da7213->supplies[i].supply = da7213_supply_names[i]; in da7213_i2c_probe()
2171 ret = devm_regulator_bulk_get(&i2c->dev, DA7213_NUM_SUPPLIES, in da7213_i2c_probe()
2172 da7213->supplies); in da7213_i2c_probe()
2174 dev_err(&i2c->dev, "Failed to get supplies: %d\n", ret); in da7213_i2c_probe()
2178 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_i2c_probe()
2182 ret = devm_add_action_or_reset(&i2c->dev, da7213_power_off, da7213); in da7213_i2c_probe()
2186 da7213->regmap = devm_regmap_init_i2c(i2c, &da7213_regmap_config); in da7213_i2c_probe()
2187 if (IS_ERR(da7213->regmap)) { in da7213_i2c_probe()
2188 ret = PTR_ERR(da7213->regmap); in da7213_i2c_probe()
2189 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); in da7213_i2c_probe()
2193 pm_runtime_set_autosuspend_delay(&i2c->dev, 100); in da7213_i2c_probe()
2194 pm_runtime_use_autosuspend(&i2c->dev); in da7213_i2c_probe()
2195 pm_runtime_set_active(&i2c->dev); in da7213_i2c_probe()
2196 pm_runtime_enable(&i2c->dev); in da7213_i2c_probe()
2198 ret = devm_snd_soc_register_component(&i2c->dev, in da7213_i2c_probe()
2201 dev_err(&i2c->dev, "Failed to register da7213 component: %d\n", in da7213_i2c_probe()
2209 pm_runtime_disable(&i2c->dev); in da7213_i2c_remove()
2216 regcache_cache_only(da7213->regmap, true); in da7213_runtime_suspend()
2217 regcache_mark_dirty(da7213->regmap); in da7213_runtime_suspend()
2218 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_runtime_suspend()
2228 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_runtime_resume()
2231 regcache_cache_only(da7213->regmap, false); in da7213_runtime_resume()
2232 regcache_sync(da7213->regmap); in da7213_runtime_resume()