Lines Matching +full:sm8250 +full:- +full:lpass +full:- +full:wsa +full:- +full:macro
1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
10 #include <linux/clk-provider.h>
12 #include <sound/soc-dapm.h>
16 #include "lpass-wsa-macro.h"
311 {24000, -EINVAL},/* 24K */
352 struct clk *macro; member
359 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
462 SOC_DAPM_ENUM("WSA RX_MIX EC0_Mux", rx_mix_ec0_enum);
465 SOC_DAPM_ENUM("WSA RX_MIX EC1_Mux", rx_mix_ec1_enum);
468 /* WSA Macro */
806 * wsa_macro_set_spkr_mode - Configures speaker compander and smartboost
812 * Returns 0 on success or -EINVAL on error.
816 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_set_spkr_mode() local
818 wsa->spkr_mode = mode; in wsa_macro_set_spkr_mode()
851 struct snd_soc_component *component = dai->component; in wsa_macro_set_prim_interpolator_rate()
852 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_set_prim_interpolator_rate() local
854 for_each_set_bit(port, &wsa->active_ch_mask[dai->id], WSA_MACRO_RX_MAX) { in wsa_macro_set_prim_interpolator_rate()
857 dev_err(component->dev, "%s: Invalid RX port, Dai ID is %d\n", in wsa_macro_set_prim_interpolator_rate()
858 __func__, dai->id); in wsa_macro_set_prim_interpolator_rate()
859 return -EINVAL; in wsa_macro_set_prim_interpolator_rate()
903 struct snd_soc_component *component = dai->component; in wsa_macro_set_mix_interpolator_rate()
904 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_set_mix_interpolator_rate() local
906 for_each_set_bit(port, &wsa->active_ch_mask[dai->id], WSA_MACRO_RX_MAX) { in wsa_macro_set_mix_interpolator_rate()
909 dev_err(component->dev, "%s: Invalid RX port, Dai ID is %d\n", in wsa_macro_set_mix_interpolator_rate()
910 __func__, dai->id); in wsa_macro_set_mix_interpolator_rate()
911 return -EINVAL; in wsa_macro_set_mix_interpolator_rate()
962 return -EINVAL; in wsa_macro_set_interpolator_rate()
973 struct snd_soc_component *component = dai->component; in wsa_macro_hw_params()
976 switch (substream->stream) { in wsa_macro_hw_params()
980 dev_err(component->dev, in wsa_macro_hw_params()
996 struct snd_soc_component *component = dai->component; in wsa_macro_get_channel_map()
997 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_get_channel_map() local
1000 switch (dai->id) { in wsa_macro_get_channel_map()
1002 *tx_slot = wsa->active_ch_mask[dai->id]; in wsa_macro_get_channel_map()
1003 *tx_num = wsa->active_ch_cnt[dai->id]; in wsa_macro_get_channel_map()
1007 for_each_set_bit(temp, &wsa->active_ch_mask[dai->id], in wsa_macro_get_channel_map()
1032 dev_err(component->dev, "%s: Invalid AIF\n", __func__); in wsa_macro_get_channel_map()
1102 static void wsa_macro_mclk_enable(struct wsa_macro *wsa, bool mclk_enable) in wsa_macro_mclk_enable() argument
1104 struct regmap *regmap = wsa->regmap; in wsa_macro_mclk_enable()
1107 if (wsa->wsa_mclk_users == 0) { in wsa_macro_mclk_enable()
1121 wsa->wsa_mclk_users++; in wsa_macro_mclk_enable()
1123 if (wsa->wsa_mclk_users <= 0) { in wsa_macro_mclk_enable()
1124 dev_err(wsa->dev, "clock already disabled\n"); in wsa_macro_mclk_enable()
1125 wsa->wsa_mclk_users = 0; in wsa_macro_mclk_enable()
1128 wsa->wsa_mclk_users--; in wsa_macro_mclk_enable()
1129 if (wsa->wsa_mclk_users == 0) { in wsa_macro_mclk_enable()
1145 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_mclk_event()
1146 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_mclk_event() local
1148 wsa_macro_mclk_enable(wsa, event == SND_SOC_DAPM_PRE_PMU); in wsa_macro_mclk_event()
1156 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_vi_feedback()
1157 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_enable_vi_feedback() local
1160 if (test_bit(WSA_MACRO_TX0, &wsa->active_ch_mask[WSA_MACRO_AIF_VI])) { in wsa_macro_enable_vi_feedback()
1163 } else if (test_bit(WSA_MACRO_TX1, &wsa->active_ch_mask[WSA_MACRO_AIF_VI])) { in wsa_macro_enable_vi_feedback()
1219 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_mix_path()
1223 switch (w->shift) { in wsa_macro_enable_mix_path()
1294 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_config_compander() local
1296 if (!wsa->comp_enabled[comp]) in wsa_macro_config_compander()
1342 struct wsa_macro *wsa, in wsa_macro_enable_softclip_clk() argument
1352 if (wsa->softclip_clk_users[path] == 0) { in wsa_macro_enable_softclip_clk()
1361 wsa->softclip_clk_users[path]++; in wsa_macro_enable_softclip_clk()
1363 wsa->softclip_clk_users[path]--; in wsa_macro_enable_softclip_clk()
1364 if (wsa->softclip_clk_users[path] == 0) { in wsa_macro_enable_softclip_clk()
1380 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_config_softclip() local
1388 if (!wsa->is_softclip_on[softclip_path]) in wsa_macro_config_softclip()
1396 wsa_macro_enable_softclip_clk(component, wsa, softclip_path, in wsa_macro_config_softclip()
1407 wsa_macro_enable_softclip_clk(component, wsa, softclip_path, in wsa_macro_config_softclip()
1448 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_main_path()
1451 reg = CDC_WSA_RX0_RX_PATH_CTL + WSA_MACRO_RX_PATH_OFFSET * w->shift; in wsa_macro_enable_main_path()
1454 if (wsa_macro_adie_lb(component, w->shift)) { in wsa_macro_enable_main_path()
1491 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_enable_prim_interpolator() local
1497 wsa->prim_int_users[ind]++; in wsa_macro_enable_prim_interpolator()
1498 if (wsa->prim_int_users[ind] == 1) { in wsa_macro_enable_prim_interpolator()
1519 wsa->prim_int_users[ind]--; in wsa_macro_enable_prim_interpolator()
1520 if (wsa->prim_int_users[ind] == 0) { in wsa_macro_enable_prim_interpolator()
1533 struct wsa_macro *wsa, in wsa_macro_config_ear_spkr_gain() argument
1538 switch (wsa->spkr_mode) { in wsa_macro_config_ear_spkr_gain()
1541 comp_gain_offset = -12; in wsa_macro_config_ear_spkr_gain()
1545 comp_gain_offset = -15; in wsa_macro_config_ear_spkr_gain()
1552 if (wsa->comp_enabled[WSA_MACRO_COMP1] && in wsa_macro_config_ear_spkr_gain()
1554 (wsa->ear_spkr_gain != 0)) { in wsa_macro_config_ear_spkr_gain()
1555 /* For example, val is -8(-12+5-1) for 4dB of gain */ in wsa_macro_config_ear_spkr_gain()
1556 val = comp_gain_offset + wsa->ear_spkr_gain - 1; in wsa_macro_config_ear_spkr_gain()
1563 * ear_spkr_gain is non-zero. in wsa_macro_config_ear_spkr_gain()
1565 if (wsa->comp_enabled[WSA_MACRO_COMP1] && in wsa_macro_config_ear_spkr_gain()
1567 (wsa->ear_spkr_gain != 0)) { in wsa_macro_config_ear_spkr_gain()
1580 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_interpolator()
1585 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_enable_interpolator() local
1587 if (w->shift == WSA_MACRO_COMP1) { in wsa_macro_enable_interpolator()
1590 } else if (w->shift == WSA_MACRO_COMP2) { in wsa_macro_enable_interpolator()
1601 wsa_macro_config_compander(component, w->shift, event); in wsa_macro_enable_interpolator()
1602 wsa_macro_config_softclip(component, w->shift, event); in wsa_macro_enable_interpolator()
1604 if ((wsa->spkr_gain_offset == WSA_MACRO_GAIN_OFFSET_M1P5_DB) && in wsa_macro_enable_interpolator()
1605 (wsa->comp_enabled[WSA_MACRO_COMP1] || in wsa_macro_enable_interpolator()
1606 wsa->comp_enabled[WSA_MACRO_COMP2])) { in wsa_macro_enable_interpolator()
1623 offset_val = -2; in wsa_macro_enable_interpolator()
1628 wsa_macro_config_ear_spkr_gain(component, wsa, in wsa_macro_enable_interpolator()
1632 wsa_macro_config_compander(component, w->shift, event); in wsa_macro_enable_interpolator()
1633 wsa_macro_config_softclip(component, w->shift, event); in wsa_macro_enable_interpolator()
1635 if ((wsa->spkr_gain_offset == WSA_MACRO_GAIN_OFFSET_M1P5_DB) && in wsa_macro_enable_interpolator()
1636 (wsa->comp_enabled[WSA_MACRO_COMP1] || in wsa_macro_enable_interpolator()
1637 wsa->comp_enabled[WSA_MACRO_COMP2])) { in wsa_macro_enable_interpolator()
1659 wsa_macro_config_ear_spkr_gain(component, wsa, in wsa_macro_enable_interpolator()
1671 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_spk_boost_event()
1675 if (!strcmp(w->name, "WSA_RX INT0 CHAIN")) { in wsa_macro_spk_boost_event()
1680 } else if (!strcmp(w->name, "WSA_RX INT1 CHAIN")) { in wsa_macro_spk_boost_event()
1719 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wsa_macro_enable_echo()
1720 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_enable_echo() local
1725 switch (w->shift) { in wsa_macro_enable_echo()
1728 ec_tx = val - 1; in wsa_macro_enable_echo()
1732 ec_tx = (val >> CDC_WSA_RX_MIX_TX1_SEL_SHFT) - 1; in wsa_macro_enable_echo()
1735 dev_err(component->dev, "%s: Invalid shift %u\n", in wsa_macro_enable_echo()
1736 __func__, w->shift); in wsa_macro_enable_echo()
1737 return -EINVAL; in wsa_macro_enable_echo()
1740 if (wsa->ec_hq[ec_tx]) { in wsa_macro_enable_echo()
1760 int ec_tx = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_get_ec_hq()
1761 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_get_ec_hq() local
1763 ucontrol->value.integer.value[0] = wsa->ec_hq[ec_tx]; in wsa_macro_get_ec_hq()
1772 int ec_tx = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_set_ec_hq()
1773 int value = ucontrol->value.integer.value[0]; in wsa_macro_set_ec_hq()
1774 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_set_ec_hq() local
1776 wsa->ec_hq[ec_tx] = value; in wsa_macro_set_ec_hq()
1786 int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_get_compander()
1787 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_get_compander() local
1789 ucontrol->value.integer.value[0] = wsa->comp_enabled[comp]; in wsa_macro_get_compander()
1797 int comp = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_set_compander()
1798 int value = ucontrol->value.integer.value[0]; in wsa_macro_set_compander()
1799 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_set_compander() local
1801 wsa->comp_enabled[comp] = value; in wsa_macro_set_compander()
1810 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_ear_spkr_pa_gain_get() local
1812 ucontrol->value.integer.value[0] = wsa->ear_spkr_gain; in wsa_macro_ear_spkr_pa_gain_get()
1821 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_ear_spkr_pa_gain_put() local
1823 wsa->ear_spkr_gain = ucontrol->value.integer.value[0]; in wsa_macro_ear_spkr_pa_gain_put()
1834 snd_soc_dapm_to_component(widget->dapm); in wsa_macro_rx_mux_get()
1835 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_rx_mux_get() local
1837 ucontrol->value.integer.value[0] = in wsa_macro_rx_mux_get()
1838 wsa->rx_port_value[widget->shift]; in wsa_macro_rx_mux_get()
1848 snd_soc_dapm_to_component(widget->dapm); in wsa_macro_rx_mux_put()
1849 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in wsa_macro_rx_mux_put()
1851 u32 rx_port_value = ucontrol->value.integer.value[0]; in wsa_macro_rx_mux_put()
1854 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_rx_mux_put() local
1856 aif_rst = wsa->rx_port_value[widget->shift]; in wsa_macro_rx_mux_put()
1859 dev_err(component->dev, "%s: AIF reset already\n", __func__); in wsa_macro_rx_mux_put()
1863 dev_err(component->dev, "%s: Invalid AIF reset\n", __func__); in wsa_macro_rx_mux_put()
1867 wsa->rx_port_value[widget->shift] = rx_port_value; in wsa_macro_rx_mux_put()
1869 bit_input = widget->shift; in wsa_macro_rx_mux_put()
1873 if (wsa->active_ch_cnt[aif_rst]) { in wsa_macro_rx_mux_put()
1875 &wsa->active_ch_mask[aif_rst]); in wsa_macro_rx_mux_put()
1876 wsa->active_ch_cnt[aif_rst]--; in wsa_macro_rx_mux_put()
1882 &wsa->active_ch_mask[rx_port_value]); in wsa_macro_rx_mux_put()
1883 wsa->active_ch_cnt[rx_port_value]++; in wsa_macro_rx_mux_put()
1886 dev_err(component->dev, in wsa_macro_rx_mux_put()
1887 "%s: Invalid AIF_ID for WSA RX MUX %d\n", in wsa_macro_rx_mux_put()
1889 return -EINVAL; in wsa_macro_rx_mux_put()
1892 snd_soc_dapm_mux_update_power(widget->dapm, kcontrol, in wsa_macro_rx_mux_put()
1901 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_soft_clip_enable_get() local
1902 int path = ((struct soc_mixer_control *)kcontrol->private_value)->shift; in wsa_macro_soft_clip_enable_get()
1904 ucontrol->value.integer.value[0] = wsa->is_softclip_on[path]; in wsa_macro_soft_clip_enable_get()
1913 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_soft_clip_enable_put() local
1914 int path = ((struct soc_mixer_control *) kcontrol->private_value)->shift; in wsa_macro_soft_clip_enable_put()
1916 wsa->is_softclip_on[path] = ucontrol->value.integer.value[0]; in wsa_macro_soft_clip_enable_put()
1935 -84, 40, digital_gain),
1937 -84, 40, digital_gain),
1959 SOC_DAPM_ENUM_EXT("WSA RX0 Mux", rx_mux_enum,
1961 SOC_DAPM_ENUM_EXT("WSA RX1 Mux", rx_mux_enum,
1963 SOC_DAPM_ENUM_EXT("WSA RX_MIX0 Mux", rx_mux_enum,
1965 SOC_DAPM_ENUM_EXT("WSA RX_MIX1 Mux", rx_mux_enum,
1973 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); in wsa_macro_vi_feed_mixer_get()
1974 struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; in wsa_macro_vi_feed_mixer_get()
1975 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_vi_feed_mixer_get() local
1976 u32 spk_tx_id = mixer->shift; in wsa_macro_vi_feed_mixer_get()
1977 u32 dai_id = widget->shift; in wsa_macro_vi_feed_mixer_get()
1979 if (test_bit(spk_tx_id, &wsa->active_ch_mask[dai_id])) in wsa_macro_vi_feed_mixer_get()
1980 ucontrol->value.integer.value[0] = 1; in wsa_macro_vi_feed_mixer_get()
1982 ucontrol->value.integer.value[0] = 0; in wsa_macro_vi_feed_mixer_get()
1991 struct snd_soc_component *component = snd_soc_dapm_to_component(widget->dapm); in wsa_macro_vi_feed_mixer_put()
1992 struct soc_mixer_control *mixer = (struct soc_mixer_control *)kcontrol->private_value; in wsa_macro_vi_feed_mixer_put()
1993 struct wsa_macro *wsa = snd_soc_component_get_drvdata(component); in wsa_macro_vi_feed_mixer_put() local
1994 u32 enable = ucontrol->value.integer.value[0]; in wsa_macro_vi_feed_mixer_put()
1995 u32 spk_tx_id = mixer->shift; in wsa_macro_vi_feed_mixer_put()
2000 &wsa->active_ch_mask[WSA_MACRO_AIF_VI])) { in wsa_macro_vi_feed_mixer_put()
2002 &wsa->active_ch_mask[WSA_MACRO_AIF_VI]); in wsa_macro_vi_feed_mixer_put()
2003 wsa->active_ch_cnt[WSA_MACRO_AIF_VI]++; in wsa_macro_vi_feed_mixer_put()
2007 &wsa->active_ch_mask[WSA_MACRO_AIF_VI])) { in wsa_macro_vi_feed_mixer_put()
2009 &wsa->active_ch_mask[WSA_MACRO_AIF_VI]); in wsa_macro_vi_feed_mixer_put()
2010 wsa->active_ch_cnt[WSA_MACRO_AIF_VI]++; in wsa_macro_vi_feed_mixer_put()
2015 &wsa->active_ch_mask[WSA_MACRO_AIF_VI])) { in wsa_macro_vi_feed_mixer_put()
2017 &wsa->active_ch_mask[WSA_MACRO_AIF_VI]); in wsa_macro_vi_feed_mixer_put()
2018 wsa->active_ch_cnt[WSA_MACRO_AIF_VI]--; in wsa_macro_vi_feed_mixer_put()
2022 &wsa->active_ch_mask[WSA_MACRO_AIF_VI])) { in wsa_macro_vi_feed_mixer_put()
2024 &wsa->active_ch_mask[WSA_MACRO_AIF_VI]); in wsa_macro_vi_feed_mixer_put()
2025 wsa->active_ch_cnt[WSA_MACRO_AIF_VI]--; in wsa_macro_vi_feed_mixer_put()
2028 snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, NULL); in wsa_macro_vi_feed_mixer_put()
2043 SND_SOC_DAPM_AIF_IN("WSA AIF1 PB", "WSA_AIF1 Playback", 0,
2045 SND_SOC_DAPM_AIF_IN("WSA AIF_MIX1 PB", "WSA_AIF_MIX1 Playback", 0,
2048 SND_SOC_DAPM_AIF_OUT_E("WSA AIF_VI", "WSA_AIF_VI Capture", 0,
2052 SND_SOC_DAPM_AIF_OUT("WSA AIF_ECHO", "WSA_AIF_ECHO Capture", 0,
2057 SND_SOC_DAPM_MUX_E("WSA RX_MIX EC0_MUX", SND_SOC_NOPM,
2061 SND_SOC_DAPM_MUX_E("WSA RX_MIX EC1_MUX", SND_SOC_NOPM,
2066 SND_SOC_DAPM_MUX("WSA RX0 MUX", SND_SOC_NOPM, WSA_MACRO_RX0, 0,
2068 SND_SOC_DAPM_MUX("WSA RX1 MUX", SND_SOC_NOPM, WSA_MACRO_RX1, 0,
2070 SND_SOC_DAPM_MUX("WSA RX_MIX0 MUX", SND_SOC_NOPM, WSA_MACRO_RX_MIX0, 0,
2072 SND_SOC_DAPM_MUX("WSA RX_MIX1 MUX", SND_SOC_NOPM, WSA_MACRO_RX_MIX1, 0,
2075 SND_SOC_DAPM_MIXER("WSA RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
2076 SND_SOC_DAPM_MIXER("WSA RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
2077 SND_SOC_DAPM_MIXER("WSA RX_MIX0", SND_SOC_NOPM, 0, 0, NULL, 0),
2078 SND_SOC_DAPM_MIXER("WSA RX_MIX1", SND_SOC_NOPM, 0, 0, NULL, 0),
2104 SND_SOC_DAPM_INPUT("WSA SRC0_INP"),
2147 {"WSA AIF_VI", NULL, "WSA_AIF_VI Mixer"},
2148 {"WSA AIF_VI", NULL, "WSA_MCLK"},
2150 {"WSA RX_MIX EC0_MUX", "RX_MIX_TX0", "WSA_RX INT0 SEC MIX"},
2151 {"WSA RX_MIX EC1_MUX", "RX_MIX_TX0", "WSA_RX INT0 SEC MIX"},
2152 {"WSA RX_MIX EC0_MUX", "RX_MIX_TX1", "WSA_RX INT1 SEC MIX"},
2153 {"WSA RX_MIX EC1_MUX", "RX_MIX_TX1", "WSA_RX INT1 SEC MIX"},
2154 {"WSA AIF_ECHO", NULL, "WSA RX_MIX EC0_MUX"},
2155 {"WSA AIF_ECHO", NULL, "WSA RX_MIX EC1_MUX"},
2156 {"WSA AIF_ECHO", NULL, "WSA_MCLK"},
2158 {"WSA AIF1 PB", NULL, "WSA_MCLK"},
2159 {"WSA AIF_MIX1 PB", NULL, "WSA_MCLK"},
2161 {"WSA RX0 MUX", "AIF1_PB", "WSA AIF1 PB"},
2162 {"WSA RX1 MUX", "AIF1_PB", "WSA AIF1 PB"},
2163 {"WSA RX_MIX0 MUX", "AIF1_PB", "WSA AIF1 PB"},
2164 {"WSA RX_MIX1 MUX", "AIF1_PB", "WSA AIF1 PB"},
2166 {"WSA RX0 MUX", "AIF_MIX1_PB", "WSA AIF_MIX1 PB"},
2167 {"WSA RX1 MUX", "AIF_MIX1_PB", "WSA AIF_MIX1 PB"},
2168 {"WSA RX_MIX0 MUX", "AIF_MIX1_PB", "WSA AIF_MIX1 PB"},
2169 {"WSA RX_MIX1 MUX", "AIF_MIX1_PB", "WSA AIF_MIX1 PB"},
2171 {"WSA RX0", NULL, "WSA RX0 MUX"},
2172 {"WSA RX1", NULL, "WSA RX1 MUX"},
2173 {"WSA RX_MIX0", NULL, "WSA RX_MIX0 MUX"},
2174 {"WSA RX_MIX1", NULL, "WSA RX_MIX1 MUX"},
2176 {"WSA RX0", NULL, "WSA_RX0_CLK"},
2177 {"WSA RX1", NULL, "WSA_RX1_CLK"},
2178 {"WSA RX_MIX0", NULL, "WSA_RX_MIX0_CLK"},
2179 {"WSA RX_MIX1", NULL, "WSA_RX_MIX1_CLK"},
2181 {"WSA_RX0 INP0", "RX0", "WSA RX0"},
2182 {"WSA_RX0 INP0", "RX1", "WSA RX1"},
2183 {"WSA_RX0 INP0", "RX_MIX0", "WSA RX_MIX0"},
2184 {"WSA_RX0 INP0", "RX_MIX1", "WSA RX_MIX1"},
2189 {"WSA_RX0 INP1", "RX0", "WSA RX0"},
2190 {"WSA_RX0 INP1", "RX1", "WSA RX1"},
2191 {"WSA_RX0 INP1", "RX_MIX0", "WSA RX_MIX0"},
2192 {"WSA_RX0 INP1", "RX_MIX1", "WSA RX_MIX1"},
2197 {"WSA_RX0 INP2", "RX0", "WSA RX0"},
2198 {"WSA_RX0 INP2", "RX1", "WSA RX1"},
2199 {"WSA_RX0 INP2", "RX_MIX0", "WSA RX_MIX0"},
2200 {"WSA_RX0 INP2", "RX_MIX1", "WSA RX_MIX1"},
2205 {"WSA_RX0 MIX INP", "RX0", "WSA RX0"},
2206 {"WSA_RX0 MIX INP", "RX1", "WSA RX1"},
2207 {"WSA_RX0 MIX INP", "RX_MIX0", "WSA RX_MIX0"},
2208 {"WSA_RX0 MIX INP", "RX_MIX1", "WSA RX_MIX1"},
2213 {"WSA_RX0 INT0 SIDETONE MIX", "SRC0", "WSA SRC0_INP"},
2220 {"WSA_RX1 INP0", "RX0", "WSA RX0"},
2221 {"WSA_RX1 INP0", "RX1", "WSA RX1"},
2222 {"WSA_RX1 INP0", "RX_MIX0", "WSA RX_MIX0"},
2223 {"WSA_RX1 INP0", "RX_MIX1", "WSA RX_MIX1"},
2228 {"WSA_RX1 INP1", "RX0", "WSA RX0"},
2229 {"WSA_RX1 INP1", "RX1", "WSA RX1"},
2230 {"WSA_RX1 INP1", "RX_MIX0", "WSA RX_MIX0"},
2231 {"WSA_RX1 INP1", "RX_MIX1", "WSA RX_MIX1"},
2236 {"WSA_RX1 INP2", "RX0", "WSA RX0"},
2237 {"WSA_RX1 INP2", "RX1", "WSA RX1"},
2238 {"WSA_RX1 INP2", "RX_MIX0", "WSA RX_MIX0"},
2239 {"WSA_RX1 INP2", "RX_MIX1", "WSA RX_MIX1"},
2244 {"WSA_RX1 MIX INP", "RX0", "WSA RX0"},
2245 {"WSA_RX1 MIX INP", "RX1", "WSA RX1"},
2246 {"WSA_RX1 MIX INP", "RX_MIX0", "WSA RX_MIX0"},
2247 {"WSA_RX1 MIX INP", "RX_MIX1", "WSA RX_MIX1"},
2258 static int wsa_swrm_clock(struct wsa_macro *wsa, bool enable) in wsa_swrm_clock() argument
2260 struct regmap *regmap = wsa->regmap; in wsa_swrm_clock()
2265 ret = clk_prepare_enable(wsa->mclk); in wsa_swrm_clock()
2267 dev_err(wsa->dev, "failed to enable mclk\n"); in wsa_swrm_clock()
2270 wsa_macro_mclk_enable(wsa, true); in wsa_swrm_clock()
2286 wsa_macro_mclk_enable(wsa, false); in wsa_swrm_clock()
2287 clk_disable_unprepare(wsa->mclk); in wsa_swrm_clock()
2295 struct wsa_macro *wsa = snd_soc_component_get_drvdata(comp); in wsa_macro_component_probe() local
2297 snd_soc_component_init_regmap(comp, wsa->regmap); in wsa_macro_component_probe()
2299 wsa->spkr_gain_offset = WSA_MACRO_GAIN_OFFSET_M1P5_DB; in wsa_macro_component_probe()
2327 struct wsa_macro *wsa = to_wsa_macro(hw); in swclk_gate_is_enabled() local
2330 regmap_read(wsa->regmap, CDC_WSA_CLK_RST_CTRL_SWR_CONTROL, &val); in swclk_gate_is_enabled()
2349 static int wsa_macro_register_mclk_output(struct wsa_macro *wsa) in wsa_macro_register_mclk_output() argument
2351 struct device *dev = wsa->dev; in wsa_macro_register_mclk_output()
2358 parent_clk_name = __clk_get_name(wsa->npl); in wsa_macro_register_mclk_output()
2365 wsa->hw.init = &init; in wsa_macro_register_mclk_output()
2366 hw = &wsa->hw; in wsa_macro_register_mclk_output()
2367 ret = clk_hw_register(wsa->dev, hw); in wsa_macro_register_mclk_output()
2375 .name = "WSA MACRO",
2387 struct device *dev = &pdev->dev; in wsa_macro_probe()
2388 struct wsa_macro *wsa; in wsa_macro_probe() local
2392 wsa = devm_kzalloc(dev, sizeof(*wsa), GFP_KERNEL); in wsa_macro_probe()
2393 if (!wsa) in wsa_macro_probe()
2394 return -ENOMEM; in wsa_macro_probe()
2396 wsa->macro = devm_clk_get_optional(dev, "macro"); in wsa_macro_probe()
2397 if (IS_ERR(wsa->macro)) in wsa_macro_probe()
2398 return PTR_ERR(wsa->macro); in wsa_macro_probe()
2400 wsa->dcodec = devm_clk_get_optional(dev, "dcodec"); in wsa_macro_probe()
2401 if (IS_ERR(wsa->dcodec)) in wsa_macro_probe()
2402 return PTR_ERR(wsa->dcodec); in wsa_macro_probe()
2404 wsa->mclk = devm_clk_get(dev, "mclk"); in wsa_macro_probe()
2405 if (IS_ERR(wsa->mclk)) in wsa_macro_probe()
2406 return PTR_ERR(wsa->mclk); in wsa_macro_probe()
2408 wsa->npl = devm_clk_get(dev, "npl"); in wsa_macro_probe()
2409 if (IS_ERR(wsa->npl)) in wsa_macro_probe()
2410 return PTR_ERR(wsa->npl); in wsa_macro_probe()
2412 wsa->fsgen = devm_clk_get(dev, "fsgen"); in wsa_macro_probe()
2413 if (IS_ERR(wsa->fsgen)) in wsa_macro_probe()
2414 return PTR_ERR(wsa->fsgen); in wsa_macro_probe()
2420 wsa->regmap = devm_regmap_init_mmio(dev, base, &wsa_regmap_config); in wsa_macro_probe()
2421 if (IS_ERR(wsa->regmap)) in wsa_macro_probe()
2422 return PTR_ERR(wsa->regmap); in wsa_macro_probe()
2424 dev_set_drvdata(dev, wsa); in wsa_macro_probe()
2426 wsa->dev = dev; in wsa_macro_probe()
2429 clk_set_rate(wsa->mclk, WSA_MACRO_MCLK_FREQ); in wsa_macro_probe()
2430 clk_set_rate(wsa->npl, WSA_MACRO_MCLK_FREQ); in wsa_macro_probe()
2432 ret = clk_prepare_enable(wsa->macro); in wsa_macro_probe()
2436 ret = clk_prepare_enable(wsa->dcodec); in wsa_macro_probe()
2440 ret = clk_prepare_enable(wsa->mclk); in wsa_macro_probe()
2444 ret = clk_prepare_enable(wsa->npl); in wsa_macro_probe()
2448 ret = clk_prepare_enable(wsa->fsgen); in wsa_macro_probe()
2452 ret = wsa_macro_register_mclk_output(wsa); in wsa_macro_probe()
2472 clk_disable_unprepare(wsa->fsgen); in wsa_macro_probe()
2474 clk_disable_unprepare(wsa->npl); in wsa_macro_probe()
2476 clk_disable_unprepare(wsa->mclk); in wsa_macro_probe()
2478 clk_disable_unprepare(wsa->dcodec); in wsa_macro_probe()
2480 clk_disable_unprepare(wsa->macro); in wsa_macro_probe()
2488 struct wsa_macro *wsa = dev_get_drvdata(&pdev->dev); in wsa_macro_remove() local
2490 clk_disable_unprepare(wsa->macro); in wsa_macro_remove()
2491 clk_disable_unprepare(wsa->dcodec); in wsa_macro_remove()
2492 clk_disable_unprepare(wsa->mclk); in wsa_macro_remove()
2493 clk_disable_unprepare(wsa->npl); in wsa_macro_remove()
2494 clk_disable_unprepare(wsa->fsgen); in wsa_macro_remove()
2501 struct wsa_macro *wsa = dev_get_drvdata(dev); in wsa_macro_runtime_suspend() local
2503 regcache_cache_only(wsa->regmap, true); in wsa_macro_runtime_suspend()
2504 regcache_mark_dirty(wsa->regmap); in wsa_macro_runtime_suspend()
2506 clk_disable_unprepare(wsa->mclk); in wsa_macro_runtime_suspend()
2507 clk_disable_unprepare(wsa->npl); in wsa_macro_runtime_suspend()
2508 clk_disable_unprepare(wsa->fsgen); in wsa_macro_runtime_suspend()
2515 struct wsa_macro *wsa = dev_get_drvdata(dev); in wsa_macro_runtime_resume() local
2518 ret = clk_prepare_enable(wsa->mclk); in wsa_macro_runtime_resume()
2524 ret = clk_prepare_enable(wsa->npl); in wsa_macro_runtime_resume()
2530 ret = clk_prepare_enable(wsa->fsgen); in wsa_macro_runtime_resume()
2536 regcache_cache_only(wsa->regmap, false); in wsa_macro_runtime_resume()
2537 regcache_sync(wsa->regmap); in wsa_macro_runtime_resume()
2541 clk_disable_unprepare(wsa->npl); in wsa_macro_runtime_resume()
2543 clk_disable_unprepare(wsa->mclk); in wsa_macro_runtime_resume()
2553 {.compatible = "qcom,sc7280-lpass-wsa-macro"},
2554 {.compatible = "qcom,sm8250-lpass-wsa-macro"},
2555 {.compatible = "qcom,sm8450-lpass-wsa-macro"},
2556 {.compatible = "qcom,sc8280xp-lpass-wsa-macro" },
2572 MODULE_DESCRIPTION("WSA macro driver");