Lines Matching +full:micbias2 +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);
235 offset_l = -avg_left_data; in da7213_alc_calib_man()
236 offset_r = -avg_right_data; in da7213_alc_calib_man()
267 dev_warn(component->dev, in da7213_alc_calib_auto()
325 if (da7213->alc_calib_auto) in da7213_alc_calib()
353 if ((!ret) && (da7213->alc_en)) in da7213_put_mixin_gain()
366 if (ucontrol->value.integer.value[0] || in da7213_put_alc_sw()
367 ucontrol->value.integer.value[1]) { in da7213_put_alc_sw()
368 if (!da7213->alc_en) { in da7213_put_alc_sw()
370 da7213->alc_en = true; in da7213_put_alc_sw()
373 da7213->alc_en = false; in da7213_put_alc_sw()
735 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in da7213_dai_event()
744 if (da7213->master) in da7213_dai_event()
777 dev_warn(component->dev, "SRM failed to lock\n"); in da7213_dai_event()
789 /* PC free-running */ in da7213_dai_event()
795 if (da7213->master) in da7213_dai_event()
800 return -EINVAL; in da7213_dai_event()
811 * Power Supply
819 /* Use a supply here as this controls both input & output DAIs */
1158 struct snd_soc_component *component = dai->component; in da7213_hw_params()
1178 return -EINVAL; in da7213_hw_params()
1185 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1189 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1193 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1197 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1201 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1205 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1209 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1213 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1217 da7213->out_rate = DA7213_PLL_FREQ_OUT_90316800; in da7213_hw_params()
1221 da7213->out_rate = DA7213_PLL_FREQ_OUT_98304000; in da7213_hw_params()
1224 return -EINVAL; in da7213_hw_params()
1236 struct snd_soc_component *component = codec_dai->component; in da7213_set_dai_fmt()
1244 da7213->master = true; in da7213_set_dai_fmt()
1247 da7213->master = false; in da7213_set_dai_fmt()
1250 return -EINVAL; in da7213_set_dai_fmt()
1272 return -EINVAL; in da7213_set_dai_fmt()
1292 return -EINVAL; in da7213_set_dai_fmt()
1296 return -EINVAL; in da7213_set_dai_fmt()
1318 return -EINVAL; in da7213_set_dai_fmt()
1337 struct snd_soc_component *component = dai->component; in da7213_mute()
1364 if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) in da7213_set_component_sysclk()
1368 dev_err(component->dev, "Unsupported MCLK value %d\n", in da7213_set_component_sysclk()
1370 return -EINVAL; in da7213_set_component_sysclk()
1384 dev_err(component->dev, "Unknown clock source %d\n", clk_id); in da7213_set_component_sysclk()
1385 return -EINVAL; in da7213_set_component_sysclk()
1388 da7213->clk_src = clk_id; in da7213_set_component_sysclk()
1390 if (da7213->mclk) { in da7213_set_component_sysclk()
1391 freq = clk_round_rate(da7213->mclk, freq); in da7213_set_component_sysclk()
1392 ret = clk_set_rate(da7213->mclk, freq); in da7213_set_component_sysclk()
1394 dev_err(component->dev, "Failed to set clock rate %d\n", in da7213_set_component_sysclk()
1400 da7213->mclk_rate = freq; in da7213_set_component_sysclk()
1405 /* Supported PLL input frequencies are 32KHz, 5MHz - 54MHz. */
1418 if (da7213->mclk_rate == 32768) { in _da7213_set_component_pll()
1419 if (!da7213->master) { in _da7213_set_component_pll()
1420 dev_err(component->dev, in _da7213_set_component_pll()
1422 return -EINVAL; in _da7213_set_component_pll()
1432 if (da7213->mclk_rate < 5000000) { in _da7213_set_component_pll()
1433 dev_err(component->dev, in _da7213_set_component_pll()
1435 da7213->mclk_rate); in _da7213_set_component_pll()
1436 return -EINVAL; in _da7213_set_component_pll()
1437 } else if (da7213->mclk_rate <= 9000000) { in _da7213_set_component_pll()
1440 } else if (da7213->mclk_rate <= 18000000) { in _da7213_set_component_pll()
1443 } else if (da7213->mclk_rate <= 36000000) { in _da7213_set_component_pll()
1446 } else if (da7213->mclk_rate <= 54000000) { in _da7213_set_component_pll()
1450 dev_err(component->dev, in _da7213_set_component_pll()
1452 da7213->mclk_rate); in _da7213_set_component_pll()
1453 return -EINVAL; in _da7213_set_component_pll()
1455 freq_ref = (da7213->mclk_rate / indiv); in _da7213_set_component_pll()
1474 if (da7213->mclk_rate != 32768) { in _da7213_set_component_pll()
1475 dev_err(component->dev, in _da7213_set_component_pll()
1477 return -EINVAL; in _da7213_set_component_pll()
1484 dev_err(component->dev, "Invalid PLL config\n"); in _da7213_set_component_pll()
1485 return -EINVAL; in _da7213_set_component_pll()
1522 da7213->fixed_clk_auto_pll = false; in da7213_set_component_pll()
1536 .name = "da7213-hifi",
1562 if (!da7213->fixed_clk_auto_pll) in da7213_set_auto_pll()
1565 da7213->mclk_rate = clk_get_rate(da7213->mclk); in da7213_set_auto_pll()
1568 /* Slave mode needs SRM for non-harmonic frequencies */ in da7213_set_auto_pll()
1569 if (da7213->master) in da7213_set_auto_pll()
1575 switch (da7213->out_rate) { in da7213_set_auto_pll()
1577 if (da7213->mclk_rate == 11289600 || in da7213_set_auto_pll()
1578 da7213->mclk_rate == 22579200 || in da7213_set_auto_pll()
1579 da7213->mclk_rate == 45158400) in da7213_set_auto_pll()
1583 if (da7213->mclk_rate == 12288000 || in da7213_set_auto_pll()
1584 da7213->mclk_rate == 24576000 || in da7213_set_auto_pll()
1585 da7213->mclk_rate == 49152000) in da7213_set_auto_pll()
1590 return -1; in da7213_set_auto_pll()
1598 da7213->mclk_rate, da7213->out_rate); in da7213_set_auto_pll()
1613 if (da7213->mclk) { in da7213_set_bias_level()
1614 ret = clk_prepare_enable(da7213->mclk); in da7213_set_bias_level()
1616 dev_err(component->dev, in da7213_set_bias_level()
1633 if (da7213->mclk) { in da7213_set_bias_level()
1635 clk_disable_unprepare(da7213->mclk); in da7213_set_bias_level()
1680 dev_warn(component->dev, "Invalid micbias level\n"); in da7213_of_micbias_lvl()
1693 dev_warn(component->dev, "Invalid DMIC data select type\n"); in da7213_of_dmic_data_sel()
1706 dev_warn(component->dev, "Invalid DMIC sample phase\n"); in da7213_of_dmic_samplephase()
1720 dev_warn(component->dev, "Invalid DMIC clock rate\n"); in da7213_of_dmic_clkrate()
1728 struct device *dev = component->dev; in da7213_fw_to_pdata()
1733 pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); in da7213_fw_to_pdata()
1737 if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) in da7213_fw_to_pdata()
1738 pdata->micbias1_lvl = da7213_of_micbias_lvl(component, fw_val32); in da7213_fw_to_pdata()
1740 pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; in da7213_fw_to_pdata()
1742 if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) in da7213_fw_to_pdata()
1743 pdata->micbias2_lvl = da7213_of_micbias_lvl(component, fw_val32); in da7213_fw_to_pdata()
1745 pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; in da7213_fw_to_pdata()
1747 if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) in da7213_fw_to_pdata()
1748 pdata->dmic_data_sel = da7213_of_dmic_data_sel(component, fw_str); in da7213_fw_to_pdata()
1750 pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; in da7213_fw_to_pdata()
1752 if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) in da7213_fw_to_pdata()
1753 pdata->dmic_samplephase = in da7213_fw_to_pdata()
1756 pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; in da7213_fw_to_pdata()
1758 if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) in da7213_fw_to_pdata()
1759 pdata->dmic_clk_rate = da7213_of_dmic_clkrate(component, fw_val32); in da7213_fw_to_pdata()
1761 pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; in da7213_fw_to_pdata()
1770 pm_runtime_get_sync(component->dev); in da7213_probe()
1775 da7213->alc_calib_auto = true; in da7213_probe()
1777 /* Default PC counter to free-running */ in da7213_probe()
1832 da7213->pdata = dev_get_platdata(component->dev); in da7213_probe()
1833 if (!da7213->pdata) in da7213_probe()
1834 da7213->pdata = da7213_fw_to_pdata(component); in da7213_probe()
1837 if (da7213->pdata) { in da7213_probe()
1838 struct da7213_platform_data *pdata = da7213->pdata; in da7213_probe()
1842 switch (pdata->micbias1_lvl) { in da7213_probe()
1847 micbias_lvl |= (pdata->micbias1_lvl << in da7213_probe()
1851 switch (pdata->micbias2_lvl) { in da7213_probe()
1856 micbias_lvl |= (pdata->micbias2_lvl << in da7213_probe()
1865 switch (pdata->dmic_data_sel) { in da7213_probe()
1868 dmic_cfg |= (pdata->dmic_data_sel << in da7213_probe()
1872 switch (pdata->dmic_samplephase) { in da7213_probe()
1875 dmic_cfg |= (pdata->dmic_samplephase << in da7213_probe()
1879 switch (pdata->dmic_clk_rate) { in da7213_probe()
1882 dmic_cfg |= (pdata->dmic_clk_rate << in da7213_probe()
1892 pm_runtime_put_sync(component->dev); in da7213_probe()
1895 da7213->mclk = devm_clk_get(component->dev, "mclk"); in da7213_probe()
1896 if (IS_ERR(da7213->mclk)) { in da7213_probe()
1897 if (PTR_ERR(da7213->mclk) != -ENOENT) in da7213_probe()
1898 return PTR_ERR(da7213->mclk); in da7213_probe()
1900 da7213->mclk = NULL; in da7213_probe()
1904 * with the simple-audio-card driver. */ in da7213_probe()
1905 da7213->fixed_clk_auto_pll = true; in da7213_probe()
1941 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_power_off()
1955 da7213 = devm_kzalloc(&i2c->dev, sizeof(*da7213), GFP_KERNEL); in da7213_i2c_probe()
1957 return -ENOMEM; in da7213_i2c_probe()
1963 da7213->supplies[i].supply = da7213_supply_names[i]; in da7213_i2c_probe()
1965 ret = devm_regulator_bulk_get(&i2c->dev, DA7213_NUM_SUPPLIES, in da7213_i2c_probe()
1966 da7213->supplies); in da7213_i2c_probe()
1968 dev_err(&i2c->dev, "Failed to get supplies: %d\n", ret); in da7213_i2c_probe()
1972 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_i2c_probe()
1976 ret = devm_add_action_or_reset(&i2c->dev, da7213_power_off, da7213); in da7213_i2c_probe()
1980 da7213->regmap = devm_regmap_init_i2c(i2c, &da7213_regmap_config); in da7213_i2c_probe()
1981 if (IS_ERR(da7213->regmap)) { in da7213_i2c_probe()
1982 ret = PTR_ERR(da7213->regmap); in da7213_i2c_probe()
1983 dev_err(&i2c->dev, "regmap_init() failed: %d\n", ret); in da7213_i2c_probe()
1987 pm_runtime_set_autosuspend_delay(&i2c->dev, 100); in da7213_i2c_probe()
1988 pm_runtime_use_autosuspend(&i2c->dev); in da7213_i2c_probe()
1989 pm_runtime_set_active(&i2c->dev); in da7213_i2c_probe()
1990 pm_runtime_enable(&i2c->dev); in da7213_i2c_probe()
1992 ret = devm_snd_soc_register_component(&i2c->dev, in da7213_i2c_probe()
1995 dev_err(&i2c->dev, "Failed to register da7213 component: %d\n", in da7213_i2c_probe()
2005 regcache_cache_only(da7213->regmap, true); in da7213_runtime_suspend()
2006 regcache_mark_dirty(da7213->regmap); in da7213_runtime_suspend()
2007 regulator_bulk_disable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_runtime_suspend()
2017 ret = regulator_bulk_enable(DA7213_NUM_SUPPLIES, da7213->supplies); in da7213_runtime_resume()
2020 regcache_cache_only(da7213->regmap, false); in da7213_runtime_resume()
2021 regcache_sync(da7213->regmap); in da7213_runtime_resume()