Lines Matching +full:milli +full:- +full:ohm
1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/clk-provider.h>
21 #include <sound/soc-dapm.h>
23 #include "wcd-clsh-v2.h"
24 #include "wcd-mbhc-v2.h"
430 COMPANDER_5, /* LO3_SE - not used in Tavil */
431 COMPANDER_6, /* LO4_SE - not used in Tavil */
515 .name = "WCD9335-IFC-DEV",
581 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
597 "Class H Invalid", "Class-H Hi-Fi", "Class-H Low Power", "Class-AB",
598 "Class-H Hi-Fi Low Power"
1266 if (sido_src == wcd->sido_input_src) in wcd934x_set_sido_input_src()
1270 regmap_update_bits(wcd->regmap, WCD934X_ANA_RCO, in wcd934x_set_sido_input_src()
1275 wcd->sido_input_src = sido_src; in wcd934x_set_sido_input_src()
1282 mutex_lock(&wcd->sysclk_mutex); in wcd934x_enable_ana_bias_and_sysclk()
1284 if (++wcd->sysclk_users != 1) { in wcd934x_enable_ana_bias_and_sysclk()
1285 mutex_unlock(&wcd->sysclk_mutex); in wcd934x_enable_ana_bias_and_sysclk()
1288 mutex_unlock(&wcd->sysclk_mutex); in wcd934x_enable_ana_bias_and_sysclk()
1290 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_enable_ana_bias_and_sysclk()
1293 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_enable_ana_bias_and_sysclk()
1297 * 1ms delay is required after pre-charge is enabled in wcd934x_enable_ana_bias_and_sysclk()
1301 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_enable_ana_bias_and_sysclk()
1303 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_enable_ana_bias_and_sysclk()
1311 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_enable_ana_bias_and_sysclk()
1314 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_enable_ana_bias_and_sysclk()
1317 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_enable_ana_bias_and_sysclk()
1320 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_enable_ana_bias_and_sysclk()
1322 regmap_update_bits(wcd->regmap, in wcd934x_enable_ana_bias_and_sysclk()
1326 regmap_update_bits(wcd->regmap, in wcd934x_enable_ana_bias_and_sysclk()
1330 regmap_update_bits(wcd->regmap, WCD934X_CODEC_RPM_CLK_GATE, in wcd934x_enable_ana_bias_and_sysclk()
1345 mutex_lock(&wcd->sysclk_mutex); in wcd934x_disable_ana_bias_and_syclk()
1346 if (--wcd->sysclk_users != 0) { in wcd934x_disable_ana_bias_and_syclk()
1347 mutex_unlock(&wcd->sysclk_mutex); in wcd934x_disable_ana_bias_and_syclk()
1350 mutex_unlock(&wcd->sysclk_mutex); in wcd934x_disable_ana_bias_and_syclk()
1352 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_disable_ana_bias_and_syclk()
1355 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_disable_ana_bias_and_syclk()
1357 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_disable_ana_bias_and_syclk()
1368 ret = clk_prepare_enable(wcd->extclk); in __wcd934x_cdc_mclk_enable()
1371 dev_err(wcd->dev, "%s: ext clk enable failed\n", in __wcd934x_cdc_mclk_enable()
1379 regmap_read(wcd->regmap, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL, in __wcd934x_cdc_mclk_enable()
1387 clk_disable_unprepare(wcd->extclk); in __wcd934x_cdc_mclk_enable()
1396 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_mclk()
1397 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_enable_mclk()
1416 regmap = wcd->regmap; in wcd934x_get_version()
1446 wcd->version = ver; in wcd934x_get_version()
1447 dev_info(wcd->dev, "WCD934X Minor:0x%x Version:0x%x\n", id_minor, ver); in wcd934x_get_version()
1458 regmap_update_bits(wcd->regmap, in wcd934x_enable_efuse_sensing()
1462 regmap_update_bits(wcd->regmap, in wcd934x_enable_efuse_sensing()
1473 rc = regmap_read(wcd->regmap, in wcd934x_enable_efuse_sensing()
1486 regmap_update_bits(wcd->regmap, in wcd934x_swrm_clock()
1491 regmap_update_bits(wcd->regmap, in wcd934x_swrm_clock()
1503 struct snd_soc_component *comp = dai->component; in wcd934x_set_prim_interpolator_rate()
1504 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_set_prim_interpolator_rate()
1509 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd934x_set_prim_interpolator_rate()
1510 inp = ch->shift + INTn_1_INP_SEL_RX0; in wcd934x_set_prim_interpolator_rate()
1542 dev_err(wcd->dev, in wcd934x_set_prim_interpolator_rate()
1560 struct snd_soc_component *component = dai->component; in wcd934x_set_mix_interpolator_rate()
1561 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_set_mix_interpolator_rate()
1565 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd934x_set_mix_interpolator_rate()
1574 if (val == (ch->shift + INTn_2_INP_SEL_RX0)) { in wcd934x_set_mix_interpolator_rate()
1582 dev_err(component->dev, in wcd934x_set_mix_interpolator_rate()
1584 dai->id); in wcd934x_set_mix_interpolator_rate()
1585 return -EINVAL; in wcd934x_set_mix_interpolator_rate()
1612 dev_err(dai->dev, "Unsupported sample rate: %d\n", sample_rate); in wcd934x_set_interpolator_rate()
1613 return -EINVAL; in wcd934x_set_interpolator_rate()
1629 struct snd_soc_component *comp = dai->component; in wcd934x_set_decimator_rate()
1634 int decimator = -1; in wcd934x_set_decimator_rate()
1636 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd934x_set_decimator_rate()
1637 tx_port = ch->port; in wcd934x_set_decimator_rate()
1638 /* Find the SB TX MUX input - which decimator is connected */ in wcd934x_set_decimator_rate()
1647 shift = ((tx_port - 4) << 1); in wcd934x_set_decimator_rate()
1652 shift = ((tx_port - 8) << 1); in wcd934x_set_decimator_rate()
1666 dev_err(wcd->dev, "Invalid SLIM TX%u port DAI ID:%d\n", in wcd934x_set_decimator_rate()
1667 tx_port, dai->id); in wcd934x_set_decimator_rate()
1668 return -EINVAL; in wcd934x_set_decimator_rate()
1686 decimator = tx_mux_sel - 1; in wcd934x_set_decimator_rate()
1693 dev_err(wcd->dev, "ERROR: Invalid tx_port: %d\n", in wcd934x_set_decimator_rate()
1695 return -EINVAL; in wcd934x_set_decimator_rate()
1711 struct list_head *slim_ch_list = &dai_data->slim_ch_list; in wcd934x_slim_set_hw_params()
1712 struct slim_stream_config *cfg = &dai_data->sconfig; in wcd934x_slim_set_hw_params()
1717 cfg->ch_count = 0; in wcd934x_slim_set_hw_params()
1718 cfg->direction = direction; in wcd934x_slim_set_hw_params()
1719 cfg->port_mask = 0; in wcd934x_slim_set_hw_params()
1723 cfg->ch_count++; in wcd934x_slim_set_hw_params()
1724 payload |= 1 << ch->shift; in wcd934x_slim_set_hw_params()
1725 cfg->port_mask |= BIT(ch->port); in wcd934x_slim_set_hw_params()
1728 cfg->chs = kcalloc(cfg->ch_count, sizeof(unsigned int), GFP_KERNEL); in wcd934x_slim_set_hw_params()
1729 if (!cfg->chs) in wcd934x_slim_set_hw_params()
1730 return -ENOMEM; in wcd934x_slim_set_hw_params()
1734 cfg->chs[i++] = ch->ch_num; in wcd934x_slim_set_hw_params()
1737 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1738 WCD934X_SLIM_PGD_RX_PORT_MULTI_CHNL_0(ch->port), in wcd934x_slim_set_hw_params()
1745 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1746 WCD934X_SLIM_PGD_RX_PORT_CFG(ch->port), in wcd934x_slim_set_hw_params()
1751 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1752 WCD934X_SLIM_PGD_TX_PORT_MULTI_CHNL_0(ch->port), in wcd934x_slim_set_hw_params()
1758 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1759 WCD934X_SLIM_PGD_TX_PORT_MULTI_CHNL_1(ch->port), in wcd934x_slim_set_hw_params()
1765 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1766 WCD934X_SLIM_PGD_TX_PORT_CFG(ch->port), in wcd934x_slim_set_hw_params()
1774 dai_data->sruntime = slim_stream_allocate(wcd->sdev, "WCD934x-SLIM"); in wcd934x_slim_set_hw_params()
1779 dev_err(wcd->dev, "Error Setting slim hw params\n"); in wcd934x_slim_set_hw_params()
1780 kfree(cfg->chs); in wcd934x_slim_set_hw_params()
1781 cfg->chs = NULL; in wcd934x_slim_set_hw_params()
1793 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_hw_params()
1795 switch (substream->stream) { in wcd934x_hw_params()
1799 dev_err(wcd->dev, "cannot set sample rate: %u\n", in wcd934x_hw_params()
1805 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd934x_hw_params()
1808 dev_err(wcd->dev, "Invalid format 0x%x\n", in wcd934x_hw_params()
1810 return -EINVAL; in wcd934x_hw_params()
1838 dev_err(wcd->dev, "Invalid TX sample rate: %d\n", in wcd934x_hw_params()
1840 return -EINVAL; in wcd934x_hw_params()
1847 dev_err(wcd->dev, "Cannot set TX Decimator rate\n"); in wcd934x_hw_params()
1852 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd934x_hw_params()
1855 dev_err(wcd->dev, "Invalid format 0x%x\n", in wcd934x_hw_params()
1857 return -EINVAL; in wcd934x_hw_params()
1861 dev_err(wcd->dev, "Invalid stream type %d\n", in wcd934x_hw_params()
1862 substream->stream); in wcd934x_hw_params()
1863 return -EINVAL; in wcd934x_hw_params()
1866 wcd->dai[dai->id].sconfig.rate = params_rate(params); in wcd934x_hw_params()
1868 return wcd934x_slim_set_hw_params(wcd, &wcd->dai[dai->id], substream->stream); in wcd934x_hw_params()
1877 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_hw_free()
1879 dai_data = &wcd->dai[dai->id]; in wcd934x_hw_free()
1881 kfree(dai_data->sconfig.chs); in wcd934x_hw_free()
1893 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_trigger()
1895 dai_data = &wcd->dai[dai->id]; in wcd934x_trigger()
1901 cfg = &dai_data->sconfig; in wcd934x_trigger()
1902 slim_stream_prepare(dai_data->sruntime, cfg); in wcd934x_trigger()
1903 slim_stream_enable(dai_data->sruntime); in wcd934x_trigger()
1908 slim_stream_disable(dai_data->sruntime); in wcd934x_trigger()
1909 slim_stream_unprepare(dai_data->sruntime); in wcd934x_trigger()
1927 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_set_channel_map()
1930 dev_err(wcd->dev, "Invalid tx %d or rx %d channel count\n", in wcd934x_set_channel_map()
1932 return -EINVAL; in wcd934x_set_channel_map()
1936 dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n", in wcd934x_set_channel_map()
1938 return -EINVAL; in wcd934x_set_channel_map()
1941 wcd->num_rx_port = rx_num; in wcd934x_set_channel_map()
1943 wcd->rx_chs[i].ch_num = rx_slot[i]; in wcd934x_set_channel_map()
1944 INIT_LIST_HEAD(&wcd->rx_chs[i].list); in wcd934x_set_channel_map()
1947 wcd->num_tx_port = tx_num; in wcd934x_set_channel_map()
1949 wcd->tx_chs[i].ch_num = tx_slot[i]; in wcd934x_set_channel_map()
1950 INIT_LIST_HEAD(&wcd->tx_chs[i].list); in wcd934x_set_channel_map()
1964 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_get_channel_map()
1966 switch (dai->id) { in wcd934x_get_channel_map()
1972 dev_err(wcd->dev, "Invalid rx_slot %p or rx_num %p\n", in wcd934x_get_channel_map()
1974 return -EINVAL; in wcd934x_get_channel_map()
1977 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd934x_get_channel_map()
1978 rx_slot[i++] = ch->ch_num; in wcd934x_get_channel_map()
1986 dev_err(wcd->dev, "Invalid tx_slot %p or tx_num %p\n", in wcd934x_get_channel_map()
1988 return -EINVAL; in wcd934x_get_channel_map()
1991 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd934x_get_channel_map()
1992 tx_slot[i++] = ch->ch_num; in wcd934x_get_channel_map()
1997 dev_err(wcd->dev, "Invalid DAI ID %x\n", dai->id); in wcd934x_get_channel_map()
2128 regmap_read(wcd->regmap, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL, &val); in swclk_gate_is_enabled()
2150 struct clk *parent = wcd->extclk; in wcd934x_register_mclk_output()
2151 struct device *dev = wcd->dev; in wcd934x_register_mclk_output()
2152 struct device_node *np = dev->parent->of_node; in wcd934x_register_mclk_output()
2159 if (of_property_read_u32(np, "clock-frequency", &wcd->rate)) in wcd934x_register_mclk_output()
2164 of_property_read_string(np, "clock-output-names", &clk_name); in wcd934x_register_mclk_output()
2171 wcd->hw.init = &init; in wcd934x_register_mclk_output()
2173 hw = &wcd->hw; in wcd934x_register_mclk_output()
2174 ret = devm_clk_hw_register(wcd->dev->parent, hw); in wcd934x_register_mclk_output()
2190 if (of_property_read_u32(dev->parent->of_node, micbias, &mv)) { in wcd934x_get_micbias_val()
2194 /* convert it to milli volts */ in wcd934x_get_micbias_val()
2207 return (mv - 1000) / 50; in wcd934x_get_micbias_val()
2213 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_init_dmic()
2216 vout_ctl_1 = wcd934x_get_micbias_val(comp->dev, in wcd934x_init_dmic()
2217 "qcom,micbias1-microvolt", NULL); in wcd934x_init_dmic()
2218 vout_ctl_2 = wcd934x_get_micbias_val(comp->dev, in wcd934x_init_dmic()
2219 "qcom,micbias2-microvolt", in wcd934x_init_dmic()
2220 &wcd->micb2_mv); in wcd934x_init_dmic()
2221 vout_ctl_3 = wcd934x_get_micbias_val(comp->dev, in wcd934x_init_dmic()
2222 "qcom,micbias3-microvolt", NULL); in wcd934x_init_dmic()
2223 vout_ctl_4 = wcd934x_get_micbias_val(comp->dev, in wcd934x_init_dmic()
2224 "qcom,micbias4-microvolt", NULL); in wcd934x_init_dmic()
2235 if (wcd->rate == WCD934X_MCLK_CLK_9P6MHZ) in wcd934x_init_dmic()
2240 wcd->dmic_sample_rate = def_dmic_rate; in wcd934x_init_dmic()
2251 struct regmap *rm = wcd->regmap; in wcd934x_hw_init()
2263 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_comp_init()
2284 regmap_read(wcd->if_regmap, i, &val); in wcd934x_slim_irq_handler()
2294 port_id = j - 16; in wcd934x_slim_irq_handler()
2297 regmap_read(wcd->if_regmap, in wcd934x_slim_irq_handler()
2306 regmap_read(wcd->if_regmap, reg, &int_val); in wcd934x_slim_irq_handler()
2310 dev_err_ratelimited(wcd->dev, in wcd934x_slim_irq_handler()
2315 dev_err_ratelimited(wcd->dev, in wcd934x_slim_irq_handler()
2328 wcd->if_regmap, reg, &int_val); in wcd934x_slim_irq_handler()
2331 regmap_write(wcd->if_regmap, in wcd934x_slim_irq_handler()
2337 dev_err_ratelimited(wcd->dev, in wcd934x_slim_irq_handler()
2341 regmap_write(wcd->if_regmap, in wcd934x_slim_irq_handler()
2371 dev_err(component->dev, "%s: invalid number of buttons: %d\n", in wcd934x_mbhc_program_btn_thr()
2413 int micb_index = micb_num - 1; in wcd934x_micbias_control()
2430 dev_err(component->dev, "%s: Invalid micbias number: %d\n", in wcd934x_micbias_control()
2432 return -EINVAL; in wcd934x_micbias_control()
2434 mutex_lock(&wcd934x->micb_lock); in wcd934x_micbias_control()
2438 wcd934x->pullup_ref[micb_index]++; in wcd934x_micbias_control()
2439 if ((wcd934x->pullup_ref[micb_index] == 1) && in wcd934x_micbias_control()
2440 (wcd934x->micb_ref[micb_index] == 0)) in wcd934x_micbias_control()
2446 if (wcd934x->pullup_ref[micb_index] > 0) in wcd934x_micbias_control()
2447 wcd934x->pullup_ref[micb_index]--; in wcd934x_micbias_control()
2449 if ((wcd934x->pullup_ref[micb_index] == 0) && in wcd934x_micbias_control()
2450 (wcd934x->micb_ref[micb_index] == 0)) in wcd934x_micbias_control()
2455 wcd934x->micb_ref[micb_index]++; in wcd934x_micbias_control()
2456 if (wcd934x->micb_ref[micb_index] == 1) { in wcd934x_micbias_control()
2461 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2466 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2470 if (wcd934x->micb_ref[micb_index] > 0) in wcd934x_micbias_control()
2471 wcd934x->micb_ref[micb_index]--; in wcd934x_micbias_control()
2473 if ((wcd934x->micb_ref[micb_index] == 0) && in wcd934x_micbias_control()
2474 (wcd934x->pullup_ref[micb_index] > 0)) in wcd934x_micbias_control()
2478 else if ((wcd934x->micb_ref[micb_index] == 0) && in wcd934x_micbias_control()
2479 (wcd934x->pullup_ref[micb_index] == 0)) { in wcd934x_micbias_control()
2481 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2487 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2491 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2496 mutex_unlock(&wcd934x->micb_lock); in wcd934x_micbias_control()
2504 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_mbhc_request_micbias()
2538 return -EINVAL; in wcd934x_get_micb_vout_ctl_val()
2540 return (micb_mv - 1000) / 50; in wcd934x_get_micb_vout_ctl_val()
2563 return -EINVAL; in wcd934x_mbhc_micb_adjust_voltage()
2565 mutex_lock(&wcd934x->micb_lock); in wcd934x_mbhc_micb_adjust_voltage()
2570 * to avoid slow micbias ramp-up or down enable pull-up in wcd934x_mbhc_micb_adjust_voltage()
2571 * momentarily, change the micbias value and then re-enable in wcd934x_mbhc_micb_adjust_voltage()
2581 ret = -EINVAL; in wcd934x_mbhc_micb_adjust_voltage()
2610 mutex_unlock(&wcd934x->micb_lock); in wcd934x_mbhc_micb_adjust_voltage()
2621 return -EINVAL; in wcd934x_mbhc_micb_ctrl_threshold_mic()
2627 if (wcd934x->micb2_mv >= WCD_MBHC_THR_HS_MICB_MV) in wcd934x_mbhc_micb_ctrl_threshold_mic()
2630 micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : wcd934x->micb2_mv; in wcd934x_mbhc_micb_ctrl_threshold_mic()
2650 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x20, 0x20); in wcd934x_mbhc_get_result_params()
2652 regmap_read(wcd934x->regmap, WCD934X_ANA_MBHC_RESULT_2, &val); in wcd934x_mbhc_get_result_params()
2657 regmap_read(wcd934x->regmap, WCD934X_ANA_MBHC_RESULT_1, &val1); in wcd934x_mbhc_get_result_params()
2659 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x20, 0x00); in wcd934x_mbhc_get_result_params()
2667 dev_err(wcd934x->dev, "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n", in wcd934x_mbhc_get_result_params()
2672 denom = (x1 * d1) - (1 << (14 - noff)); in wcd934x_mbhc_get_result_params()
2678 dev_dbg(wcd934x->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%di (milliohm)\n", in wcd934x_mbhc_get_result_params()
2684 regmap_read(wcd934x->regmap, WCD934X_ANA_MBHC_RESULT_1, &val); in wcd934x_mbhc_get_result_params()
2685 regmap_read(wcd934x->regmap, WCD934X_ANA_MBHC_RESULT_2, &val1); in wcd934x_mbhc_get_result_params()
2699 struct wcd934x_codec *wcd934x = dev_get_drvdata(component->dev); in wcd934x_mbhc_zdet_ramp()
2703 WCD934X_ZDET_MAXV_CTL_MASK, zdet_param->ldo_ctl); in wcd934x_mbhc_zdet_ramp()
2705 WCD934X_VTH_MASK, zdet_param->btn5); in wcd934x_mbhc_zdet_ramp()
2707 WCD934X_VTH_MASK, zdet_param->btn6); in wcd934x_mbhc_zdet_ramp()
2709 WCD934X_VTH_MASK, zdet_param->btn7); in wcd934x_mbhc_zdet_ramp()
2711 WCD934X_ZDET_RANGE_CTL_MASK, zdet_param->noff); in wcd934x_mbhc_zdet_ramp()
2713 0x0F, zdet_param->nshift); in wcd934x_mbhc_zdet_ramp()
2718 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x80, 0x80); in wcd934x_mbhc_zdet_ramp()
2719 wcd934x_mbhc_get_result_params(wcd934x, d1_a, zdet_param->noff, &zdet); in wcd934x_mbhc_zdet_ramp()
2720 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x80, 0x00); in wcd934x_mbhc_zdet_ramp()
2728 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x40, 0x40); in wcd934x_mbhc_zdet_ramp()
2729 wcd934x_mbhc_get_result_params(wcd934x, d1_a, zdet_param->noff, &zdet); in wcd934x_mbhc_zdet_ramp()
2730 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x40, 0x00); in wcd934x_mbhc_zdet_ramp()
2748 q1_cal = (10000 - ((q1 & 0x7F) * 25)); in wcd934x_wcd_mbhc_qfuse_cal()
2758 struct wcd934x_codec *wcd934x = dev_get_drvdata(component->dev); in wcd934x_wcd_mbhc_calc_impedance()
2764 {4, 0, 4, 0x08, 0x14, 0x18}, /* < 32ohm */ in wcd934x_wcd_mbhc_calc_impedance()
2765 {2, 0, 3, 0x18, 0x7C, 0x90}, /* 32ohm < Z < 400ohm */ in wcd934x_wcd_mbhc_calc_impedance()
2766 {1, 4, 5, 0x18, 0x7C, 0x90}, /* 400ohm < Z < 1200ohm */ in wcd934x_wcd_mbhc_calc_impedance()
2767 {1, 6, 7, 0x18, 0x7C, 0x90}, /* >1200ohm */ in wcd934x_wcd_mbhc_calc_impedance()
2786 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ELECT, 0x80, 0x00); in wcd934x_wcd_mbhc_calc_impedance()
2789 /* For NO-jack, disable L_DET_EN before Z-det measurements */ in wcd934x_wcd_mbhc_calc_impedance()
2790 if (wcd934x->mbhc_cfg.hphl_swh) in wcd934x_wcd_mbhc_calc_impedance()
2791 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_MECH, 0x80, 0x00); in wcd934x_wcd_mbhc_calc_impedance()
2794 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_MECH, 0x01, 0x00); in wcd934x_wcd_mbhc_calc_impedance()
2828 dev_info(component->dev, "%s: impedance on HPH_L = %d(ohms)\n", in wcd934x_wcd_mbhc_calc_impedance()
2835 (zdet_param_ptr->noff == 0x6)) || in wcd934x_wcd_mbhc_calc_impedance()
2860 dev_err(component->dev, "%s: impedance on HPH_R = %d(ohms)\n", in wcd934x_wcd_mbhc_calc_impedance()
2866 dev_dbg(component->dev, in wcd934x_wcd_mbhc_calc_impedance()
2875 dev_dbg(component->dev, in wcd934x_wcd_mbhc_calc_impedance()
2878 wcd_mbhc_set_hph_type(wcd934x->mbhc, WCD_MBHC_HPH_MONO); in wcd934x_wcd_mbhc_calc_impedance()
2895 /* Parallel of left Z and 9 ohm pull down resistor */ in wcd934x_wcd_mbhc_calc_impedance()
2897 z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls); in wcd934x_wcd_mbhc_calc_impedance()
2898 z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl)); in wcd934x_wcd_mbhc_calc_impedance()
2900 dev_err(component->dev, "%s: stereo plug type detected\n", in wcd934x_wcd_mbhc_calc_impedance()
2902 wcd_mbhc_set_hph_type(wcd934x->mbhc, WCD_MBHC_HPH_STEREO); in wcd934x_wcd_mbhc_calc_impedance()
2904 dev_err(component->dev, "%s: MONO plug type detected\n", in wcd934x_wcd_mbhc_calc_impedance()
2906 wcd_mbhc_set_hph_type(wcd934x->mbhc, WCD_MBHC_HPH_MONO); in wcd934x_wcd_mbhc_calc_impedance()
2914 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_MECH, 0x01, 0x01); in wcd934x_wcd_mbhc_calc_impedance()
2916 /* For NO-jack, re-enable L_DET_EN after Z-det measurements */ in wcd934x_wcd_mbhc_calc_impedance()
2917 if (wcd934x->mbhc_cfg.hphl_swh) in wcd934x_wcd_mbhc_calc_impedance()
2918 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_MECH, 0x80, 0x80); in wcd934x_wcd_mbhc_calc_impedance()
2923 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ELECT, 0x80, 0x80); in wcd934x_wcd_mbhc_calc_impedance()
2971 ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd->mbhc); in wcd934x_get_hph_type()
2985 mc = (struct soc_mixer_control *)(kcontrol->private_value); in wcd934x_hph_impedance_get()
2986 hphr = mc->shift; in wcd934x_hph_impedance_get()
2987 wcd_mbhc_get_impedance(wcd->mbhc, &zl, &zr); in wcd934x_hph_impedance_get()
2988 dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr); in wcd934x_hph_impedance_get()
2989 ucontrol->value.integer.value[0] = hphr ? zr : zl; in wcd934x_hph_impedance_get()
3007 struct wcd934x_ddata *data = dev_get_drvdata(component->dev->parent); in wcd934x_mbhc_init()
3009 struct wcd_mbhc_intr *intr_ids = &wcd->intr_ids; in wcd934x_mbhc_init()
3011 intr_ids->mbhc_sw_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3013 intr_ids->mbhc_btn_press_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3015 intr_ids->mbhc_btn_release_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3017 intr_ids->mbhc_hs_ins_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3019 intr_ids->mbhc_hs_rem_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3021 intr_ids->hph_left_ocp = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3023 intr_ids->hph_right_ocp = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3026 wcd->mbhc = wcd_mbhc_init(component, &mbhc_cb, intr_ids, wcd_mbhc_fields, true); in wcd934x_mbhc_init()
3027 if (IS_ERR(wcd->mbhc)) { in wcd934x_mbhc_init()
3028 wcd->mbhc = NULL; in wcd934x_mbhc_init()
3029 return -EINVAL; in wcd934x_mbhc_init()
3044 if (!wcd->mbhc) in wcd934x_mbhc_deinit()
3047 wcd_mbhc_deinit(wcd->mbhc); in wcd934x_mbhc_deinit()
3052 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_comp_probe()
3055 snd_soc_component_init_regmap(component, wcd->regmap); in wcd934x_comp_probe()
3056 wcd->component = component; in wcd934x_comp_probe()
3058 /* Class-H Init*/ in wcd934x_comp_probe()
3059 wcd->clsh_ctrl = wcd_clsh_ctrl_alloc(component, wcd->version); in wcd934x_comp_probe()
3060 if (IS_ERR(wcd->clsh_ctrl)) in wcd934x_comp_probe()
3061 return PTR_ERR(wcd->clsh_ctrl); in wcd934x_comp_probe()
3063 /* Default HPH Mode to Class-H Low HiFi */ in wcd934x_comp_probe()
3064 wcd->hph_mode = CLS_H_LOHIFI; in wcd934x_comp_probe()
3069 INIT_LIST_HEAD(&wcd->dai[i].slim_ch_list); in wcd934x_comp_probe()
3074 dev_err(component->dev, "Failed to Initialize MBHC\n"); in wcd934x_comp_probe()
3081 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_comp_remove()
3084 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd934x_comp_remove()
3091 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_comp_set_sysclk()
3094 wcd->rate = freq; in wcd934x_comp_set_sysclk()
3096 if (wcd->rate == WCD934X_MCLK_CLK_12P288MHZ) in wcd934x_comp_set_sysclk()
3103 return clk_set_rate(wcd->extclk, freq); in wcd934x_comp_set_sysclk()
3148 /* Mask top 2 bits, 7-8 are reserved */ in set_iir_band_coeff()
3159 (struct wcd_iir_filter_ctl *)kcontrol->private_value; in wcd934x_put_iir_band_audio_mixer()
3160 struct soc_bytes_ext *params = &ctl->bytes_ext; in wcd934x_put_iir_band_audio_mixer()
3161 int iir_idx = ctl->iir_idx; in wcd934x_put_iir_band_audio_mixer()
3162 int band_idx = ctl->band_idx; in wcd934x_put_iir_band_audio_mixer()
3166 memcpy(&coeff[0], ucontrol->value.bytes.data, params->max); in wcd934x_put_iir_band_audio_mixer()
3188 (struct wcd_iir_filter_ctl *)kcontrol->private_value; in wcd934x_get_iir_band_audio_mixer()
3189 struct soc_bytes_ext *params = &ctl->bytes_ext; in wcd934x_get_iir_band_audio_mixer()
3190 int iir_idx = ctl->iir_idx; in wcd934x_get_iir_band_audio_mixer()
3191 int band_idx = ctl->band_idx; in wcd934x_get_iir_band_audio_mixer()
3200 memcpy(ucontrol->value.bytes.data, &coeff[0], params->max); in wcd934x_get_iir_band_audio_mixer()
3209 (struct wcd_iir_filter_ctl *)kcontrol->private_value; in wcd934x_iir_filter_info()
3210 struct soc_bytes_ext *params = &ctl->bytes_ext; in wcd934x_iir_filter_info()
3212 ucontrol->type = SNDRV_CTL_ELEM_TYPE_BYTES; in wcd934x_iir_filter_info()
3213 ucontrol->count = params->max; in wcd934x_iir_filter_info()
3222 int comp = ((struct soc_mixer_control *)kc->private_value)->shift; in wcd934x_compander_get()
3223 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_compander_get()
3225 ucontrol->value.integer.value[0] = wcd->comp_enabled[comp]; in wcd934x_compander_get()
3234 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_compander_set()
3235 int comp = ((struct soc_mixer_control *)kc->private_value)->shift; in wcd934x_compander_set()
3236 int value = ucontrol->value.integer.value[0]; in wcd934x_compander_set()
3239 if (wcd->comp_enabled[comp] == value) in wcd934x_compander_set()
3242 wcd->comp_enabled[comp] = value; in wcd934x_compander_set()
3275 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_rx_hph_mode_get()
3277 ucontrol->value.enumerated.item[0] = wcd->hph_mode; in wcd934x_rx_hph_mode_get()
3286 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_rx_hph_mode_put()
3289 mode_val = ucontrol->value.enumerated.item[0]; in wcd934x_rx_hph_mode_put()
3291 if (mode_val == wcd->hph_mode) in wcd934x_rx_hph_mode_put()
3295 dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); in wcd934x_rx_hph_mode_put()
3298 wcd->hph_mode = mode_val; in wcd934x_rx_hph_mode_put()
3308 struct wcd934x_codec *wcd = dev_get_drvdata(dapm->dev); in slim_rx_mux_get()
3310 ucontrol->value.enumerated.item[0] = wcd->rx_port_value[w->shift]; in slim_rx_mux_get()
3333 aif_id = -1; in slim_rx_mux_to_dai_id()
3344 struct wcd934x_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_put()
3345 struct soc_enum *e = (struct soc_enum *)kc->private_value; in slim_rx_mux_put()
3348 u32 port_id = w->shift; in slim_rx_mux_put()
3351 int prev_mux_idx = wcd->rx_port_value[port_id]; in slim_rx_mux_put()
3354 mux_idx = ucontrol->value.enumerated.item[0]; in slim_rx_mux_put()
3365 list_for_each_entry_safe(ch, c, &wcd->dai[aif_id].slim_ch_list, list) { in slim_rx_mux_put()
3366 if (ch->port == port_id + WCD934X_RX_START) { in slim_rx_mux_put()
3368 list_del_init(&ch->list); in slim_rx_mux_put()
3381 if (list_empty(&wcd->rx_chs[port_id].list)) { in slim_rx_mux_put()
3382 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
3383 &wcd->dai[aif_id].slim_ch_list); in slim_rx_mux_put()
3385 dev_err(wcd->dev ,"SLIM_RX%d PORT is busy\n", port_id); in slim_rx_mux_put()
3391 dev_err(wcd->dev, "Unknown AIF %d\n", mux_idx); in slim_rx_mux_put()
3395 wcd->rx_port_value[port_id] = mux_idx; in slim_rx_mux_put()
3396 snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id], in slim_rx_mux_put()
3401 return -EINVAL; in slim_rx_mux_put()
3407 struct soc_enum *e = (struct soc_enum *)kc->private_value; in wcd934x_int_dem_inp_mux_put()
3412 val = ucontrol->value.enumerated.item[0]; in wcd934x_int_dem_inp_mux_put()
3413 if (e->reg == WCD934X_CDC_RX0_RX_PATH_SEC0) in wcd934x_int_dem_inp_mux_put()
3415 else if (e->reg == WCD934X_CDC_RX1_RX_PATH_SEC0) in wcd934x_int_dem_inp_mux_put()
3417 else if (e->reg == WCD934X_CDC_RX2_RX_PATH_SEC0) in wcd934x_int_dem_inp_mux_put()
3420 return -EINVAL; in wcd934x_int_dem_inp_mux_put()
3439 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in wcd934x_dec_enum_put()
3446 val = ucontrol->value.enumerated.item[0]; in wcd934x_dec_enum_put()
3447 if (val > e->items - 1) in wcd934x_dec_enum_put()
3448 return -EINVAL; in wcd934x_dec_enum_put()
3450 switch (e->reg) { in wcd934x_dec_enum_put()
3452 if (e->shift_l == 0) in wcd934x_dec_enum_put()
3454 else if (e->shift_l == 2) in wcd934x_dec_enum_put()
3456 else if (e->shift_l == 4) in wcd934x_dec_enum_put()
3460 if (e->shift_l == 0) in wcd934x_dec_enum_put()
3462 else if (e->shift_l == 2) in wcd934x_dec_enum_put()
3466 if (e->shift_l == 0) in wcd934x_dec_enum_put()
3468 else if (e->shift_l == 2) in wcd934x_dec_enum_put()
3472 if (e->shift_l == 0) in wcd934x_dec_enum_put()
3474 else if (e->shift_l == 2) in wcd934x_dec_enum_put()
3478 dev_err(comp->dev, "%s: e->reg: 0x%x not expected\n", in wcd934x_dec_enum_put()
3479 __func__, e->reg); in wcd934x_dec_enum_put()
3480 return -EINVAL; in wcd934x_dec_enum_put()
3824 struct wcd934x_codec *wcd = dev_get_drvdata(dapm->dev); in slim_tx_mixer_get()
3826 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_get()
3827 int port_id = mixer->shift; in slim_tx_mixer_get()
3829 ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id]; in slim_tx_mixer_get()
3838 struct wcd934x_codec *wcd = dev_get_drvdata(widget->dapm->dev); in slim_tx_mixer_put()
3841 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_put()
3842 int enable = ucontrol->value.integer.value[0]; in slim_tx_mixer_put()
3844 int dai_id = widget->shift; in slim_tx_mixer_put()
3845 int port_id = mixer->shift; in slim_tx_mixer_put()
3848 if (enable == wcd->tx_port_value[port_id]) in slim_tx_mixer_put()
3852 if (list_empty(&wcd->tx_chs[port_id].list)) { in slim_tx_mixer_put()
3853 list_add_tail(&wcd->tx_chs[port_id].list, in slim_tx_mixer_put()
3854 &wcd->dai[dai_id].slim_ch_list); in slim_tx_mixer_put()
3856 dev_err(wcd->dev ,"SLIM_TX%d PORT is busy\n", port_id); in slim_tx_mixer_put()
3862 list_for_each_entry_safe(ch, c, &wcd->dai[dai_id].slim_ch_list, list) { in slim_tx_mixer_put()
3863 if (ch->port == port_id) { in slim_tx_mixer_put()
3865 list_del_init(&wcd->tx_chs[port_id].list); in slim_tx_mixer_put()
3873 wcd->tx_port_value[port_id] = enable; in slim_tx_mixer_put()
3874 snd_soc_dapm_mixer_update_power(widget->dapm, kc, enable, update); in slim_tx_mixer_put()
3982 -84, 40, digital_gain), /* -84dB min - 40dB max */
3984 -84, 40, digital_gain),
3986 -84, 40, digital_gain),
3988 -84, 40, digital_gain),
3990 -84, 40, digital_gain),
3992 -84, 40, digital_gain),
3994 -84, 40, digital_gain),
3997 -84, 40, digital_gain),
4000 -84, 40, digital_gain),
4003 -84, 40, digital_gain),
4006 -84, 40, digital_gain),
4009 -84, 40, digital_gain),
4012 -84, 40, digital_gain),
4015 -84, 40, digital_gain),
4018 -84, 40, digital_gain),
4020 -84, 40, digital_gain),
4022 -84, 40, digital_gain),
4024 -84, 40, digital_gain),
4026 -84, 40, digital_gain),
4028 -84, 40, digital_gain),
4030 -84, 40, digital_gain),
4032 -84, 40, digital_gain),
4034 -84, 40, digital_gain),
4037 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40,
4040 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40,
4043 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40,
4046 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40,
4049 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40,
4052 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40,
4055 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40,
4058 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40,
4141 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_codec_enable_int_port()
4144 list_for_each_entry(ch, &dai->slim_ch_list, list) { in wcd934x_codec_enable_int_port()
4145 if (ch->port >= WCD934X_RX_START) { in wcd934x_codec_enable_int_port()
4146 port_num = ch->port - WCD934X_RX_START; in wcd934x_codec_enable_int_port()
4149 port_num = ch->port; in wcd934x_codec_enable_int_port()
4153 regmap_read(wcd->if_regmap, reg, &val); in wcd934x_codec_enable_int_port()
4155 regmap_write(wcd->if_regmap, reg, in wcd934x_codec_enable_int_port()
4163 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_slim()
4165 struct wcd_slim_codec_dai_data *dai = &wcd->dai[w->shift]; in wcd934x_codec_enable_slim()
4253 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_config_compander()
4261 compander = interp_n - 1; in wcd934x_config_compander()
4262 if (!wcd->comp_enabled[compander]) in wcd934x_config_compander()
4310 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_interp_clk()
4311 int interp_idx = w->shift; in wcd934x_codec_enable_interp_clk()
4351 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_mix_path()
4357 (w->shift * WCD934X_RX_PATH_CTL_OFFSET); in wcd934x_codec_enable_mix_path()
4359 (w->shift * WCD934X_RX_PATH_CTL_OFFSET); in wcd934x_codec_enable_mix_path()
4382 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_set_iir_gain()
4383 int reg = w->reg; in wcd934x_codec_set_iir_gain()
4417 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_main_path()
4420 gain_reg = WCD934X_CDC_RX0_RX_VOL_CTL + (w->shift * in wcd934x_codec_enable_main_path()
4436 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_ear_dac_event()
4437 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_ear_dac_event()
4445 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd934x_codec_ear_dac_event()
4450 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd934x_codec_ear_dac_event()
4462 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_hphl_dac_event()
4463 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_hphl_dac_event()
4464 int hph_mode = wcd->hph_mode; in wcd934x_codec_hphl_dac_event()
4475 return -EINVAL; in wcd934x_codec_hphl_dac_event()
4487 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd934x_codec_hphl_dac_event()
4494 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd934x_codec_hphl_dac_event()
4514 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_hphr_dac_event()
4515 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_hphr_dac_event()
4516 int hph_mode = wcd->hph_mode; in wcd934x_codec_hphr_dac_event()
4525 return -EINVAL; in wcd934x_codec_hphr_dac_event()
4537 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd934x_codec_hphr_dac_event()
4545 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd934x_codec_hphr_dac_event()
4563 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_lineout_dac_event()
4564 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_lineout_dac_event()
4568 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd934x_codec_lineout_dac_event()
4572 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd934x_codec_lineout_dac_event()
4584 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_hphl_pa()
4618 wcd_mbhc_event_notify(wcd->mbhc, WCD_EVENT_POST_HPHL_PA_OFF); in wcd934x_codec_enable_hphl_pa()
4637 wcd_mbhc_event_notify(wcd->mbhc, WCD_EVENT_POST_HPHL_PA_OFF); in wcd934x_codec_enable_hphl_pa()
4648 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_hphr_pa()
4684 wcd_mbhc_event_notify(wcd->mbhc, WCD_EVENT_PRE_HPHR_PA_OFF); in wcd934x_codec_enable_hphr_pa()
4702 wcd_mbhc_event_notify(wcd->mbhc, WCD_EVENT_POST_HPHR_PA_OFF); in wcd934x_codec_enable_hphr_pa()
4725 adc_mux_index - 4; in wcd934x_get_dmic_sample_rate()
4731 & 0xF8) >> 3) - 1; in wcd934x_get_dmic_sample_rate()
4745 dmic_fs = min(wcd->dmic_sample_rate, WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ); in wcd934x_get_dmic_sample_rate()
4749 dmic_fs = wcd->dmic_sample_rate; in wcd934x_get_dmic_sample_rate()
4768 dev_err(comp->dev, in wcd934x_get_dmic_clk_val()
4795 dev_err(comp->dev, in wcd934x_get_dmic_clk_val()
4808 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_dmic()
4809 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_enable_dmic()
4819 wname = strpbrk(w->name, "012345"); in wcd934x_codec_enable_dmic()
4821 dev_err(comp->dev, "%s: widget not found\n", __func__); in wcd934x_codec_enable_dmic()
4822 return -EINVAL; in wcd934x_codec_enable_dmic()
4827 dev_err(comp->dev, "%s: Invalid DMIC line on the codec\n", in wcd934x_codec_enable_dmic()
4829 return -EINVAL; in wcd934x_codec_enable_dmic()
4835 dmic_clk_cnt = &wcd->dmic_0_1_clk_cnt; in wcd934x_codec_enable_dmic()
4840 dmic_clk_cnt = &wcd->dmic_2_3_clk_cnt; in wcd934x_codec_enable_dmic()
4845 dmic_clk_cnt = &wcd->dmic_4_5_clk_cnt; in wcd934x_codec_enable_dmic()
4849 dev_err(comp->dev, "%s: Invalid DMIC Selection\n", in wcd934x_codec_enable_dmic()
4851 return -EINVAL; in wcd934x_codec_enable_dmic()
4858 dmic_rate_val = wcd934x_get_dmic_clk_val(comp, wcd->rate, in wcd934x_codec_enable_dmic()
4872 (*dmic_clk_cnt)--; in wcd934x_codec_enable_dmic()
4908 (adc_mux_n - 4); in wcd934x_codec_find_amic_input()
4912 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4918 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4921 ((adc_mux_n == 8) ? (adc_mux_n - 8) : in wcd934x_codec_find_amic_input()
4922 (adc_mux_n - 9)); in wcd934x_codec_find_amic_input()
4926 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4932 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4938 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4974 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_dec()
4984 char *wname __free(kfree) = kstrndup(w->name, 15, GFP_KERNEL); in wcd934x_codec_enable_dec()
4986 return -ENOMEM; in wcd934x_codec_enable_dec()
4991 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd934x_codec_enable_dec()
4992 __func__, w->name); in wcd934x_codec_enable_dec()
4993 return -EINVAL; in wcd934x_codec_enable_dec()
4999 dev_err(comp->dev, "%s: decimator index not found\n", in wcd934x_codec_enable_dec()
5001 return -EINVAL; in wcd934x_codec_enable_dec()
5006 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd934x_codec_enable_dec()
5008 return -EINVAL; in wcd934x_codec_enable_dec()
5136 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_adc()
5140 wcd934x_codec_set_tx_hold(comp, w->reg, true); in wcd934x_codec_enable_adc()
5153 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_micbias()
5154 int micb_num = w->shift; in wcd934x_codec_enable_micbias()
5683 /* RX0-RX7 */
5817 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_set_jack()
5820 if (!wcd->mbhc) in wcd934x_codec_set_jack()
5821 return -ENOTSUPP; in wcd934x_codec_set_jack()
5823 if (jack && !wcd->mbhc_started) { in wcd934x_codec_set_jack()
5824 ret = wcd_mbhc_start(wcd->mbhc, &wcd->mbhc_cfg, jack); in wcd934x_codec_set_jack()
5825 wcd->mbhc_started = true; in wcd934x_codec_set_jack()
5826 } else if (wcd->mbhc_started) { in wcd934x_codec_set_jack()
5827 wcd_mbhc_stop(wcd->mbhc); in wcd934x_codec_set_jack()
5828 wcd->mbhc_started = false; in wcd934x_codec_set_jack()
5850 struct device *dev = &wcd->sdev->dev; in wcd934x_codec_parse_data()
5851 struct wcd_mbhc_config *cfg = &wcd->mbhc_cfg; in wcd934x_codec_parse_data()
5854 ifc_dev_np = of_parse_phandle(dev->of_node, "slim-ifc-dev", 0); in wcd934x_codec_parse_data()
5856 return dev_err_probe(dev, -EINVAL, "No Interface device found\n"); in wcd934x_codec_parse_data()
5858 wcd->sidev = of_slim_get_device(wcd->sdev->ctrl, ifc_dev_np); in wcd934x_codec_parse_data()
5860 if (!wcd->sidev) in wcd934x_codec_parse_data()
5861 return dev_err_probe(dev, -EINVAL, "Unable to get SLIM Interface device\n"); in wcd934x_codec_parse_data()
5863 slim_get_logical_addr(wcd->sidev); in wcd934x_codec_parse_data()
5864 wcd->if_regmap = regmap_init_slimbus(wcd->sidev, in wcd934x_codec_parse_data()
5866 if (IS_ERR(wcd->if_regmap)) in wcd934x_codec_parse_data()
5867 return dev_err_probe(dev, PTR_ERR(wcd->if_regmap), in wcd934x_codec_parse_data()
5870 of_property_read_u32(dev->parent->of_node, "qcom,dmic-sample-rate", in wcd934x_codec_parse_data()
5871 &wcd->dmic_sample_rate); in wcd934x_codec_parse_data()
5873 cfg->mbhc_micbias = MIC_BIAS_2; in wcd934x_codec_parse_data()
5874 cfg->anc_micbias = MIC_BIAS_2; in wcd934x_codec_parse_data()
5875 cfg->v_hs_max = WCD_MBHC_HS_V_MAX; in wcd934x_codec_parse_data()
5876 cfg->num_btn = WCD934X_MBHC_MAX_BUTTONS; in wcd934x_codec_parse_data()
5877 cfg->micb_mv = wcd->micb2_mv; in wcd934x_codec_parse_data()
5878 cfg->linein_th = 5000; in wcd934x_codec_parse_data()
5879 cfg->hs_thr = 1700; in wcd934x_codec_parse_data()
5880 cfg->hph_thr = 50; in wcd934x_codec_parse_data()
5890 struct device *dev = &pdev->dev; in wcd934x_codec_probe()
5891 struct wcd934x_ddata *data = dev_get_drvdata(dev->parent); in wcd934x_codec_probe()
5897 return -ENOMEM; in wcd934x_codec_probe()
5899 wcd->dev = dev; in wcd934x_codec_probe()
5900 wcd->regmap = data->regmap; in wcd934x_codec_probe()
5901 wcd->extclk = data->extclk; in wcd934x_codec_probe()
5902 wcd->sdev = to_slim_device(data->dev); in wcd934x_codec_probe()
5903 mutex_init(&wcd->sysclk_mutex); in wcd934x_codec_probe()
5904 mutex_init(&wcd->micb_lock); in wcd934x_codec_probe()
5911 regmap_update_bits(wcd->regmap, WCD934X_CODEC_RPM_CLK_MCLK_CFG, in wcd934x_codec_probe()
5914 memcpy(wcd->rx_chs, wcd934x_rx_chs, sizeof(wcd934x_rx_chs)); in wcd934x_codec_probe()
5915 memcpy(wcd->tx_chs, wcd934x_tx_chs, sizeof(wcd934x_tx_chs)); in wcd934x_codec_probe()
5917 irq = regmap_irq_get_virq(data->irq_data, WCD934X_IRQ_SLIMBUS); in wcd934x_codec_probe()
5919 return dev_err_probe(wcd->dev, irq, "Failed to get SLIM IRQ\n"); in wcd934x_codec_probe()
5938 .name = "wcd934x-codec",
5948 .name = "wcd934x-codec",