Lines Matching +full:vdd +full:- +full:buck +full:- +full:sido +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
3 // Copyright (c) 2017-2018, Linaro Limited
18 #include <sound/soc-dapm.h>
25 #include "wcd-clsh-v2.h"
96 #define WCD9335_CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
418 {24000, -EINVAL},/* 24K */
560 "Class H Invalid", "Class-H Hi-Fi", "Class-H Low Power", "Class-AB",
561 "Class-H Hi-Fi Low Power"
621 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
1273 struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev); in slim_rx_mux_get()
1275 ucontrol->value.enumerated.item[0] = wcd->rx_port_value; in slim_rx_mux_get()
1284 struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_put()
1285 struct soc_enum *e = (struct soc_enum *)kc->private_value; in slim_rx_mux_put()
1287 u32 port_id = w->shift; in slim_rx_mux_put()
1289 wcd->rx_port_value = ucontrol->value.enumerated.item[0]; in slim_rx_mux_put()
1291 switch (wcd->rx_port_value) { in slim_rx_mux_put()
1293 list_del_init(&wcd->rx_chs[port_id].list); in slim_rx_mux_put()
1296 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1297 &wcd->dai[AIF1_PB].slim_ch_list); in slim_rx_mux_put()
1300 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1301 &wcd->dai[AIF2_PB].slim_ch_list); in slim_rx_mux_put()
1304 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1305 &wcd->dai[AIF3_PB].slim_ch_list); in slim_rx_mux_put()
1308 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1309 &wcd->dai[AIF4_PB].slim_ch_list); in slim_rx_mux_put()
1312 dev_err(wcd->dev, "Unknown AIF %d\n", wcd->rx_port_value); in slim_rx_mux_put()
1316 snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value, in slim_rx_mux_put()
1321 return -EINVAL; in slim_rx_mux_put()
1329 struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev); in slim_tx_mixer_get()
1331 ucontrol->value.integer.value[0] = wcd->tx_port_value; in slim_tx_mixer_get()
1341 struct wcd9335_codec *wcd = dev_get_drvdata(widget->dapm->dev); in slim_tx_mixer_put()
1344 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_put()
1345 int enable = ucontrol->value.integer.value[0]; in slim_tx_mixer_put()
1346 int dai_id = widget->shift; in slim_tx_mixer_put()
1347 int port_id = mixer->shift; in slim_tx_mixer_put()
1354 if (enable && !(wcd->tx_port_value & BIT(port_id))) { in slim_tx_mixer_put()
1355 wcd->tx_port_value |= BIT(port_id); in slim_tx_mixer_put()
1356 list_add_tail(&wcd->tx_chs[port_id].list, in slim_tx_mixer_put()
1357 &wcd->dai[dai_id].slim_ch_list); in slim_tx_mixer_put()
1358 } else if (!enable && (wcd->tx_port_value & BIT(port_id))) { in slim_tx_mixer_put()
1359 wcd->tx_port_value &= ~BIT(port_id); in slim_tx_mixer_put()
1360 list_del_init(&wcd->tx_chs[port_id].list); in slim_tx_mixer_put()
1364 dev_err(wcd->dev, "Unknown AIF %d\n", dai_id); in slim_tx_mixer_put()
1365 return -EINVAL; in slim_tx_mixer_put()
1368 snd_soc_dapm_mixer_update_power(widget->dapm, kc, enable, update); in slim_tx_mixer_put()
1476 struct soc_enum *e = (struct soc_enum *)kc->private_value; in wcd9335_put_dec_enum()
1479 val = ucontrol->value.enumerated.item[0]; in wcd9335_put_dec_enum()
1481 switch (e->reg) { in wcd9335_put_dec_enum()
1510 return -EINVAL; in wcd9335_put_dec_enum()
1525 struct soc_enum *e = (struct soc_enum *)kc->private_value; in wcd9335_int_dem_inp_mux_put()
1530 val = ucontrol->value.enumerated.item[0]; in wcd9335_int_dem_inp_mux_put()
1532 if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1534 else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1536 else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1539 return -EINVAL; in wcd9335_int_dem_inp_mux_put()
1613 struct snd_soc_component *component = dai->component; in wcd9335_set_mix_interpolator_rate()
1614 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_set_mix_interpolator_rate()
1618 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_mix_interpolator_rate()
1624 if (val == (ch->shift + INTn_2_INP_SEL_RX0)) in wcd9335_set_mix_interpolator_rate()
1639 struct snd_soc_component *comp = dai->component; in wcd9335_set_prim_interpolator_rate()
1640 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_set_prim_interpolator_rate()
1645 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_prim_interpolator_rate()
1646 inp = ch->shift + INTn_1_MIX_INP_SEL_RX0; in wcd9335_set_prim_interpolator_rate()
1669 dev_info(wcd->dev, in wcd9335_set_prim_interpolator_rate()
1712 struct list_head *slim_ch_list = &dai_data->slim_ch_list; in wcd9335_slim_set_hw_params()
1713 struct slim_stream_config *cfg = &dai_data->sconfig; in wcd9335_slim_set_hw_params()
1718 cfg->ch_count = 0; in wcd9335_slim_set_hw_params()
1719 cfg->direction = direction; in wcd9335_slim_set_hw_params()
1720 cfg->port_mask = 0; in wcd9335_slim_set_hw_params()
1724 cfg->ch_count++; in wcd9335_slim_set_hw_params()
1725 payload |= 1 << ch->shift; in wcd9335_slim_set_hw_params()
1726 cfg->port_mask |= BIT(ch->port); in wcd9335_slim_set_hw_params()
1729 cfg->chs = kcalloc(cfg->ch_count, sizeof(unsigned int), GFP_KERNEL); in wcd9335_slim_set_hw_params()
1730 if (!cfg->chs) in wcd9335_slim_set_hw_params()
1731 return -ENOMEM; in wcd9335_slim_set_hw_params()
1735 cfg->chs[i++] = ch->ch_num; in wcd9335_slim_set_hw_params()
1738 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1739 WCD9335_SLIM_PGD_RX_PORT_MULTI_CHNL_0(ch->port), in wcd9335_slim_set_hw_params()
1746 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1747 WCD9335_SLIM_PGD_RX_PORT_CFG(ch->port), in wcd9335_slim_set_hw_params()
1752 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1753 WCD9335_SLIM_PGD_TX_PORT_MULTI_CHNL_0(ch->port), in wcd9335_slim_set_hw_params()
1759 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1760 WCD9335_SLIM_PGD_TX_PORT_MULTI_CHNL_1(ch->port), in wcd9335_slim_set_hw_params()
1766 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1767 WCD9335_SLIM_PGD_TX_PORT_CFG(ch->port), in wcd9335_slim_set_hw_params()
1775 dai_data->sruntime = slim_stream_allocate(wcd->slim, "WCD9335-SLIM"); in wcd9335_slim_set_hw_params()
1780 dev_err(wcd->dev, "Error Setting slim hw params\n"); in wcd9335_slim_set_hw_params()
1781 kfree(cfg->chs); in wcd9335_slim_set_hw_params()
1782 cfg->chs = NULL; in wcd9335_slim_set_hw_params()
1790 struct snd_soc_component *comp = dai->component; in wcd9335_set_decimator_rate()
1795 int decimator = -1; in wcd9335_set_decimator_rate()
1797 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_decimator_rate()
1798 tx_port = ch->port; in wcd9335_set_decimator_rate()
1800 dev_err(wcd->dev, "Invalid SLIM TX%u port DAI ID:%d\n", in wcd9335_set_decimator_rate()
1801 tx_port, dai->id); in wcd9335_set_decimator_rate()
1802 return -EINVAL; in wcd9335_set_decimator_rate()
1804 /* Find the SB TX MUX input - which decimator is connected */ in wcd9335_set_decimator_rate()
1811 shift = ((tx_port - 4) << 1); in wcd9335_set_decimator_rate()
1815 shift = ((tx_port - 8) << 1); in wcd9335_set_decimator_rate()
1826 return -EINVAL; in wcd9335_set_decimator_rate()
1841 decimator = tx_mux_sel - 1; in wcd9335_set_decimator_rate()
1854 dev_err(wcd->dev, "RX_MIX_TX%u going to SLIM TX%u\n", in wcd9335_set_decimator_rate()
1857 dev_err(wcd->dev, "ERROR: Invalid decimator: %d\n", in wcd9335_set_decimator_rate()
1859 return -EINVAL; in wcd9335_set_decimator_rate()
1873 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_hw_params()
1875 switch (substream->stream) { in wcd9335_hw_params()
1879 dev_err(wcd->dev, "cannot set sample rate: %u\n", in wcd9335_hw_params()
1885 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd9335_hw_params()
1888 dev_err(wcd->dev, "%s: Invalid format 0x%x\n", in wcd9335_hw_params()
1890 return -EINVAL; in wcd9335_hw_params()
1918 dev_err(wcd->dev, "%s: Invalid TX sample rate: %d\n", in wcd9335_hw_params()
1920 return -EINVAL; in wcd9335_hw_params()
1927 dev_err(wcd->dev, "Cannot set TX Decimator rate\n"); in wcd9335_hw_params()
1932 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd9335_hw_params()
1935 dev_err(wcd->dev, "%s: Invalid format 0x%x\n", in wcd9335_hw_params()
1937 return -EINVAL; in wcd9335_hw_params()
1941 dev_err(wcd->dev, "Invalid stream type %d\n", in wcd9335_hw_params()
1942 substream->stream); in wcd9335_hw_params()
1943 return -EINVAL; in wcd9335_hw_params()
1946 wcd->dai[dai->id].sconfig.rate = params_rate(params); in wcd9335_hw_params()
1947 wcd9335_slim_set_hw_params(wcd, &wcd->dai[dai->id], substream->stream); in wcd9335_hw_params()
1959 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_trigger()
1961 dai_data = &wcd->dai[dai->id]; in wcd9335_trigger()
1967 cfg = &dai_data->sconfig; in wcd9335_trigger()
1968 slim_stream_prepare(dai_data->sruntime, cfg); in wcd9335_trigger()
1969 slim_stream_enable(dai_data->sruntime); in wcd9335_trigger()
1974 slim_stream_unprepare(dai_data->sruntime); in wcd9335_trigger()
1975 slim_stream_disable(dai_data->sruntime); in wcd9335_trigger()
1991 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_set_channel_map()
1994 dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n", in wcd9335_set_channel_map()
1996 return -EINVAL; in wcd9335_set_channel_map()
1999 wcd->num_rx_port = rx_num; in wcd9335_set_channel_map()
2001 wcd->rx_chs[i].ch_num = rx_slot[i]; in wcd9335_set_channel_map()
2002 INIT_LIST_HEAD(&wcd->rx_chs[i].list); in wcd9335_set_channel_map()
2005 wcd->num_tx_port = tx_num; in wcd9335_set_channel_map()
2007 wcd->tx_chs[i].ch_num = tx_slot[i]; in wcd9335_set_channel_map()
2008 INIT_LIST_HEAD(&wcd->tx_chs[i].list); in wcd9335_set_channel_map()
2022 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_get_channel_map()
2024 switch (dai->id) { in wcd9335_get_channel_map()
2030 dev_err(wcd->dev, "Invalid rx_slot %p or rx_num %p\n", in wcd9335_get_channel_map()
2032 return -EINVAL; in wcd9335_get_channel_map()
2035 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd9335_get_channel_map()
2036 rx_slot[i++] = ch->ch_num; in wcd9335_get_channel_map()
2044 dev_err(wcd->dev, "Invalid tx_slot %p or tx_num %p\n", in wcd9335_get_channel_map()
2046 return -EINVAL; in wcd9335_get_channel_map()
2048 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd9335_get_channel_map()
2049 tx_slot[i++] = ch->ch_num; in wcd9335_get_channel_map()
2054 dev_err(wcd->dev, "Invalid DAI ID %x\n", dai->id); in wcd9335_get_channel_map()
2178 int comp = ((struct soc_mixer_control *)kc->private_value)->shift; in wcd9335_get_compander()
2179 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_get_compander()
2181 ucontrol->value.integer.value[0] = wcd->comp_enabled[comp]; in wcd9335_get_compander()
2189 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_set_compander()
2190 int comp = ((struct soc_mixer_control *) kc->private_value)->shift; in wcd9335_set_compander()
2191 int value = ucontrol->value.integer.value[0]; in wcd9335_set_compander()
2194 wcd->comp_enabled[comp] = value; in wcd9335_set_compander()
2228 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_rx_hph_mode_get()
2230 ucontrol->value.enumerated.item[0] = wcd->hph_mode; in wcd9335_rx_hph_mode_get()
2239 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_rx_hph_mode_put()
2242 mode_val = ucontrol->value.enumerated.item[0]; in wcd9335_rx_hph_mode_put()
2245 dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); in wcd9335_rx_hph_mode_put()
2248 wcd->hph_mode = mode_val; in wcd9335_rx_hph_mode_put()
2254 /* -84dB min - 40dB max */
2256 0, -84, 40, digital_gain),
2258 0, -84, 40, digital_gain),
2260 0, -84, 40, digital_gain),
2262 0, -84, 40, digital_gain),
2264 0, -84, 40, digital_gain),
2266 0, -84, 40, digital_gain),
2268 0, -84, 40, digital_gain),
2270 0, -84, 40, digital_gain),
2272 0, -84, 40, digital_gain),
2275 0, -84, 40, digital_gain),
2278 0, -84, 40, digital_gain),
2281 0, -84, 40, digital_gain),
2284 0, -84, 40, digital_gain),
2287 0, -84, 40, digital_gain),
2290 0, -84, 40, digital_gain),
2293 0, -84, 40, digital_gain),
2296 0, -84, 40, digital_gain),
2299 0, -84, 40, digital_gain),
2507 int micb_index = micb_num - 1; in wcd9335_micbias_control()
2510 if ((micb_index < 0) || (micb_index > WCD9335_MAX_MICBIAS - 1)) { in wcd9335_micbias_control()
2511 dev_err(wcd->dev, "Invalid micbias index, micb_ind:%d\n", in wcd9335_micbias_control()
2513 return -EINVAL; in wcd9335_micbias_control()
2530 dev_err(component->dev, "%s: Invalid micbias number: %d\n", in wcd9335_micbias_control()
2532 return -EINVAL; in wcd9335_micbias_control()
2537 wcd->pullup_ref[micb_index]++; in wcd9335_micbias_control()
2538 if ((wcd->pullup_ref[micb_index] == 1) && in wcd9335_micbias_control()
2539 (wcd->micb_ref[micb_index] == 0)) in wcd9335_micbias_control()
2544 wcd->pullup_ref[micb_index]--; in wcd9335_micbias_control()
2545 if ((wcd->pullup_ref[micb_index] == 0) && in wcd9335_micbias_control()
2546 (wcd->micb_ref[micb_index] == 0)) in wcd9335_micbias_control()
2551 wcd->micb_ref[micb_index]++; in wcd9335_micbias_control()
2552 if (wcd->micb_ref[micb_index] == 1) in wcd9335_micbias_control()
2557 wcd->micb_ref[micb_index]--; in wcd9335_micbias_control()
2558 if ((wcd->micb_ref[micb_index] == 0) && in wcd9335_micbias_control()
2559 (wcd->pullup_ref[micb_index] > 0)) in wcd9335_micbias_control()
2562 else if ((wcd->micb_ref[micb_index] == 0) && in wcd9335_micbias_control()
2563 (wcd->pullup_ref[micb_index] == 0)) { in wcd9335_micbias_control()
2576 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in __wcd9335_codec_enable_micbias()
2579 if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) in __wcd9335_codec_enable_micbias()
2581 else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2"))) in __wcd9335_codec_enable_micbias()
2583 else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3"))) in __wcd9335_codec_enable_micbias()
2585 else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4"))) in __wcd9335_codec_enable_micbias()
2588 return -EINVAL; in __wcd9335_codec_enable_micbias()
2646 dev_err(comp->dev, "%s: invalid amic: %d\n", in wcd9335_codec_set_tx_hold()
2655 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_adc()
2659 wcd9335_codec_set_tx_hold(comp, w->reg, true); in wcd9335_codec_enable_adc()
2683 reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + adc_mux_n - 4; in wcd9335_codec_find_amic_input()
2715 dev_err(comp->dev, "invalid amic: %d\n", amic); in wcd9335_codec_get_amic_pwlvl_reg()
2725 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_dec()
2736 widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL); in wcd9335_codec_enable_dec()
2738 return -ENOMEM; in wcd9335_codec_enable_dec()
2743 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd9335_codec_enable_dec()
2744 __func__, w->name); in wcd9335_codec_enable_dec()
2745 ret = -EINVAL; in wcd9335_codec_enable_dec()
2752 dev_err(comp->dev, "%s: decimator index not found\n", in wcd9335_codec_enable_dec()
2754 ret = -EINVAL; in wcd9335_codec_enable_dec()
2760 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd9335_codec_enable_dec()
2762 ret = -EINVAL; in wcd9335_codec_enable_dec()
2861 dev_err(component->dev, in wcd9335_get_dmic_clk_val()
2872 dev_err(component->dev, in wcd9335_get_dmic_clk_val()
2899 dev_err(component->dev, in wcd9335_get_dmic_clk_val()
2912 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_dmic()
2922 wname = strpbrk(w->name, "012345"); in wcd9335_codec_enable_dmic()
2924 dev_err(comp->dev, "%s: widget not found\n", __func__); in wcd9335_codec_enable_dmic()
2925 return -EINVAL; in wcd9335_codec_enable_dmic()
2930 dev_err(comp->dev, "%s: Invalid DMIC line on the codec\n", in wcd9335_codec_enable_dmic()
2932 return -EINVAL; in wcd9335_codec_enable_dmic()
2938 dmic_clk_cnt = &(wcd->dmic_0_1_clk_cnt); in wcd9335_codec_enable_dmic()
2943 dmic_clk_cnt = &(wcd->dmic_2_3_clk_cnt); in wcd9335_codec_enable_dmic()
2948 dmic_clk_cnt = &(wcd->dmic_4_5_clk_cnt); in wcd9335_codec_enable_dmic()
2952 dev_err(comp->dev, "%s: Invalid DMIC Selection\n", in wcd9335_codec_enable_dmic()
2954 return -EINVAL; in wcd9335_codec_enable_dmic()
2961 wcd->mclk_rate, in wcd9335_codec_enable_dmic()
2962 wcd->dmic_sample_rate); in wcd9335_codec_enable_dmic()
2977 wcd->mclk_rate, in wcd9335_codec_enable_dmic()
2978 wcd->mad_dmic_sample_rate); in wcd9335_codec_enable_dmic()
2979 (*dmic_clk_cnt)--; in wcd9335_codec_enable_dmic()
2999 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_enable_int_port()
3002 list_for_each_entry(ch, &dai->slim_ch_list, list) { in wcd9335_codec_enable_int_port()
3003 if (ch->port >= WCD9335_RX_START) { in wcd9335_codec_enable_int_port()
3004 port_num = ch->port - WCD9335_RX_START; in wcd9335_codec_enable_int_port()
3007 port_num = ch->port; in wcd9335_codec_enable_int_port()
3011 regmap_read(wcd->if_regmap, reg, &val); in wcd9335_codec_enable_int_port()
3013 regmap_write(wcd->if_regmap, reg, in wcd9335_codec_enable_int_port()
3022 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_slim()
3024 struct wcd_slim_codec_dai_data *dai = &wcd->dai[w->shift]; in wcd9335_codec_enable_slim()
3031 kfree(dai->sconfig.chs); in wcd9335_codec_enable_slim()
3042 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_mix_path()
3047 switch (w->reg) { in wcd9335_codec_enable_mix_path()
3076 dev_err(comp->dev, "%s: No gain register avail for %s\n", in wcd9335_codec_enable_mix_path()
3077 __func__, w->name); in wcd9335_codec_enable_mix_path()
3193 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_prim_interpolator()
3199 wcd->prim_int_users[ind]++; in wcd9335_codec_enable_prim_interpolator()
3200 if (wcd->prim_int_users[ind] == 1) { in wcd9335_codec_enable_prim_interpolator()
3218 wcd->prim_int_users[ind]--; in wcd9335_codec_enable_prim_interpolator()
3219 if (wcd->prim_int_users[ind] == 0) { in wcd9335_codec_enable_prim_interpolator()
3240 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_config_compander()
3248 comp = interp_n - 1; in wcd9335_config_compander()
3249 if (!wcd->comp_enabled[comp]) in wcd9335_config_compander()
3301 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_interpolator()
3307 if (!(strcmp(w->name, "RX INT0 INTERP"))) { in wcd9335_codec_enable_interpolator()
3310 } else if (!(strcmp(w->name, "RX INT1 INTERP"))) { in wcd9335_codec_enable_interpolator()
3313 } else if (!(strcmp(w->name, "RX INT2 INTERP"))) { in wcd9335_codec_enable_interpolator()
3316 } else if (!(strcmp(w->name, "RX INT3 INTERP"))) { in wcd9335_codec_enable_interpolator()
3319 } else if (!(strcmp(w->name, "RX INT4 INTERP"))) { in wcd9335_codec_enable_interpolator()
3322 } else if (!(strcmp(w->name, "RX INT5 INTERP"))) { in wcd9335_codec_enable_interpolator()
3325 } else if (!(strcmp(w->name, "RX INT6 INTERP"))) { in wcd9335_codec_enable_interpolator()
3328 } else if (!(strcmp(w->name, "RX INT7 INTERP"))) { in wcd9335_codec_enable_interpolator()
3331 } else if (!(strcmp(w->name, "RX INT8 INTERP"))) { in wcd9335_codec_enable_interpolator()
3335 dev_err(comp->dev, "%s: Interpolator reg not found\n", in wcd9335_codec_enable_interpolator()
3337 return -EINVAL; in wcd9335_codec_enable_interpolator()
3346 wcd9335_config_compander(comp, w->shift, event); in wcd9335_codec_enable_interpolator()
3352 wcd9335_config_compander(comp, w->shift, event); in wcd9335_codec_enable_interpolator()
3363 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_hph_mode_gain_opt()
3387 wcd->hph_l_gain = hph_l_en & 0x1F; in wcd9335_codec_hph_mode_gain_opt()
3392 wcd->hph_r_gain = hph_r_en & 0x1F; in wcd9335_codec_hph_mode_gain_opt()
3537 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_hphl_dac_event()
3538 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_hphl_dac_event()
3539 int hph_mode = wcd->hph_mode; in wcd9335_codec_hphl_dac_event()
3549 dev_err(comp->dev, "Incorrect DEM Input\n"); in wcd9335_codec_hphl_dac_event()
3550 return -EINVAL; in wcd9335_codec_hphl_dac_event()
3552 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_hphl_dac_event()
3569 if (!(wcd_clsh_ctrl_get_state(wcd->clsh_ctrl) & in wcd9335_codec_hphl_dac_event()
3573 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_hphl_dac_event()
3586 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_lineout_dac_event()
3587 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_lineout_dac_event()
3591 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_lineout_dac_event()
3595 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_lineout_dac_event()
3606 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_ear_dac_event()
3607 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_ear_dac_event()
3611 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_ear_dac_event()
3616 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_ear_dac_event()
3646 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3651 if (wcd->comp_enabled[COMPANDER_1] || in wcd9335_codec_hph_post_pa_config()
3652 wcd->comp_enabled[COMPANDER_2]) { in wcd9335_codec_hph_post_pa_config()
3654 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3658 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3662 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3667 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3670 wcd->hph_l_gain); in wcd9335_codec_hph_post_pa_config()
3671 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3674 wcd->hph_r_gain); in wcd9335_codec_hph_post_pa_config()
3678 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3688 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_hphr_dac_event()
3689 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_hphr_dac_event()
3690 int hph_mode = wcd->hph_mode; in wcd9335_codec_hphr_dac_event()
3702 dev_err(comp->dev, "DEM Input not set correctly, hph_mode: %d\n", in wcd9335_codec_hphr_dac_event()
3704 return -EINVAL; in wcd9335_codec_hphr_dac_event()
3707 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, in wcd9335_codec_hphr_dac_event()
3720 if (!(wcd_clsh_ctrl_get_state(wcd->clsh_ctrl) & in wcd9335_codec_hphr_dac_event()
3724 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_hphr_dac_event()
3737 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_hphl_pa()
3738 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_hphl_pa()
3739 int hph_mode = wcd->hph_mode; in wcd9335_codec_enable_hphl_pa()
3785 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_lineout_pa()
3788 if (w->reg == WCD9335_ANA_LO_1_2) { in wcd9335_codec_enable_lineout_pa()
3789 if (w->shift == 7) { in wcd9335_codec_enable_lineout_pa()
3792 } else if (w->shift == 6) { in wcd9335_codec_enable_lineout_pa()
3796 } else if (w->reg == WCD9335_ANA_LO_3_4) { in wcd9335_codec_enable_lineout_pa()
3797 if (w->shift == 7) { in wcd9335_codec_enable_lineout_pa()
3800 } else if (w->shift == 6) { in wcd9335_codec_enable_lineout_pa()
3805 dev_err(comp->dev, "Error enabling lineout PA\n"); in wcd9335_codec_enable_lineout_pa()
3806 return -EINVAL; in wcd9335_codec_enable_lineout_pa()
3856 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_rx_bias()
3857 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_rx_bias()
3861 wcd->rx_bias_count++; in wcd9335_codec_enable_rx_bias()
3862 if (wcd->rx_bias_count == 1) { in wcd9335_codec_enable_rx_bias()
3871 wcd->rx_bias_count--; in wcd9335_codec_enable_rx_bias()
3872 if (!wcd->rx_bias_count) in wcd9335_codec_enable_rx_bias()
3886 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_hphr_pa()
3887 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_hphr_pa()
3888 int hph_mode = wcd->hph_mode; in wcd9335_codec_enable_hphr_pa()
3932 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_ear_pa()
3977 regmap_read(wcd->if_regmap, i, &val); in wcd9335_slimbus_irq()
3983 port_id = (tx ? j - 16 : j); in wcd9335_slimbus_irq()
3984 regmap_read(wcd->if_regmap, in wcd9335_slimbus_irq()
3994 wcd->if_regmap, reg, &int_val); in wcd9335_slimbus_irq()
4004 dev_err_ratelimited(wcd->dev, in wcd9335_slimbus_irq()
4009 dev_err_ratelimited(wcd->dev, in wcd9335_slimbus_irq()
4022 wcd->if_regmap, reg, &int_val); in wcd9335_slimbus_irq()
4025 regmap_write(wcd->if_regmap, in wcd9335_slimbus_irq()
4030 regmap_write(wcd->if_regmap, in wcd9335_slimbus_irq()
4052 irq = regmap_irq_get_virq(wcd->irq_data, wcd9335_irqs[i].irq); in wcd9335_setup_irqs()
4054 dev_err(wcd->dev, "Failed to get %s\n", in wcd9335_setup_irqs()
4059 ret = devm_request_threaded_irq(wcd->dev, irq, NULL, in wcd9335_setup_irqs()
4065 dev_err(wcd->dev, "Failed to request %s\n", in wcd9335_setup_irqs()
4073 regmap_write(wcd->if_regmap, WCD9335_SLIM_PGD_PORT_INT_EN0 + i, in wcd9335_setup_irqs()
4082 struct snd_soc_component *comp = wcd->component; in wcd9335_cdc_sido_ccl_enable()
4085 if (++wcd->sido_ccl_cnt == 1) in wcd9335_cdc_sido_ccl_enable()
4089 if (wcd->sido_ccl_cnt == 0) { in wcd9335_cdc_sido_ccl_enable()
4090 dev_err(wcd->dev, "sido_ccl already disabled\n"); in wcd9335_cdc_sido_ccl_enable()
4093 if (--wcd->sido_ccl_cnt == 0) in wcd9335_cdc_sido_ccl_enable()
4101 wcd->master_bias_users++; in wcd9335_enable_master_bias()
4102 if (wcd->master_bias_users == 1) { in wcd9335_enable_master_bias()
4103 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4106 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4110 * 1ms delay is required after pre-charge is enabled in wcd9335_enable_master_bias()
4114 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4117 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4128 if (wcd->master_bias_users <= 0) in wcd9335_enable_mclk()
4129 return -EINVAL; in wcd9335_enable_mclk()
4131 if (((wcd->clk_mclk_users == 0) && (wcd->clk_type == WCD_CLK_MCLK)) || in wcd9335_enable_mclk()
4132 ((wcd->clk_mclk_users > 0) && (wcd->clk_type != WCD_CLK_MCLK))) { in wcd9335_enable_mclk()
4133 dev_err(wcd->dev, "Error enabling MCLK, clk_type: %d\n", in wcd9335_enable_mclk()
4134 wcd->clk_type); in wcd9335_enable_mclk()
4135 return -EINVAL; in wcd9335_enable_mclk()
4138 if (++wcd->clk_mclk_users == 1) { in wcd9335_enable_mclk()
4139 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4142 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4145 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4148 regmap_update_bits(wcd->regmap, in wcd9335_enable_mclk()
4152 regmap_update_bits(wcd->regmap, in wcd9335_enable_mclk()
4163 wcd->clk_type = WCD_CLK_MCLK; in wcd9335_enable_mclk()
4170 if (wcd->clk_mclk_users <= 0) in wcd9335_disable_mclk()
4171 return -EINVAL; in wcd9335_disable_mclk()
4173 if (--wcd->clk_mclk_users == 0) { in wcd9335_disable_mclk()
4174 if (wcd->clk_rco_users > 0) { in wcd9335_disable_mclk()
4176 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4179 wcd->clk_type = WCD_CLK_RCO; in wcd9335_disable_mclk()
4181 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4184 wcd->clk_type = WCD_CLK_OFF; in wcd9335_disable_mclk()
4187 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4197 if (wcd->master_bias_users <= 0) in wcd9335_disable_master_bias()
4198 return -EINVAL; in wcd9335_disable_master_bias()
4200 wcd->master_bias_users--; in wcd9335_disable_master_bias()
4201 if (wcd->master_bias_users == 0) { in wcd9335_disable_master_bias()
4202 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_disable_master_bias()
4205 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_disable_master_bias()
4219 ret = clk_prepare_enable(wcd->mclk); in wcd9335_cdc_req_mclk_enable()
4221 dev_err(wcd->dev, "%s: ext clk enable failed\n", in wcd9335_cdc_req_mclk_enable()
4235 clk_disable_unprepare(wcd->mclk); in wcd9335_cdc_req_mclk_enable()
4245 struct snd_soc_component *comp = wcd->component; in wcd9335_codec_apply_sido_voltage()
4248 if (req_mv == wcd->sido_voltage) in wcd9335_codec_apply_sido_voltage()
4259 /* 1 msec sleep required after SIDO Vout_D voltage change */ in wcd9335_codec_apply_sido_voltage()
4261 wcd->sido_voltage = req_mv; in wcd9335_codec_apply_sido_voltage()
4272 /* enable mclk before setting SIDO voltage */ in wcd9335_codec_update_sido_voltage()
4275 dev_err(wcd->dev, "Ext clk enable failed\n"); in wcd9335_codec_update_sido_voltage()
4289 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in _wcd9335_codec_enable_mclk()
4301 wcd->sido_voltage); in _wcd9335_codec_enable_mclk()
4311 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_mclk()
4780 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_enable_sido_buck()
4795 wcd->sido_input_src = SIDO_SOURCE_RCO_BG; in wcd9335_enable_sido_buck()
4824 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_init()
4828 regmap_update_bits(wcd->regmap, WCD9335_CODEC_RPM_CLK_GATE, in wcd9335_codec_init()
4831 regmap_update_bits(wcd->regmap, WCD9335_CODEC_RPM_CLK_MCLK_CFG, in wcd9335_codec_init()
4846 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_probe()
4849 snd_soc_component_init_regmap(component, wcd->regmap); in wcd9335_codec_probe()
4850 /* Class-H Init*/ in wcd9335_codec_probe()
4851 wcd->clsh_ctrl = wcd_clsh_ctrl_alloc(component, wcd->version); in wcd9335_codec_probe()
4852 if (IS_ERR(wcd->clsh_ctrl)) in wcd9335_codec_probe()
4853 return PTR_ERR(wcd->clsh_ctrl); in wcd9335_codec_probe()
4855 /* Default HPH Mode to Class-H HiFi */ in wcd9335_codec_probe()
4856 wcd->hph_mode = CLS_H_HIFI; in wcd9335_codec_probe()
4857 wcd->component = component; in wcd9335_codec_probe()
4862 INIT_LIST_HEAD(&wcd->dai[i].slim_ch_list); in wcd9335_codec_probe()
4869 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_remove()
4871 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd9335_codec_remove()
4872 free_irq(regmap_irq_get_virq(wcd->irq_data, WCD9335_IRQ_SLIMBUS), wcd); in wcd9335_codec_remove()
4879 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_set_sysclk()
4881 wcd->mclk_rate = freq; in wcd9335_codec_set_sysclk()
4883 if (wcd->mclk_rate == WCD9335_MCLK_CLK_12P288MHZ) in wcd9335_codec_set_sysclk()
4888 else if (wcd->mclk_rate == WCD9335_MCLK_CLK_9P6MHZ) in wcd9335_codec_set_sysclk()
4894 return clk_set_rate(wcd->mclk, freq); in wcd9335_codec_set_sysclk()
4911 struct device *dev = wcd->dev; in wcd9335_probe()
4913 memcpy(wcd->rx_chs, wcd9335_rx_chs, sizeof(wcd9335_rx_chs)); in wcd9335_probe()
4914 memcpy(wcd->tx_chs, wcd9335_tx_chs, sizeof(wcd9335_tx_chs)); in wcd9335_probe()
4916 wcd->sido_input_src = SIDO_SOURCE_INTERNAL; in wcd9335_probe()
4917 wcd->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV; in wcd9335_probe()
4969 .name = "WCD9335-IFC-DEV",
5016 struct device *dev = wcd->dev; in wcd9335_parse_dt()
5017 struct device_node *np = dev->of_node; in wcd9335_parse_dt()
5020 wcd->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0); in wcd9335_parse_dt()
5021 if (wcd->reset_gpio < 0) { in wcd9335_parse_dt()
5023 return wcd->reset_gpio; in wcd9335_parse_dt()
5026 wcd->mclk = devm_clk_get(dev, "mclk"); in wcd9335_parse_dt()
5027 if (IS_ERR(wcd->mclk)) { in wcd9335_parse_dt()
5029 return PTR_ERR(wcd->mclk); in wcd9335_parse_dt()
5032 wcd->native_clk = devm_clk_get(dev, "slimbus"); in wcd9335_parse_dt()
5033 if (IS_ERR(wcd->native_clk)) { in wcd9335_parse_dt()
5035 return PTR_ERR(wcd->native_clk); in wcd9335_parse_dt()
5038 wcd->supplies[0].supply = "vdd-buck"; in wcd9335_parse_dt()
5039 wcd->supplies[1].supply = "vdd-buck-sido"; in wcd9335_parse_dt()
5040 wcd->supplies[2].supply = "vdd-tx"; in wcd9335_parse_dt()
5041 wcd->supplies[3].supply = "vdd-rx"; in wcd9335_parse_dt()
5042 wcd->supplies[4].supply = "vdd-io"; in wcd9335_parse_dt()
5044 ret = regulator_bulk_get(dev, WCD9335_MAX_SUPPLY, wcd->supplies); in wcd9335_parse_dt()
5055 struct device *dev = wcd->dev; in wcd9335_power_on_reset()
5058 ret = regulator_bulk_enable(WCD9335_MAX_SUPPLY, wcd->supplies); in wcd9335_power_on_reset()
5073 gpio_direction_output(wcd->reset_gpio, 0); in wcd9335_power_on_reset()
5075 gpio_set_value(wcd->reset_gpio, 1); in wcd9335_power_on_reset()
5083 struct regmap *rm = wcd->regmap; in wcd9335_bring_up()
5090 dev_err(wcd->dev, "WCD9335 CODEC version detection fail!\n"); in wcd9335_bring_up()
5091 return -EINVAL; in wcd9335_bring_up()
5095 dev_info(wcd->dev, "WCD9335 CODEC version is v2.0\n"); in wcd9335_bring_up()
5096 wcd->version = WCD9335_VERSION_2_0; in wcd9335_bring_up()
5106 dev_err(wcd->dev, "WCD9335 CODEC version not supported\n"); in wcd9335_bring_up()
5107 return -EINVAL; in wcd9335_bring_up()
5122 wcd->intr1 = of_irq_get_byname(wcd->dev->of_node, "intr1"); in wcd9335_irq_init()
5123 if (wcd->intr1 < 0) { in wcd9335_irq_init()
5124 if (wcd->intr1 != -EPROBE_DEFER) in wcd9335_irq_init()
5125 dev_err(wcd->dev, "Unable to configure IRQ\n"); in wcd9335_irq_init()
5127 return wcd->intr1; in wcd9335_irq_init()
5130 ret = devm_regmap_add_irq_chip(wcd->dev, wcd->regmap, wcd->intr1, in wcd9335_irq_init()
5132 &wcd9335_regmap_irq1_chip, &wcd->irq_data); in wcd9335_irq_init()
5134 dev_err(wcd->dev, "Failed to register IRQ chip: %d\n", ret); in wcd9335_irq_init()
5141 struct device *dev = &slim->dev; in wcd9335_slim_probe()
5147 return -ENOMEM; in wcd9335_slim_probe()
5149 wcd->dev = dev; in wcd9335_slim_probe()
5168 struct device *dev = &sdev->dev; in wcd9335_slim_status()
5175 ifc_dev_np = of_parse_phandle(dev->of_node, "slim-ifc-dev", 0); in wcd9335_slim_status()
5178 return -EINVAL; in wcd9335_slim_status()
5181 wcd->slim = sdev; in wcd9335_slim_status()
5182 wcd->slim_ifc_dev = of_slim_get_device(sdev->ctrl, ifc_dev_np); in wcd9335_slim_status()
5184 if (!wcd->slim_ifc_dev) { in wcd9335_slim_status()
5186 return -EINVAL; in wcd9335_slim_status()
5189 slim_get_logical_addr(wcd->slim_ifc_dev); in wcd9335_slim_status()
5191 wcd->regmap = regmap_init_slimbus(sdev, &wcd9335_regmap_config); in wcd9335_slim_status()
5192 if (IS_ERR(wcd->regmap)) { in wcd9335_slim_status()
5194 return PTR_ERR(wcd->regmap); in wcd9335_slim_status()
5197 wcd->if_regmap = regmap_init_slimbus(wcd->slim_ifc_dev, in wcd9335_slim_status()
5199 if (IS_ERR(wcd->if_regmap)) { in wcd9335_slim_status()
5201 return PTR_ERR(wcd->if_regmap); in wcd9335_slim_status()
5227 .name = "wcd9335-slim",