Lines Matching +full:mix +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
12 #include <linux/clk-provider.h>
14 #include <sound/soc-dapm.h>
19 #include "lpass-macro-common.h"
20 #include "lpass-wsa-macro.h"
356 {24000, -EINVAL},/* 24K */
381 * struct wsa_reg_layout - Register layout differences
386 * @compander1_reg_offset: offset between compander registers (compander1 - compander0)
388 * @softclip1_reg_offset: offset between compander registers (softclip1 - softclip0)
447 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
531 SOC_DAPM_ENUM("WSA_RX0 MIX Mux", rx0_mix_chain_enum_v2_1);
543 SOC_DAPM_ENUM("WSA_RX0 MIX Mux", rx0_mix_chain_enum_v2_5);
546 SOC_DAPM_ENUM("WSA_RX0 SIDETONE MIX Mux", rx0_sidetone_mix_enum);
591 SOC_DAPM_ENUM("WSA_RX1 MIX Mux", rx1_mix_chain_enum_v2_1);
603 SOC_DAPM_ENUM("WSA_RX1 MIX Mux", rx1_mix_chain_enum_v2_5);
991 if (wsa->codec_version >= LPASS_CODEC_VERSION_2_5) in wsa_is_rw_register()
1052 if (wsa->codec_version >= LPASS_CODEC_VERSION_2_5) in wsa_is_readable_register()
1100 if (wsa->codec_version >= LPASS_CODEC_VERSION_2_5) in wsa_is_volatile_register()
1120 * wsa_macro_set_spkr_mode - Configures speaker compander and smartboost
1126 * Returns 0 on success or -EINVAL on error.
1132 wsa->spkr_mode = mode; in wsa_macro_set_spkr_mode()
1165 struct snd_soc_component *component = dai->component; in wsa_macro_set_prim_interpolator_rate()
1168 for_each_set_bit(port, &wsa->active_ch_mask[dai->id], WSA_MACRO_RX_MAX) { in wsa_macro_set_prim_interpolator_rate()
1171 dev_err(component->dev, "%s: Invalid RX port, Dai ID is %d\n", in wsa_macro_set_prim_interpolator_rate()
1172 __func__, dai->id); in wsa_macro_set_prim_interpolator_rate()
1173 return -EINVAL; in wsa_macro_set_prim_interpolator_rate()
1186 wsa->reg_layout->rx_intx_1_mix_inp0_sel_mask); in wsa_macro_set_prim_interpolator_rate()
1188 wsa->reg_layout->rx_intx_1_mix_inp1_sel_mask); in wsa_macro_set_prim_interpolator_rate()
1190 wsa->reg_layout->rx_intx_1_mix_inp2_sel_mask); in wsa_macro_set_prim_interpolator_rate()
1217 struct snd_soc_component *component = dai->component; in wsa_macro_set_mix_interpolator_rate()
1220 for_each_set_bit(port, &wsa->active_ch_mask[dai->id], WSA_MACRO_RX_MAX) { in wsa_macro_set_mix_interpolator_rate()
1223 dev_err(component->dev, "%s: Invalid RX port, Dai ID is %d\n", in wsa_macro_set_mix_interpolator_rate()
1224 __func__, dai->id); in wsa_macro_set_mix_interpolator_rate()
1225 return -EINVAL; in wsa_macro_set_mix_interpolator_rate()
1231 wsa->reg_layout->rx_intx_2_sel_mask); in wsa_macro_set_mix_interpolator_rate()
1276 return -EINVAL; in wsa_macro_set_interpolator_rate()
1287 struct snd_soc_component *component = dai->component; in wsa_macro_hw_params()
1291 switch (substream->stream) { in wsa_macro_hw_params()
1295 dev_err(component->dev, in wsa_macro_hw_params()
1302 if (dai->id == WSA_MACRO_AIF_VI) in wsa_macro_hw_params()
1303 wsa->pcm_rate_vi = params_rate(params); in wsa_macro_hw_params()
1316 struct snd_soc_component *component = dai->component; in wsa_macro_get_channel_map()
1320 switch (dai->id) { in wsa_macro_get_channel_map()
1322 *tx_slot = wsa->active_ch_mask[dai->id]; in wsa_macro_get_channel_map()
1323 *tx_num = wsa->active_ch_cnt[dai->id]; in wsa_macro_get_channel_map()
1327 for_each_set_bit(temp, &wsa->active_ch_mask[dai->id], in wsa_macro_get_channel_map()
1352 dev_err(component->dev, "%s: Invalid AIF\n", __func__); in wsa_macro_get_channel_map()
1424 struct regmap *regmap = wsa->regmap; in wsa_macro_mclk_enable()
1427 if (wsa->wsa_mclk_users == 0) { in wsa_macro_mclk_enable()
1441 wsa->wsa_mclk_users++; in wsa_macro_mclk_enable()
1443 if (wsa->wsa_mclk_users <= 0) { in wsa_macro_mclk_enable()
1444 dev_err(wsa->dev, "clock already disabled\n"); in wsa_macro_mclk_enable()
1445 wsa->wsa_mclk_users = 0; in wsa_macro_mclk_enable()
1448 wsa->wsa_mclk_users--; in wsa_macro_mclk_enable()
1449 if (wsa->wsa_mclk_users == 0) { in wsa_macro_mclk_enable()
1512 if (test_bit(WSA_MACRO_TX0, &wsa->active_ch_mask[WSA_MACRO_AIF_VI])) in wsa_macro_enable_disable_vi_feedback()
1517 if (test_bit(WSA_MACRO_TX1, &wsa->active_ch_mask[WSA_MACRO_AIF_VI])) in wsa_macro_enable_disable_vi_feedback()
1526 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_mclk_event()
1537 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_vi_feedback()
1541 switch (wsa->pcm_rate_vi) { in wsa_macro_enable_vi_feedback()
1579 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_mix_path()
1583 switch (w->shift) { in wsa_macro_enable_mix_path()
1656 if (!wsa->comp_enabled[comp]) in wsa_macro_config_compander()
1660 (comp * wsa->reg_layout->compander1_reg_offset); in wsa_macro_config_compander()
1706 u16 softclip_clk_reg = wsa->reg_layout->softclip0_reg_base + in wsa_macro_enable_softclip_clk()
1707 (path * wsa->reg_layout->softclip1_reg_offset); in wsa_macro_enable_softclip_clk()
1712 if (wsa->softclip_clk_users[path] == 0) { in wsa_macro_enable_softclip_clk()
1721 wsa->softclip_clk_users[path]++; in wsa_macro_enable_softclip_clk()
1723 wsa->softclip_clk_users[path]--; in wsa_macro_enable_softclip_clk()
1724 if (wsa->softclip_clk_users[path] == 0) { in wsa_macro_enable_softclip_clk()
1748 if (!wsa->is_softclip_on[softclip_path]) in wsa_macro_config_softclip()
1752 (softclip_path * wsa->reg_layout->softclip1_reg_offset); in wsa_macro_config_softclip()
1785 wsa->reg_layout->rx_intx_1_mix_inp0_sel_mask); in wsa_macro_adie_lb()
1791 wsa->reg_layout->rx_intx_1_mix_inp1_sel_mask); in wsa_macro_adie_lb()
1797 wsa->reg_layout->rx_intx_1_mix_inp2_sel_mask); in wsa_macro_adie_lb()
1809 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_main_path()
1812 reg = CDC_WSA_RX0_RX_PATH_CTL + WSA_MACRO_RX_PATH_OFFSET * w->shift; in wsa_macro_enable_main_path()
1815 if (wsa_macro_adie_lb(component, w->shift)) { in wsa_macro_enable_main_path()
1858 wsa->prim_int_users[ind]++; in wsa_macro_enable_prim_interpolator()
1859 if (wsa->prim_int_users[ind] == 1) { in wsa_macro_enable_prim_interpolator()
1880 wsa->prim_int_users[ind]--; in wsa_macro_enable_prim_interpolator()
1881 if (wsa->prim_int_users[ind] == 0) { in wsa_macro_enable_prim_interpolator()
1899 switch (wsa->spkr_mode) { in wsa_macro_config_ear_spkr_gain()
1902 comp_gain_offset = -12; in wsa_macro_config_ear_spkr_gain()
1906 comp_gain_offset = -15; in wsa_macro_config_ear_spkr_gain()
1913 if (wsa->comp_enabled[WSA_MACRO_COMP1] && in wsa_macro_config_ear_spkr_gain()
1915 (wsa->ear_spkr_gain != 0)) { in wsa_macro_config_ear_spkr_gain()
1916 /* For example, val is -8(-12+5-1) for 4dB of gain */ in wsa_macro_config_ear_spkr_gain()
1917 val = comp_gain_offset + wsa->ear_spkr_gain - 1; in wsa_macro_config_ear_spkr_gain()
1924 * ear_spkr_gain is non-zero. in wsa_macro_config_ear_spkr_gain()
1926 if (wsa->comp_enabled[WSA_MACRO_COMP1] && in wsa_macro_config_ear_spkr_gain()
1928 (wsa->ear_spkr_gain != 0)) { in wsa_macro_config_ear_spkr_gain()
1941 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_interpolator()
1947 if (w->shift == WSA_MACRO_COMP1) { in wsa_macro_enable_interpolator()
1950 } else if (w->shift == WSA_MACRO_COMP2) { in wsa_macro_enable_interpolator()
1961 wsa_macro_config_compander(component, w->shift, event); in wsa_macro_enable_interpolator()
1962 wsa_macro_config_softclip(component, w->shift, event); in wsa_macro_enable_interpolator()
1964 if ((wsa->spkr_gain_offset == WSA_MACRO_GAIN_OFFSET_M1P5_DB) && in wsa_macro_enable_interpolator()
1965 (wsa->comp_enabled[WSA_MACRO_COMP1] || in wsa_macro_enable_interpolator()
1966 wsa->comp_enabled[WSA_MACRO_COMP2])) { in wsa_macro_enable_interpolator()
1990 wsa_macro_config_compander(component, w->shift, event); in wsa_macro_enable_interpolator()
1991 wsa_macro_config_softclip(component, w->shift, event); in wsa_macro_enable_interpolator()
1993 if ((wsa->spkr_gain_offset == WSA_MACRO_GAIN_OFFSET_M1P5_DB) && in wsa_macro_enable_interpolator()
1994 (wsa->comp_enabled[WSA_MACRO_COMP1] || in wsa_macro_enable_interpolator()
1995 wsa->comp_enabled[WSA_MACRO_COMP2])) { in wsa_macro_enable_interpolator()
2025 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_spk_boost_event()
2040 dev_warn(component->dev, "Incorrect widget name in the driver\n"); in wsa_macro_spk_boost_event()
2041 return -EINVAL; in wsa_macro_spk_boost_event()
2076 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_echo()
2082 switch (w->shift) { in wsa_macro_enable_echo()
2085 ec_tx = val - 1; in wsa_macro_enable_echo()
2089 ec_tx = (val >> CDC_WSA_RX_MIX_TX1_SEL_SHFT) - 1; in wsa_macro_enable_echo()
2092 dev_err(component->dev, "%s: Invalid shift %u\n", in wsa_macro_enable_echo()
2093 __func__, w->shift); in wsa_macro_enable_echo()
2094 return -EINVAL; in wsa_macro_enable_echo()
2097 if (wsa->ec_hq[ec_tx]) { in wsa_macro_enable_echo()
2117 int ec_tx = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_get_ec_hq()
2120 ucontrol->value.integer.value[0] = wsa->ec_hq[ec_tx]; in wsa_macro_get_ec_hq()
2129 int ec_tx = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_set_ec_hq()
2130 int value = ucontrol->value.integer.value[0]; in wsa_macro_set_ec_hq()
2133 wsa->ec_hq[ec_tx] = value; in wsa_macro_set_ec_hq()
2143 int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_get_compander()
2146 ucontrol->value.integer.value[0] = wsa->comp_enabled[comp]; in wsa_macro_get_compander()
2154 int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_set_compander()
2155 int value = ucontrol->value.integer.value[0]; in wsa_macro_set_compander()
2158 wsa->comp_enabled[comp] = value; in wsa_macro_set_compander()
2169 ucontrol->value.integer.value[0] = wsa->ear_spkr_gain; in wsa_macro_ear_spkr_pa_gain_get()
2180 wsa->ear_spkr_gain = ucontrol->value.integer.value[0]; in wsa_macro_ear_spkr_pa_gain_put()
2191 snd_soc_dapm_to_component(widget->dapm); in wsa_macro_rx_mux_get()
2194 ucontrol->value.integer.value[0] = in wsa_macro_rx_mux_get()
2195 wsa->rx_port_value[widget->shift]; in wsa_macro_rx_mux_get()
2205 snd_soc_dapm_to_component(widget->dapm); in wsa_macro_rx_mux_put()
2206 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in wsa_macro_rx_mux_put()
2208 u32 rx_port_value = ucontrol->value.integer.value[0]; in wsa_macro_rx_mux_put()
2213 aif_rst = wsa->rx_port_value[widget->shift]; in wsa_macro_rx_mux_put()
2218 dev_err(component->dev, "%s: Invalid AIF reset\n", __func__); in wsa_macro_rx_mux_put()
2222 wsa->rx_port_value[widget->shift] = rx_port_value; in wsa_macro_rx_mux_put()
2224 bit_input = widget->shift; in wsa_macro_rx_mux_put()
2228 if (wsa->active_ch_cnt[aif_rst]) { in wsa_macro_rx_mux_put()
2230 &wsa->active_ch_mask[aif_rst]); in wsa_macro_rx_mux_put()
2231 wsa->active_ch_cnt[aif_rst]--; in wsa_macro_rx_mux_put()
2237 &wsa->active_ch_mask[rx_port_value]); in wsa_macro_rx_mux_put()
2238 wsa->active_ch_cnt[rx_port_value]++; in wsa_macro_rx_mux_put()
2241 dev_err(component->dev, in wsa_macro_rx_mux_put()
2244 return -EINVAL; in wsa_macro_rx_mux_put()
2247 snd_soc_dapm_mux_update_power(widget->dapm, kcontrol, in wsa_macro_rx_mux_put()
2257 int path = ((struct soc_mixer_control *)kcontrol->private_value)->shift; in wsa_macro_soft_clip_enable_get()
2259 ucontrol->value.integer.value[0] = wsa->is_softclip_on[path]; in wsa_macro_soft_clip_enable_get()
2269 int path = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_soft_clip_enable_put()
2271 wsa->is_softclip_on[path] = ucontrol->value.integer.value[0]; in wsa_macro_soft_clip_enable_put()
2290 -84, 40, digital_gain),
2292 -84, 40, digital_gain),
2328 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); in wsa_macro_vi_feed_mixer_get()
2329 struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; in wsa_macro_vi_feed_mixer_get()
2331 u32 spk_tx_id = mixer->shift; in wsa_macro_vi_feed_mixer_get()
2332 u32 dai_id = widget->shift; in wsa_macro_vi_feed_mixer_get()
2334 if (test_bit(spk_tx_id, &wsa->active_ch_mask[dai_id])) in wsa_macro_vi_feed_mixer_get()
2335 ucontrol->value.integer.value[0] = 1; in wsa_macro_vi_feed_mixer_get()
2337 ucontrol->value.integer.value[0] = 0; in wsa_macro_vi_feed_mixer_get()
2346 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); in wsa_macro_vi_feed_mixer_put()
2347 struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; in wsa_macro_vi_feed_mixer_put()
2349 u32 enable = ucontrol->value.integer.value[0]; in wsa_macro_vi_feed_mixer_put()
2350 u32 spk_tx_id = mixer->shift; in wsa_macro_vi_feed_mixer_put()
2351 u32 dai_id = widget->shift; in wsa_macro_vi_feed_mixer_put()
2356 &wsa->active_ch_mask[dai_id])) { in wsa_macro_vi_feed_mixer_put()
2358 &wsa->active_ch_mask[dai_id]); in wsa_macro_vi_feed_mixer_put()
2359 wsa->active_ch_cnt[dai_id]++; in wsa_macro_vi_feed_mixer_put()
2363 &wsa->active_ch_mask[dai_id])) { in wsa_macro_vi_feed_mixer_put()
2365 &wsa->active_ch_mask[dai_id]); in wsa_macro_vi_feed_mixer_put()
2366 wsa->active_ch_cnt[dai_id]++; in wsa_macro_vi_feed_mixer_put()
2371 &wsa->active_ch_mask[dai_id])) { in wsa_macro_vi_feed_mixer_put()
2373 &wsa->active_ch_mask[dai_id]); in wsa_macro_vi_feed_mixer_put()
2374 wsa->active_ch_cnt[dai_id]--; in wsa_macro_vi_feed_mixer_put()
2378 &wsa->active_ch_mask[dai_id])) { in wsa_macro_vi_feed_mixer_put()
2380 &wsa->active_ch_mask[dai_id]); in wsa_macro_vi_feed_mixer_put()
2381 wsa->active_ch_cnt[dai_id]--; in wsa_macro_vi_feed_mixer_put()
2384 snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL); in wsa_macro_vi_feed_mixer_put()
2436 SND_SOC_DAPM_MIXER_E("WSA_RX INT0 MIX", SND_SOC_NOPM, 0, 0, NULL, 0,
2438 SND_SOC_DAPM_MIXER_E("WSA_RX INT1 MIX", SND_SOC_NOPM, 1, 0, NULL, 0,
2441 SND_SOC_DAPM_MIXER("WSA_RX INT0 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2442 SND_SOC_DAPM_MIXER("WSA_RX INT1 SEC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2444 SND_SOC_DAPM_MUX("WSA_RX0 INT0 SIDETONE MIX", CDC_WSA_RX0_RX_PATH_CFG1,
2490 SND_SOC_DAPM_MUX_E("WSA_RX0 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX0,
2496 SND_SOC_DAPM_MUX_E("WSA_RX1 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX1,
2505 SND_SOC_DAPM_MUX_E("WSA_RX0 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX0,
2511 SND_SOC_DAPM_MUX_E("WSA_RX1 MIX INP", SND_SOC_NOPM, WSA_MACRO_RX_MIX1,
2523 {"WSA RX_MIX EC0_MUX", "RX_MIX_TX0", "WSA_RX INT0 SEC MIX"},
2524 {"WSA RX_MIX EC1_MUX", "RX_MIX_TX0", "WSA_RX INT0 SEC MIX"},
2525 {"WSA RX_MIX EC0_MUX", "RX_MIX_TX1", "WSA_RX INT1 SEC MIX"},
2526 {"WSA RX_MIX EC1_MUX", "RX_MIX_TX1", "WSA_RX INT1 SEC MIX"},
2560 {"WSA_RX INT0 MIX", NULL, "WSA_RX0 INP0"},
2568 {"WSA_RX INT0 MIX", NULL, "WSA_RX0 INP1"},
2576 {"WSA_RX INT0 MIX", NULL, "WSA_RX0 INP2"},
2578 {"WSA_RX0 MIX INP", "RX0", "WSA RX0"},
2579 {"WSA_RX0 MIX INP", "RX1", "WSA RX1"},
2580 {"WSA_RX0 MIX INP", "RX_MIX0", "WSA RX_MIX0"},
2581 {"WSA_RX0 MIX INP", "RX_MIX1", "WSA RX_MIX1"},
2582 {"WSA_RX INT0 SEC MIX", NULL, "WSA_RX0 MIX INP"},
2584 {"WSA_RX INT0 SEC MIX", NULL, "WSA_RX INT0 MIX"},
2585 {"WSA_RX INT0 INTERP", NULL, "WSA_RX INT0 SEC MIX"},
2586 {"WSA_RX0 INT0 SIDETONE MIX", "SRC0", "WSA SRC0_INP"},
2587 {"WSA_RX INT0 INTERP", NULL, "WSA_RX0 INT0 SIDETONE MIX"},
2599 {"WSA_RX INT1 MIX", NULL, "WSA_RX1 INP0"},
2607 {"WSA_RX INT1 MIX", NULL, "WSA_RX1 INP1"},
2615 {"WSA_RX INT1 MIX", NULL, "WSA_RX1 INP2"},
2617 {"WSA_RX1 MIX INP", "RX0", "WSA RX0"},
2618 {"WSA_RX1 MIX INP", "RX1", "WSA RX1"},
2619 {"WSA_RX1 MIX INP", "RX_MIX0", "WSA RX_MIX0"},
2620 {"WSA_RX1 MIX INP", "RX_MIX1", "WSA RX_MIX1"},
2621 {"WSA_RX INT1 SEC MIX", NULL, "WSA_RX1 MIX INP"},
2623 {"WSA_RX INT1 SEC MIX", NULL, "WSA_RX INT1 MIX"},
2624 {"WSA_RX INT1 INTERP", NULL, "WSA_RX INT1 SEC MIX"},
2633 struct regmap *regmap = wsa->regmap; in wsa_swrm_clock()
2638 ret = clk_prepare_enable(wsa->mclk); in wsa_swrm_clock()
2640 dev_err(wsa->dev, "failed to enable mclk\n"); in wsa_swrm_clock()
2653 clk_disable_unprepare(wsa->mclk); in wsa_swrm_clock()
2666 snd_soc_component_init_regmap(comp, wsa->regmap); in wsa_macro_component_probe()
2668 wsa->spkr_gain_offset = WSA_MACRO_GAIN_OFFSET_M1P5_DB; in wsa_macro_component_probe()
2681 switch (wsa->codec_version) { in wsa_macro_component_probe()
2698 return -EINVAL; in wsa_macro_component_probe()
2719 regmap_read(wsa->regmap, CDC_WSA_CLK_RST_CTRL_SWR_CONTROL, &val); in swclk_gate_is_enabled()
2740 struct device *dev = wsa->dev; in wsa_macro_register_mclk_output()
2746 if (wsa->npl) in wsa_macro_register_mclk_output()
2747 parent_clk_name = __clk_get_name(wsa->npl); in wsa_macro_register_mclk_output()
2749 parent_clk_name = __clk_get_name(wsa->mclk); in wsa_macro_register_mclk_output()
2752 of_property_read_string(dev_of_node(dev), "clock-output-names", in wsa_macro_register_mclk_output()
2758 wsa->hw.init = &init; in wsa_macro_register_mclk_output()
2759 hw = &wsa->hw; in wsa_macro_register_mclk_output()
2760 ret = clk_hw_register(wsa->dev, hw); in wsa_macro_register_mclk_output()
2780 struct device *dev = &pdev->dev; in wsa_macro_probe()
2790 return -ENOMEM; in wsa_macro_probe()
2792 wsa->macro = devm_clk_get_optional(dev, "macro"); in wsa_macro_probe()
2793 if (IS_ERR(wsa->macro)) in wsa_macro_probe()
2794 return dev_err_probe(dev, PTR_ERR(wsa->macro), "unable to get macro clock\n"); in wsa_macro_probe()
2796 wsa->dcodec = devm_clk_get_optional(dev, "dcodec"); in wsa_macro_probe()
2797 if (IS_ERR(wsa->dcodec)) in wsa_macro_probe()
2798 return dev_err_probe(dev, PTR_ERR(wsa->dcodec), "unable to get dcodec clock\n"); in wsa_macro_probe()
2800 wsa->mclk = devm_clk_get(dev, "mclk"); in wsa_macro_probe()
2801 if (IS_ERR(wsa->mclk)) in wsa_macro_probe()
2802 return dev_err_probe(dev, PTR_ERR(wsa->mclk), "unable to get mclk clock\n"); in wsa_macro_probe()
2805 wsa->npl = devm_clk_get(dev, "npl"); in wsa_macro_probe()
2806 if (IS_ERR(wsa->npl)) in wsa_macro_probe()
2807 return dev_err_probe(dev, PTR_ERR(wsa->npl), "unable to get npl clock\n"); in wsa_macro_probe()
2810 wsa->fsgen = devm_clk_get(dev, "fsgen"); in wsa_macro_probe()
2811 if (IS_ERR(wsa->fsgen)) in wsa_macro_probe()
2812 return dev_err_probe(dev, PTR_ERR(wsa->fsgen), "unable to get fsgen clock\n"); in wsa_macro_probe()
2818 wsa->codec_version = lpass_macro_get_codec_version(); in wsa_macro_probe()
2821 switch (wsa->codec_version) { in wsa_macro_probe()
2827 wsa->reg_layout = &wsa_codec_v2_1; in wsa_macro_probe()
2832 return -ENOMEM; in wsa_macro_probe()
2842 wsa->reg_layout = &wsa_codec_v2_5; in wsa_macro_probe()
2847 return -ENOMEM; in wsa_macro_probe()
2854 dev_err(dev, "Unsupported Codec version (%d)\n", wsa->codec_version); in wsa_macro_probe()
2855 return -EINVAL; in wsa_macro_probe()
2862 return -ENOMEM; in wsa_macro_probe()
2864 reg_config->reg_defaults = reg_defaults; in wsa_macro_probe()
2865 reg_config->num_reg_defaults = def_count; in wsa_macro_probe()
2867 wsa->regmap = devm_regmap_init_mmio(dev, base, reg_config); in wsa_macro_probe()
2868 if (IS_ERR(wsa->regmap)) in wsa_macro_probe()
2869 return PTR_ERR(wsa->regmap); in wsa_macro_probe()
2873 wsa->dev = dev; in wsa_macro_probe()
2876 clk_set_rate(wsa->mclk, WSA_MACRO_MCLK_FREQ); in wsa_macro_probe()
2877 clk_set_rate(wsa->npl, WSA_MACRO_MCLK_FREQ); in wsa_macro_probe()
2879 ret = clk_prepare_enable(wsa->macro); in wsa_macro_probe()
2883 ret = clk_prepare_enable(wsa->dcodec); in wsa_macro_probe()
2887 ret = clk_prepare_enable(wsa->mclk); in wsa_macro_probe()
2891 ret = clk_prepare_enable(wsa->npl); in wsa_macro_probe()
2895 ret = clk_prepare_enable(wsa->fsgen); in wsa_macro_probe()
2900 regmap_update_bits(wsa->regmap, CDC_WSA_CLK_RST_CTRL_SWR_CONTROL, in wsa_macro_probe()
2903 regmap_update_bits(wsa->regmap, CDC_WSA_CLK_RST_CTRL_SWR_CONTROL, in wsa_macro_probe()
2907 regmap_update_bits(wsa->regmap, CDC_WSA_CLK_RST_CTRL_SWR_CONTROL, in wsa_macro_probe()
2929 clk_disable_unprepare(wsa->fsgen); in wsa_macro_probe()
2931 clk_disable_unprepare(wsa->npl); in wsa_macro_probe()
2933 clk_disable_unprepare(wsa->mclk); in wsa_macro_probe()
2935 clk_disable_unprepare(wsa->dcodec); in wsa_macro_probe()
2937 clk_disable_unprepare(wsa->macro); in wsa_macro_probe()
2945 struct wsa_macro *wsa = dev_get_drvdata(&pdev->dev); in wsa_macro_remove()
2947 clk_disable_unprepare(wsa->macro); in wsa_macro_remove()
2948 clk_disable_unprepare(wsa->dcodec); in wsa_macro_remove()
2949 clk_disable_unprepare(wsa->mclk); in wsa_macro_remove()
2950 clk_disable_unprepare(wsa->npl); in wsa_macro_remove()
2951 clk_disable_unprepare(wsa->fsgen); in wsa_macro_remove()
2958 regcache_cache_only(wsa->regmap, true); in wsa_macro_runtime_suspend()
2959 regcache_mark_dirty(wsa->regmap); in wsa_macro_runtime_suspend()
2961 clk_disable_unprepare(wsa->fsgen); in wsa_macro_runtime_suspend()
2962 clk_disable_unprepare(wsa->npl); in wsa_macro_runtime_suspend()
2963 clk_disable_unprepare(wsa->mclk); in wsa_macro_runtime_suspend()
2973 ret = clk_prepare_enable(wsa->mclk); in wsa_macro_runtime_resume()
2979 ret = clk_prepare_enable(wsa->npl); in wsa_macro_runtime_resume()
2985 ret = clk_prepare_enable(wsa->fsgen); in wsa_macro_runtime_resume()
2991 regcache_cache_only(wsa->regmap, false); in wsa_macro_runtime_resume()
2992 regcache_sync(wsa->regmap); in wsa_macro_runtime_resume()
2996 clk_disable_unprepare(wsa->npl); in wsa_macro_runtime_resume()
2998 clk_disable_unprepare(wsa->mclk); in wsa_macro_runtime_resume()
3009 .compatible = "qcom,sc7280-lpass-wsa-macro",
3012 .compatible = "qcom,sm8250-lpass-wsa-macro",
3015 .compatible = "qcom,sm8450-lpass-wsa-macro",
3018 .compatible = "qcom,sm8550-lpass-wsa-macro",
3020 .compatible = "qcom,sc8280xp-lpass-wsa-macro",