Lines Matching +full:mux +full:- +full:int +full:- +full:port
1 // SPDX-License-Identifier: GPL-2.0
6 #include <linux/clk-provider.h>
21 #include <sound/soc-dapm.h>
23 #include "wcd-clsh-v2.h"
24 #include "wcd-mbhc-v2.h"
35 /* slave port water mark level
85 {.port = p + WCD934X_RX_START, .shift = p,}
88 {.port = p, .shift = p,}
154 {"RX INT" #id "_1 MIX1 INP0", "RX0", "SLIM RX0"}, \
155 {"RX INT" #id "_1 MIX1 INP0", "RX1", "SLIM RX1"}, \
156 {"RX INT" #id "_1 MIX1 INP0", "RX2", "SLIM RX2"}, \
157 {"RX INT" #id "_1 MIX1 INP0", "RX3", "SLIM RX3"}, \
158 {"RX INT" #id "_1 MIX1 INP0", "RX4", "SLIM RX4"}, \
159 {"RX INT" #id "_1 MIX1 INP0", "RX5", "SLIM RX5"}, \
160 {"RX INT" #id "_1 MIX1 INP0", "RX6", "SLIM RX6"}, \
161 {"RX INT" #id "_1 MIX1 INP0", "RX7", "SLIM RX7"}, \
162 {"RX INT" #id "_1 MIX1 INP0", "IIR0", "IIR0"}, \
163 {"RX INT" #id "_1 MIX1 INP0", "IIR1", "IIR1"}, \
164 {"RX INT" #id "_1 MIX1 INP1", "RX0", "SLIM RX0"}, \
165 {"RX INT" #id "_1 MIX1 INP1", "RX1", "SLIM RX1"}, \
166 {"RX INT" #id "_1 MIX1 INP1", "RX2", "SLIM RX2"}, \
167 {"RX INT" #id "_1 MIX1 INP1", "RX3", "SLIM RX3"}, \
168 {"RX INT" #id "_1 MIX1 INP1", "RX4", "SLIM RX4"}, \
169 {"RX INT" #id "_1 MIX1 INP1", "RX5", "SLIM RX5"}, \
170 {"RX INT" #id "_1 MIX1 INP1", "RX6", "SLIM RX6"}, \
171 {"RX INT" #id "_1 MIX1 INP1", "RX7", "SLIM RX7"}, \
172 {"RX INT" #id "_1 MIX1 INP1", "IIR0", "IIR0"}, \
173 {"RX INT" #id "_1 MIX1 INP1", "IIR1", "IIR1"}, \
174 {"RX INT" #id "_1 MIX1 INP2", "RX0", "SLIM RX0"}, \
175 {"RX INT" #id "_1 MIX1 INP2", "RX1", "SLIM RX1"}, \
176 {"RX INT" #id "_1 MIX1 INP2", "RX2", "SLIM RX2"}, \
177 {"RX INT" #id "_1 MIX1 INP2", "RX3", "SLIM RX3"}, \
178 {"RX INT" #id "_1 MIX1 INP2", "RX4", "SLIM RX4"}, \
179 {"RX INT" #id "_1 MIX1 INP2", "RX5", "SLIM RX5"}, \
180 {"RX INT" #id "_1 MIX1 INP2", "RX6", "SLIM RX6"}, \
181 {"RX INT" #id "_1 MIX1 INP2", "RX7", "SLIM RX7"}, \
182 {"RX INT" #id "_1 MIX1 INP2", "IIR0", "IIR0"}, \
183 {"RX INT" #id "_1 MIX1 INP2", "IIR1", "IIR1"}, \
184 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP0"}, \
185 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP1"}, \
186 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP2"}, \
187 {"RX INT" #id "_2 MUX", "RX0", "SLIM RX0"}, \
188 {"RX INT" #id "_2 MUX", "RX1", "SLIM RX1"}, \
189 {"RX INT" #id "_2 MUX", "RX2", "SLIM RX2"}, \
190 {"RX INT" #id "_2 MUX", "RX3", "SLIM RX3"}, \
191 {"RX INT" #id "_2 MUX", "RX4", "SLIM RX4"}, \
192 {"RX INT" #id "_2 MUX", "RX5", "SLIM RX5"}, \
193 {"RX INT" #id "_2 MUX", "RX6", "SLIM RX6"}, \
194 {"RX INT" #id "_2 MUX", "RX7", "SLIM RX7"}, \
195 {"RX INT" #id "_2 MUX", NULL, "INT" #id "_CLK"}, \
196 {"RX INT" #id "_2 MUX", NULL, "DSMDEM" #id "_CLK"}, \
197 {"RX INT" #id "_2 INTERP", NULL, "RX INT" #id "_2 MUX"}, \
198 {"RX INT" #id " SEC MIX", NULL, "RX INT" #id "_2 INTERP"}, \
199 {"RX INT" #id "_1 INTERP", NULL, "RX INT" #id "_1 MIX1"}, \
200 {"RX INT" #id "_1 INTERP", NULL, "INT" #id "_CLK"}, \
201 {"RX INT" #id "_1 INTERP", NULL, "DSMDEM" #id "_CLK"}, \
202 {"RX INT" #id " SEC MIX", NULL, "RX INT" #id "_1 INTERP"}
205 {"RX INT" #id " MIX2", NULL, "RX INT" #id " SEC MIX"}, \
206 {"RX INT" #id " MIX2", NULL, "RX INT" #id " MIX2 INP"}
209 {"SLIM RX"#id" MUX", "AIF1_PB", "AIF1 PB"}, \
210 {"SLIM RX"#id" MUX", "AIF2_PB", "AIF2 PB"}, \
211 {"SLIM RX"#id" MUX", "AIF3_PB", "AIF3 PB"}, \
212 {"SLIM RX"#id" MUX", "AIF4_PB", "AIF4 PB"}, \
213 {"SLIM RX"#id, NULL, "SLIM RX"#id" MUX"}
216 {"ADC MUX" #id, "DMIC", "DMIC MUX" #id }, \
217 {"ADC MUX" #id, "AMIC", "AMIC MUX" #id }, \
218 {"DMIC MUX" #id, "DMIC0", "DMIC0"}, \
219 {"DMIC MUX" #id, "DMIC1", "DMIC1"}, \
220 {"DMIC MUX" #id, "DMIC2", "DMIC2"}, \
221 {"DMIC MUX" #id, "DMIC3", "DMIC3"}, \
222 {"DMIC MUX" #id, "DMIC4", "DMIC4"}, \
223 {"DMIC MUX" #id, "DMIC5", "DMIC5"}, \
224 {"AMIC MUX" #id, "ADC1", "ADC1"}, \
225 {"AMIC MUX" #id, "ADC2", "ADC2"}, \
226 {"AMIC MUX" #id, "ADC3", "ADC3"}, \
227 {"AMIC MUX" #id, "ADC4", "ADC4"}
230 {"IIR" #id, NULL, "IIR" #id " INP0 MUX"}, \
231 {"IIR" #id " INP0 MUX", "DEC0", "ADC MUX0"}, \
232 {"IIR" #id " INP0 MUX", "DEC1", "ADC MUX1"}, \
233 {"IIR" #id " INP0 MUX", "DEC2", "ADC MUX2"}, \
234 {"IIR" #id " INP0 MUX", "DEC3", "ADC MUX3"}, \
235 {"IIR" #id " INP0 MUX", "DEC4", "ADC MUX4"}, \
236 {"IIR" #id " INP0 MUX", "DEC5", "ADC MUX5"}, \
237 {"IIR" #id " INP0 MUX", "DEC6", "ADC MUX6"}, \
238 {"IIR" #id " INP0 MUX", "DEC7", "ADC MUX7"}, \
239 {"IIR" #id " INP0 MUX", "DEC8", "ADC MUX8"}, \
240 {"IIR" #id " INP0 MUX", "RX0", "SLIM RX0"}, \
241 {"IIR" #id " INP0 MUX", "RX1", "SLIM RX1"}, \
242 {"IIR" #id " INP0 MUX", "RX2", "SLIM RX2"}, \
243 {"IIR" #id " INP0 MUX", "RX3", "SLIM RX3"}, \
244 {"IIR" #id " INP0 MUX", "RX4", "SLIM RX4"}, \
245 {"IIR" #id " INP0 MUX", "RX5", "SLIM RX5"}, \
246 {"IIR" #id " INP0 MUX", "RX6", "SLIM RX6"}, \
247 {"IIR" #id " INP0 MUX", "RX7", "SLIM RX7"}, \
248 {"IIR" #id, NULL, "IIR" #id " INP1 MUX"}, \
249 {"IIR" #id " INP1 MUX", "DEC0", "ADC MUX0"}, \
250 {"IIR" #id " INP1 MUX", "DEC1", "ADC MUX1"}, \
251 {"IIR" #id " INP1 MUX", "DEC2", "ADC MUX2"}, \
252 {"IIR" #id " INP1 MUX", "DEC3", "ADC MUX3"}, \
253 {"IIR" #id " INP1 MUX", "DEC4", "ADC MUX4"}, \
254 {"IIR" #id " INP1 MUX", "DEC5", "ADC MUX5"}, \
255 {"IIR" #id " INP1 MUX", "DEC6", "ADC MUX6"}, \
256 {"IIR" #id " INP1 MUX", "DEC7", "ADC MUX7"}, \
257 {"IIR" #id " INP1 MUX", "DEC8", "ADC MUX8"}, \
258 {"IIR" #id " INP1 MUX", "RX0", "SLIM RX0"}, \
259 {"IIR" #id " INP1 MUX", "RX1", "SLIM RX1"}, \
260 {"IIR" #id " INP1 MUX", "RX2", "SLIM RX2"}, \
261 {"IIR" #id " INP1 MUX", "RX3", "SLIM RX3"}, \
262 {"IIR" #id " INP1 MUX", "RX4", "SLIM RX4"}, \
263 {"IIR" #id " INP1 MUX", "RX5", "SLIM RX5"}, \
264 {"IIR" #id " INP1 MUX", "RX6", "SLIM RX6"}, \
265 {"IIR" #id " INP1 MUX", "RX7", "SLIM RX7"}, \
266 {"IIR" #id, NULL, "IIR" #id " INP2 MUX"}, \
267 {"IIR" #id " INP2 MUX", "DEC0", "ADC MUX0"}, \
268 {"IIR" #id " INP2 MUX", "DEC1", "ADC MUX1"}, \
269 {"IIR" #id " INP2 MUX", "DEC2", "ADC MUX2"}, \
270 {"IIR" #id " INP2 MUX", "DEC3", "ADC MUX3"}, \
271 {"IIR" #id " INP2 MUX", "DEC4", "ADC MUX4"}, \
272 {"IIR" #id " INP2 MUX", "DEC5", "ADC MUX5"}, \
273 {"IIR" #id " INP2 MUX", "DEC6", "ADC MUX6"}, \
274 {"IIR" #id " INP2 MUX", "DEC7", "ADC MUX7"}, \
275 {"IIR" #id " INP2 MUX", "DEC8", "ADC MUX8"}, \
276 {"IIR" #id " INP2 MUX", "RX0", "SLIM RX0"}, \
277 {"IIR" #id " INP2 MUX", "RX1", "SLIM RX1"}, \
278 {"IIR" #id " INP2 MUX", "RX2", "SLIM RX2"}, \
279 {"IIR" #id " INP2 MUX", "RX3", "SLIM RX3"}, \
280 {"IIR" #id " INP2 MUX", "RX4", "SLIM RX4"}, \
281 {"IIR" #id " INP2 MUX", "RX5", "SLIM RX5"}, \
282 {"IIR" #id " INP2 MUX", "RX6", "SLIM RX6"}, \
283 {"IIR" #id " INP2 MUX", "RX7", "SLIM RX7"}, \
284 {"IIR" #id, NULL, "IIR" #id " INP3 MUX"}, \
285 {"IIR" #id " INP3 MUX", "DEC0", "ADC MUX0"}, \
286 {"IIR" #id " INP3 MUX", "DEC1", "ADC MUX1"}, \
287 {"IIR" #id " INP3 MUX", "DEC2", "ADC MUX2"}, \
288 {"IIR" #id " INP3 MUX", "DEC3", "ADC MUX3"}, \
289 {"IIR" #id " INP3 MUX", "DEC4", "ADC MUX4"}, \
290 {"IIR" #id " INP3 MUX", "DEC5", "ADC MUX5"}, \
291 {"IIR" #id " INP3 MUX", "DEC6", "ADC MUX6"}, \
292 {"IIR" #id " INP3 MUX", "DEC7", "ADC MUX7"}, \
293 {"IIR" #id " INP3 MUX", "DEC8", "ADC MUX8"}, \
294 {"IIR" #id " INP3 MUX", "RX0", "SLIM RX0"}, \
295 {"IIR" #id " INP3 MUX", "RX1", "SLIM RX1"}, \
296 {"IIR" #id " INP3 MUX", "RX2", "SLIM RX2"}, \
297 {"IIR" #id " INP3 MUX", "RX3", "SLIM RX3"}, \
298 {"IIR" #id " INP3 MUX", "RX4", "SLIM RX4"}, \
299 {"IIR" #id " INP3 MUX", "RX5", "SLIM RX5"}, \
300 {"IIR" #id " INP3 MUX", "RX6", "SLIM RX6"}, \
301 {"IIR" #id " INP3 MUX", "RX7", "SLIM RX7"}
307 {"SLIM TX" #id, NULL, "CDC_IF TX" #id " MUX"}
368 u16 port; member
430 COMPANDER_5, /* LO3_SE - not used in Tavil */
431 COMPANDER_6, /* LO4_SE - not used in Tavil */
480 int sample_rate;
481 int rate_val;
515 .name = "WCD9335-IFC-DEV",
547 int rate;
550 int num_rx_port;
551 int num_tx_port;
554 int sido_input_src;
555 int dmic_0_1_clk_cnt;
556 int dmic_2_3_clk_cnt;
557 int dmic_4_5_clk_cnt;
558 int dmic_sample_rate;
559 int comp_enabled[COMPANDER_MAX];
560 int sysclk_users;
576 unsigned int iir_idx;
577 unsigned int band_idx;
581 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
597 "Class H Invalid", "Class-H Hi-Fi", "Class-H Low Power", "Class-AB",
598 "Class-H Hi-Fi Low Power"
662 "ZERO", "RX INT0_2 MUX",
666 "ZERO", "RX INT1_2 MUX",
670 "ZERO", "RX INT2_2 MUX",
674 "ZERO", "RX INT3_2 MUX",
678 "ZERO", "RX INT4_2 MUX",
682 "ZERO", "RX INT7_2 MUX",
686 "ZERO", "RX INT8_2 MUX",
1264 static int wcd934x_set_sido_input_src(struct wcd934x_codec *wcd, int sido_src) in wcd934x_set_sido_input_src()
1266 if (sido_src == wcd->sido_input_src) in wcd934x_set_sido_input_src()
1270 regmap_update_bits(wcd->regmap, WCD934X_ANA_RCO, in wcd934x_set_sido_input_src()
1275 wcd->sido_input_src = sido_src; in wcd934x_set_sido_input_src()
1280 static int wcd934x_enable_ana_bias_and_sysclk(struct wcd934x_codec *wcd) in wcd934x_enable_ana_bias_and_sysclk()
1282 mutex_lock(&wcd->sysclk_mutex); in wcd934x_enable_ana_bias_and_sysclk()
1284 if (++wcd->sysclk_users != 1) { in wcd934x_enable_ana_bias_and_sysclk()
1285 mutex_unlock(&wcd->sysclk_mutex); in wcd934x_enable_ana_bias_and_sysclk()
1288 mutex_unlock(&wcd->sysclk_mutex); in wcd934x_enable_ana_bias_and_sysclk()
1290 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_enable_ana_bias_and_sysclk()
1293 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_enable_ana_bias_and_sysclk()
1297 * 1ms delay is required after pre-charge is enabled in wcd934x_enable_ana_bias_and_sysclk()
1301 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_enable_ana_bias_and_sysclk()
1303 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_enable_ana_bias_and_sysclk()
1311 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_enable_ana_bias_and_sysclk()
1314 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_enable_ana_bias_and_sysclk()
1317 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_enable_ana_bias_and_sysclk()
1320 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_enable_ana_bias_and_sysclk()
1322 regmap_update_bits(wcd->regmap, in wcd934x_enable_ana_bias_and_sysclk()
1326 regmap_update_bits(wcd->regmap, in wcd934x_enable_ana_bias_and_sysclk()
1330 regmap_update_bits(wcd->regmap, WCD934X_CODEC_RPM_CLK_GATE, in wcd934x_enable_ana_bias_and_sysclk()
1343 static int wcd934x_disable_ana_bias_and_syclk(struct wcd934x_codec *wcd) in wcd934x_disable_ana_bias_and_syclk()
1345 mutex_lock(&wcd->sysclk_mutex); in wcd934x_disable_ana_bias_and_syclk()
1346 if (--wcd->sysclk_users != 0) { in wcd934x_disable_ana_bias_and_syclk()
1347 mutex_unlock(&wcd->sysclk_mutex); in wcd934x_disable_ana_bias_and_syclk()
1350 mutex_unlock(&wcd->sysclk_mutex); in wcd934x_disable_ana_bias_and_syclk()
1352 regmap_update_bits(wcd->regmap, WCD934X_CLK_SYS_MCLK_PRG, in wcd934x_disable_ana_bias_and_syclk()
1355 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_disable_ana_bias_and_syclk()
1357 regmap_update_bits(wcd->regmap, WCD934X_ANA_BIAS, in wcd934x_disable_ana_bias_and_syclk()
1363 static int __wcd934x_cdc_mclk_enable(struct wcd934x_codec *wcd, bool enable) in __wcd934x_cdc_mclk_enable()
1365 int ret = 0; in __wcd934x_cdc_mclk_enable()
1368 ret = clk_prepare_enable(wcd->extclk); in __wcd934x_cdc_mclk_enable()
1371 dev_err(wcd->dev, "%s: ext clk enable failed\n", in __wcd934x_cdc_mclk_enable()
1377 int val; in __wcd934x_cdc_mclk_enable()
1379 regmap_read(wcd->regmap, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL, in __wcd934x_cdc_mclk_enable()
1387 clk_disable_unprepare(wcd->extclk); in __wcd934x_cdc_mclk_enable()
1393 static int wcd934x_codec_enable_mclk(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_mclk()
1394 struct snd_kcontrol *kc, int event) in wcd934x_codec_enable_mclk()
1396 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_mclk()
1397 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_enable_mclk()
1409 static int wcd934x_get_version(struct wcd934x_codec *wcd) in wcd934x_get_version()
1411 int val1, val2, ver, ret; in wcd934x_get_version()
1416 regmap = wcd->regmap; in wcd934x_get_version()
1446 wcd->version = ver; in wcd934x_get_version()
1447 dev_info(wcd->dev, "WCD934X Minor:0x%x Version:0x%x\n", id_minor, ver); in wcd934x_get_version()
1454 int rc, val; in wcd934x_enable_efuse_sensing()
1458 regmap_update_bits(wcd->regmap, in wcd934x_enable_efuse_sensing()
1462 regmap_update_bits(wcd->regmap, in wcd934x_enable_efuse_sensing()
1473 rc = regmap_read(wcd->regmap, in wcd934x_enable_efuse_sensing()
1482 static int wcd934x_swrm_clock(struct wcd934x_codec *wcd, bool enable) in wcd934x_swrm_clock()
1486 regmap_update_bits(wcd->regmap, in wcd934x_swrm_clock()
1491 regmap_update_bits(wcd->regmap, in wcd934x_swrm_clock()
1500 static int wcd934x_set_prim_interpolator_rate(struct snd_soc_dai *dai, in wcd934x_set_prim_interpolator_rate()
1503 struct snd_soc_component *comp = dai->component; in wcd934x_set_prim_interpolator_rate()
1504 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_set_prim_interpolator_rate()
1507 int inp, j; in wcd934x_set_prim_interpolator_rate()
1509 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd934x_set_prim_interpolator_rate()
1510 inp = ch->shift + INTn_1_INP_SEL_RX0; in wcd934x_set_prim_interpolator_rate()
1512 * Loop through all interpolator MUX inputs and find out in wcd934x_set_prim_interpolator_rate()
1513 * to which interpolator input, the slim rx port in wcd934x_set_prim_interpolator_rate()
1542 dev_err(wcd->dev, in wcd934x_set_prim_interpolator_rate()
1543 "Cannot set 44.1KHz on INT%d\n", in wcd934x_set_prim_interpolator_rate()
1557 static int wcd934x_set_mix_interpolator_rate(struct snd_soc_dai *dai, in wcd934x_set_mix_interpolator_rate()
1558 int rate_val, u32 rate) in wcd934x_set_mix_interpolator_rate()
1560 struct snd_soc_component *component = dai->component; in wcd934x_set_mix_interpolator_rate()
1561 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_set_mix_interpolator_rate()
1563 int val, j; in wcd934x_set_mix_interpolator_rate()
1565 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd934x_set_mix_interpolator_rate()
1574 if (val == (ch->shift + INTn_2_INP_SEL_RX0)) { in wcd934x_set_mix_interpolator_rate()
1582 dev_err(component->dev, in wcd934x_set_mix_interpolator_rate()
1584 dai->id); in wcd934x_set_mix_interpolator_rate()
1585 return -EINVAL; in wcd934x_set_mix_interpolator_rate()
1599 static int wcd934x_set_interpolator_rate(struct snd_soc_dai *dai, in wcd934x_set_interpolator_rate()
1602 int rate_val = 0; in wcd934x_set_interpolator_rate()
1603 int i, ret; in wcd934x_set_interpolator_rate()
1612 dev_err(dai->dev, "Unsupported sample rate: %d\n", sample_rate); in wcd934x_set_interpolator_rate()
1613 return -EINVAL; in wcd934x_set_interpolator_rate()
1626 static int wcd934x_set_decimator_rate(struct snd_soc_dai *dai, in wcd934x_set_decimator_rate()
1629 struct snd_soc_component *comp = dai->component; in wcd934x_set_decimator_rate()
1633 int tx_port, tx_port_reg; in wcd934x_set_decimator_rate()
1634 int decimator = -1; in wcd934x_set_decimator_rate()
1636 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd934x_set_decimator_rate()
1637 tx_port = ch->port; in wcd934x_set_decimator_rate()
1638 /* Find the SB TX MUX input - which decimator is connected */ in wcd934x_set_decimator_rate()
1647 shift = ((tx_port - 4) << 1); in wcd934x_set_decimator_rate()
1652 shift = ((tx_port - 8) << 1); in wcd934x_set_decimator_rate()
1666 dev_err(wcd->dev, "Invalid SLIM TX%u port DAI ID:%d\n", in wcd934x_set_decimator_rate()
1667 tx_port, dai->id); in wcd934x_set_decimator_rate()
1668 return -EINVAL; in wcd934x_set_decimator_rate()
1686 decimator = tx_mux_sel - 1; in wcd934x_set_decimator_rate()
1693 dev_err(wcd->dev, "ERROR: Invalid tx_port: %d\n", in wcd934x_set_decimator_rate()
1695 return -EINVAL; in wcd934x_set_decimator_rate()
1707 static int wcd934x_slim_set_hw_params(struct wcd934x_codec *wcd, in wcd934x_slim_set_hw_params()
1709 int direction) in wcd934x_slim_set_hw_params()
1711 struct list_head *slim_ch_list = &dai_data->slim_ch_list; in wcd934x_slim_set_hw_params()
1712 struct slim_stream_config *cfg = &dai_data->sconfig; in wcd934x_slim_set_hw_params()
1715 int ret, i; in wcd934x_slim_set_hw_params()
1717 cfg->ch_count = 0; in wcd934x_slim_set_hw_params()
1718 cfg->direction = direction; in wcd934x_slim_set_hw_params()
1719 cfg->port_mask = 0; in wcd934x_slim_set_hw_params()
1723 cfg->ch_count++; in wcd934x_slim_set_hw_params()
1724 payload |= 1 << ch->shift; in wcd934x_slim_set_hw_params()
1725 cfg->port_mask |= BIT(ch->port); in wcd934x_slim_set_hw_params()
1728 cfg->chs = kcalloc(cfg->ch_count, sizeof(unsigned int), GFP_KERNEL); in wcd934x_slim_set_hw_params()
1729 if (!cfg->chs) in wcd934x_slim_set_hw_params()
1730 return -ENOMEM; in wcd934x_slim_set_hw_params()
1734 cfg->chs[i++] = ch->ch_num; in wcd934x_slim_set_hw_params()
1737 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1738 WCD934X_SLIM_PGD_RX_PORT_MULTI_CHNL_0(ch->port), in wcd934x_slim_set_hw_params()
1744 /* configure the slave port for water mark and enable*/ in wcd934x_slim_set_hw_params()
1745 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1746 WCD934X_SLIM_PGD_RX_PORT_CFG(ch->port), in wcd934x_slim_set_hw_params()
1751 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1752 WCD934X_SLIM_PGD_TX_PORT_MULTI_CHNL_0(ch->port), in wcd934x_slim_set_hw_params()
1758 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1759 WCD934X_SLIM_PGD_TX_PORT_MULTI_CHNL_1(ch->port), in wcd934x_slim_set_hw_params()
1764 /* configure the slave port for water mark and enable*/ in wcd934x_slim_set_hw_params()
1765 ret = regmap_write(wcd->if_regmap, in wcd934x_slim_set_hw_params()
1766 WCD934X_SLIM_PGD_TX_PORT_CFG(ch->port), in wcd934x_slim_set_hw_params()
1774 dai_data->sruntime = slim_stream_allocate(wcd->sdev, "WCD934x-SLIM"); in wcd934x_slim_set_hw_params()
1779 dev_err(wcd->dev, "Error Setting slim hw params\n"); in wcd934x_slim_set_hw_params()
1780 kfree(cfg->chs); in wcd934x_slim_set_hw_params()
1781 cfg->chs = NULL; in wcd934x_slim_set_hw_params()
1786 static int wcd934x_hw_params(struct snd_pcm_substream *substream, in wcd934x_hw_params()
1791 int ret, tx_fs_rate = 0; in wcd934x_hw_params()
1793 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_hw_params()
1795 switch (substream->stream) { in wcd934x_hw_params()
1799 dev_err(wcd->dev, "cannot set sample rate: %u\n", in wcd934x_hw_params()
1805 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd934x_hw_params()
1808 dev_err(wcd->dev, "Invalid format 0x%x\n", in wcd934x_hw_params()
1810 return -EINVAL; in wcd934x_hw_params()
1838 dev_err(wcd->dev, "Invalid TX sample rate: %d\n", in wcd934x_hw_params()
1840 return -EINVAL; in wcd934x_hw_params()
1847 dev_err(wcd->dev, "Cannot set TX Decimator rate\n"); in wcd934x_hw_params()
1852 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd934x_hw_params()
1855 dev_err(wcd->dev, "Invalid format 0x%x\n", in wcd934x_hw_params()
1857 return -EINVAL; in wcd934x_hw_params()
1861 dev_err(wcd->dev, "Invalid stream type %d\n", in wcd934x_hw_params()
1862 substream->stream); in wcd934x_hw_params()
1863 return -EINVAL; in wcd934x_hw_params()
1866 wcd->dai[dai->id].sconfig.rate = params_rate(params); in wcd934x_hw_params()
1868 return wcd934x_slim_set_hw_params(wcd, &wcd->dai[dai->id], substream->stream); in wcd934x_hw_params()
1871 static int wcd934x_hw_free(struct snd_pcm_substream *substream, in wcd934x_hw_free()
1877 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_hw_free()
1879 dai_data = &wcd->dai[dai->id]; in wcd934x_hw_free()
1881 kfree(dai_data->sconfig.chs); in wcd934x_hw_free()
1886 static int wcd934x_trigger(struct snd_pcm_substream *substream, int cmd, in wcd934x_trigger()
1893 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_trigger()
1895 dai_data = &wcd->dai[dai->id]; in wcd934x_trigger()
1901 cfg = &dai_data->sconfig; in wcd934x_trigger()
1902 slim_stream_prepare(dai_data->sruntime, cfg); in wcd934x_trigger()
1903 slim_stream_enable(dai_data->sruntime); in wcd934x_trigger()
1908 slim_stream_disable(dai_data->sruntime); in wcd934x_trigger()
1909 slim_stream_unprepare(dai_data->sruntime); in wcd934x_trigger()
1918 static int wcd934x_set_channel_map(struct snd_soc_dai *dai, in wcd934x_set_channel_map()
1919 unsigned int tx_num, in wcd934x_set_channel_map()
1920 const unsigned int *tx_slot, in wcd934x_set_channel_map()
1921 unsigned int rx_num, in wcd934x_set_channel_map()
1922 const unsigned int *rx_slot) in wcd934x_set_channel_map()
1925 int i; in wcd934x_set_channel_map()
1927 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_set_channel_map()
1930 dev_err(wcd->dev, "Invalid tx %d or rx %d channel count\n", in wcd934x_set_channel_map()
1932 return -EINVAL; in wcd934x_set_channel_map()
1936 dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n", in wcd934x_set_channel_map()
1938 return -EINVAL; in wcd934x_set_channel_map()
1941 wcd->num_rx_port = rx_num; in wcd934x_set_channel_map()
1943 wcd->rx_chs[i].ch_num = rx_slot[i]; in wcd934x_set_channel_map()
1944 INIT_LIST_HEAD(&wcd->rx_chs[i].list); in wcd934x_set_channel_map()
1947 wcd->num_tx_port = tx_num; in wcd934x_set_channel_map()
1949 wcd->tx_chs[i].ch_num = tx_slot[i]; in wcd934x_set_channel_map()
1950 INIT_LIST_HEAD(&wcd->tx_chs[i].list); in wcd934x_set_channel_map()
1956 static int wcd934x_get_channel_map(const struct snd_soc_dai *dai, in wcd934x_get_channel_map()
1957 unsigned int *tx_num, unsigned int *tx_slot, in wcd934x_get_channel_map()
1958 unsigned int *rx_num, unsigned int *rx_slot) in wcd934x_get_channel_map()
1962 int i = 0; in wcd934x_get_channel_map()
1964 wcd = snd_soc_component_get_drvdata(dai->component); in wcd934x_get_channel_map()
1966 switch (dai->id) { in wcd934x_get_channel_map()
1972 dev_err(wcd->dev, "Invalid rx_slot %p or rx_num %p\n", in wcd934x_get_channel_map()
1974 return -EINVAL; in wcd934x_get_channel_map()
1977 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd934x_get_channel_map()
1978 rx_slot[i++] = ch->ch_num; in wcd934x_get_channel_map()
1986 dev_err(wcd->dev, "Invalid tx_slot %p or tx_num %p\n", in wcd934x_get_channel_map()
1988 return -EINVAL; in wcd934x_get_channel_map()
1991 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd934x_get_channel_map()
1992 tx_slot[i++] = ch->ch_num; in wcd934x_get_channel_map()
1997 dev_err(wcd->dev, "Invalid DAI ID %x\n", dai->id); in wcd934x_get_channel_map()
2113 static int swclk_gate_enable(struct clk_hw *hw) in swclk_gate_enable()
2123 static int swclk_gate_is_enabled(struct clk_hw *hw) in swclk_gate_is_enabled()
2126 int ret, val; in swclk_gate_is_enabled()
2128 regmap_read(wcd->regmap, WCD934X_CDC_CLK_RST_CTRL_SWR_CONTROL, &val); in swclk_gate_is_enabled()
2150 struct clk *parent = wcd->extclk; in wcd934x_register_mclk_output()
2151 struct device *dev = wcd->dev; in wcd934x_register_mclk_output()
2152 struct device_node *np = dev->parent->of_node; in wcd934x_register_mclk_output()
2157 int ret; in wcd934x_register_mclk_output()
2159 if (of_property_read_u32(np, "clock-frequency", &wcd->rate)) in wcd934x_register_mclk_output()
2164 of_property_read_string(np, "clock-output-names", &clk_name); in wcd934x_register_mclk_output()
2171 wcd->hw.init = &init; in wcd934x_register_mclk_output()
2173 hw = &wcd->hw; in wcd934x_register_mclk_output()
2174 ret = devm_clk_hw_register(wcd->dev->parent, hw); in wcd934x_register_mclk_output()
2185 static int wcd934x_get_micbias_val(struct device *dev, const char *micbias, in wcd934x_get_micbias_val()
2188 int mv; in wcd934x_get_micbias_val()
2190 if (of_property_read_u32(dev->parent->of_node, micbias, &mv)) { in wcd934x_get_micbias_val()
2207 return (mv - 1000) / 50; in wcd934x_get_micbias_val()
2210 static int wcd934x_init_dmic(struct snd_soc_component *comp) in wcd934x_init_dmic()
2212 int vout_ctl_1, vout_ctl_2, vout_ctl_3, vout_ctl_4; in wcd934x_init_dmic()
2213 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_init_dmic()
2216 vout_ctl_1 = wcd934x_get_micbias_val(comp->dev, in wcd934x_init_dmic()
2217 "qcom,micbias1-microvolt", NULL); in wcd934x_init_dmic()
2218 vout_ctl_2 = wcd934x_get_micbias_val(comp->dev, in wcd934x_init_dmic()
2219 "qcom,micbias2-microvolt", in wcd934x_init_dmic()
2220 &wcd->micb2_mv); in wcd934x_init_dmic()
2221 vout_ctl_3 = wcd934x_get_micbias_val(comp->dev, in wcd934x_init_dmic()
2222 "qcom,micbias3-microvolt", NULL); in wcd934x_init_dmic()
2223 vout_ctl_4 = wcd934x_get_micbias_val(comp->dev, in wcd934x_init_dmic()
2224 "qcom,micbias4-microvolt", NULL); in wcd934x_init_dmic()
2235 if (wcd->rate == WCD934X_MCLK_CLK_9P6MHZ) in wcd934x_init_dmic()
2240 wcd->dmic_sample_rate = def_dmic_rate; in wcd934x_init_dmic()
2251 struct regmap *rm = wcd->regmap; in wcd934x_hw_init()
2261 static int wcd934x_comp_init(struct snd_soc_component *component) in wcd934x_comp_init()
2263 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_comp_init()
2272 static irqreturn_t wcd934x_slim_irq_handler(int irq, void *data) in wcd934x_slim_irq_handler()
2276 int i, j, port_id; in wcd934x_slim_irq_handler()
2277 unsigned int val, int_val = 0; in wcd934x_slim_irq_handler()
2284 regmap_read(wcd->if_regmap, i, &val); in wcd934x_slim_irq_handler()
2294 port_id = j - 16; in wcd934x_slim_irq_handler()
2297 regmap_read(wcd->if_regmap, in wcd934x_slim_irq_handler()
2306 regmap_read(wcd->if_regmap, reg, &int_val); in wcd934x_slim_irq_handler()
2310 dev_err_ratelimited(wcd->dev, in wcd934x_slim_irq_handler()
2311 "overflow error on %s port %d, value %x\n", in wcd934x_slim_irq_handler()
2315 dev_err_ratelimited(wcd->dev, in wcd934x_slim_irq_handler()
2316 "underflow error on %s port %d, value %x\n", in wcd934x_slim_irq_handler()
2328 wcd->if_regmap, reg, &int_val); in wcd934x_slim_irq_handler()
2331 regmap_write(wcd->if_regmap, in wcd934x_slim_irq_handler()
2337 dev_err_ratelimited(wcd->dev, in wcd934x_slim_irq_handler()
2338 "Port Closed %s port %d, value %x\n", in wcd934x_slim_irq_handler()
2341 regmap_write(wcd->if_regmap, in wcd934x_slim_irq_handler()
2365 int *btn_low, int *btn_high, in wcd934x_mbhc_program_btn_thr()
2366 int num_btn, bool is_micbias) in wcd934x_mbhc_program_btn_thr()
2368 int i, vth; in wcd934x_mbhc_program_btn_thr()
2371 dev_err(component->dev, "%s: invalid number of buttons: %d\n", in wcd934x_mbhc_program_btn_thr()
2383 static bool wcd934x_mbhc_micb_en_status(struct snd_soc_component *component, int micb_num) in wcd934x_mbhc_micb_en_status()
2409 static int wcd934x_micbias_control(struct snd_soc_component *component, in wcd934x_micbias_control()
2410 int micb_num, int req, bool is_dapm) in wcd934x_micbias_control()
2413 int micb_index = micb_num - 1; in wcd934x_micbias_control()
2430 dev_err(component->dev, "%s: Invalid micbias number: %d\n", in wcd934x_micbias_control()
2432 return -EINVAL; in wcd934x_micbias_control()
2434 mutex_lock(&wcd934x->micb_lock); in wcd934x_micbias_control()
2438 wcd934x->pullup_ref[micb_index]++; in wcd934x_micbias_control()
2439 if ((wcd934x->pullup_ref[micb_index] == 1) && in wcd934x_micbias_control()
2440 (wcd934x->micb_ref[micb_index] == 0)) in wcd934x_micbias_control()
2446 if (wcd934x->pullup_ref[micb_index] > 0) in wcd934x_micbias_control()
2447 wcd934x->pullup_ref[micb_index]--; in wcd934x_micbias_control()
2449 if ((wcd934x->pullup_ref[micb_index] == 0) && in wcd934x_micbias_control()
2450 (wcd934x->micb_ref[micb_index] == 0)) in wcd934x_micbias_control()
2455 wcd934x->micb_ref[micb_index]++; in wcd934x_micbias_control()
2456 if (wcd934x->micb_ref[micb_index] == 1) { in wcd934x_micbias_control()
2461 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2466 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2470 if (wcd934x->micb_ref[micb_index] > 0) in wcd934x_micbias_control()
2471 wcd934x->micb_ref[micb_index]--; in wcd934x_micbias_control()
2473 if ((wcd934x->micb_ref[micb_index] == 0) && in wcd934x_micbias_control()
2474 (wcd934x->pullup_ref[micb_index] > 0)) in wcd934x_micbias_control()
2478 else if ((wcd934x->micb_ref[micb_index] == 0) && in wcd934x_micbias_control()
2479 (wcd934x->pullup_ref[micb_index] == 0)) { in wcd934x_micbias_control()
2481 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2487 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2491 wcd_mbhc_event_notify(wcd934x->mbhc, in wcd934x_micbias_control()
2496 mutex_unlock(&wcd934x->micb_lock); in wcd934x_micbias_control()
2501 static int wcd934x_mbhc_request_micbias(struct snd_soc_component *component, in wcd934x_mbhc_request_micbias()
2502 int micb_num, int req) in wcd934x_mbhc_request_micbias()
2504 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_mbhc_request_micbias()
2505 int ret; in wcd934x_mbhc_request_micbias()
2534 static int wcd934x_get_micb_vout_ctl_val(u32 micb_mv) in wcd934x_get_micb_vout_ctl_val()
2538 return -EINVAL; in wcd934x_get_micb_vout_ctl_val()
2540 return (micb_mv - 1000) / 50; in wcd934x_get_micb_vout_ctl_val()
2543 static int wcd934x_mbhc_micb_adjust_voltage(struct snd_soc_component *component, in wcd934x_mbhc_micb_adjust_voltage()
2544 int req_volt, int micb_num) in wcd934x_mbhc_micb_adjust_voltage()
2547 int cur_vout_ctl, req_vout_ctl, micb_reg, micb_en, ret = 0; in wcd934x_mbhc_micb_adjust_voltage()
2563 return -EINVAL; in wcd934x_mbhc_micb_adjust_voltage()
2565 mutex_lock(&wcd934x->micb_lock); in wcd934x_mbhc_micb_adjust_voltage()
2570 * to avoid slow micbias ramp-up or down enable pull-up in wcd934x_mbhc_micb_adjust_voltage()
2571 * momentarily, change the micbias value and then re-enable in wcd934x_mbhc_micb_adjust_voltage()
2581 ret = -EINVAL; in wcd934x_mbhc_micb_adjust_voltage()
2610 mutex_unlock(&wcd934x->micb_lock); in wcd934x_mbhc_micb_adjust_voltage()
2614 static int wcd934x_mbhc_micb_ctrl_threshold_mic(struct snd_soc_component *component, in wcd934x_mbhc_micb_ctrl_threshold_mic()
2615 int micb_num, bool req_en) in wcd934x_mbhc_micb_ctrl_threshold_mic()
2618 int rc, micb_mv; in wcd934x_mbhc_micb_ctrl_threshold_mic()
2621 return -EINVAL; in wcd934x_mbhc_micb_ctrl_threshold_mic()
2627 if (wcd934x->micb2_mv >= WCD_MBHC_THR_HS_MICB_MV) in wcd934x_mbhc_micb_ctrl_threshold_mic()
2630 micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : wcd934x->micb2_mv; in wcd934x_mbhc_micb_ctrl_threshold_mic()
2641 int i; in wcd934x_mbhc_get_result_params()
2642 int val, val1; in wcd934x_mbhc_get_result_params()
2646 static const int minCode_param[] = { in wcd934x_mbhc_get_result_params()
2650 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x20, 0x20); in wcd934x_mbhc_get_result_params()
2652 regmap_read(wcd934x->regmap, WCD934X_ANA_MBHC_RESULT_2, &val); in wcd934x_mbhc_get_result_params()
2657 regmap_read(wcd934x->regmap, WCD934X_ANA_MBHC_RESULT_1, &val1); in wcd934x_mbhc_get_result_params()
2659 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x20, 0x00); in wcd934x_mbhc_get_result_params()
2667 dev_err(wcd934x->dev, "%s: Impedance detect ramp error, c1=%d, x1=0x%x\n", in wcd934x_mbhc_get_result_params()
2672 denom = (x1 * d1) - (1 << (14 - noff)); in wcd934x_mbhc_get_result_params()
2678 dev_dbg(wcd934x->dev, "%s: d1=%d, c1=%d, x1=0x%x, z_val=%di (milliohm)\n", in wcd934x_mbhc_get_result_params()
2684 regmap_read(wcd934x->regmap, WCD934X_ANA_MBHC_RESULT_1, &val); in wcd934x_mbhc_get_result_params()
2685 regmap_read(wcd934x->regmap, WCD934X_ANA_MBHC_RESULT_2, &val1); in wcd934x_mbhc_get_result_params()
2699 struct wcd934x_codec *wcd934x = dev_get_drvdata(component->dev); in wcd934x_mbhc_zdet_ramp()
2703 WCD934X_ZDET_MAXV_CTL_MASK, zdet_param->ldo_ctl); in wcd934x_mbhc_zdet_ramp()
2705 WCD934X_VTH_MASK, zdet_param->btn5); in wcd934x_mbhc_zdet_ramp()
2707 WCD934X_VTH_MASK, zdet_param->btn6); in wcd934x_mbhc_zdet_ramp()
2709 WCD934X_VTH_MASK, zdet_param->btn7); in wcd934x_mbhc_zdet_ramp()
2711 WCD934X_ZDET_RANGE_CTL_MASK, zdet_param->noff); in wcd934x_mbhc_zdet_ramp()
2713 0x0F, zdet_param->nshift); in wcd934x_mbhc_zdet_ramp()
2718 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x80, 0x80); in wcd934x_mbhc_zdet_ramp()
2719 wcd934x_mbhc_get_result_params(wcd934x, d1_a, zdet_param->noff, &zdet); in wcd934x_mbhc_zdet_ramp()
2720 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x80, 0x00); in wcd934x_mbhc_zdet_ramp()
2728 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x40, 0x40); in wcd934x_mbhc_zdet_ramp()
2729 wcd934x_mbhc_get_result_params(wcd934x, d1_a, zdet_param->noff, &zdet); in wcd934x_mbhc_zdet_ramp()
2730 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ZDET, 0x40, 0x00); in wcd934x_mbhc_zdet_ramp()
2736 int32_t *z_val, int flag_l_r) in wcd934x_wcd_mbhc_qfuse_cal()
2739 int q1_cal; in wcd934x_wcd_mbhc_qfuse_cal()
2748 q1_cal = (10000 - ((q1 & 0x7F) * 25)); in wcd934x_wcd_mbhc_qfuse_cal()
2758 struct wcd934x_codec *wcd934x = dev_get_drvdata(component->dev); in wcd934x_wcd_mbhc_calc_impedance()
2761 int zMono, z_diff1, z_diff2; in wcd934x_wcd_mbhc_calc_impedance()
2786 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ELECT, 0x80, 0x00); in wcd934x_wcd_mbhc_calc_impedance()
2789 /* For NO-jack, disable L_DET_EN before Z-det measurements */ in wcd934x_wcd_mbhc_calc_impedance()
2790 if (wcd934x->mbhc_cfg.hphl_swh) in wcd934x_wcd_mbhc_calc_impedance()
2791 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_MECH, 0x80, 0x00); in wcd934x_wcd_mbhc_calc_impedance()
2794 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_MECH, 0x01, 0x00); in wcd934x_wcd_mbhc_calc_impedance()
2828 dev_info(component->dev, "%s: impedance on HPH_L = %d(ohms)\n", in wcd934x_wcd_mbhc_calc_impedance()
2835 (zdet_param_ptr->noff == 0x6)) || in wcd934x_wcd_mbhc_calc_impedance()
2860 dev_err(component->dev, "%s: impedance on HPH_R = %d(ohms)\n", in wcd934x_wcd_mbhc_calc_impedance()
2866 dev_dbg(component->dev, in wcd934x_wcd_mbhc_calc_impedance()
2875 dev_dbg(component->dev, in wcd934x_wcd_mbhc_calc_impedance()
2878 wcd_mbhc_set_hph_type(wcd934x->mbhc, WCD_MBHC_HPH_MONO); in wcd934x_wcd_mbhc_calc_impedance()
2897 z_diff1 = (z1Ls > zMono) ? (z1Ls - zMono) : (zMono - z1Ls); in wcd934x_wcd_mbhc_calc_impedance()
2898 z_diff2 = ((*zl) > z1Ls) ? ((*zl) - z1Ls) : (z1Ls - (*zl)); in wcd934x_wcd_mbhc_calc_impedance()
2900 dev_err(component->dev, "%s: stereo plug type detected\n", in wcd934x_wcd_mbhc_calc_impedance()
2902 wcd_mbhc_set_hph_type(wcd934x->mbhc, WCD_MBHC_HPH_STEREO); in wcd934x_wcd_mbhc_calc_impedance()
2904 dev_err(component->dev, "%s: MONO plug type detected\n", in wcd934x_wcd_mbhc_calc_impedance()
2906 wcd_mbhc_set_hph_type(wcd934x->mbhc, WCD_MBHC_HPH_MONO); in wcd934x_wcd_mbhc_calc_impedance()
2914 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_MECH, 0x01, 0x01); in wcd934x_wcd_mbhc_calc_impedance()
2916 /* For NO-jack, re-enable L_DET_EN after Z-det measurements */ in wcd934x_wcd_mbhc_calc_impedance()
2917 if (wcd934x->mbhc_cfg.hphl_swh) in wcd934x_wcd_mbhc_calc_impedance()
2918 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_MECH, 0x80, 0x80); in wcd934x_wcd_mbhc_calc_impedance()
2923 regmap_update_bits(wcd934x->regmap, WCD934X_ANA_MBHC_ELECT, 0x80, 0x80); in wcd934x_wcd_mbhc_calc_impedance()
2965 static int wcd934x_get_hph_type(struct snd_kcontrol *kcontrol, in wcd934x_get_hph_type()
2971 ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd->mbhc); in wcd934x_get_hph_type()
2976 static int wcd934x_hph_impedance_get(struct snd_kcontrol *kcontrol, in wcd934x_hph_impedance_get()
2985 mc = (struct soc_mixer_control *)(kcontrol->private_value); in wcd934x_hph_impedance_get()
2986 hphr = mc->shift; in wcd934x_hph_impedance_get()
2987 wcd_mbhc_get_impedance(wcd->mbhc, &zl, &zr); in wcd934x_hph_impedance_get()
2988 dev_dbg(component->dev, "%s: zl=%u(ohms), zr=%u(ohms)\n", __func__, zl, zr); in wcd934x_hph_impedance_get()
2989 ucontrol->value.integer.value[0] = hphr ? zr : zl; in wcd934x_hph_impedance_get()
3005 static int wcd934x_mbhc_init(struct snd_soc_component *component) in wcd934x_mbhc_init()
3007 struct wcd934x_ddata *data = dev_get_drvdata(component->dev->parent); in wcd934x_mbhc_init()
3009 struct wcd_mbhc_intr *intr_ids = &wcd->intr_ids; in wcd934x_mbhc_init()
3011 intr_ids->mbhc_sw_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3013 intr_ids->mbhc_btn_press_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3015 intr_ids->mbhc_btn_release_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3017 intr_ids->mbhc_hs_ins_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3019 intr_ids->mbhc_hs_rem_intr = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3021 intr_ids->hph_left_ocp = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3023 intr_ids->hph_right_ocp = regmap_irq_get_virq(data->irq_data, in wcd934x_mbhc_init()
3026 wcd->mbhc = wcd_mbhc_init(component, &mbhc_cb, intr_ids, wcd_mbhc_fields, true); in wcd934x_mbhc_init()
3027 if (IS_ERR(wcd->mbhc)) { in wcd934x_mbhc_init()
3028 wcd->mbhc = NULL; in wcd934x_mbhc_init()
3029 return -EINVAL; in wcd934x_mbhc_init()
3044 if (!wcd->mbhc) in wcd934x_mbhc_deinit()
3047 wcd_mbhc_deinit(wcd->mbhc); in wcd934x_mbhc_deinit()
3050 static int wcd934x_comp_probe(struct snd_soc_component *component) in wcd934x_comp_probe()
3052 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_comp_probe()
3053 int i; in wcd934x_comp_probe()
3055 snd_soc_component_init_regmap(component, wcd->regmap); in wcd934x_comp_probe()
3056 wcd->component = component; in wcd934x_comp_probe()
3058 /* Class-H Init*/ in wcd934x_comp_probe()
3059 wcd->clsh_ctrl = wcd_clsh_ctrl_alloc(component, wcd->version); in wcd934x_comp_probe()
3060 if (IS_ERR(wcd->clsh_ctrl)) in wcd934x_comp_probe()
3061 return PTR_ERR(wcd->clsh_ctrl); in wcd934x_comp_probe()
3063 /* Default HPH Mode to Class-H Low HiFi */ in wcd934x_comp_probe()
3064 wcd->hph_mode = CLS_H_LOHIFI; in wcd934x_comp_probe()
3069 INIT_LIST_HEAD(&wcd->dai[i].slim_ch_list); in wcd934x_comp_probe()
3074 dev_err(component->dev, "Failed to Initialize MBHC\n"); in wcd934x_comp_probe()
3081 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_comp_remove()
3084 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd934x_comp_remove()
3087 static int wcd934x_comp_set_sysclk(struct snd_soc_component *comp, in wcd934x_comp_set_sysclk()
3088 int clk_id, int source, in wcd934x_comp_set_sysclk()
3089 unsigned int freq, int dir) in wcd934x_comp_set_sysclk()
3091 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_comp_set_sysclk()
3092 int val = WCD934X_CODEC_RPM_CLK_MCLK_CFG_9P6MHZ; in wcd934x_comp_set_sysclk()
3094 wcd->rate = freq; in wcd934x_comp_set_sysclk()
3096 if (wcd->rate == WCD934X_MCLK_CLK_12P288MHZ) in wcd934x_comp_set_sysclk()
3103 return clk_set_rate(wcd->extclk, freq); in wcd934x_comp_set_sysclk()
3107 int iir_idx, int band_idx, int coeff_idx) in get_iir_band_coeff()
3110 int reg, b2_reg; in get_iir_band_coeff()
3141 int iir_idx, int band_idx, uint32_t value) in set_iir_band_coeff()
3143 int reg = WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B2_CTL + 16 * iir_idx; in set_iir_band_coeff()
3148 /* Mask top 2 bits, 7-8 are reserved */ in set_iir_band_coeff()
3152 static int wcd934x_put_iir_band_audio_mixer( in wcd934x_put_iir_band_audio_mixer()
3159 (struct wcd_iir_filter_ctl *)kcontrol->private_value; in wcd934x_put_iir_band_audio_mixer()
3160 struct soc_bytes_ext *params = &ctl->bytes_ext; in wcd934x_put_iir_band_audio_mixer()
3161 int iir_idx = ctl->iir_idx; in wcd934x_put_iir_band_audio_mixer()
3162 int band_idx = ctl->band_idx; in wcd934x_put_iir_band_audio_mixer()
3164 int reg = WCD934X_CDC_SIDETONE_IIR0_IIR_COEF_B1_CTL + 16 * iir_idx; in wcd934x_put_iir_band_audio_mixer()
3166 memcpy(&coeff[0], ucontrol->value.bytes.data, params->max); in wcd934x_put_iir_band_audio_mixer()
3182 static int wcd934x_get_iir_band_audio_mixer(struct snd_kcontrol *kcontrol, in wcd934x_get_iir_band_audio_mixer()
3188 (struct wcd_iir_filter_ctl *)kcontrol->private_value; in wcd934x_get_iir_band_audio_mixer()
3189 struct soc_bytes_ext *params = &ctl->bytes_ext; in wcd934x_get_iir_band_audio_mixer()
3190 int iir_idx = ctl->iir_idx; in wcd934x_get_iir_band_audio_mixer()
3191 int band_idx = ctl->band_idx; in wcd934x_get_iir_band_audio_mixer()
3200 memcpy(ucontrol->value.bytes.data, &coeff[0], params->max); in wcd934x_get_iir_band_audio_mixer()
3205 static int wcd934x_iir_filter_info(struct snd_kcontrol *kcontrol, in wcd934x_iir_filter_info()
3209 (struct wcd_iir_filter_ctl *)kcontrol->private_value; in wcd934x_iir_filter_info()
3210 struct soc_bytes_ext *params = &ctl->bytes_ext; in wcd934x_iir_filter_info()
3212 ucontrol->type = SNDRV_CTL_ELEM_TYPE_BYTES; in wcd934x_iir_filter_info()
3213 ucontrol->count = params->max; in wcd934x_iir_filter_info()
3218 static int wcd934x_compander_get(struct snd_kcontrol *kc, in wcd934x_compander_get()
3222 int comp = ((struct soc_mixer_control *)kc->private_value)->shift; in wcd934x_compander_get()
3223 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_compander_get()
3225 ucontrol->value.integer.value[0] = wcd->comp_enabled[comp]; in wcd934x_compander_get()
3230 static int wcd934x_compander_set(struct snd_kcontrol *kc, in wcd934x_compander_set()
3234 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_compander_set()
3235 int comp = ((struct soc_mixer_control *)kc->private_value)->shift; in wcd934x_compander_set()
3236 int value = ucontrol->value.integer.value[0]; in wcd934x_compander_set()
3237 int sel; in wcd934x_compander_set()
3239 if (wcd->comp_enabled[comp] == value) in wcd934x_compander_set()
3242 wcd->comp_enabled[comp] = value; in wcd934x_compander_set()
3271 static int wcd934x_rx_hph_mode_get(struct snd_kcontrol *kc, in wcd934x_rx_hph_mode_get()
3275 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_rx_hph_mode_get()
3277 ucontrol->value.enumerated.item[0] = wcd->hph_mode; in wcd934x_rx_hph_mode_get()
3282 static int wcd934x_rx_hph_mode_put(struct snd_kcontrol *kc, in wcd934x_rx_hph_mode_put()
3286 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_rx_hph_mode_put()
3289 mode_val = ucontrol->value.enumerated.item[0]; in wcd934x_rx_hph_mode_put()
3291 if (mode_val == wcd->hph_mode) in wcd934x_rx_hph_mode_put()
3295 dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); in wcd934x_rx_hph_mode_put()
3298 wcd->hph_mode = mode_val; in wcd934x_rx_hph_mode_put()
3303 static int slim_rx_mux_get(struct snd_kcontrol *kc, in slim_rx_mux_get()
3308 struct wcd934x_codec *wcd = dev_get_drvdata(dapm->dev); in slim_rx_mux_get()
3310 ucontrol->value.enumerated.item[0] = wcd->rx_port_value[w->shift]; in slim_rx_mux_get()
3315 static int slim_rx_mux_to_dai_id(int mux) in slim_rx_mux_to_dai_id() argument
3317 int aif_id; in slim_rx_mux_to_dai_id()
3319 switch (mux) { in slim_rx_mux_to_dai_id()
3333 aif_id = -1; in slim_rx_mux_to_dai_id()
3340 static int slim_rx_mux_put(struct snd_kcontrol *kc, in slim_rx_mux_put()
3344 struct wcd934x_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_put()
3345 struct soc_enum *e = (struct soc_enum *)kc->private_value; in slim_rx_mux_put()
3348 u32 port_id = w->shift; in slim_rx_mux_put()
3350 int mux_idx; in slim_rx_mux_put()
3351 int prev_mux_idx = wcd->rx_port_value[port_id]; in slim_rx_mux_put()
3352 int aif_id; in slim_rx_mux_put()
3354 mux_idx = ucontrol->value.enumerated.item[0]; in slim_rx_mux_put()
3365 list_for_each_entry_safe(ch, c, &wcd->dai[aif_id].slim_ch_list, list) { in slim_rx_mux_put()
3366 if (ch->port == port_id + WCD934X_RX_START) { in slim_rx_mux_put()
3368 list_del_init(&ch->list); in slim_rx_mux_put()
3381 if (list_empty(&wcd->rx_chs[port_id].list)) { in slim_rx_mux_put()
3382 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
3383 &wcd->dai[aif_id].slim_ch_list); in slim_rx_mux_put()
3385 dev_err(wcd->dev ,"SLIM_RX%d PORT is busy\n", port_id); in slim_rx_mux_put()
3391 dev_err(wcd->dev, "Unknown AIF %d\n", mux_idx); in slim_rx_mux_put()
3395 wcd->rx_port_value[port_id] = mux_idx; in slim_rx_mux_put()
3396 snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id], in slim_rx_mux_put()
3401 return -EINVAL; in slim_rx_mux_put()
3404 static int wcd934x_int_dem_inp_mux_put(struct snd_kcontrol *kc, in wcd934x_int_dem_inp_mux_put()
3407 struct soc_enum *e = (struct soc_enum *)kc->private_value; in wcd934x_int_dem_inp_mux_put()
3409 int reg, val; in wcd934x_int_dem_inp_mux_put()
3412 val = ucontrol->value.enumerated.item[0]; in wcd934x_int_dem_inp_mux_put()
3413 if (e->reg == WCD934X_CDC_RX0_RX_PATH_SEC0) in wcd934x_int_dem_inp_mux_put()
3415 else if (e->reg == WCD934X_CDC_RX1_RX_PATH_SEC0) in wcd934x_int_dem_inp_mux_put()
3417 else if (e->reg == WCD934X_CDC_RX2_RX_PATH_SEC0) in wcd934x_int_dem_inp_mux_put()
3420 return -EINVAL; in wcd934x_int_dem_inp_mux_put()
3435 static int wcd934x_dec_enum_put(struct snd_kcontrol *kcontrol, in wcd934x_dec_enum_put()
3439 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in wcd934x_dec_enum_put()
3440 unsigned int val; in wcd934x_dec_enum_put()
3446 val = ucontrol->value.enumerated.item[0]; in wcd934x_dec_enum_put()
3447 if (val > e->items - 1) in wcd934x_dec_enum_put()
3448 return -EINVAL; in wcd934x_dec_enum_put()
3450 switch (e->reg) { in wcd934x_dec_enum_put()
3452 if (e->shift_l == 0) in wcd934x_dec_enum_put()
3454 else if (e->shift_l == 2) in wcd934x_dec_enum_put()
3456 else if (e->shift_l == 4) in wcd934x_dec_enum_put()
3460 if (e->shift_l == 0) in wcd934x_dec_enum_put()
3462 else if (e->shift_l == 2) in wcd934x_dec_enum_put()
3466 if (e->shift_l == 0) in wcd934x_dec_enum_put()
3468 else if (e->shift_l == 2) in wcd934x_dec_enum_put()
3472 if (e->shift_l == 0) in wcd934x_dec_enum_put()
3474 else if (e->shift_l == 2) in wcd934x_dec_enum_put()
3478 dev_err(comp->dev, "%s: e->reg: 0x%x not expected\n", in wcd934x_dec_enum_put()
3479 __func__, e->reg); in wcd934x_dec_enum_put()
3480 return -EINVAL; in wcd934x_dec_enum_put()
3493 SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
3496 SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
3499 SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
3502 SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
3505 SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
3508 SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
3511 SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
3514 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
3517 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
3520 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
3523 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
3526 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
3529 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
3532 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
3535 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
3538 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
3541 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
3544 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
3547 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
3550 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
3553 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
3556 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
3559 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
3562 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
3565 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
3568 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
3571 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
3574 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
3577 SOC_DAPM_ENUM("RX INT0 MIX2 INP Mux", rx_int0_mix2_inp_mux_enum);
3580 SOC_DAPM_ENUM("RX INT1 MIX2 INP Mux", rx_int1_mix2_inp_mux_enum);
3583 SOC_DAPM_ENUM("RX INT2 MIX2 INP Mux", rx_int2_mix2_inp_mux_enum);
3586 SOC_DAPM_ENUM("RX INT3 MIX2 INP Mux", rx_int3_mix2_inp_mux_enum);
3589 SOC_DAPM_ENUM("RX INT4 MIX2 INP Mux", rx_int4_mix2_inp_mux_enum);
3592 SOC_DAPM_ENUM("RX INT7 MIX2 INP Mux", rx_int7_mix2_inp_mux_enum);
3595 SOC_DAPM_ENUM("IIR0 INP0 Mux", iir0_inp0_mux_enum);
3597 SOC_DAPM_ENUM("IIR0 INP1 Mux", iir0_inp1_mux_enum);
3599 SOC_DAPM_ENUM("IIR0 INP2 Mux", iir0_inp2_mux_enum);
3601 SOC_DAPM_ENUM("IIR0 INP3 Mux", iir0_inp3_mux_enum);
3604 SOC_DAPM_ENUM("IIR1 INP0 Mux", iir1_inp0_mux_enum);
3606 SOC_DAPM_ENUM("IIR1 INP1 Mux", iir1_inp1_mux_enum);
3608 SOC_DAPM_ENUM("IIR1 INP2 Mux", iir1_inp2_mux_enum);
3610 SOC_DAPM_ENUM("IIR1 INP3 Mux", iir1_inp3_mux_enum);
3613 SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
3615 SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
3617 SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
3619 SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
3621 SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
3623 SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
3625 SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
3627 SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
3648 SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
3653 SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
3658 SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
3663 SOC_DAPM_ENUM("RX INT0_1 INTERP Mux", rx_int0_1_interp_mux_enum);
3666 SOC_DAPM_ENUM("RX INT1_1 INTERP Mux", rx_int1_1_interp_mux_enum);
3669 SOC_DAPM_ENUM("RX INT2_1 INTERP Mux", rx_int2_1_interp_mux_enum);
3672 SOC_DAPM_ENUM("RX INT3_1 INTERP Mux", rx_int3_1_interp_mux_enum);
3675 SOC_DAPM_ENUM("RX INT4_1 INTERP Mux", rx_int4_1_interp_mux_enum);
3678 SOC_DAPM_ENUM("RX INT7_1 INTERP Mux", rx_int7_1_interp_mux_enum);
3681 SOC_DAPM_ENUM("RX INT8_1 INTERP Mux", rx_int8_1_interp_mux_enum);
3684 SOC_DAPM_ENUM("RX INT0_2 INTERP Mux", rx_int0_2_interp_mux_enum);
3687 SOC_DAPM_ENUM("RX INT1_2 INTERP Mux", rx_int1_2_interp_mux_enum);
3690 SOC_DAPM_ENUM("RX INT2_2 INTERP Mux", rx_int2_2_interp_mux_enum);
3693 SOC_DAPM_ENUM("RX INT3_2 INTERP Mux", rx_int3_2_interp_mux_enum);
3696 SOC_DAPM_ENUM("RX INT4_2 INTERP Mux", rx_int4_2_interp_mux_enum);
3699 SOC_DAPM_ENUM("RX INT7_2 INTERP Mux", rx_int7_2_interp_mux_enum);
3702 SOC_DAPM_ENUM("RX INT8_2 INTERP Mux", rx_int8_2_interp_mux_enum);
3705 SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
3708 SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
3711 SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
3714 SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
3717 SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
3720 SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
3723 SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
3726 SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
3729 SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
3732 SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
3735 SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
3738 SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
3741 SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
3744 SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
3747 SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
3750 SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
3753 SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
3756 SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
3759 SOC_DAPM_ENUM("AMIC4_5 SEL Mux", tx_amic4_5_enum);
3762 SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_enum,
3765 SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_enum,
3768 SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_enum,
3771 SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_enum,
3774 SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_enum,
3777 SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_enum,
3780 SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_enum,
3783 SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_enum,
3786 SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_enum,
3790 SOC_DAPM_ENUM("CDC_IF TX0 MUX Mux", cdc_if_tx0_mux_enum);
3792 SOC_DAPM_ENUM("CDC_IF TX1 MUX Mux", cdc_if_tx1_mux_enum);
3794 SOC_DAPM_ENUM("CDC_IF TX2 MUX Mux", cdc_if_tx2_mux_enum);
3796 SOC_DAPM_ENUM("CDC_IF TX3 MUX Mux", cdc_if_tx3_mux_enum);
3798 SOC_DAPM_ENUM("CDC_IF TX4 MUX Mux", cdc_if_tx4_mux_enum);
3800 SOC_DAPM_ENUM("CDC_IF TX5 MUX Mux", cdc_if_tx5_mux_enum);
3802 SOC_DAPM_ENUM("CDC_IF TX6 MUX Mux", cdc_if_tx6_mux_enum);
3804 SOC_DAPM_ENUM("CDC_IF TX7 MUX Mux", cdc_if_tx7_mux_enum);
3806 SOC_DAPM_ENUM("CDC_IF TX8 MUX Mux", cdc_if_tx8_mux_enum);
3808 SOC_DAPM_ENUM("CDC_IF TX9 MUX Mux", cdc_if_tx9_mux_enum);
3810 SOC_DAPM_ENUM("CDC_IF TX10 MUX Mux", cdc_if_tx10_mux_enum);
3812 SOC_DAPM_ENUM("CDC_IF TX11 MUX Mux", cdc_if_tx11_mux_enum);
3814 SOC_DAPM_ENUM("CDC_IF TX11 INP1 MUX Mux", cdc_if_tx11_inp1_mux_enum);
3816 SOC_DAPM_ENUM("CDC_IF TX13 MUX Mux", cdc_if_tx13_mux_enum);
3818 SOC_DAPM_ENUM("CDC_IF TX13 INP1 MUX Mux", cdc_if_tx13_inp1_mux_enum);
3820 static int slim_tx_mixer_get(struct snd_kcontrol *kc, in slim_tx_mixer_get()
3824 struct wcd934x_codec *wcd = dev_get_drvdata(dapm->dev); in slim_tx_mixer_get()
3826 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_get()
3827 int port_id = mixer->shift; in slim_tx_mixer_get()
3829 ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id]; in slim_tx_mixer_get()
3834 static int slim_tx_mixer_put(struct snd_kcontrol *kc, in slim_tx_mixer_put()
3838 struct wcd934x_codec *wcd = dev_get_drvdata(widget->dapm->dev); in slim_tx_mixer_put()
3841 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_put()
3842 int enable = ucontrol->value.integer.value[0]; in slim_tx_mixer_put()
3844 int dai_id = widget->shift; in slim_tx_mixer_put()
3845 int port_id = mixer->shift; in slim_tx_mixer_put()
3848 if (enable == wcd->tx_port_value[port_id]) in slim_tx_mixer_put()
3852 if (list_empty(&wcd->tx_chs[port_id].list)) { in slim_tx_mixer_put()
3853 list_add_tail(&wcd->tx_chs[port_id].list, in slim_tx_mixer_put()
3854 &wcd->dai[dai_id].slim_ch_list); in slim_tx_mixer_put()
3856 dev_err(wcd->dev ,"SLIM_TX%d PORT is busy\n", port_id); in slim_tx_mixer_put()
3862 list_for_each_entry_safe(ch, c, &wcd->dai[dai_id].slim_ch_list, list) { in slim_tx_mixer_put()
3863 if (ch->port == port_id) { in slim_tx_mixer_put()
3865 list_del_init(&wcd->tx_chs[port_id].list); in slim_tx_mixer_put()
3873 wcd->tx_port_value[port_id] = enable; in slim_tx_mixer_put()
3874 snd_soc_dapm_mixer_update_power(widget->dapm, kc, enable, update); in slim_tx_mixer_put()
3982 -84, 40, digital_gain), /* -84dB min - 40dB max */
3984 -84, 40, digital_gain),
3986 -84, 40, digital_gain),
3988 -84, 40, digital_gain),
3990 -84, 40, digital_gain),
3992 -84, 40, digital_gain),
3994 -84, 40, digital_gain),
3997 -84, 40, digital_gain),
4000 -84, 40, digital_gain),
4003 -84, 40, digital_gain),
4006 -84, 40, digital_gain),
4009 -84, 40, digital_gain),
4012 -84, 40, digital_gain),
4015 -84, 40, digital_gain),
4018 -84, 40, digital_gain),
4020 -84, 40, digital_gain),
4022 -84, 40, digital_gain),
4024 -84, 40, digital_gain),
4026 -84, 40, digital_gain),
4028 -84, 40, digital_gain),
4030 -84, 40, digital_gain),
4032 -84, 40, digital_gain),
4034 -84, 40, digital_gain),
4037 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B1_CTL, -84, 40,
4040 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B2_CTL, -84, 40,
4043 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B3_CTL, -84, 40,
4046 WCD934X_CDC_SIDETONE_IIR0_IIR_GAIN_B4_CTL, -84, 40,
4049 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B1_CTL, -84, 40,
4052 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B2_CTL, -84, 40,
4055 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B3_CTL, -84, 40,
4058 WCD934X_CDC_SIDETONE_IIR1_IIR_GAIN_B4_CTL, -84, 40,
4138 int port_num = 0; in wcd934x_codec_enable_int_port()
4140 unsigned int val = 0; in wcd934x_codec_enable_int_port()
4141 struct wcd934x_codec *wcd = dev_get_drvdata(component->dev); in wcd934x_codec_enable_int_port()
4144 list_for_each_entry(ch, &dai->slim_ch_list, list) { in wcd934x_codec_enable_int_port()
4145 if (ch->port >= WCD934X_RX_START) { in wcd934x_codec_enable_int_port()
4146 port_num = ch->port - WCD934X_RX_START; in wcd934x_codec_enable_int_port()
4149 port_num = ch->port; in wcd934x_codec_enable_int_port()
4153 regmap_read(wcd->if_regmap, reg, &val); in wcd934x_codec_enable_int_port()
4155 regmap_write(wcd->if_regmap, reg, in wcd934x_codec_enable_int_port()
4160 static int wcd934x_codec_enable_slim(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_slim()
4161 struct snd_kcontrol *kc, int event) in wcd934x_codec_enable_slim()
4163 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_slim()
4165 struct wcd_slim_codec_dai_data *dai = &wcd->dai[w->shift]; in wcd934x_codec_enable_slim()
4177 u16 interp_idx, int event) in wcd934x_codec_hd2_control()
4215 u16 interp_idx, int event) in wcd934x_codec_hphdelay_lutbypass()
4250 static int wcd934x_config_compander(struct snd_soc_component *comp, in wcd934x_config_compander()
4251 int interp_n, int event) in wcd934x_config_compander()
4253 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_config_compander()
4254 int compander; in wcd934x_config_compander()
4261 compander = interp_n - 1; in wcd934x_config_compander()
4262 if (!wcd->comp_enabled[compander]) in wcd934x_config_compander()
4307 static int wcd934x_codec_enable_interp_clk(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_interp_clk()
4308 struct snd_kcontrol *kc, int event) in wcd934x_codec_enable_interp_clk()
4310 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_interp_clk()
4311 int interp_idx = w->shift; in wcd934x_codec_enable_interp_clk()
4348 static int wcd934x_codec_enable_mix_path(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_mix_path()
4349 struct snd_kcontrol *kc, int event) in wcd934x_codec_enable_mix_path()
4351 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_mix_path()
4352 int offset_val = 0; in wcd934x_codec_enable_mix_path()
4354 int val = 0; in wcd934x_codec_enable_mix_path()
4357 (w->shift * WCD934X_RX_PATH_CTL_OFFSET); in wcd934x_codec_enable_mix_path()
4359 (w->shift * WCD934X_RX_PATH_CTL_OFFSET); in wcd934x_codec_enable_mix_path()
4379 static int wcd934x_codec_set_iir_gain(struct snd_soc_dapm_widget *w, in wcd934x_codec_set_iir_gain()
4380 struct snd_kcontrol *kcontrol, int event) in wcd934x_codec_set_iir_gain()
4382 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_set_iir_gain()
4383 int reg = w->reg; in wcd934x_codec_set_iir_gain()
4413 static int wcd934x_codec_enable_main_path(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_main_path()
4415 int event) in wcd934x_codec_enable_main_path()
4417 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_main_path()
4420 gain_reg = WCD934X_CDC_RX0_RX_VOL_CTL + (w->shift * in wcd934x_codec_enable_main_path()
4433 static int wcd934x_codec_ear_dac_event(struct snd_soc_dapm_widget *w, in wcd934x_codec_ear_dac_event()
4434 struct snd_kcontrol *kc, int event) in wcd934x_codec_ear_dac_event()
4436 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_ear_dac_event()
4437 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_ear_dac_event()
4445 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd934x_codec_ear_dac_event()
4450 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd934x_codec_ear_dac_event()
4458 static int wcd934x_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, in wcd934x_codec_hphl_dac_event()
4460 int event) in wcd934x_codec_hphl_dac_event()
4462 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_hphl_dac_event()
4463 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_hphl_dac_event()
4464 int hph_mode = wcd->hph_mode; in wcd934x_codec_hphl_dac_event()
4475 return -EINVAL; in wcd934x_codec_hphl_dac_event()
4487 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd934x_codec_hphl_dac_event()
4494 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd934x_codec_hphl_dac_event()
4510 static int wcd934x_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, in wcd934x_codec_hphr_dac_event()
4512 int event) in wcd934x_codec_hphr_dac_event()
4514 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_hphr_dac_event()
4515 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_hphr_dac_event()
4516 int hph_mode = wcd->hph_mode; in wcd934x_codec_hphr_dac_event()
4525 return -EINVAL; in wcd934x_codec_hphr_dac_event()
4537 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd934x_codec_hphr_dac_event()
4545 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd934x_codec_hphr_dac_event()
4560 static int wcd934x_codec_lineout_dac_event(struct snd_soc_dapm_widget *w, in wcd934x_codec_lineout_dac_event()
4561 struct snd_kcontrol *kc, int event) in wcd934x_codec_lineout_dac_event()
4563 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_lineout_dac_event()
4564 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_lineout_dac_event()
4568 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd934x_codec_lineout_dac_event()
4572 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd934x_codec_lineout_dac_event()
4580 static int wcd934x_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_hphl_pa()
4582 int event) in wcd934x_codec_enable_hphl_pa()
4584 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_hphl_pa()
4618 wcd_mbhc_event_notify(wcd->mbhc, WCD_EVENT_POST_HPHL_PA_OFF); in wcd934x_codec_enable_hphl_pa()
4637 wcd_mbhc_event_notify(wcd->mbhc, WCD_EVENT_POST_HPHL_PA_OFF); in wcd934x_codec_enable_hphl_pa()
4644 static int wcd934x_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_hphr_pa()
4646 int event) in wcd934x_codec_enable_hphr_pa()
4648 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_hphr_pa()
4684 wcd_mbhc_event_notify(wcd->mbhc, WCD_EVENT_PRE_HPHR_PA_OFF); in wcd934x_codec_enable_hphr_pa()
4702 wcd_mbhc_event_notify(wcd->mbhc, WCD_EVENT_POST_HPHR_PA_OFF); in wcd934x_codec_enable_hphr_pa()
4710 unsigned int dmic, in wcd934x_get_dmic_sample_rate()
4725 adc_mux_index - 4; in wcd934x_get_dmic_sample_rate()
4731 & 0xF8) >> 3) - 1; in wcd934x_get_dmic_sample_rate()
4745 dmic_fs = min(wcd->dmic_sample_rate, WCD9XXX_DMIC_SAMPLE_RATE_2P4MHZ); in wcd934x_get_dmic_sample_rate()
4749 dmic_fs = wcd->dmic_sample_rate; in wcd934x_get_dmic_sample_rate()
4768 dev_err(comp->dev, in wcd934x_get_dmic_clk_val()
4795 dev_err(comp->dev, in wcd934x_get_dmic_clk_val()
4805 static int wcd934x_codec_enable_dmic(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_dmic()
4806 struct snd_kcontrol *kcontrol, int event) in wcd934x_codec_enable_dmic()
4808 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_dmic()
4809 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_enable_dmic()
4814 unsigned int dmic; in wcd934x_codec_enable_dmic()
4816 int ret; in wcd934x_codec_enable_dmic()
4819 wname = strpbrk(w->name, "012345"); in wcd934x_codec_enable_dmic()
4821 dev_err(comp->dev, "%s: widget not found\n", __func__); in wcd934x_codec_enable_dmic()
4822 return -EINVAL; in wcd934x_codec_enable_dmic()
4827 dev_err(comp->dev, "%s: Invalid DMIC line on the codec\n", in wcd934x_codec_enable_dmic()
4829 return -EINVAL; in wcd934x_codec_enable_dmic()
4835 dmic_clk_cnt = &wcd->dmic_0_1_clk_cnt; in wcd934x_codec_enable_dmic()
4840 dmic_clk_cnt = &wcd->dmic_2_3_clk_cnt; in wcd934x_codec_enable_dmic()
4845 dmic_clk_cnt = &wcd->dmic_4_5_clk_cnt; in wcd934x_codec_enable_dmic()
4849 dev_err(comp->dev, "%s: Invalid DMIC Selection\n", in wcd934x_codec_enable_dmic()
4851 return -EINVAL; in wcd934x_codec_enable_dmic()
4858 dmic_rate_val = wcd934x_get_dmic_clk_val(comp, wcd->rate, in wcd934x_codec_enable_dmic()
4872 (*dmic_clk_cnt)--; in wcd934x_codec_enable_dmic()
4882 static int wcd934x_codec_find_amic_input(struct snd_soc_component *comp, in wcd934x_codec_find_amic_input()
4883 int adc_mux_n) in wcd934x_codec_find_amic_input()
4908 (adc_mux_n - 4); in wcd934x_codec_find_amic_input()
4912 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4918 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4921 ((adc_mux_n == 8) ? (adc_mux_n - 8) : in wcd934x_codec_find_amic_input()
4922 (adc_mux_n - 9)); in wcd934x_codec_find_amic_input()
4926 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4932 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4938 adc_mux_n - 4; in wcd934x_codec_find_amic_input()
4950 int amic) in wcd934x_codec_get_amic_pwlvl_reg()
4971 static int wcd934x_codec_enable_dec(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_dec()
4972 struct snd_kcontrol *kcontrol, int event) in wcd934x_codec_enable_dec()
4974 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_dec()
4975 unsigned int decimator; in wcd934x_codec_enable_dec()
4978 int ret = 0, amic_n; in wcd934x_codec_enable_dec()
4984 char *wname __free(kfree) = kstrndup(w->name, 15, GFP_KERNEL); in wcd934x_codec_enable_dec()
4986 return -ENOMEM; in wcd934x_codec_enable_dec()
4991 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd934x_codec_enable_dec()
4992 __func__, w->name); in wcd934x_codec_enable_dec()
4993 return -EINVAL; in wcd934x_codec_enable_dec()
4999 dev_err(comp->dev, "%s: decimator index not found\n", in wcd934x_codec_enable_dec()
5001 return -EINVAL; in wcd934x_codec_enable_dec()
5006 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd934x_codec_enable_dec()
5008 return -EINVAL; in wcd934x_codec_enable_dec()
5133 static int wcd934x_codec_enable_adc(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_adc()
5134 struct snd_kcontrol *kcontrol, int event) in wcd934x_codec_enable_adc()
5136 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_adc()
5140 wcd934x_codec_set_tx_hold(comp, w->reg, true); in wcd934x_codec_enable_adc()
5149 static int wcd934x_codec_enable_micbias(struct snd_soc_dapm_widget *w, in wcd934x_codec_enable_micbias()
5151 int event) in wcd934x_codec_enable_micbias()
5153 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in wcd934x_codec_enable_micbias()
5154 int micb_num = w->shift; in wcd934x_codec_enable_micbias()
5200 SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, WCD934X_RX0, 0,
5202 SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, WCD934X_RX1, 0,
5204 SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, WCD934X_RX2, 0,
5206 SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, WCD934X_RX3, 0,
5208 SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, WCD934X_RX4, 0,
5210 SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, WCD934X_RX5, 0,
5212 SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, WCD934X_RX6, 0,
5214 SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, WCD934X_RX7, 0,
5226 SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", SND_SOC_NOPM, INTERP_EAR, 0,
5230 SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", SND_SOC_NOPM, INTERP_HPHL, 0,
5234 SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", SND_SOC_NOPM, INTERP_HPHR, 0,
5238 SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", SND_SOC_NOPM, INTERP_LO1, 0,
5242 SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", SND_SOC_NOPM, INTERP_LO2, 0,
5246 SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", SND_SOC_NOPM, INTERP_SPKR1, 0,
5250 SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", SND_SOC_NOPM, INTERP_SPKR2, 0,
5353 SND_SOC_DAPM_MUX("IIR0 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp0_mux),
5354 SND_SOC_DAPM_MUX("IIR0 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp1_mux),
5355 SND_SOC_DAPM_MUX("IIR0 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp2_mux),
5356 SND_SOC_DAPM_MUX("IIR0 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir0_inp3_mux),
5357 SND_SOC_DAPM_MUX("IIR1 INP0 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp0_mux),
5358 SND_SOC_DAPM_MUX("IIR1 INP1 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp1_mux),
5359 SND_SOC_DAPM_MUX("IIR1 INP2 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp2_mux),
5360 SND_SOC_DAPM_MUX("IIR1 INP3 MUX", SND_SOC_NOPM, 0, 0, &iir1_inp3_mux),
5372 SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
5374 SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
5376 SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
5641 SND_SOC_DAPM_MUX("CDC_IF TX0 MUX", SND_SOC_NOPM, WCD934X_TX0, 0,
5643 SND_SOC_DAPM_MUX("CDC_IF TX1 MUX", SND_SOC_NOPM, WCD934X_TX1, 0,
5645 SND_SOC_DAPM_MUX("CDC_IF TX2 MUX", SND_SOC_NOPM, WCD934X_TX2, 0,
5647 SND_SOC_DAPM_MUX("CDC_IF TX3 MUX", SND_SOC_NOPM, WCD934X_TX3, 0,
5649 SND_SOC_DAPM_MUX("CDC_IF TX4 MUX", SND_SOC_NOPM, WCD934X_TX4, 0,
5651 SND_SOC_DAPM_MUX("CDC_IF TX5 MUX", SND_SOC_NOPM, WCD934X_TX5, 0,
5653 SND_SOC_DAPM_MUX("CDC_IF TX6 MUX", SND_SOC_NOPM, WCD934X_TX6, 0,
5655 SND_SOC_DAPM_MUX("CDC_IF TX7 MUX", SND_SOC_NOPM, WCD934X_TX7, 0,
5657 SND_SOC_DAPM_MUX("CDC_IF TX8 MUX", SND_SOC_NOPM, WCD934X_TX8, 0,
5659 SND_SOC_DAPM_MUX("CDC_IF TX9 MUX", SND_SOC_NOPM, WCD934X_TX9, 0,
5661 SND_SOC_DAPM_MUX("CDC_IF TX10 MUX", SND_SOC_NOPM, WCD934X_TX10, 0,
5663 SND_SOC_DAPM_MUX("CDC_IF TX11 MUX", SND_SOC_NOPM, WCD934X_TX11, 0,
5665 SND_SOC_DAPM_MUX("CDC_IF TX11 INP1 MUX", SND_SOC_NOPM, WCD934X_TX11, 0,
5667 SND_SOC_DAPM_MUX("CDC_IF TX13 MUX", SND_SOC_NOPM, WCD934X_TX13, 0,
5669 SND_SOC_DAPM_MUX("CDC_IF TX13 INP1 MUX", SND_SOC_NOPM, WCD934X_TX13, 0,
5683 /* RX0-RX7 */
5696 {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 MIX2"},
5697 {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
5706 {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 MIX3"},
5707 {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
5716 {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 MIX3"},
5717 {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
5782 {"CDC_IF TX0 MUX", "DEC0", "ADC MUX0"},
5783 {"CDC_IF TX1 MUX", "DEC1", "ADC MUX1"},
5784 {"CDC_IF TX2 MUX", "DEC2", "ADC MUX2"},
5785 {"CDC_IF TX3 MUX", "DEC3", "ADC MUX3"},
5786 {"CDC_IF TX4 MUX", "DEC4", "ADC MUX4"},
5787 {"CDC_IF TX5 MUX", "DEC5", "ADC MUX5"},
5788 {"CDC_IF TX6 MUX", "DEC6", "ADC MUX6"},
5789 {"CDC_IF TX7 MUX", "DEC7", "ADC MUX7"},
5790 {"CDC_IF TX8 MUX", "DEC8", "ADC MUX8"},
5814 static int wcd934x_codec_set_jack(struct snd_soc_component *comp, in wcd934x_codec_set_jack()
5817 struct wcd934x_codec *wcd = dev_get_drvdata(comp->dev); in wcd934x_codec_set_jack()
5818 int ret = 0; in wcd934x_codec_set_jack()
5820 if (!wcd->mbhc) in wcd934x_codec_set_jack()
5821 return -ENOTSUPP; in wcd934x_codec_set_jack()
5823 if (jack && !wcd->mbhc_started) { in wcd934x_codec_set_jack()
5824 ret = wcd_mbhc_start(wcd->mbhc, &wcd->mbhc_cfg, jack); in wcd934x_codec_set_jack()
5825 wcd->mbhc_started = true; in wcd934x_codec_set_jack()
5826 } else if (wcd->mbhc_started) { in wcd934x_codec_set_jack()
5827 wcd_mbhc_stop(wcd->mbhc); in wcd934x_codec_set_jack()
5828 wcd->mbhc_started = false; in wcd934x_codec_set_jack()
5848 static int wcd934x_codec_parse_data(struct wcd934x_codec *wcd) in wcd934x_codec_parse_data()
5850 struct device *dev = &wcd->sdev->dev; in wcd934x_codec_parse_data()
5851 struct wcd_mbhc_config *cfg = &wcd->mbhc_cfg; in wcd934x_codec_parse_data()
5854 ifc_dev_np = of_parse_phandle(dev->of_node, "slim-ifc-dev", 0); in wcd934x_codec_parse_data()
5856 return dev_err_probe(dev, -EINVAL, "No Interface device found\n"); in wcd934x_codec_parse_data()
5858 wcd->sidev = of_slim_get_device(wcd->sdev->ctrl, ifc_dev_np); in wcd934x_codec_parse_data()
5860 if (!wcd->sidev) in wcd934x_codec_parse_data()
5861 return dev_err_probe(dev, -EINVAL, "Unable to get SLIM Interface device\n"); in wcd934x_codec_parse_data()
5863 slim_get_logical_addr(wcd->sidev); in wcd934x_codec_parse_data()
5864 wcd->if_regmap = regmap_init_slimbus(wcd->sidev, in wcd934x_codec_parse_data()
5866 if (IS_ERR(wcd->if_regmap)) in wcd934x_codec_parse_data()
5867 return dev_err_probe(dev, PTR_ERR(wcd->if_regmap), in wcd934x_codec_parse_data()
5870 of_property_read_u32(dev->parent->of_node, "qcom,dmic-sample-rate", in wcd934x_codec_parse_data()
5871 &wcd->dmic_sample_rate); in wcd934x_codec_parse_data()
5873 cfg->mbhc_micbias = MIC_BIAS_2; in wcd934x_codec_parse_data()
5874 cfg->anc_micbias = MIC_BIAS_2; in wcd934x_codec_parse_data()
5875 cfg->v_hs_max = WCD_MBHC_HS_V_MAX; in wcd934x_codec_parse_data()
5876 cfg->num_btn = WCD934X_MBHC_MAX_BUTTONS; in wcd934x_codec_parse_data()
5877 cfg->micb_mv = wcd->micb2_mv; in wcd934x_codec_parse_data()
5878 cfg->linein_th = 5000; in wcd934x_codec_parse_data()
5879 cfg->hs_thr = 1700; in wcd934x_codec_parse_data()
5880 cfg->hph_thr = 50; in wcd934x_codec_parse_data()
5888 static int wcd934x_codec_probe(struct platform_device *pdev) in wcd934x_codec_probe()
5890 struct device *dev = &pdev->dev; in wcd934x_codec_probe()
5891 struct wcd934x_ddata *data = dev_get_drvdata(dev->parent); in wcd934x_codec_probe()
5893 int ret, irq; in wcd934x_codec_probe()
5897 return -ENOMEM; in wcd934x_codec_probe()
5899 wcd->dev = dev; in wcd934x_codec_probe()
5900 wcd->regmap = data->regmap; in wcd934x_codec_probe()
5901 wcd->extclk = data->extclk; in wcd934x_codec_probe()
5902 wcd->sdev = to_slim_device(data->dev); in wcd934x_codec_probe()
5903 mutex_init(&wcd->sysclk_mutex); in wcd934x_codec_probe()
5904 mutex_init(&wcd->micb_lock); in wcd934x_codec_probe()
5911 regmap_update_bits(wcd->regmap, WCD934X_CODEC_RPM_CLK_MCLK_CFG, in wcd934x_codec_probe()
5914 memcpy(wcd->rx_chs, wcd934x_rx_chs, sizeof(wcd934x_rx_chs)); in wcd934x_codec_probe()
5915 memcpy(wcd->tx_chs, wcd934x_tx_chs, sizeof(wcd934x_tx_chs)); in wcd934x_codec_probe()
5917 irq = regmap_irq_get_virq(data->irq_data, WCD934X_IRQ_SLIMBUS); in wcd934x_codec_probe()
5919 return dev_err_probe(wcd->dev, irq, "Failed to get SLIM IRQ\n"); in wcd934x_codec_probe()
5938 .name = "wcd934x-codec",
5948 .name = "wcd934x-codec",