Lines Matching +full:mux +full:- +full:int +full:- +full:port
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
3 // Copyright (c) 2017-2018, Linaro Limited
19 #include <sound/soc-dapm.h>
26 #include "wcd-clsh-v2.h"
28 #include <dt-bindings/sound/qcom,wcd9335.h>
38 /* slave port water mark level
93 {.port = p + WCD9335_RX_START, .shift = p,}
96 {.port = p, .shift = p,}
99 #define WCD9335_CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
102 {"RX INT" #id "_1 MIX1 INP0", "RX0", "SLIM RX0"}, \
103 {"RX INT" #id "_1 MIX1 INP0", "RX1", "SLIM RX1"}, \
104 {"RX INT" #id "_1 MIX1 INP0", "RX2", "SLIM RX2"}, \
105 {"RX INT" #id "_1 MIX1 INP0", "RX3", "SLIM RX3"}, \
106 {"RX INT" #id "_1 MIX1 INP0", "RX4", "SLIM RX4"}, \
107 {"RX INT" #id "_1 MIX1 INP0", "RX5", "SLIM RX5"}, \
108 {"RX INT" #id "_1 MIX1 INP0", "RX6", "SLIM RX6"}, \
109 {"RX INT" #id "_1 MIX1 INP0", "RX7", "SLIM RX7"}, \
110 {"RX INT" #id "_1 MIX1 INP1", "RX0", "SLIM RX0"}, \
111 {"RX INT" #id "_1 MIX1 INP1", "RX1", "SLIM RX1"}, \
112 {"RX INT" #id "_1 MIX1 INP1", "RX2", "SLIM RX2"}, \
113 {"RX INT" #id "_1 MIX1 INP1", "RX3", "SLIM RX3"}, \
114 {"RX INT" #id "_1 MIX1 INP1", "RX4", "SLIM RX4"}, \
115 {"RX INT" #id "_1 MIX1 INP1", "RX5", "SLIM RX5"}, \
116 {"RX INT" #id "_1 MIX1 INP1", "RX6", "SLIM RX6"}, \
117 {"RX INT" #id "_1 MIX1 INP1", "RX7", "SLIM RX7"}, \
118 {"RX INT" #id "_1 MIX1 INP2", "RX0", "SLIM RX0"}, \
119 {"RX INT" #id "_1 MIX1 INP2", "RX1", "SLIM RX1"}, \
120 {"RX INT" #id "_1 MIX1 INP2", "RX2", "SLIM RX2"}, \
121 {"RX INT" #id "_1 MIX1 INP2", "RX3", "SLIM RX3"}, \
122 {"RX INT" #id "_1 MIX1 INP2", "RX4", "SLIM RX4"}, \
123 {"RX INT" #id "_1 MIX1 INP2", "RX5", "SLIM RX5"}, \
124 {"RX INT" #id "_1 MIX1 INP2", "RX6", "SLIM RX6"}, \
125 {"RX INT" #id "_1 MIX1 INP2", "RX7", "SLIM RX7"}, \
126 {"RX INT" #id "_2 MUX", "RX0", "SLIM RX0"}, \
127 {"RX INT" #id "_2 MUX", "RX1", "SLIM RX1"}, \
128 {"RX INT" #id "_2 MUX", "RX2", "SLIM RX2"}, \
129 {"RX INT" #id "_2 MUX", "RX3", "SLIM RX3"}, \
130 {"RX INT" #id "_2 MUX", "RX4", "SLIM RX4"}, \
131 {"RX INT" #id "_2 MUX", "RX5", "SLIM RX5"}, \
132 {"RX INT" #id "_2 MUX", "RX6", "SLIM RX6"}, \
133 {"RX INT" #id "_2 MUX", "RX7", "SLIM RX7"}, \
134 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP0"}, \
135 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP1"}, \
136 {"RX INT" #id "_1 MIX1", NULL, "RX INT" #id "_1 MIX1 INP2"}, \
137 {"RX INT" #id " SEC MIX", NULL, "RX INT" #id "_2 MUX"}, \
138 {"RX INT" #id " SEC MIX", NULL, "RX INT" #id "_1 MIX1"}, \
139 {"RX INT" #id " MIX2", NULL, "RX INT" #id " SEC MIX"}, \
140 {"RX INT" #id " INTERP", NULL, "RX INT" #id " MIX2"}
143 {"AIF1_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id " MUX"}, \
144 {"AIF2_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id " MUX"}, \
145 {"AIF3_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id " MUX"}, \
146 {"SLIM TX" #id " MUX", "DEC" #id, "ADC MUX" #id}, \
147 {"ADC MUX" #id, "DMIC", "DMIC MUX" #id}, \
148 {"ADC MUX" #id, "AMIC", "AMIC MUX" #id}, \
149 {"DMIC MUX" #id, "DMIC0", "DMIC0"}, \
150 {"DMIC MUX" #id, "DMIC1", "DMIC1"}, \
151 {"DMIC MUX" #id, "DMIC2", "DMIC2"}, \
152 {"DMIC MUX" #id, "DMIC3", "DMIC3"}, \
153 {"DMIC MUX" #id, "DMIC4", "DMIC4"}, \
154 {"DMIC MUX" #id, "DMIC5", "DMIC5"}, \
155 {"AMIC MUX" #id, "ADC1", "ADC1"}, \
156 {"AMIC MUX" #id, "ADC2", "ADC2"}, \
157 {"AMIC MUX" #id, "ADC3", "ADC3"}, \
158 {"AMIC MUX" #id, "ADC4", "ADC4"}, \
159 {"AMIC MUX" #id, "ADC5", "ADC5"}, \
160 {"AMIC MUX" #id, "ADC6", "ADC6"}
285 u16 port; member
313 int sido_input_src;
319 int master_bias_users;
320 int clk_mclk_users;
321 int clk_rco_users;
322 int sido_ccl_cnt;
327 int prim_int_users[WCD9335_NUM_INTERPOLATORS];
329 int comp_enabled[COMPANDER_MAX];
331 int intr1;
332 int reset_gpio;
335 unsigned int rx_port_value[WCD9335_RX_MAX];
336 unsigned int tx_port_value[WCD9335_TX_MAX];
337 int hph_l_gain;
338 int hph_r_gain;
342 int micb_ref[WCD9335_MAX_MICBIAS];
343 int pullup_ref[WCD9335_MAX_MICBIAS];
345 int dmic_0_1_clk_cnt;
346 int dmic_2_3_clk_cnt;
347 int dmic_4_5_clk_cnt;
351 int irq;
352 irqreturn_t (*handler)(int irq, void *data);
392 int rate;
393 int rate_val;
405 {24000, -EINVAL},/* 24K */
547 "Class H Invalid", "Class-H Hi-Fi", "Class-H Low Power", "Class-AB",
548 "Class-H Hi-Fi Low Power"
608 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
1041 SOC_DAPM_ENUM("RX INT0_2 MUX Mux", rx_int0_2_mux_chain_enum);
1044 SOC_DAPM_ENUM("RX INT1_2 MUX Mux", rx_int1_2_mux_chain_enum);
1047 SOC_DAPM_ENUM("RX INT2_2 MUX Mux", rx_int2_2_mux_chain_enum);
1050 SOC_DAPM_ENUM("RX INT3_2 MUX Mux", rx_int3_2_mux_chain_enum);
1053 SOC_DAPM_ENUM("RX INT4_2 MUX Mux", rx_int4_2_mux_chain_enum);
1056 SOC_DAPM_ENUM("RX INT5_2 MUX Mux", rx_int5_2_mux_chain_enum);
1059 SOC_DAPM_ENUM("RX INT6_2 MUX Mux", rx_int6_2_mux_chain_enum);
1062 SOC_DAPM_ENUM("RX INT7_2 MUX Mux", rx_int7_2_mux_chain_enum);
1065 SOC_DAPM_ENUM("RX INT8_2 MUX Mux", rx_int8_2_mux_chain_enum);
1068 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP0 Mux", rx_int0_1_mix_inp0_chain_enum);
1071 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP1 Mux", rx_int0_1_mix_inp1_chain_enum);
1074 SOC_DAPM_ENUM("RX INT0_1 MIX1 INP2 Mux", rx_int0_1_mix_inp2_chain_enum);
1077 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP0 Mux", rx_int1_1_mix_inp0_chain_enum);
1080 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP1 Mux", rx_int1_1_mix_inp1_chain_enum);
1083 SOC_DAPM_ENUM("RX INT1_1 MIX1 INP2 Mux", rx_int1_1_mix_inp2_chain_enum);
1086 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP0 Mux", rx_int2_1_mix_inp0_chain_enum);
1089 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP1 Mux", rx_int2_1_mix_inp1_chain_enum);
1092 SOC_DAPM_ENUM("RX INT2_1 MIX1 INP2 Mux", rx_int2_1_mix_inp2_chain_enum);
1095 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP0 Mux", rx_int3_1_mix_inp0_chain_enum);
1098 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP1 Mux", rx_int3_1_mix_inp1_chain_enum);
1101 SOC_DAPM_ENUM("RX INT3_1 MIX1 INP2 Mux", rx_int3_1_mix_inp2_chain_enum);
1104 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP0 Mux", rx_int4_1_mix_inp0_chain_enum);
1107 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP1 Mux", rx_int4_1_mix_inp1_chain_enum);
1110 SOC_DAPM_ENUM("RX INT4_1 MIX1 INP2 Mux", rx_int4_1_mix_inp2_chain_enum);
1113 SOC_DAPM_ENUM("RX INT5_1 MIX1 INP0 Mux", rx_int5_1_mix_inp0_chain_enum);
1116 SOC_DAPM_ENUM("RX INT5_1 MIX1 INP1 Mux", rx_int5_1_mix_inp1_chain_enum);
1119 SOC_DAPM_ENUM("RX INT5_1 MIX1 INP2 Mux", rx_int5_1_mix_inp2_chain_enum);
1122 SOC_DAPM_ENUM("RX INT6_1 MIX1 INP0 Mux", rx_int6_1_mix_inp0_chain_enum);
1125 SOC_DAPM_ENUM("RX INT6_1 MIX1 INP1 Mux", rx_int6_1_mix_inp1_chain_enum);
1128 SOC_DAPM_ENUM("RX INT6_1 MIX1 INP2 Mux", rx_int6_1_mix_inp2_chain_enum);
1131 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP0 Mux", rx_int7_1_mix_inp0_chain_enum);
1134 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP1 Mux", rx_int7_1_mix_inp1_chain_enum);
1137 SOC_DAPM_ENUM("RX INT7_1 MIX1 INP2 Mux", rx_int7_1_mix_inp2_chain_enum);
1140 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP0 Mux", rx_int8_1_mix_inp0_chain_enum);
1143 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP1 Mux", rx_int8_1_mix_inp1_chain_enum);
1146 SOC_DAPM_ENUM("RX INT8_1 MIX1 INP2 Mux", rx_int8_1_mix_inp2_chain_enum);
1149 SOC_DAPM_ENUM("RX INT0 INTERP Mux", rx_int0_interp_mux_enum);
1152 SOC_DAPM_ENUM("RX INT1 INTERP Mux", rx_int1_interp_mux_enum);
1155 SOC_DAPM_ENUM("RX INT2 INTERP Mux", rx_int2_interp_mux_enum);
1158 SOC_DAPM_ENUM("RX INT3 INTERP Mux", rx_int3_interp_mux_enum);
1161 SOC_DAPM_ENUM("RX INT4 INTERP Mux", rx_int4_interp_mux_enum);
1164 SOC_DAPM_ENUM("RX INT5 INTERP Mux", rx_int5_interp_mux_enum);
1167 SOC_DAPM_ENUM("RX INT6 INTERP Mux", rx_int6_interp_mux_enum);
1170 SOC_DAPM_ENUM("RX INT7 INTERP Mux", rx_int7_interp_mux_enum);
1173 SOC_DAPM_ENUM("RX INT8 INTERP Mux", rx_int8_interp_mux_enum);
1176 SOC_DAPM_ENUM("DMIC MUX0 Mux", tx_dmic_mux0_enum);
1179 SOC_DAPM_ENUM("DMIC MUX1 Mux", tx_dmic_mux1_enum);
1182 SOC_DAPM_ENUM("DMIC MUX2 Mux", tx_dmic_mux2_enum);
1185 SOC_DAPM_ENUM("DMIC MUX3 Mux", tx_dmic_mux3_enum);
1188 SOC_DAPM_ENUM("DMIC MUX4 Mux", tx_dmic_mux4_enum);
1191 SOC_DAPM_ENUM("DMIC MUX5 Mux", tx_dmic_mux5_enum);
1194 SOC_DAPM_ENUM("DMIC MUX6 Mux", tx_dmic_mux6_enum);
1197 SOC_DAPM_ENUM("DMIC MUX7 Mux", tx_dmic_mux7_enum);
1200 SOC_DAPM_ENUM("DMIC MUX8 Mux", tx_dmic_mux8_enum);
1203 SOC_DAPM_ENUM("AMIC MUX0 Mux", tx_amic_mux0_enum);
1206 SOC_DAPM_ENUM("AMIC MUX1 Mux", tx_amic_mux1_enum);
1209 SOC_DAPM_ENUM("AMIC MUX2 Mux", tx_amic_mux2_enum);
1212 SOC_DAPM_ENUM("AMIC MUX3 Mux", tx_amic_mux3_enum);
1215 SOC_DAPM_ENUM("AMIC MUX4 Mux", tx_amic_mux4_enum);
1218 SOC_DAPM_ENUM("AMIC MUX5 Mux", tx_amic_mux5_enum);
1221 SOC_DAPM_ENUM("AMIC MUX6 Mux", tx_amic_mux6_enum);
1224 SOC_DAPM_ENUM("AMIC MUX7 Mux", tx_amic_mux7_enum);
1227 SOC_DAPM_ENUM("AMIC MUX8 Mux", tx_amic_mux8_enum);
1230 SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
1233 SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
1236 SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
1239 SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
1242 SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
1245 SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
1248 SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
1251 SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
1254 SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
1256 static int slim_rx_mux_get(struct snd_kcontrol *kc, in slim_rx_mux_get()
1260 struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_get()
1261 u32 port_id = w->shift; in slim_rx_mux_get()
1263 ucontrol->value.enumerated.item[0] = wcd->rx_port_value[port_id]; in slim_rx_mux_get()
1268 static int slim_rx_mux_put(struct snd_kcontrol *kc, in slim_rx_mux_put()
1272 struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_put()
1273 struct soc_enum *e = (struct soc_enum *)kc->private_value; in slim_rx_mux_put()
1275 u32 port_id = w->shift; in slim_rx_mux_put()
1277 if (wcd->rx_port_value[port_id] == ucontrol->value.enumerated.item[0]) in slim_rx_mux_put()
1280 wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0]; in slim_rx_mux_put()
1283 list_del_init(&wcd->rx_chs[port_id].list); in slim_rx_mux_put()
1285 switch (wcd->rx_port_value[port_id]) { in slim_rx_mux_put()
1290 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1291 &wcd->dai[AIF1_PB].slim_ch_list); in slim_rx_mux_put()
1294 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1295 &wcd->dai[AIF2_PB].slim_ch_list); in slim_rx_mux_put()
1298 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1299 &wcd->dai[AIF3_PB].slim_ch_list); in slim_rx_mux_put()
1302 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1303 &wcd->dai[AIF4_PB].slim_ch_list); in slim_rx_mux_put()
1306 dev_err(wcd->dev, "Unknown AIF %d\n", wcd->rx_port_value[port_id]); in slim_rx_mux_put()
1310 snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id], in slim_rx_mux_put()
1315 return -EINVAL; in slim_rx_mux_put()
1318 static int slim_tx_mixer_get(struct snd_kcontrol *kc, in slim_tx_mixer_get()
1323 struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev); in slim_tx_mixer_get()
1326 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_get()
1327 int dai_id = widget->shift; in slim_tx_mixer_get()
1328 int port_id = mixer->shift; in slim_tx_mixer_get()
1330 ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id] == dai_id; in slim_tx_mixer_get()
1335 static int slim_tx_mixer_put(struct snd_kcontrol *kc, in slim_tx_mixer_put()
1340 struct wcd9335_codec *wcd = dev_get_drvdata(widget->dapm->dev); in slim_tx_mixer_put()
1343 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_put()
1344 int enable = ucontrol->value.integer.value[0]; in slim_tx_mixer_put()
1345 int dai_id = widget->shift; in slim_tx_mixer_put()
1346 int port_id = mixer->shift; in slim_tx_mixer_put()
1353 if (enable && wcd->tx_port_value[port_id] != dai_id) { in slim_tx_mixer_put()
1354 wcd->tx_port_value[port_id] = dai_id; in slim_tx_mixer_put()
1355 list_add_tail(&wcd->tx_chs[port_id].list, in slim_tx_mixer_put()
1356 &wcd->dai[dai_id].slim_ch_list); in slim_tx_mixer_put()
1357 } else if (!enable && wcd->tx_port_value[port_id] == dai_id) { in slim_tx_mixer_put()
1358 wcd->tx_port_value[port_id] = -1; in slim_tx_mixer_put()
1359 list_del_init(&wcd->tx_chs[port_id].list); in slim_tx_mixer_put()
1363 dev_err(wcd->dev, "Unknown AIF %d\n", dai_id); in slim_tx_mixer_put()
1364 return -EINVAL; in slim_tx_mixer_put()
1367 snd_soc_dapm_mixer_update_power(widget->dapm, kc, enable, update); in slim_tx_mixer_put()
1373 SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
1375 SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
1377 SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
1379 SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
1381 SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
1383 SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
1385 SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
1387 SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
1470 static int wcd9335_put_dec_enum(struct snd_kcontrol *kc, in wcd9335_put_dec_enum()
1475 struct soc_enum *e = (struct soc_enum *)kc->private_value; in wcd9335_put_dec_enum()
1476 unsigned int val, reg, sel; in wcd9335_put_dec_enum()
1478 val = ucontrol->value.enumerated.item[0]; in wcd9335_put_dec_enum()
1480 switch (e->reg) { in wcd9335_put_dec_enum()
1509 return -EINVAL; in wcd9335_put_dec_enum()
1521 static int wcd9335_int_dem_inp_mux_put(struct snd_kcontrol *kc, in wcd9335_int_dem_inp_mux_put()
1524 struct soc_enum *e = (struct soc_enum *)kc->private_value; in wcd9335_int_dem_inp_mux_put()
1526 int reg, val; in wcd9335_int_dem_inp_mux_put()
1529 val = ucontrol->value.enumerated.item[0]; in wcd9335_int_dem_inp_mux_put()
1531 if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1533 else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1535 else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1538 return -EINVAL; in wcd9335_int_dem_inp_mux_put()
1549 SOC_DAPM_ENUM_EXT("RX INT0 DEM MUX Mux", rx_int0_dem_inp_mux_enum,
1554 SOC_DAPM_ENUM_EXT("RX INT1 DEM MUX Mux", rx_int1_dem_inp_mux_enum,
1559 SOC_DAPM_ENUM_EXT("RX INT2 DEM MUX Mux", rx_int2_dem_inp_mux_enum,
1564 SOC_DAPM_ENUM_EXT("ADC MUX0 Mux", tx_adc_mux0_chain_enum,
1569 SOC_DAPM_ENUM_EXT("ADC MUX1 Mux", tx_adc_mux1_chain_enum,
1574 SOC_DAPM_ENUM_EXT("ADC MUX2 Mux", tx_adc_mux2_chain_enum,
1579 SOC_DAPM_ENUM_EXT("ADC MUX3 Mux", tx_adc_mux3_chain_enum,
1584 SOC_DAPM_ENUM_EXT("ADC MUX4 Mux", tx_adc_mux4_chain_enum,
1589 SOC_DAPM_ENUM_EXT("ADC MUX5 Mux", tx_adc_mux5_chain_enum,
1594 SOC_DAPM_ENUM_EXT("ADC MUX6 Mux", tx_adc_mux6_chain_enum,
1599 SOC_DAPM_ENUM_EXT("ADC MUX7 Mux", tx_adc_mux7_chain_enum,
1604 SOC_DAPM_ENUM_EXT("ADC MUX8 Mux", tx_adc_mux8_chain_enum,
1608 static int wcd9335_set_mix_interpolator_rate(struct snd_soc_dai *dai, in wcd9335_set_mix_interpolator_rate()
1609 int rate_val, in wcd9335_set_mix_interpolator_rate()
1612 struct snd_soc_component *component = dai->component; in wcd9335_set_mix_interpolator_rate()
1613 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_set_mix_interpolator_rate()
1615 int val, j; in wcd9335_set_mix_interpolator_rate()
1617 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_mix_interpolator_rate()
1623 if (val == (ch->shift + INTn_2_INP_SEL_RX0)) in wcd9335_set_mix_interpolator_rate()
1634 static int wcd9335_set_prim_interpolator_rate(struct snd_soc_dai *dai, in wcd9335_set_prim_interpolator_rate()
1638 struct snd_soc_component *comp = dai->component; in wcd9335_set_prim_interpolator_rate()
1639 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_set_prim_interpolator_rate()
1642 int inp, j; in wcd9335_set_prim_interpolator_rate()
1644 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_prim_interpolator_rate()
1645 inp = ch->shift + INTn_1_MIX_INP_SEL_RX0; in wcd9335_set_prim_interpolator_rate()
1647 * Loop through all interpolator MUX inputs and find out in wcd9335_set_prim_interpolator_rate()
1648 * to which interpolator input, the slim rx port in wcd9335_set_prim_interpolator_rate()
1668 dev_info(wcd->dev, in wcd9335_set_prim_interpolator_rate()
1682 static int wcd9335_set_interpolator_rate(struct snd_soc_dai *dai, u32 rate) in wcd9335_set_interpolator_rate()
1684 int i; in wcd9335_set_interpolator_rate()
1707 static int wcd9335_slim_set_hw_params(struct wcd9335_codec *wcd, in wcd9335_slim_set_hw_params()
1709 int direction) in wcd9335_slim_set_hw_params()
1711 struct list_head *slim_ch_list = &dai_data->slim_ch_list; in wcd9335_slim_set_hw_params()
1712 struct slim_stream_config *cfg = &dai_data->sconfig; in wcd9335_slim_set_hw_params()
1715 int ret, i; in wcd9335_slim_set_hw_params()
1717 cfg->ch_count = 0; in wcd9335_slim_set_hw_params()
1718 cfg->direction = direction; in wcd9335_slim_set_hw_params()
1719 cfg->port_mask = 0; in wcd9335_slim_set_hw_params()
1723 cfg->ch_count++; in wcd9335_slim_set_hw_params()
1724 payload |= 1 << ch->shift; in wcd9335_slim_set_hw_params()
1725 cfg->port_mask |= BIT(ch->port); in wcd9335_slim_set_hw_params()
1728 cfg->chs = kcalloc(cfg->ch_count, sizeof(unsigned int), GFP_KERNEL); in wcd9335_slim_set_hw_params()
1729 if (!cfg->chs) in wcd9335_slim_set_hw_params()
1730 return -ENOMEM; in wcd9335_slim_set_hw_params()
1734 cfg->chs[i++] = ch->ch_num; in wcd9335_slim_set_hw_params()
1737 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1738 WCD9335_SLIM_PGD_RX_PORT_MULTI_CHNL_0(ch->port), in wcd9335_slim_set_hw_params()
1744 /* configure the slave port for water mark and enable*/ in wcd9335_slim_set_hw_params()
1745 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1746 WCD9335_SLIM_PGD_RX_PORT_CFG(ch->port), in wcd9335_slim_set_hw_params()
1751 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1752 WCD9335_SLIM_PGD_TX_PORT_MULTI_CHNL_0(ch->port), in wcd9335_slim_set_hw_params()
1758 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1759 WCD9335_SLIM_PGD_TX_PORT_MULTI_CHNL_1(ch->port), in wcd9335_slim_set_hw_params()
1764 /* configure the slave port for water mark and enable*/ in wcd9335_slim_set_hw_params()
1765 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1766 WCD9335_SLIM_PGD_TX_PORT_CFG(ch->port), in wcd9335_slim_set_hw_params()
1774 dai_data->sruntime = slim_stream_allocate(wcd->slim, "WCD9335-SLIM"); in wcd9335_slim_set_hw_params()
1779 dev_err(wcd->dev, "Error Setting slim hw params\n"); in wcd9335_slim_set_hw_params()
1780 kfree(cfg->chs); in wcd9335_slim_set_hw_params()
1781 cfg->chs = NULL; in wcd9335_slim_set_hw_params()
1786 static int wcd9335_set_decimator_rate(struct snd_soc_dai *dai, in wcd9335_set_decimator_rate()
1789 struct snd_soc_component *comp = dai->component; in wcd9335_set_decimator_rate()
1793 int tx_port, tx_port_reg; in wcd9335_set_decimator_rate()
1794 int decimator = -1; in wcd9335_set_decimator_rate()
1796 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_decimator_rate()
1797 tx_port = ch->port; in wcd9335_set_decimator_rate()
1799 dev_err(wcd->dev, "Invalid SLIM TX%u port DAI ID:%d\n", in wcd9335_set_decimator_rate()
1800 tx_port, dai->id); in wcd9335_set_decimator_rate()
1801 return -EINVAL; in wcd9335_set_decimator_rate()
1803 /* Find the SB TX MUX input - which decimator is connected */ in wcd9335_set_decimator_rate()
1810 shift = ((tx_port - 4) << 1); in wcd9335_set_decimator_rate()
1814 shift = ((tx_port - 8) << 1); in wcd9335_set_decimator_rate()
1838 decimator = tx_mux_sel - 1; in wcd9335_set_decimator_rate()
1850 /* Check if the TX Mux input is RX MIX TXn */ in wcd9335_set_decimator_rate()
1851 dev_err(wcd->dev, "RX_MIX_TX%u going to SLIM TX%u\n", in wcd9335_set_decimator_rate()
1854 dev_err(wcd->dev, "ERROR: Invalid decimator: %d\n", in wcd9335_set_decimator_rate()
1856 return -EINVAL; in wcd9335_set_decimator_rate()
1863 static int wcd9335_hw_params(struct snd_pcm_substream *substream, in wcd9335_hw_params()
1868 int ret, tx_fs_rate = 0; in wcd9335_hw_params()
1870 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_hw_params()
1872 switch (substream->stream) { in wcd9335_hw_params()
1876 dev_err(wcd->dev, "cannot set sample rate: %u\n", in wcd9335_hw_params()
1882 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd9335_hw_params()
1885 dev_err(wcd->dev, "%s: Invalid format 0x%x\n", in wcd9335_hw_params()
1887 return -EINVAL; in wcd9335_hw_params()
1915 dev_err(wcd->dev, "%s: Invalid TX sample rate: %d\n", in wcd9335_hw_params()
1917 return -EINVAL; in wcd9335_hw_params()
1924 dev_err(wcd->dev, "Cannot set TX Decimator rate\n"); in wcd9335_hw_params()
1929 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd9335_hw_params()
1932 dev_err(wcd->dev, "%s: Invalid format 0x%x\n", in wcd9335_hw_params()
1934 return -EINVAL; in wcd9335_hw_params()
1938 dev_err(wcd->dev, "Invalid stream type %d\n", in wcd9335_hw_params()
1939 substream->stream); in wcd9335_hw_params()
1940 return -EINVAL; in wcd9335_hw_params()
1943 wcd->dai[dai->id].sconfig.rate = params_rate(params); in wcd9335_hw_params()
1944 wcd9335_slim_set_hw_params(wcd, &wcd->dai[dai->id], substream->stream); in wcd9335_hw_params()
1949 static int wcd9335_trigger(struct snd_pcm_substream *substream, int cmd, in wcd9335_trigger()
1956 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_trigger()
1958 dai_data = &wcd->dai[dai->id]; in wcd9335_trigger()
1964 cfg = &dai_data->sconfig; in wcd9335_trigger()
1965 slim_stream_prepare(dai_data->sruntime, cfg); in wcd9335_trigger()
1966 slim_stream_enable(dai_data->sruntime); in wcd9335_trigger()
1971 slim_stream_disable(dai_data->sruntime); in wcd9335_trigger()
1972 slim_stream_unprepare(dai_data->sruntime); in wcd9335_trigger()
1981 static int wcd9335_set_channel_map(struct snd_soc_dai *dai, in wcd9335_set_channel_map()
1982 unsigned int tx_num, in wcd9335_set_channel_map()
1983 const unsigned int *tx_slot, in wcd9335_set_channel_map()
1984 unsigned int rx_num, in wcd9335_set_channel_map()
1985 const unsigned int *rx_slot) in wcd9335_set_channel_map()
1988 int i; in wcd9335_set_channel_map()
1990 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_set_channel_map()
1993 dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n", in wcd9335_set_channel_map()
1995 return -EINVAL; in wcd9335_set_channel_map()
1998 wcd->num_rx_port = rx_num; in wcd9335_set_channel_map()
2000 wcd->rx_chs[i].ch_num = rx_slot[i]; in wcd9335_set_channel_map()
2001 INIT_LIST_HEAD(&wcd->rx_chs[i].list); in wcd9335_set_channel_map()
2004 wcd->num_tx_port = tx_num; in wcd9335_set_channel_map()
2006 wcd->tx_chs[i].ch_num = tx_slot[i]; in wcd9335_set_channel_map()
2007 INIT_LIST_HEAD(&wcd->tx_chs[i].list); in wcd9335_set_channel_map()
2013 static int wcd9335_get_channel_map(const struct snd_soc_dai *dai, in wcd9335_get_channel_map()
2014 unsigned int *tx_num, unsigned int *tx_slot, in wcd9335_get_channel_map()
2015 unsigned int *rx_num, unsigned int *rx_slot) in wcd9335_get_channel_map()
2019 int i = 0; in wcd9335_get_channel_map()
2021 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_get_channel_map()
2023 switch (dai->id) { in wcd9335_get_channel_map()
2029 dev_err(wcd->dev, "Invalid rx_slot %p or rx_num %p\n", in wcd9335_get_channel_map()
2031 return -EINVAL; in wcd9335_get_channel_map()
2034 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd9335_get_channel_map()
2035 rx_slot[i++] = ch->ch_num; in wcd9335_get_channel_map()
2043 dev_err(wcd->dev, "Invalid tx_slot %p or tx_num %p\n", in wcd9335_get_channel_map()
2045 return -EINVAL; in wcd9335_get_channel_map()
2047 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd9335_get_channel_map()
2048 tx_slot[i++] = ch->ch_num; in wcd9335_get_channel_map()
2053 dev_err(wcd->dev, "Invalid DAI ID %x\n", dai->id); in wcd9335_get_channel_map()
2172 static int wcd9335_get_compander(struct snd_kcontrol *kc, in wcd9335_get_compander()
2177 int comp = ((struct soc_mixer_control *)kc->private_value)->shift; in wcd9335_get_compander()
2178 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_get_compander()
2180 ucontrol->value.integer.value[0] = wcd->comp_enabled[comp]; in wcd9335_get_compander()
2184 static int wcd9335_set_compander(struct snd_kcontrol *kc, in wcd9335_set_compander()
2188 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_set_compander()
2189 int comp = ((struct soc_mixer_control *) kc->private_value)->shift; in wcd9335_set_compander()
2190 int value = ucontrol->value.integer.value[0]; in wcd9335_set_compander()
2191 int sel; in wcd9335_set_compander()
2193 wcd->comp_enabled[comp] = value; in wcd9335_set_compander()
2223 static int wcd9335_rx_hph_mode_get(struct snd_kcontrol *kc, in wcd9335_rx_hph_mode_get()
2227 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_rx_hph_mode_get()
2229 ucontrol->value.enumerated.item[0] = wcd->hph_mode; in wcd9335_rx_hph_mode_get()
2234 static int wcd9335_rx_hph_mode_put(struct snd_kcontrol *kc, in wcd9335_rx_hph_mode_put()
2238 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_rx_hph_mode_put()
2241 mode_val = ucontrol->value.enumerated.item[0]; in wcd9335_rx_hph_mode_put()
2244 dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); in wcd9335_rx_hph_mode_put()
2247 wcd->hph_mode = mode_val; in wcd9335_rx_hph_mode_put()
2253 /* -84dB min - 40dB max */
2255 -84, 40, digital_gain),
2257 -84, 40, digital_gain),
2259 -84, 40, digital_gain),
2261 -84, 40, digital_gain),
2263 -84, 40, digital_gain),
2265 -84, 40, digital_gain),
2267 -84, 40, digital_gain),
2269 -84, 40, digital_gain),
2271 -84, 40, digital_gain),
2273 -84, 40, digital_gain),
2275 -84, 40, digital_gain),
2277 -84, 40, digital_gain),
2279 -84, 40, digital_gain),
2281 -84, 40, digital_gain),
2283 -84, 40, digital_gain),
2285 -84, 40, digital_gain),
2287 -84, 40, digital_gain),
2289 -84, 40, digital_gain),
2368 {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
2369 {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
2370 {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
2371 {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
2372 {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
2373 {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
2374 {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
2375 {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
2377 {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
2378 {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
2379 {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
2380 {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
2381 {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
2382 {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
2383 {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
2384 {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
2386 {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
2387 {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
2388 {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
2389 {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
2390 {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
2391 {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
2392 {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
2393 {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
2395 {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
2396 {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
2397 {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
2398 {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
2399 {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
2400 {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
2401 {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
2402 {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
2404 {"SLIM RX0", NULL, "SLIM RX0 MUX"},
2405 {"SLIM RX1", NULL, "SLIM RX1 MUX"},
2406 {"SLIM RX2", NULL, "SLIM RX2 MUX"},
2407 {"SLIM RX3", NULL, "SLIM RX3 MUX"},
2408 {"SLIM RX4", NULL, "SLIM RX4 MUX"},
2409 {"SLIM RX5", NULL, "SLIM RX5 MUX"},
2410 {"SLIM RX6", NULL, "SLIM RX6 MUX"},
2411 {"SLIM RX7", NULL, "SLIM RX7 MUX"},
2424 {"RX INT0 DEM MUX", "CLSH_DSM_OUT", "RX INT0 INTERP"},
2425 {"RX INT0 DAC", NULL, "RX INT0 DEM MUX"},
2431 {"RX INT1 DEM MUX", "CLSH_DSM_OUT", "RX INT1 INTERP"},
2432 {"RX INT1 DAC", NULL, "RX INT1 DEM MUX"},
2438 {"RX INT2 DEM MUX", "CLSH_DSM_OUT", "RX INT2 INTERP"},
2439 {"RX INT2 DAC", NULL, "RX INT2 DEM MUX"},
2473 /* ADC Mux */
2493 static int wcd9335_micbias_control(struct snd_soc_component *component, in wcd9335_micbias_control()
2494 int micb_num, int req, bool is_dapm) in wcd9335_micbias_control()
2497 int micb_index = micb_num - 1; in wcd9335_micbias_control()
2500 if ((micb_index < 0) || (micb_index > WCD9335_MAX_MICBIAS - 1)) { in wcd9335_micbias_control()
2501 dev_err(wcd->dev, "Invalid micbias index, micb_ind:%d\n", in wcd9335_micbias_control()
2503 return -EINVAL; in wcd9335_micbias_control()
2520 dev_err(component->dev, "%s: Invalid micbias number: %d\n", in wcd9335_micbias_control()
2522 return -EINVAL; in wcd9335_micbias_control()
2527 wcd->pullup_ref[micb_index]++; in wcd9335_micbias_control()
2528 if ((wcd->pullup_ref[micb_index] == 1) && in wcd9335_micbias_control()
2529 (wcd->micb_ref[micb_index] == 0)) in wcd9335_micbias_control()
2534 wcd->pullup_ref[micb_index]--; in wcd9335_micbias_control()
2535 if ((wcd->pullup_ref[micb_index] == 0) && in wcd9335_micbias_control()
2536 (wcd->micb_ref[micb_index] == 0)) in wcd9335_micbias_control()
2541 wcd->micb_ref[micb_index]++; in wcd9335_micbias_control()
2542 if (wcd->micb_ref[micb_index] == 1) in wcd9335_micbias_control()
2547 wcd->micb_ref[micb_index]--; in wcd9335_micbias_control()
2548 if ((wcd->micb_ref[micb_index] == 0) && in wcd9335_micbias_control()
2549 (wcd->pullup_ref[micb_index] > 0)) in wcd9335_micbias_control()
2552 else if ((wcd->micb_ref[micb_index] == 0) && in wcd9335_micbias_control()
2553 (wcd->pullup_ref[micb_index] == 0)) { in wcd9335_micbias_control()
2563 static int __wcd9335_codec_enable_micbias(struct snd_soc_dapm_widget *w, in __wcd9335_codec_enable_micbias()
2564 int event) in __wcd9335_codec_enable_micbias()
2566 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in __wcd9335_codec_enable_micbias()
2567 int micb_num; in __wcd9335_codec_enable_micbias()
2569 if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) in __wcd9335_codec_enable_micbias()
2571 else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2"))) in __wcd9335_codec_enable_micbias()
2573 else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3"))) in __wcd9335_codec_enable_micbias()
2575 else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4"))) in __wcd9335_codec_enable_micbias()
2578 return -EINVAL; in __wcd9335_codec_enable_micbias()
2601 static int wcd9335_codec_enable_micbias(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_micbias()
2602 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_micbias()
2636 dev_err(comp->dev, "%s: invalid amic: %d\n", in wcd9335_codec_set_tx_hold()
2642 static int wcd9335_codec_enable_adc(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_adc()
2643 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_adc()
2645 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_adc()
2649 wcd9335_codec_set_tx_hold(comp, w->reg, true); in wcd9335_codec_enable_adc()
2658 static int wcd9335_codec_find_amic_input(struct snd_soc_component *comp, in wcd9335_codec_find_amic_input()
2659 int adc_mux_n) in wcd9335_codec_find_amic_input()
2661 int mux_sel, reg, mreg; in wcd9335_codec_find_amic_input()
2667 /* Check whether adc mux input is AMIC or DMIC */ in wcd9335_codec_find_amic_input()
2673 reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + adc_mux_n - 4; in wcd9335_codec_find_amic_input()
2685 int amic) in wcd9335_codec_get_amic_pwlvl_reg()
2705 dev_err(comp->dev, "invalid amic: %d\n", amic); in wcd9335_codec_get_amic_pwlvl_reg()
2712 static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_dec()
2713 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_dec()
2715 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_dec()
2716 unsigned int decimator; in wcd9335_codec_enable_dec()
2719 int ret = 0, amic_n; in wcd9335_codec_enable_dec()
2725 char *wname __free(kfree) = kmemdup_nul(w->name, 15, GFP_KERNEL); in wcd9335_codec_enable_dec()
2727 return -ENOMEM; in wcd9335_codec_enable_dec()
2732 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd9335_codec_enable_dec()
2733 __func__, w->name); in wcd9335_codec_enable_dec()
2734 return -EINVAL; in wcd9335_codec_enable_dec()
2740 dev_err(comp->dev, "%s: decimator index not found\n", in wcd9335_codec_enable_dec()
2742 return -EINVAL; in wcd9335_codec_enable_dec()
2747 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd9335_codec_enable_dec()
2749 return -EINVAL; in wcd9335_codec_enable_dec()
2853 static int wcd9335_codec_enable_dmic(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_dmic()
2854 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_dmic()
2856 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_dmic()
2862 unsigned int dmic; in wcd9335_codec_enable_dmic()
2863 int ret; in wcd9335_codec_enable_dmic()
2866 wname = strpbrk(w->name, "012345"); in wcd9335_codec_enable_dmic()
2868 dev_err(comp->dev, "%s: widget not found\n", __func__); in wcd9335_codec_enable_dmic()
2869 return -EINVAL; in wcd9335_codec_enable_dmic()
2874 dev_err(comp->dev, "%s: Invalid DMIC line on the codec\n", in wcd9335_codec_enable_dmic()
2876 return -EINVAL; in wcd9335_codec_enable_dmic()
2882 dmic_clk_cnt = &(wcd->dmic_0_1_clk_cnt); in wcd9335_codec_enable_dmic()
2887 dmic_clk_cnt = &(wcd->dmic_2_3_clk_cnt); in wcd9335_codec_enable_dmic()
2892 dmic_clk_cnt = &(wcd->dmic_4_5_clk_cnt); in wcd9335_codec_enable_dmic()
2896 dev_err(comp->dev, "%s: Invalid DMIC Selection\n", in wcd9335_codec_enable_dmic()
2898 return -EINVAL; in wcd9335_codec_enable_dmic()
2903 dmic_rate_val = wcd9335_get_dmic_clk_val(comp, wcd->mclk_rate); in wcd9335_codec_enable_dmic()
2915 dmic_rate_val = wcd9335_get_dmic_clk_val(comp, wcd->mclk_rate); in wcd9335_codec_enable_dmic()
2916 (*dmic_clk_cnt)--; in wcd9335_codec_enable_dmic()
2933 int port_num = 0; in wcd9335_codec_enable_int_port()
2935 unsigned int val = 0; in wcd9335_codec_enable_int_port()
2936 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_enable_int_port()
2939 list_for_each_entry(ch, &dai->slim_ch_list, list) { in wcd9335_codec_enable_int_port()
2940 if (ch->port >= WCD9335_RX_START) { in wcd9335_codec_enable_int_port()
2941 port_num = ch->port - WCD9335_RX_START; in wcd9335_codec_enable_int_port()
2944 port_num = ch->port; in wcd9335_codec_enable_int_port()
2948 regmap_read(wcd->if_regmap, reg, &val); in wcd9335_codec_enable_int_port()
2950 regmap_write(wcd->if_regmap, reg, in wcd9335_codec_enable_int_port()
2955 static int wcd9335_codec_enable_slim(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_slim()
2957 int event) in wcd9335_codec_enable_slim()
2959 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_slim()
2961 struct wcd_slim_codec_dai_data *dai = &wcd->dai[w->shift]; in wcd9335_codec_enable_slim()
2968 kfree(dai->sconfig.chs); in wcd9335_codec_enable_slim()
2976 static int wcd9335_codec_enable_mix_path(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_mix_path()
2977 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_mix_path()
2979 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_mix_path()
2981 int val = 0; in wcd9335_codec_enable_mix_path()
2983 switch (w->reg) { in wcd9335_codec_enable_mix_path()
3012 dev_err(comp->dev, "%s: No gain register avail for %s\n", in wcd9335_codec_enable_mix_path()
3013 __func__, w->name); in wcd9335_codec_enable_mix_path()
3085 u16 prim_int_reg, int event) in wcd9335_codec_hd2_control()
3124 static int wcd9335_codec_enable_prim_interpolator( in wcd9335_codec_enable_prim_interpolator()
3126 u16 reg, int event) in wcd9335_codec_enable_prim_interpolator()
3128 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_prim_interpolator()
3130 int prim_int_reg = wcd9335_interp_get_primary_reg(reg, &ind); in wcd9335_codec_enable_prim_interpolator()
3134 wcd->prim_int_users[ind]++; in wcd9335_codec_enable_prim_interpolator()
3135 if (wcd->prim_int_users[ind] == 1) { in wcd9335_codec_enable_prim_interpolator()
3153 wcd->prim_int_users[ind]--; in wcd9335_codec_enable_prim_interpolator()
3154 if (wcd->prim_int_users[ind] == 0) { in wcd9335_codec_enable_prim_interpolator()
3172 static int wcd9335_config_compander(struct snd_soc_component *component, in wcd9335_config_compander()
3173 int interp_n, int event) in wcd9335_config_compander()
3175 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_config_compander()
3176 int comp; in wcd9335_config_compander()
3183 comp = interp_n - 1; in wcd9335_config_compander()
3184 if (!wcd->comp_enabled[comp]) in wcd9335_config_compander()
3233 static int wcd9335_codec_enable_interpolator(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_interpolator()
3234 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_interpolator()
3236 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_interpolator()
3239 int val; in wcd9335_codec_enable_interpolator()
3269 dev_err(comp->dev, "%s: Interpolator reg not found\n", in wcd9335_codec_enable_interpolator()
3271 return -EINVAL; in wcd9335_codec_enable_interpolator()
3280 wcd9335_config_compander(comp, w->shift, event); in wcd9335_codec_enable_interpolator()
3285 wcd9335_config_compander(comp, w->shift, event); in wcd9335_codec_enable_interpolator()
3296 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_hph_mode_gain_opt()
3320 wcd->hph_l_gain = hph_l_en & 0x1F; in wcd9335_codec_hph_mode_gain_opt()
3325 wcd->hph_r_gain = hph_r_en & 0x1F; in wcd9335_codec_hph_mode_gain_opt()
3330 int event) in wcd9335_codec_hph_lohifi_config()
3367 int event) in wcd9335_codec_hph_lp_config()
3425 int event) in wcd9335_codec_hph_hifi_config()
3451 int event, int mode) in wcd9335_codec_hph_mode_config()
3466 static int wcd9335_codec_hphl_dac_event(struct snd_soc_dapm_widget *w, in wcd9335_codec_hphl_dac_event()
3468 int event) in wcd9335_codec_hphl_dac_event()
3470 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_hphl_dac_event()
3471 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_hphl_dac_event()
3472 int hph_mode = wcd->hph_mode; in wcd9335_codec_hphl_dac_event()
3482 dev_err(comp->dev, "Incorrect DEM Input\n"); in wcd9335_codec_hphl_dac_event()
3483 return -EINVAL; in wcd9335_codec_hphl_dac_event()
3485 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_hphl_dac_event()
3502 if (!(wcd_clsh_ctrl_get_state(wcd->clsh_ctrl) & in wcd9335_codec_hphl_dac_event()
3506 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_hphl_dac_event()
3516 static int wcd9335_codec_lineout_dac_event(struct snd_soc_dapm_widget *w, in wcd9335_codec_lineout_dac_event()
3517 struct snd_kcontrol *kc, int event) in wcd9335_codec_lineout_dac_event()
3519 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_lineout_dac_event()
3520 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_lineout_dac_event()
3524 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_lineout_dac_event()
3528 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_lineout_dac_event()
3536 static int wcd9335_codec_ear_dac_event(struct snd_soc_dapm_widget *w, in wcd9335_codec_ear_dac_event()
3537 struct snd_kcontrol *kc, int event) in wcd9335_codec_ear_dac_event()
3539 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_ear_dac_event()
3540 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_ear_dac_event()
3544 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_ear_dac_event()
3549 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_ear_dac_event()
3558 int mode, int event) in wcd9335_codec_hph_post_pa_config()
3579 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3584 if (wcd->comp_enabled[COMPANDER_1] || in wcd9335_codec_hph_post_pa_config()
3585 wcd->comp_enabled[COMPANDER_2]) { in wcd9335_codec_hph_post_pa_config()
3587 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3591 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3595 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3600 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3603 wcd->hph_l_gain); in wcd9335_codec_hph_post_pa_config()
3604 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3607 wcd->hph_r_gain); in wcd9335_codec_hph_post_pa_config()
3611 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3617 static int wcd9335_codec_hphr_dac_event(struct snd_soc_dapm_widget *w, in wcd9335_codec_hphr_dac_event()
3619 int event) in wcd9335_codec_hphr_dac_event()
3621 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_hphr_dac_event()
3622 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_hphr_dac_event()
3623 int hph_mode = wcd->hph_mode; in wcd9335_codec_hphr_dac_event()
3635 dev_err(comp->dev, "DEM Input not set correctly, hph_mode: %d\n", in wcd9335_codec_hphr_dac_event()
3637 return -EINVAL; in wcd9335_codec_hphr_dac_event()
3640 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, in wcd9335_codec_hphr_dac_event()
3653 if (!(wcd_clsh_ctrl_get_state(wcd->clsh_ctrl) & in wcd9335_codec_hphr_dac_event()
3657 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_hphr_dac_event()
3666 static int wcd9335_codec_enable_hphl_pa(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_hphl_pa()
3668 int event) in wcd9335_codec_enable_hphl_pa()
3670 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_hphl_pa()
3671 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_hphl_pa()
3672 int hph_mode = wcd->hph_mode; in wcd9335_codec_enable_hphl_pa()
3714 static int wcd9335_codec_enable_lineout_pa(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_lineout_pa()
3716 int event) in wcd9335_codec_enable_lineout_pa()
3718 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_lineout_pa()
3719 int vol_reg = 0, mix_vol_reg = 0; in wcd9335_codec_enable_lineout_pa()
3721 if (w->reg == WCD9335_ANA_LO_1_2) { in wcd9335_codec_enable_lineout_pa()
3722 if (w->shift == 7) { in wcd9335_codec_enable_lineout_pa()
3725 } else if (w->shift == 6) { in wcd9335_codec_enable_lineout_pa()
3729 } else if (w->reg == WCD9335_ANA_LO_3_4) { in wcd9335_codec_enable_lineout_pa()
3730 if (w->shift == 7) { in wcd9335_codec_enable_lineout_pa()
3733 } else if (w->shift == 6) { in wcd9335_codec_enable_lineout_pa()
3738 dev_err(comp->dev, "Error enabling lineout PA\n"); in wcd9335_codec_enable_lineout_pa()
3739 return -EINVAL; in wcd9335_codec_enable_lineout_pa()
3786 static int wcd9335_codec_enable_rx_bias(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_rx_bias()
3787 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_rx_bias()
3789 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_rx_bias()
3790 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_rx_bias()
3794 wcd->rx_bias_count++; in wcd9335_codec_enable_rx_bias()
3795 if (wcd->rx_bias_count == 1) { in wcd9335_codec_enable_rx_bias()
3804 wcd->rx_bias_count--; in wcd9335_codec_enable_rx_bias()
3805 if (!wcd->rx_bias_count) in wcd9335_codec_enable_rx_bias()
3816 static int wcd9335_codec_enable_hphr_pa(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_hphr_pa()
3817 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_hphr_pa()
3819 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_hphr_pa()
3820 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_hphr_pa()
3821 int hph_mode = wcd->hph_mode; in wcd9335_codec_enable_hphr_pa()
3862 static int wcd9335_codec_enable_ear_pa(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_ear_pa()
3863 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_ear_pa()
3865 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_ear_pa()
3898 static irqreturn_t wcd9335_slimbus_irq(int irq, void *data) in wcd9335_slimbus_irq()
3902 int i, j, port_id; in wcd9335_slimbus_irq()
3903 unsigned int val, int_val = 0; in wcd9335_slimbus_irq()
3910 regmap_read(wcd->if_regmap, i, &val); in wcd9335_slimbus_irq()
3916 port_id = (tx ? j - 16 : j); in wcd9335_slimbus_irq()
3917 regmap_read(wcd->if_regmap, in wcd9335_slimbus_irq()
3927 wcd->if_regmap, reg, &int_val); in wcd9335_slimbus_irq()
3937 dev_err_ratelimited(wcd->dev, in wcd9335_slimbus_irq()
3938 "%s: overflow error on %s port %d, value %x\n", in wcd9335_slimbus_irq()
3942 dev_err_ratelimited(wcd->dev, in wcd9335_slimbus_irq()
3943 "%s: underflow error on %s port %d, value %x\n", in wcd9335_slimbus_irq()
3955 wcd->if_regmap, reg, &int_val); in wcd9335_slimbus_irq()
3958 regmap_write(wcd->if_regmap, in wcd9335_slimbus_irq()
3963 regmap_write(wcd->if_regmap, in wcd9335_slimbus_irq()
3980 static int wcd9335_setup_irqs(struct wcd9335_codec *wcd) in wcd9335_setup_irqs()
3982 int irq, ret, i; in wcd9335_setup_irqs()
3985 irq = regmap_irq_get_virq(wcd->irq_data, wcd9335_irqs[i].irq); in wcd9335_setup_irqs()
3987 dev_err(wcd->dev, "Failed to get %s\n", in wcd9335_setup_irqs()
3992 ret = devm_request_threaded_irq(wcd->dev, irq, NULL, in wcd9335_setup_irqs()
3998 dev_err(wcd->dev, "Failed to request %s\n", in wcd9335_setup_irqs()
4006 regmap_write(wcd->if_regmap, WCD9335_SLIM_PGD_PORT_INT_EN0 + i, in wcd9335_setup_irqs()
4014 int i; in wcd9335_teardown_irqs()
4018 regmap_write(wcd->if_regmap, WCD9335_SLIM_PGD_PORT_INT_EN0 + i, in wcd9335_teardown_irqs()
4025 struct snd_soc_component *comp = wcd->component; in wcd9335_cdc_sido_ccl_enable()
4028 if (++wcd->sido_ccl_cnt == 1) in wcd9335_cdc_sido_ccl_enable()
4032 if (wcd->sido_ccl_cnt == 0) { in wcd9335_cdc_sido_ccl_enable()
4033 dev_err(wcd->dev, "sido_ccl already disabled\n"); in wcd9335_cdc_sido_ccl_enable()
4036 if (--wcd->sido_ccl_cnt == 0) in wcd9335_cdc_sido_ccl_enable()
4042 static int wcd9335_enable_master_bias(struct wcd9335_codec *wcd) in wcd9335_enable_master_bias()
4044 wcd->master_bias_users++; in wcd9335_enable_master_bias()
4045 if (wcd->master_bias_users == 1) { in wcd9335_enable_master_bias()
4046 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4049 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4053 * 1ms delay is required after pre-charge is enabled in wcd9335_enable_master_bias()
4057 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4060 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4068 static int wcd9335_enable_mclk(struct wcd9335_codec *wcd) in wcd9335_enable_mclk()
4071 if (wcd->master_bias_users <= 0) in wcd9335_enable_mclk()
4072 return -EINVAL; in wcd9335_enable_mclk()
4074 if (((wcd->clk_mclk_users == 0) && (wcd->clk_type == WCD_CLK_MCLK)) || in wcd9335_enable_mclk()
4075 ((wcd->clk_mclk_users > 0) && (wcd->clk_type != WCD_CLK_MCLK))) { in wcd9335_enable_mclk()
4076 dev_err(wcd->dev, "Error enabling MCLK, clk_type: %d\n", in wcd9335_enable_mclk()
4077 wcd->clk_type); in wcd9335_enable_mclk()
4078 return -EINVAL; in wcd9335_enable_mclk()
4081 if (++wcd->clk_mclk_users == 1) { in wcd9335_enable_mclk()
4082 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4085 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4088 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4091 regmap_update_bits(wcd->regmap, in wcd9335_enable_mclk()
4095 regmap_update_bits(wcd->regmap, in wcd9335_enable_mclk()
4106 wcd->clk_type = WCD_CLK_MCLK; in wcd9335_enable_mclk()
4111 static int wcd9335_disable_mclk(struct wcd9335_codec *wcd) in wcd9335_disable_mclk()
4113 if (wcd->clk_mclk_users <= 0) in wcd9335_disable_mclk()
4114 return -EINVAL; in wcd9335_disable_mclk()
4116 if (--wcd->clk_mclk_users == 0) { in wcd9335_disable_mclk()
4117 if (wcd->clk_rco_users > 0) { in wcd9335_disable_mclk()
4119 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4122 wcd->clk_type = WCD_CLK_RCO; in wcd9335_disable_mclk()
4124 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4127 wcd->clk_type = WCD_CLK_OFF; in wcd9335_disable_mclk()
4130 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4138 static int wcd9335_disable_master_bias(struct wcd9335_codec *wcd) in wcd9335_disable_master_bias()
4140 if (wcd->master_bias_users <= 0) in wcd9335_disable_master_bias()
4141 return -EINVAL; in wcd9335_disable_master_bias()
4143 wcd->master_bias_users--; in wcd9335_disable_master_bias()
4144 if (wcd->master_bias_users == 0) { in wcd9335_disable_master_bias()
4145 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_disable_master_bias()
4148 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_disable_master_bias()
4155 static int wcd9335_cdc_req_mclk_enable(struct wcd9335_codec *wcd, in wcd9335_cdc_req_mclk_enable()
4158 int ret = 0; in wcd9335_cdc_req_mclk_enable()
4162 ret = clk_prepare_enable(wcd->mclk); in wcd9335_cdc_req_mclk_enable()
4164 dev_err(wcd->dev, "%s: ext clk enable failed\n", in wcd9335_cdc_req_mclk_enable()
4178 clk_disable_unprepare(wcd->mclk); in wcd9335_cdc_req_mclk_enable()
4188 struct snd_soc_component *comp = wcd->component; in wcd9335_codec_apply_sido_voltage()
4189 int vout_d_val; in wcd9335_codec_apply_sido_voltage()
4191 if (req_mv == wcd->sido_voltage) in wcd9335_codec_apply_sido_voltage()
4204 wcd->sido_voltage = req_mv; in wcd9335_codec_apply_sido_voltage()
4210 static int wcd9335_codec_update_sido_voltage(struct wcd9335_codec *wcd, in wcd9335_codec_update_sido_voltage()
4213 int ret = 0; in wcd9335_codec_update_sido_voltage()
4218 dev_err(wcd->dev, "Ext clk enable failed\n"); in wcd9335_codec_update_sido_voltage()
4229 static int _wcd9335_codec_enable_mclk(struct snd_soc_component *component, in _wcd9335_codec_enable_mclk()
4230 int enable) in _wcd9335_codec_enable_mclk()
4232 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in _wcd9335_codec_enable_mclk()
4233 int ret; in _wcd9335_codec_enable_mclk()
4244 wcd->sido_voltage); in _wcd9335_codec_enable_mclk()
4251 static int wcd9335_codec_enable_mclk(struct snd_soc_dapm_widget *w, in wcd9335_codec_enable_mclk()
4252 struct snd_kcontrol *kc, int event) in wcd9335_codec_enable_mclk()
4254 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_mclk()
4287 SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, WCD9335_RX0, 0,
4289 SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, WCD9335_RX1, 0,
4291 SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, WCD9335_RX2, 0,
4293 SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, WCD9335_RX3, 0,
4295 SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, WCD9335_RX4, 0,
4297 SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, WCD9335_RX5, 0,
4299 SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, WCD9335_RX6, 0,
4301 SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, WCD9335_RX7, 0,
4311 SND_SOC_DAPM_MUX_E("RX INT0_2 MUX", WCD9335_CDC_RX0_RX_PATH_MIX_CTL,
4314 SND_SOC_DAPM_MUX_E("RX INT1_2 MUX", WCD9335_CDC_RX1_RX_PATH_MIX_CTL,
4317 SND_SOC_DAPM_MUX_E("RX INT2_2 MUX", WCD9335_CDC_RX2_RX_PATH_MIX_CTL,
4320 SND_SOC_DAPM_MUX_E("RX INT3_2 MUX", WCD9335_CDC_RX3_RX_PATH_MIX_CTL,
4323 SND_SOC_DAPM_MUX_E("RX INT4_2 MUX", WCD9335_CDC_RX4_RX_PATH_MIX_CTL,
4326 SND_SOC_DAPM_MUX_E("RX INT5_2 MUX", WCD9335_CDC_RX5_RX_PATH_MIX_CTL,
4329 SND_SOC_DAPM_MUX_E("RX INT6_2 MUX", WCD9335_CDC_RX6_RX_PATH_MIX_CTL,
4332 SND_SOC_DAPM_MUX_E("RX INT7_2 MUX", WCD9335_CDC_RX7_RX_PATH_MIX_CTL,
4335 SND_SOC_DAPM_MUX_E("RX INT8_2 MUX", WCD9335_CDC_RX8_RX_PATH_MIX_CTL,
4422 SND_SOC_DAPM_MUX("RX INT0 DEM MUX", SND_SOC_NOPM, 0, 0,
4424 SND_SOC_DAPM_MUX("RX INT1 DEM MUX", SND_SOC_NOPM, 0, 0,
4426 SND_SOC_DAPM_MUX("RX INT2 DEM MUX", SND_SOC_NOPM, 0, 0,
4656 SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, WCD9335_TX0, 0,
4658 SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, WCD9335_TX1, 0,
4660 SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, WCD9335_TX2, 0,
4662 SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, WCD9335_TX3, 0,
4664 SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, WCD9335_TX4, 0,
4666 SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, WCD9335_TX5, 0,
4668 SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, WCD9335_TX6, 0,
4670 SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, WCD9335_TX7, 0,
4672 SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, WCD9335_TX8, 0,
4723 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_enable_sido_buck()
4738 wcd->sido_input_src = SIDO_SOURCE_RCO_BG; in wcd9335_enable_sido_buck()
4741 static int wcd9335_enable_efuse_sensing(struct snd_soc_component *comp) in wcd9335_enable_efuse_sensing()
4767 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_init()
4768 int i; in wcd9335_codec_init()
4771 regmap_update_bits(wcd->regmap, WCD9335_CODEC_RPM_CLK_GATE, in wcd9335_codec_init()
4774 regmap_update_bits(wcd->regmap, WCD9335_CODEC_RPM_CLK_MCLK_CFG, in wcd9335_codec_init()
4787 static int wcd9335_codec_probe(struct snd_soc_component *component) in wcd9335_codec_probe()
4789 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_probe()
4790 int ret; in wcd9335_codec_probe()
4791 int i; in wcd9335_codec_probe()
4793 snd_soc_component_init_regmap(component, wcd->regmap); in wcd9335_codec_probe()
4794 /* Class-H Init*/ in wcd9335_codec_probe()
4795 wcd->clsh_ctrl = wcd_clsh_ctrl_alloc(component, WCD9335); in wcd9335_codec_probe()
4796 if (IS_ERR(wcd->clsh_ctrl)) in wcd9335_codec_probe()
4797 return PTR_ERR(wcd->clsh_ctrl); in wcd9335_codec_probe()
4799 /* Default HPH Mode to Class-H HiFi */ in wcd9335_codec_probe()
4800 wcd->hph_mode = CLS_H_HIFI; in wcd9335_codec_probe()
4801 wcd->component = component; in wcd9335_codec_probe()
4806 INIT_LIST_HEAD(&wcd->dai[i].slim_ch_list); in wcd9335_codec_probe()
4815 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd9335_codec_probe()
4821 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_remove()
4823 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd9335_codec_remove()
4827 static int wcd9335_codec_set_sysclk(struct snd_soc_component *comp, in wcd9335_codec_set_sysclk()
4828 int clk_id, int source, in wcd9335_codec_set_sysclk()
4829 unsigned int freq, int dir) in wcd9335_codec_set_sysclk()
4831 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_set_sysclk()
4833 wcd->mclk_rate = freq; in wcd9335_codec_set_sysclk()
4835 if (wcd->mclk_rate == WCD9335_MCLK_CLK_12P288MHZ) in wcd9335_codec_set_sysclk()
4840 else if (wcd->mclk_rate == WCD9335_MCLK_CLK_9P6MHZ) in wcd9335_codec_set_sysclk()
4846 return clk_set_rate(wcd->mclk, freq); in wcd9335_codec_set_sysclk()
4862 static int wcd9335_probe(struct wcd9335_codec *wcd) in wcd9335_probe()
4864 struct device *dev = wcd->dev; in wcd9335_probe()
4866 memcpy(wcd->rx_chs, wcd9335_rx_chs, sizeof(wcd9335_rx_chs)); in wcd9335_probe()
4867 memcpy(wcd->tx_chs, wcd9335_tx_chs, sizeof(wcd9335_tx_chs)); in wcd9335_probe()
4869 wcd->sido_input_src = SIDO_SOURCE_INTERNAL; in wcd9335_probe()
4870 wcd->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV; in wcd9335_probe()
4890 static bool wcd9335_is_volatile_register(struct device *dev, unsigned int reg) in wcd9335_is_volatile_register()
4922 .name = "WCD9335-IFC-DEV",
4955 static const unsigned int wcd9335_config_regs[] = {
4973 static int wcd9335_parse_dt(struct wcd9335_codec *wcd) in wcd9335_parse_dt()
4975 struct device *dev = wcd->dev; in wcd9335_parse_dt()
4976 struct device_node *np = dev->of_node; in wcd9335_parse_dt()
4977 int ret; in wcd9335_parse_dt()
4979 wcd->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0); in wcd9335_parse_dt()
4980 if (wcd->reset_gpio < 0) in wcd9335_parse_dt()
4981 return dev_err_probe(dev, wcd->reset_gpio, "Reset GPIO missing from DT\n"); in wcd9335_parse_dt()
4983 wcd->mclk = devm_clk_get(dev, "mclk"); in wcd9335_parse_dt()
4984 if (IS_ERR(wcd->mclk)) in wcd9335_parse_dt()
4985 return dev_err_probe(dev, PTR_ERR(wcd->mclk), "mclk not found\n"); in wcd9335_parse_dt()
4987 wcd->native_clk = devm_clk_get(dev, "slimbus"); in wcd9335_parse_dt()
4988 if (IS_ERR(wcd->native_clk)) in wcd9335_parse_dt()
4989 return dev_err_probe(dev, PTR_ERR(wcd->native_clk), "slimbus clock not found\n"); in wcd9335_parse_dt()
4991 wcd->supplies[0].supply = "vdd-buck"; in wcd9335_parse_dt()
4992 wcd->supplies[1].supply = "vdd-buck-sido"; in wcd9335_parse_dt()
4993 wcd->supplies[2].supply = "vdd-tx"; in wcd9335_parse_dt()
4994 wcd->supplies[3].supply = "vdd-rx"; in wcd9335_parse_dt()
4995 wcd->supplies[4].supply = "vdd-io"; in wcd9335_parse_dt()
4997 ret = regulator_bulk_get(dev, WCD9335_MAX_SUPPLY, wcd->supplies); in wcd9335_parse_dt()
5004 static int wcd9335_power_on_reset(struct wcd9335_codec *wcd) in wcd9335_power_on_reset()
5006 struct device *dev = wcd->dev; in wcd9335_power_on_reset()
5007 int ret; in wcd9335_power_on_reset()
5009 ret = regulator_bulk_enable(WCD9335_MAX_SUPPLY, wcd->supplies); in wcd9335_power_on_reset()
5024 gpio_direction_output(wcd->reset_gpio, 0); in wcd9335_power_on_reset()
5026 gpio_set_value(wcd->reset_gpio, 1); in wcd9335_power_on_reset()
5032 static int wcd9335_bring_up(struct wcd9335_codec *wcd) in wcd9335_bring_up()
5034 struct regmap *rm = wcd->regmap; in wcd9335_bring_up()
5035 int val, byte0; in wcd9335_bring_up()
5041 dev_err(wcd->dev, "WCD9335 CODEC version detection fail!\n"); in wcd9335_bring_up()
5042 return -EINVAL; in wcd9335_bring_up()
5046 dev_info(wcd->dev, "WCD9335 CODEC version is v2.0\n"); in wcd9335_bring_up()
5056 dev_err(wcd->dev, "WCD9335 CODEC version not supported\n"); in wcd9335_bring_up()
5057 return -EINVAL; in wcd9335_bring_up()
5063 static int wcd9335_irq_init(struct wcd9335_codec *wcd) in wcd9335_irq_init()
5065 int ret; in wcd9335_irq_init()
5072 wcd->intr1 = of_irq_get_byname(wcd->dev->of_node, "intr1"); in wcd9335_irq_init()
5073 if (wcd->intr1 < 0) in wcd9335_irq_init()
5074 return dev_err_probe(wcd->dev, wcd->intr1, in wcd9335_irq_init()
5077 ret = devm_regmap_add_irq_chip(wcd->dev, wcd->regmap, wcd->intr1, in wcd9335_irq_init()
5079 &wcd9335_regmap_irq1_chip, &wcd->irq_data); in wcd9335_irq_init()
5081 return dev_err_probe(wcd->dev, ret, "Failed to register IRQ chip\n"); in wcd9335_irq_init()
5086 static int wcd9335_slim_probe(struct slim_device *slim) in wcd9335_slim_probe()
5088 struct device *dev = &slim->dev; in wcd9335_slim_probe()
5090 int ret; in wcd9335_slim_probe()
5094 return -ENOMEM; in wcd9335_slim_probe()
5096 wcd->dev = dev; in wcd9335_slim_probe()
5110 static int wcd9335_slim_status(struct slim_device *sdev, in wcd9335_slim_status()
5113 struct device *dev = &sdev->dev; in wcd9335_slim_status()
5116 int ret; in wcd9335_slim_status()
5120 ifc_dev_np = of_parse_phandle(dev->of_node, "slim-ifc-dev", 0); in wcd9335_slim_status()
5123 return -EINVAL; in wcd9335_slim_status()
5126 wcd->slim = sdev; in wcd9335_slim_status()
5127 wcd->slim_ifc_dev = of_slim_get_device(sdev->ctrl, ifc_dev_np); in wcd9335_slim_status()
5129 if (!wcd->slim_ifc_dev) { in wcd9335_slim_status()
5131 return -EINVAL; in wcd9335_slim_status()
5134 slim_get_logical_addr(wcd->slim_ifc_dev); in wcd9335_slim_status()
5136 wcd->regmap = regmap_init_slimbus(sdev, &wcd9335_regmap_config); in wcd9335_slim_status()
5137 if (IS_ERR(wcd->regmap)) in wcd9335_slim_status()
5138 return dev_err_probe(dev, PTR_ERR(wcd->regmap), in wcd9335_slim_status()
5141 wcd->if_regmap = regmap_init_slimbus(wcd->slim_ifc_dev, in wcd9335_slim_status()
5143 if (IS_ERR(wcd->if_regmap)) in wcd9335_slim_status()
5144 return dev_err_probe(dev, PTR_ERR(wcd->if_regmap), in wcd9335_slim_status()
5170 .name = "wcd9335-slim",