Lines Matching full:wcd

26 #include "wcd-clsh-v2.h"
1260 struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_get() local
1263 ucontrol->value.enumerated.item[0] = wcd->rx_port_value[port_id]; in slim_rx_mux_get()
1272 struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_put() local
1277 if (wcd->rx_port_value[port_id] == ucontrol->value.enumerated.item[0]) in slim_rx_mux_put()
1280 wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0]; in slim_rx_mux_put()
1283 list_del_init(&wcd->rx_chs[port_id].list); in slim_rx_mux_put()
1285 switch (wcd->rx_port_value[port_id]) { in slim_rx_mux_put()
1290 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1291 &wcd->dai[AIF1_PB].slim_ch_list); in slim_rx_mux_put()
1294 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1295 &wcd->dai[AIF2_PB].slim_ch_list); in slim_rx_mux_put()
1298 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1299 &wcd->dai[AIF3_PB].slim_ch_list); in slim_rx_mux_put()
1302 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1303 &wcd->dai[AIF4_PB].slim_ch_list); in slim_rx_mux_put()
1306 dev_err(wcd->dev, "Unknown AIF %d\n", wcd->rx_port_value[port_id]); in slim_rx_mux_put()
1310 snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id], in slim_rx_mux_put()
1323 struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev); in slim_tx_mixer_get() local
1330 ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id] == dai_id; in slim_tx_mixer_get()
1340 struct wcd9335_codec *wcd = dev_get_drvdata(widget->dapm->dev); in slim_tx_mixer_put() local
1353 if (enable && wcd->tx_port_value[port_id] != dai_id) { in slim_tx_mixer_put()
1354 wcd->tx_port_value[port_id] = dai_id; in slim_tx_mixer_put()
1355 list_add_tail(&wcd->tx_chs[port_id].list, in slim_tx_mixer_put()
1356 &wcd->dai[dai_id].slim_ch_list); in slim_tx_mixer_put()
1357 } else if (!enable && wcd->tx_port_value[port_id] == dai_id) { in slim_tx_mixer_put()
1358 wcd->tx_port_value[port_id] = -1; in slim_tx_mixer_put()
1359 list_del_init(&wcd->tx_chs[port_id].list); in slim_tx_mixer_put()
1363 dev_err(wcd->dev, "Unknown AIF %d\n", dai_id); in slim_tx_mixer_put()
1613 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_set_mix_interpolator_rate() local
1617 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_mix_interpolator_rate()
1639 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_set_prim_interpolator_rate() local
1644 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_prim_interpolator_rate()
1668 dev_info(wcd->dev, in wcd9335_set_prim_interpolator_rate()
1707 static int wcd9335_slim_set_hw_params(struct wcd9335_codec *wcd, in wcd9335_slim_set_hw_params() argument
1737 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1745 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1751 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1758 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1765 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1774 dai_data->sruntime = slim_stream_allocate(wcd->slim, "WCD9335-SLIM"); in wcd9335_slim_set_hw_params()
1779 dev_err(wcd->dev, "Error Setting slim hw params\n"); in wcd9335_slim_set_hw_params()
1790 struct wcd9335_codec *wcd = snd_soc_component_get_drvdata(comp); in wcd9335_set_decimator_rate() local
1796 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_decimator_rate()
1799 dev_err(wcd->dev, "Invalid SLIM TX%u port DAI ID:%d\n", in wcd9335_set_decimator_rate()
1851 dev_err(wcd->dev, "RX_MIX_TX%u going to SLIM TX%u\n", in wcd9335_set_decimator_rate()
1854 dev_err(wcd->dev, "ERROR: Invalid decimator: %d\n", in wcd9335_set_decimator_rate()
1867 struct wcd9335_codec *wcd; in wcd9335_hw_params() local
1870 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_hw_params()
1876 dev_err(wcd->dev, "cannot set sample rate: %u\n", in wcd9335_hw_params()
1882 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd9335_hw_params()
1885 dev_err(wcd->dev, "%s: Invalid format 0x%x\n", in wcd9335_hw_params()
1915 dev_err(wcd->dev, "%s: Invalid TX sample rate: %d\n", in wcd9335_hw_params()
1924 dev_err(wcd->dev, "Cannot set TX Decimator rate\n"); in wcd9335_hw_params()
1929 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd9335_hw_params()
1932 dev_err(wcd->dev, "%s: Invalid format 0x%x\n", in wcd9335_hw_params()
1938 dev_err(wcd->dev, "Invalid stream type %d\n", in wcd9335_hw_params()
1943 wcd->dai[dai->id].sconfig.rate = params_rate(params); in wcd9335_hw_params()
1944 wcd9335_slim_set_hw_params(wcd, &wcd->dai[dai->id], substream->stream); in wcd9335_hw_params()
1953 struct wcd9335_codec *wcd; in wcd9335_trigger() local
1956 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_trigger()
1958 dai_data = &wcd->dai[dai->id]; in wcd9335_trigger()
1987 struct wcd9335_codec *wcd; in wcd9335_set_channel_map() local
1990 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_set_channel_map()
1993 dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n", in wcd9335_set_channel_map()
1998 wcd->num_rx_port = rx_num; in wcd9335_set_channel_map()
2000 wcd->rx_chs[i].ch_num = rx_slot[i]; in wcd9335_set_channel_map()
2001 INIT_LIST_HEAD(&wcd->rx_chs[i].list); in wcd9335_set_channel_map()
2004 wcd->num_tx_port = tx_num; in wcd9335_set_channel_map()
2006 wcd->tx_chs[i].ch_num = tx_slot[i]; in wcd9335_set_channel_map()
2007 INIT_LIST_HEAD(&wcd->tx_chs[i].list); in wcd9335_set_channel_map()
2018 struct wcd9335_codec *wcd; in wcd9335_get_channel_map() local
2021 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_get_channel_map()
2029 dev_err(wcd->dev, "Invalid rx_slot %p or rx_num %p\n", in wcd9335_get_channel_map()
2034 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd9335_get_channel_map()
2043 dev_err(wcd->dev, "Invalid tx_slot %p or tx_num %p\n", in wcd9335_get_channel_map()
2047 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd9335_get_channel_map()
2053 dev_err(wcd->dev, "Invalid DAI ID %x\n", dai->id); in wcd9335_get_channel_map()
2178 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_get_compander() local
2180 ucontrol->value.integer.value[0] = wcd->comp_enabled[comp]; in wcd9335_get_compander()
2188 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_set_compander() local
2193 wcd->comp_enabled[comp] = value; in wcd9335_set_compander()
2227 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_rx_hph_mode_get() local
2229 ucontrol->value.enumerated.item[0] = wcd->hph_mode; in wcd9335_rx_hph_mode_get()
2238 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_rx_hph_mode_put() local
2244 dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); in wcd9335_rx_hph_mode_put()
2247 wcd->hph_mode = mode_val; in wcd9335_rx_hph_mode_put()
2496 struct wcd9335_codec *wcd = snd_soc_component_get_drvdata(component); in wcd9335_micbias_control() local
2501 dev_err(wcd->dev, "Invalid micbias index, micb_ind:%d\n", in wcd9335_micbias_control()
2527 wcd->pullup_ref[micb_index]++; in wcd9335_micbias_control()
2528 if ((wcd->pullup_ref[micb_index] == 1) && in wcd9335_micbias_control()
2529 (wcd->micb_ref[micb_index] == 0)) in wcd9335_micbias_control()
2534 wcd->pullup_ref[micb_index]--; in wcd9335_micbias_control()
2535 if ((wcd->pullup_ref[micb_index] == 0) && in wcd9335_micbias_control()
2536 (wcd->micb_ref[micb_index] == 0)) in wcd9335_micbias_control()
2541 wcd->micb_ref[micb_index]++; in wcd9335_micbias_control()
2542 if (wcd->micb_ref[micb_index] == 1) in wcd9335_micbias_control()
2547 wcd->micb_ref[micb_index]--; in wcd9335_micbias_control()
2548 if ((wcd->micb_ref[micb_index] == 0) && in wcd9335_micbias_control()
2549 (wcd->pullup_ref[micb_index] > 0)) in wcd9335_micbias_control()
2552 else if ((wcd->micb_ref[micb_index] == 0) && in wcd9335_micbias_control()
2553 (wcd->pullup_ref[micb_index] == 0)) { in wcd9335_micbias_control()
2857 struct wcd9335_codec *wcd = snd_soc_component_get_drvdata(comp); in wcd9335_codec_enable_dmic() local
2882 dmic_clk_cnt = &(wcd->dmic_0_1_clk_cnt); in wcd9335_codec_enable_dmic()
2887 dmic_clk_cnt = &(wcd->dmic_2_3_clk_cnt); in wcd9335_codec_enable_dmic()
2892 dmic_clk_cnt = &(wcd->dmic_4_5_clk_cnt); in wcd9335_codec_enable_dmic()
2903 dmic_rate_val = wcd9335_get_dmic_clk_val(comp, wcd->mclk_rate); in wcd9335_codec_enable_dmic()
2915 dmic_rate_val = wcd9335_get_dmic_clk_val(comp, wcd->mclk_rate); in wcd9335_codec_enable_dmic()
2936 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_enable_int_port() local
2948 regmap_read(wcd->if_regmap, reg, &val); in wcd9335_codec_enable_int_port()
2950 regmap_write(wcd->if_regmap, reg, in wcd9335_codec_enable_int_port()
2960 struct wcd9335_codec *wcd = snd_soc_component_get_drvdata(comp); in wcd9335_codec_enable_slim() local
2961 struct wcd_slim_codec_dai_data *dai = &wcd->dai[w->shift]; in wcd9335_codec_enable_slim()
3128 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_prim_interpolator() local
3134 wcd->prim_int_users[ind]++; in wcd9335_codec_enable_prim_interpolator()
3135 if (wcd->prim_int_users[ind] == 1) { in wcd9335_codec_enable_prim_interpolator()
3153 wcd->prim_int_users[ind]--; in wcd9335_codec_enable_prim_interpolator()
3154 if (wcd->prim_int_users[ind] == 0) { in wcd9335_codec_enable_prim_interpolator()
3175 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_config_compander() local
3184 if (!wcd->comp_enabled[comp]) in wcd9335_config_compander()
3296 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_hph_mode_gain_opt() local
3320 wcd->hph_l_gain = hph_l_en & 0x1F; in wcd9335_codec_hph_mode_gain_opt()
3325 wcd->hph_r_gain = hph_r_en & 0x1F; in wcd9335_codec_hph_mode_gain_opt()
3471 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_hphl_dac_event() local
3472 int hph_mode = wcd->hph_mode; in wcd9335_codec_hphl_dac_event()
3485 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_hphl_dac_event()
3502 if (!(wcd_clsh_ctrl_get_state(wcd->clsh_ctrl) & in wcd9335_codec_hphl_dac_event()
3506 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_hphl_dac_event()
3520 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_lineout_dac_event() local
3524 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_lineout_dac_event()
3528 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_lineout_dac_event()
3540 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_ear_dac_event() local
3544 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_ear_dac_event()
3549 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_ear_dac_event()
3557 static void wcd9335_codec_hph_post_pa_config(struct wcd9335_codec *wcd, in wcd9335_codec_hph_post_pa_config() argument
3579 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3584 if (wcd->comp_enabled[COMPANDER_1] || in wcd9335_codec_hph_post_pa_config()
3585 wcd->comp_enabled[COMPANDER_2]) { in wcd9335_codec_hph_post_pa_config()
3587 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3591 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3595 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3600 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3603 wcd->hph_l_gain); in wcd9335_codec_hph_post_pa_config()
3604 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3607 wcd->hph_r_gain); in wcd9335_codec_hph_post_pa_config()
3611 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3622 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_hphr_dac_event() local
3623 int hph_mode = wcd->hph_mode; in wcd9335_codec_hphr_dac_event()
3640 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, in wcd9335_codec_hphr_dac_event()
3653 if (!(wcd_clsh_ctrl_get_state(wcd->clsh_ctrl) & in wcd9335_codec_hphr_dac_event()
3657 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_hphr_dac_event()
3671 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_hphl_pa() local
3672 int hph_mode = wcd->hph_mode; in wcd9335_codec_enable_hphl_pa()
3684 wcd9335_codec_hph_post_pa_config(wcd, hph_mode, event); in wcd9335_codec_enable_hphl_pa()
3701 wcd9335_codec_hph_post_pa_config(wcd, hph_mode, event); in wcd9335_codec_enable_hphl_pa()
3790 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_rx_bias() local
3794 wcd->rx_bias_count++; in wcd9335_codec_enable_rx_bias()
3795 if (wcd->rx_bias_count == 1) { in wcd9335_codec_enable_rx_bias()
3804 wcd->rx_bias_count--; in wcd9335_codec_enable_rx_bias()
3805 if (!wcd->rx_bias_count) in wcd9335_codec_enable_rx_bias()
3820 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_hphr_pa() local
3821 int hph_mode = wcd->hph_mode; in wcd9335_codec_enable_hphr_pa()
3832 wcd9335_codec_hph_post_pa_config(wcd, hph_mode, event); in wcd9335_codec_enable_hphr_pa()
3849 wcd9335_codec_hph_post_pa_config(wcd, hph_mode, event); in wcd9335_codec_enable_hphr_pa()
3900 struct wcd9335_codec *wcd = data; in wcd9335_slimbus_irq() local
3910 regmap_read(wcd->if_regmap, i, &val); in wcd9335_slimbus_irq()
3917 regmap_read(wcd->if_regmap, in wcd9335_slimbus_irq()
3927 wcd->if_regmap, reg, &int_val); in wcd9335_slimbus_irq()
3937 dev_err_ratelimited(wcd->dev, in wcd9335_slimbus_irq()
3942 dev_err_ratelimited(wcd->dev, in wcd9335_slimbus_irq()
3955 wcd->if_regmap, reg, &int_val); in wcd9335_slimbus_irq()
3958 regmap_write(wcd->if_regmap, in wcd9335_slimbus_irq()
3963 regmap_write(wcd->if_regmap, in wcd9335_slimbus_irq()
3980 static int wcd9335_setup_irqs(struct wcd9335_codec *wcd) in wcd9335_setup_irqs() argument
3985 irq = regmap_irq_get_virq(wcd->irq_data, wcd9335_irqs[i].irq); in wcd9335_setup_irqs()
3987 dev_err(wcd->dev, "Failed to get %s\n", in wcd9335_setup_irqs()
3992 ret = devm_request_threaded_irq(wcd->dev, irq, NULL, in wcd9335_setup_irqs()
3996 wcd9335_irqs[i].name, wcd); in wcd9335_setup_irqs()
3998 dev_err(wcd->dev, "Failed to request %s\n", in wcd9335_setup_irqs()
4006 regmap_write(wcd->if_regmap, WCD9335_SLIM_PGD_PORT_INT_EN0 + i, in wcd9335_setup_irqs()
4012 static void wcd9335_teardown_irqs(struct wcd9335_codec *wcd) in wcd9335_teardown_irqs() argument
4018 regmap_write(wcd->if_regmap, WCD9335_SLIM_PGD_PORT_INT_EN0 + i, in wcd9335_teardown_irqs()
4022 static void wcd9335_cdc_sido_ccl_enable(struct wcd9335_codec *wcd, in wcd9335_cdc_sido_ccl_enable() argument
4025 struct snd_soc_component *comp = wcd->component; in wcd9335_cdc_sido_ccl_enable()
4028 if (++wcd->sido_ccl_cnt == 1) in wcd9335_cdc_sido_ccl_enable()
4032 if (wcd->sido_ccl_cnt == 0) { in wcd9335_cdc_sido_ccl_enable()
4033 dev_err(wcd->dev, "sido_ccl already disabled\n"); in wcd9335_cdc_sido_ccl_enable()
4036 if (--wcd->sido_ccl_cnt == 0) in wcd9335_cdc_sido_ccl_enable()
4042 static int wcd9335_enable_master_bias(struct wcd9335_codec *wcd) in wcd9335_enable_master_bias() argument
4044 wcd->master_bias_users++; in wcd9335_enable_master_bias()
4045 if (wcd->master_bias_users == 1) { in wcd9335_enable_master_bias()
4046 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4049 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4057 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4060 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4068 static int wcd9335_enable_mclk(struct wcd9335_codec *wcd) in wcd9335_enable_mclk() argument
4071 if (wcd->master_bias_users <= 0) in wcd9335_enable_mclk()
4074 if (((wcd->clk_mclk_users == 0) && (wcd->clk_type == WCD_CLK_MCLK)) || in wcd9335_enable_mclk()
4075 ((wcd->clk_mclk_users > 0) && (wcd->clk_type != WCD_CLK_MCLK))) { in wcd9335_enable_mclk()
4076 dev_err(wcd->dev, "Error enabling MCLK, clk_type: %d\n", in wcd9335_enable_mclk()
4077 wcd->clk_type); in wcd9335_enable_mclk()
4081 if (++wcd->clk_mclk_users == 1) { in wcd9335_enable_mclk()
4082 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4085 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4088 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4091 regmap_update_bits(wcd->regmap, in wcd9335_enable_mclk()
4095 regmap_update_bits(wcd->regmap, in wcd9335_enable_mclk()
4106 wcd->clk_type = WCD_CLK_MCLK; in wcd9335_enable_mclk()
4111 static int wcd9335_disable_mclk(struct wcd9335_codec *wcd) in wcd9335_disable_mclk() argument
4113 if (wcd->clk_mclk_users <= 0) in wcd9335_disable_mclk()
4116 if (--wcd->clk_mclk_users == 0) { in wcd9335_disable_mclk()
4117 if (wcd->clk_rco_users > 0) { in wcd9335_disable_mclk()
4119 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4122 wcd->clk_type = WCD_CLK_RCO; in wcd9335_disable_mclk()
4124 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4127 wcd->clk_type = WCD_CLK_OFF; in wcd9335_disable_mclk()
4130 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4138 static int wcd9335_disable_master_bias(struct wcd9335_codec *wcd) in wcd9335_disable_master_bias() argument
4140 if (wcd->master_bias_users <= 0) in wcd9335_disable_master_bias()
4143 wcd->master_bias_users--; in wcd9335_disable_master_bias()
4144 if (wcd->master_bias_users == 0) { in wcd9335_disable_master_bias()
4145 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_disable_master_bias()
4148 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_disable_master_bias()
4155 static int wcd9335_cdc_req_mclk_enable(struct wcd9335_codec *wcd, in wcd9335_cdc_req_mclk_enable() argument
4161 wcd9335_cdc_sido_ccl_enable(wcd, true); in wcd9335_cdc_req_mclk_enable()
4162 ret = clk_prepare_enable(wcd->mclk); in wcd9335_cdc_req_mclk_enable()
4164 dev_err(wcd->dev, "%s: ext clk enable failed\n", in wcd9335_cdc_req_mclk_enable()
4169 wcd9335_enable_master_bias(wcd); in wcd9335_cdc_req_mclk_enable()
4171 wcd9335_enable_mclk(wcd); in wcd9335_cdc_req_mclk_enable()
4175 wcd9335_disable_mclk(wcd); in wcd9335_cdc_req_mclk_enable()
4177 wcd9335_disable_master_bias(wcd); in wcd9335_cdc_req_mclk_enable()
4178 clk_disable_unprepare(wcd->mclk); in wcd9335_cdc_req_mclk_enable()
4179 wcd9335_cdc_sido_ccl_enable(wcd, false); in wcd9335_cdc_req_mclk_enable()
4185 static void wcd9335_codec_apply_sido_voltage(struct wcd9335_codec *wcd, in wcd9335_codec_apply_sido_voltage() argument
4188 struct snd_soc_component *comp = wcd->component; in wcd9335_codec_apply_sido_voltage()
4191 if (req_mv == wcd->sido_voltage) in wcd9335_codec_apply_sido_voltage()
4204 wcd->sido_voltage = req_mv; in wcd9335_codec_apply_sido_voltage()
4210 static int wcd9335_codec_update_sido_voltage(struct wcd9335_codec *wcd, in wcd9335_codec_update_sido_voltage() argument
4216 ret = wcd9335_cdc_req_mclk_enable(wcd, true); in wcd9335_codec_update_sido_voltage()
4218 dev_err(wcd->dev, "Ext clk enable failed\n"); in wcd9335_codec_update_sido_voltage()
4222 wcd9335_codec_apply_sido_voltage(wcd, req_mv); in wcd9335_codec_update_sido_voltage()
4223 wcd9335_cdc_req_mclk_enable(wcd, false); in wcd9335_codec_update_sido_voltage()
4232 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in _wcd9335_codec_enable_mclk() local
4236 ret = wcd9335_cdc_req_mclk_enable(wcd, true); in _wcd9335_codec_enable_mclk()
4240 wcd9335_codec_apply_sido_voltage(wcd, in _wcd9335_codec_enable_mclk()
4243 wcd9335_codec_update_sido_voltage(wcd, in _wcd9335_codec_enable_mclk()
4244 wcd->sido_voltage); in _wcd9335_codec_enable_mclk()
4245 wcd9335_cdc_req_mclk_enable(wcd, false); in _wcd9335_codec_enable_mclk()
4723 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_enable_sido_buck() local
4738 wcd->sido_input_src = SIDO_SOURCE_RCO_BG; in wcd9335_enable_sido_buck()
4767 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_init() local
4771 regmap_update_bits(wcd->regmap, WCD9335_CODEC_RPM_CLK_GATE, in wcd9335_codec_init()
4774 regmap_update_bits(wcd->regmap, WCD9335_CODEC_RPM_CLK_MCLK_CFG, in wcd9335_codec_init()
4789 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_probe() local
4793 snd_soc_component_init_regmap(component, wcd->regmap); in wcd9335_codec_probe()
4795 wcd->clsh_ctrl = wcd_clsh_ctrl_alloc(component, WCD9335); in wcd9335_codec_probe()
4796 if (IS_ERR(wcd->clsh_ctrl)) in wcd9335_codec_probe()
4797 return PTR_ERR(wcd->clsh_ctrl); in wcd9335_codec_probe()
4800 wcd->hph_mode = CLS_H_HIFI; in wcd9335_codec_probe()
4801 wcd->component = component; in wcd9335_codec_probe()
4806 INIT_LIST_HEAD(&wcd->dai[i].slim_ch_list); in wcd9335_codec_probe()
4808 ret = wcd9335_setup_irqs(wcd); in wcd9335_codec_probe()
4815 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd9335_codec_probe()
4821 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_remove() local
4823 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd9335_codec_remove()
4824 wcd9335_teardown_irqs(wcd); in wcd9335_codec_remove()
4831 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_set_sysclk() local
4833 wcd->mclk_rate = freq; in wcd9335_codec_set_sysclk()
4835 if (wcd->mclk_rate == WCD9335_MCLK_CLK_12P288MHZ) in wcd9335_codec_set_sysclk()
4840 else if (wcd->mclk_rate == WCD9335_MCLK_CLK_9P6MHZ) in wcd9335_codec_set_sysclk()
4846 return clk_set_rate(wcd->mclk, freq); in wcd9335_codec_set_sysclk()
4862 static int wcd9335_probe(struct wcd9335_codec *wcd) in wcd9335_probe() argument
4864 struct device *dev = wcd->dev; in wcd9335_probe()
4866 memcpy(wcd->rx_chs, wcd9335_rx_chs, sizeof(wcd9335_rx_chs)); in wcd9335_probe()
4867 memcpy(wcd->tx_chs, wcd9335_tx_chs, sizeof(wcd9335_tx_chs)); in wcd9335_probe()
4869 wcd->sido_input_src = SIDO_SOURCE_INTERNAL; in wcd9335_probe()
4870 wcd->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV; in wcd9335_probe()
4973 static int wcd9335_parse_dt(struct wcd9335_codec *wcd) in wcd9335_parse_dt() argument
4975 struct device *dev = wcd->dev; in wcd9335_parse_dt()
4979 wcd->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0); in wcd9335_parse_dt()
4980 if (wcd->reset_gpio < 0) in wcd9335_parse_dt()
4981 return dev_err_probe(dev, wcd->reset_gpio, "Reset GPIO missing from DT\n"); in wcd9335_parse_dt()
4983 wcd->mclk = devm_clk_get(dev, "mclk"); in wcd9335_parse_dt()
4984 if (IS_ERR(wcd->mclk)) in wcd9335_parse_dt()
4985 return dev_err_probe(dev, PTR_ERR(wcd->mclk), "mclk not found\n"); in wcd9335_parse_dt()
4987 wcd->native_clk = devm_clk_get(dev, "slimbus"); in wcd9335_parse_dt()
4988 if (IS_ERR(wcd->native_clk)) in wcd9335_parse_dt()
4989 return dev_err_probe(dev, PTR_ERR(wcd->native_clk), "slimbus clock not found\n"); in wcd9335_parse_dt()
4991 wcd->supplies[0].supply = "vdd-buck"; in wcd9335_parse_dt()
4992 wcd->supplies[1].supply = "vdd-buck-sido"; in wcd9335_parse_dt()
4993 wcd->supplies[2].supply = "vdd-tx"; in wcd9335_parse_dt()
4994 wcd->supplies[3].supply = "vdd-rx"; in wcd9335_parse_dt()
4995 wcd->supplies[4].supply = "vdd-io"; in wcd9335_parse_dt()
4997 ret = regulator_bulk_get(dev, WCD9335_MAX_SUPPLY, wcd->supplies); in wcd9335_parse_dt()
5004 static int wcd9335_power_on_reset(struct wcd9335_codec *wcd) in wcd9335_power_on_reset() argument
5006 struct device *dev = wcd->dev; in wcd9335_power_on_reset()
5009 ret = regulator_bulk_enable(WCD9335_MAX_SUPPLY, wcd->supplies); in wcd9335_power_on_reset()
5024 gpio_direction_output(wcd->reset_gpio, 0); in wcd9335_power_on_reset()
5026 gpio_set_value(wcd->reset_gpio, 1); in wcd9335_power_on_reset()
5032 static int wcd9335_bring_up(struct wcd9335_codec *wcd) in wcd9335_bring_up() argument
5034 struct regmap *rm = wcd->regmap; in wcd9335_bring_up()
5041 dev_err(wcd->dev, "WCD9335 CODEC version detection fail!\n"); in wcd9335_bring_up()
5046 dev_info(wcd->dev, "WCD9335 CODEC version is v2.0\n"); in wcd9335_bring_up()
5056 dev_err(wcd->dev, "WCD9335 CODEC version not supported\n"); in wcd9335_bring_up()
5063 static int wcd9335_irq_init(struct wcd9335_codec *wcd) in wcd9335_irq_init() argument
5072 wcd->intr1 = of_irq_get_byname(wcd->dev->of_node, "intr1"); in wcd9335_irq_init()
5073 if (wcd->intr1 < 0) in wcd9335_irq_init()
5074 return dev_err_probe(wcd->dev, wcd->intr1, in wcd9335_irq_init()
5077 ret = devm_regmap_add_irq_chip(wcd->dev, wcd->regmap, wcd->intr1, in wcd9335_irq_init()
5079 &wcd9335_regmap_irq1_chip, &wcd->irq_data); in wcd9335_irq_init()
5081 return dev_err_probe(wcd->dev, ret, "Failed to register IRQ chip\n"); in wcd9335_irq_init()
5089 struct wcd9335_codec *wcd; in wcd9335_slim_probe() local
5092 wcd = devm_kzalloc(dev, sizeof(*wcd), GFP_KERNEL); in wcd9335_slim_probe()
5093 if (!wcd) in wcd9335_slim_probe()
5096 wcd->dev = dev; in wcd9335_slim_probe()
5097 ret = wcd9335_parse_dt(wcd); in wcd9335_slim_probe()
5101 ret = wcd9335_power_on_reset(wcd); in wcd9335_slim_probe()
5105 dev_set_drvdata(dev, wcd); in wcd9335_slim_probe()
5115 struct wcd9335_codec *wcd; in wcd9335_slim_status() local
5118 wcd = dev_get_drvdata(dev); in wcd9335_slim_status()
5126 wcd->slim = sdev; in wcd9335_slim_status()
5127 wcd->slim_ifc_dev = of_slim_get_device(sdev->ctrl, ifc_dev_np); in wcd9335_slim_status()
5129 if (!wcd->slim_ifc_dev) { in wcd9335_slim_status()
5134 slim_get_logical_addr(wcd->slim_ifc_dev); in wcd9335_slim_status()
5136 wcd->regmap = regmap_init_slimbus(sdev, &wcd9335_regmap_config); in wcd9335_slim_status()
5137 if (IS_ERR(wcd->regmap)) in wcd9335_slim_status()
5138 return dev_err_probe(dev, PTR_ERR(wcd->regmap), in wcd9335_slim_status()
5141 wcd->if_regmap = regmap_init_slimbus(wcd->slim_ifc_dev, in wcd9335_slim_status()
5143 if (IS_ERR(wcd->if_regmap)) in wcd9335_slim_status()
5144 return dev_err_probe(dev, PTR_ERR(wcd->if_regmap), in wcd9335_slim_status()
5147 ret = wcd9335_bring_up(wcd); in wcd9335_slim_status()
5153 ret = wcd9335_irq_init(wcd); in wcd9335_slim_status()
5157 wcd9335_probe(wcd); in wcd9335_slim_status()