Lines Matching +full:slim +full:- +full:ifc +full:- +full:dev

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
18 #include <sound/soc-dapm.h>
25 #include "wcd-clsh-v2.h"
27 #include <dt-bindings/sound/qcom,wcd9335.h>
98 #define WCD9335_CALCULATE_VOUT_D(req_mv) (((req_mv - 650) * 10) / 25)
101 {"RX INT" #id "_1 MIX1 INP0", "RX0", "SLIM RX0"}, \
102 {"RX INT" #id "_1 MIX1 INP0", "RX1", "SLIM RX1"}, \
103 {"RX INT" #id "_1 MIX1 INP0", "RX2", "SLIM RX2"}, \
104 {"RX INT" #id "_1 MIX1 INP0", "RX3", "SLIM RX3"}, \
105 {"RX INT" #id "_1 MIX1 INP0", "RX4", "SLIM RX4"}, \
106 {"RX INT" #id "_1 MIX1 INP0", "RX5", "SLIM RX5"}, \
107 {"RX INT" #id "_1 MIX1 INP0", "RX6", "SLIM RX6"}, \
108 {"RX INT" #id "_1 MIX1 INP0", "RX7", "SLIM RX7"}, \
109 {"RX INT" #id "_1 MIX1 INP1", "RX0", "SLIM RX0"}, \
110 {"RX INT" #id "_1 MIX1 INP1", "RX1", "SLIM RX1"}, \
111 {"RX INT" #id "_1 MIX1 INP1", "RX2", "SLIM RX2"}, \
112 {"RX INT" #id "_1 MIX1 INP1", "RX3", "SLIM RX3"}, \
113 {"RX INT" #id "_1 MIX1 INP1", "RX4", "SLIM RX4"}, \
114 {"RX INT" #id "_1 MIX1 INP1", "RX5", "SLIM RX5"}, \
115 {"RX INT" #id "_1 MIX1 INP1", "RX6", "SLIM RX6"}, \
116 {"RX INT" #id "_1 MIX1 INP1", "RX7", "SLIM RX7"}, \
117 {"RX INT" #id "_1 MIX1 INP2", "RX0", "SLIM RX0"}, \
118 {"RX INT" #id "_1 MIX1 INP2", "RX1", "SLIM RX1"}, \
119 {"RX INT" #id "_1 MIX1 INP2", "RX2", "SLIM RX2"}, \
120 {"RX INT" #id "_1 MIX1 INP2", "RX3", "SLIM RX3"}, \
121 {"RX INT" #id "_1 MIX1 INP2", "RX4", "SLIM RX4"}, \
122 {"RX INT" #id "_1 MIX1 INP2", "RX5", "SLIM RX5"}, \
123 {"RX INT" #id "_1 MIX1 INP2", "RX6", "SLIM RX6"}, \
124 {"RX INT" #id "_1 MIX1 INP2", "RX7", "SLIM RX7"}, \
125 {"RX INT" #id "_2 MUX", "RX0", "SLIM RX0"}, \
126 {"RX INT" #id "_2 MUX", "RX1", "SLIM RX1"}, \
127 {"RX INT" #id "_2 MUX", "RX2", "SLIM RX2"}, \
128 {"RX INT" #id "_2 MUX", "RX3", "SLIM RX3"}, \
129 {"RX INT" #id "_2 MUX", "RX4", "SLIM RX4"}, \
130 {"RX INT" #id "_2 MUX", "RX5", "SLIM RX5"}, \
131 {"RX INT" #id "_2 MUX", "RX6", "SLIM RX6"}, \
132 {"RX INT" #id "_2 MUX", "RX7", "SLIM RX7"}, \
142 {"AIF1_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id " MUX"}, \
143 {"AIF2_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id " MUX"}, \
144 {"AIF3_CAP Mixer", "SLIM TX" #id, "SLIM TX" #id " MUX"}, \
145 {"SLIM TX" #id " MUX", "DEC" #id, "ADC MUX" #id}, \
296 struct device *dev; member
302 struct slim_device *slim; member
409 {24000, -EINVAL},/* 24K */
551 "Class H Invalid", "Class-H Hi-Fi", "Class-H Low Power", "Class-AB",
552 "Class-H Hi-Fi Low Power"
612 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
1234 SOC_DAPM_ENUM("SLIM TX0 MUX Mux", sb_tx0_mux_enum);
1237 SOC_DAPM_ENUM("SLIM TX1 MUX Mux", sb_tx1_mux_enum);
1240 SOC_DAPM_ENUM("SLIM TX2 MUX Mux", sb_tx2_mux_enum);
1243 SOC_DAPM_ENUM("SLIM TX3 MUX Mux", sb_tx3_mux_enum);
1246 SOC_DAPM_ENUM("SLIM TX4 MUX Mux", sb_tx4_mux_enum);
1249 SOC_DAPM_ENUM("SLIM TX5 MUX Mux", sb_tx5_mux_enum);
1252 SOC_DAPM_ENUM("SLIM TX6 MUX Mux", sb_tx6_mux_enum);
1255 SOC_DAPM_ENUM("SLIM TX7 MUX Mux", sb_tx7_mux_enum);
1258 SOC_DAPM_ENUM("SLIM TX8 MUX Mux", sb_tx8_mux_enum);
1264 struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_get()
1265 u32 port_id = w->shift; in slim_rx_mux_get()
1267 ucontrol->value.enumerated.item[0] = wcd->rx_port_value[port_id]; in slim_rx_mux_get()
1276 struct wcd9335_codec *wcd = dev_get_drvdata(w->dapm->dev); in slim_rx_mux_put()
1277 struct soc_enum *e = (struct soc_enum *)kc->private_value; in slim_rx_mux_put()
1279 u32 port_id = w->shift; in slim_rx_mux_put()
1281 if (wcd->rx_port_value[port_id] == ucontrol->value.enumerated.item[0]) in slim_rx_mux_put()
1284 wcd->rx_port_value[port_id] = ucontrol->value.enumerated.item[0]; in slim_rx_mux_put()
1287 list_del_init(&wcd->rx_chs[port_id].list); in slim_rx_mux_put()
1289 switch (wcd->rx_port_value[port_id]) { in slim_rx_mux_put()
1294 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1295 &wcd->dai[AIF1_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[AIF2_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[AIF3_PB].slim_ch_list); in slim_rx_mux_put()
1306 list_add_tail(&wcd->rx_chs[port_id].list, in slim_rx_mux_put()
1307 &wcd->dai[AIF4_PB].slim_ch_list); in slim_rx_mux_put()
1310 dev_err(wcd->dev, "Unknown AIF %d\n", wcd->rx_port_value[port_id]); in slim_rx_mux_put()
1314 snd_soc_dapm_mux_update_power(w->dapm, kc, wcd->rx_port_value[port_id], in slim_rx_mux_put()
1319 return -EINVAL; in slim_rx_mux_put()
1327 struct wcd9335_codec *wcd = dev_get_drvdata(dapm->dev); in slim_tx_mixer_get()
1330 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_get()
1331 int dai_id = widget->shift; in slim_tx_mixer_get()
1332 int port_id = mixer->shift; in slim_tx_mixer_get()
1334 ucontrol->value.integer.value[0] = wcd->tx_port_value[port_id] == dai_id; in slim_tx_mixer_get()
1344 struct wcd9335_codec *wcd = dev_get_drvdata(widget->dapm->dev); in slim_tx_mixer_put()
1347 (struct soc_mixer_control *)kc->private_value; in slim_tx_mixer_put()
1348 int enable = ucontrol->value.integer.value[0]; in slim_tx_mixer_put()
1349 int dai_id = widget->shift; in slim_tx_mixer_put()
1350 int port_id = mixer->shift; in slim_tx_mixer_put()
1357 if (enable && wcd->tx_port_value[port_id] != dai_id) { in slim_tx_mixer_put()
1358 wcd->tx_port_value[port_id] = dai_id; in slim_tx_mixer_put()
1359 list_add_tail(&wcd->tx_chs[port_id].list, in slim_tx_mixer_put()
1360 &wcd->dai[dai_id].slim_ch_list); in slim_tx_mixer_put()
1361 } else if (!enable && wcd->tx_port_value[port_id] == dai_id) { in slim_tx_mixer_put()
1362 wcd->tx_port_value[port_id] = -1; in slim_tx_mixer_put()
1363 list_del_init(&wcd->tx_chs[port_id].list); in slim_tx_mixer_put()
1367 dev_err(wcd->dev, "Unknown AIF %d\n", dai_id); in slim_tx_mixer_put()
1368 return -EINVAL; in slim_tx_mixer_put()
1371 snd_soc_dapm_mixer_update_power(widget->dapm, kc, enable, update); in slim_tx_mixer_put()
1377 SOC_DAPM_ENUM_EXT("SLIM RX0 Mux", slim_rx_mux_enum,
1379 SOC_DAPM_ENUM_EXT("SLIM RX1 Mux", slim_rx_mux_enum,
1381 SOC_DAPM_ENUM_EXT("SLIM RX2 Mux", slim_rx_mux_enum,
1383 SOC_DAPM_ENUM_EXT("SLIM RX3 Mux", slim_rx_mux_enum,
1385 SOC_DAPM_ENUM_EXT("SLIM RX4 Mux", slim_rx_mux_enum,
1387 SOC_DAPM_ENUM_EXT("SLIM RX5 Mux", slim_rx_mux_enum,
1389 SOC_DAPM_ENUM_EXT("SLIM RX6 Mux", slim_rx_mux_enum,
1391 SOC_DAPM_ENUM_EXT("SLIM RX7 Mux", slim_rx_mux_enum,
1396 SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD9335_TX0, 1, 0,
1398 SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD9335_TX1, 1, 0,
1400 SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD9335_TX2, 1, 0,
1402 SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD9335_TX3, 1, 0,
1404 SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD9335_TX4, 1, 0,
1406 SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD9335_TX5, 1, 0,
1408 SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD9335_TX6, 1, 0,
1410 SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD9335_TX7, 1, 0,
1412 SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD9335_TX8, 1, 0,
1414 SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, WCD9335_TX9, 1, 0,
1416 SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, WCD9335_TX10, 1, 0,
1418 SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, WCD9335_TX11, 1, 0,
1420 SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD9335_TX13, 1, 0,
1425 SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD9335_TX0, 1, 0,
1427 SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD9335_TX1, 1, 0,
1429 SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD9335_TX2, 1, 0,
1431 SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD9335_TX3, 1, 0,
1433 SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD9335_TX4, 1, 0,
1435 SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD9335_TX5, 1, 0,
1437 SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD9335_TX6, 1, 0,
1439 SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD9335_TX7, 1, 0,
1441 SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD9335_TX8, 1, 0,
1443 SOC_SINGLE_EXT("SLIM TX9", SND_SOC_NOPM, WCD9335_TX9, 1, 0,
1445 SOC_SINGLE_EXT("SLIM TX10", SND_SOC_NOPM, WCD9335_TX10, 1, 0,
1447 SOC_SINGLE_EXT("SLIM TX11", SND_SOC_NOPM, WCD9335_TX11, 1, 0,
1449 SOC_SINGLE_EXT("SLIM TX13", SND_SOC_NOPM, WCD9335_TX13, 1, 0,
1454 SOC_SINGLE_EXT("SLIM TX0", SND_SOC_NOPM, WCD9335_TX0, 1, 0,
1456 SOC_SINGLE_EXT("SLIM TX1", SND_SOC_NOPM, WCD9335_TX1, 1, 0,
1458 SOC_SINGLE_EXT("SLIM TX2", SND_SOC_NOPM, WCD9335_TX2, 1, 0,
1460 SOC_SINGLE_EXT("SLIM TX3", SND_SOC_NOPM, WCD9335_TX3, 1, 0,
1462 SOC_SINGLE_EXT("SLIM TX4", SND_SOC_NOPM, WCD9335_TX4, 1, 0,
1464 SOC_SINGLE_EXT("SLIM TX5", SND_SOC_NOPM, WCD9335_TX5, 1, 0,
1466 SOC_SINGLE_EXT("SLIM TX6", SND_SOC_NOPM, WCD9335_TX6, 1, 0,
1468 SOC_SINGLE_EXT("SLIM TX7", SND_SOC_NOPM, WCD9335_TX7, 1, 0,
1470 SOC_SINGLE_EXT("SLIM TX8", SND_SOC_NOPM, WCD9335_TX8, 1, 0,
1479 struct soc_enum *e = (struct soc_enum *)kc->private_value; in wcd9335_put_dec_enum()
1482 val = ucontrol->value.enumerated.item[0]; in wcd9335_put_dec_enum()
1484 switch (e->reg) { in wcd9335_put_dec_enum()
1513 return -EINVAL; in wcd9335_put_dec_enum()
1528 struct soc_enum *e = (struct soc_enum *)kc->private_value; in wcd9335_int_dem_inp_mux_put()
1533 val = ucontrol->value.enumerated.item[0]; in wcd9335_int_dem_inp_mux_put()
1535 if (e->reg == WCD9335_CDC_RX0_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1537 else if (e->reg == WCD9335_CDC_RX1_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1539 else if (e->reg == WCD9335_CDC_RX2_RX_PATH_SEC0) in wcd9335_int_dem_inp_mux_put()
1542 return -EINVAL; in wcd9335_int_dem_inp_mux_put()
1616 struct snd_soc_component *component = dai->component; in wcd9335_set_mix_interpolator_rate()
1617 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_set_mix_interpolator_rate()
1621 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_mix_interpolator_rate()
1627 if (val == (ch->shift + INTn_2_INP_SEL_RX0)) in wcd9335_set_mix_interpolator_rate()
1642 struct snd_soc_component *comp = dai->component; in wcd9335_set_prim_interpolator_rate()
1643 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_set_prim_interpolator_rate()
1648 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_prim_interpolator_rate()
1649 inp = ch->shift + INTn_1_MIX_INP_SEL_RX0; in wcd9335_set_prim_interpolator_rate()
1652 * to which interpolator input, the slim rx port in wcd9335_set_prim_interpolator_rate()
1672 dev_info(wcd->dev, in wcd9335_set_prim_interpolator_rate()
1715 struct list_head *slim_ch_list = &dai_data->slim_ch_list; in wcd9335_slim_set_hw_params()
1716 struct slim_stream_config *cfg = &dai_data->sconfig; in wcd9335_slim_set_hw_params()
1721 cfg->ch_count = 0; in wcd9335_slim_set_hw_params()
1722 cfg->direction = direction; in wcd9335_slim_set_hw_params()
1723 cfg->port_mask = 0; in wcd9335_slim_set_hw_params()
1727 cfg->ch_count++; in wcd9335_slim_set_hw_params()
1728 payload |= 1 << ch->shift; in wcd9335_slim_set_hw_params()
1729 cfg->port_mask |= BIT(ch->port); in wcd9335_slim_set_hw_params()
1732 cfg->chs = kcalloc(cfg->ch_count, sizeof(unsigned int), GFP_KERNEL); in wcd9335_slim_set_hw_params()
1733 if (!cfg->chs) in wcd9335_slim_set_hw_params()
1734 return -ENOMEM; in wcd9335_slim_set_hw_params()
1738 cfg->chs[i++] = ch->ch_num; in wcd9335_slim_set_hw_params()
1741 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1742 WCD9335_SLIM_PGD_RX_PORT_MULTI_CHNL_0(ch->port), in wcd9335_slim_set_hw_params()
1749 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1750 WCD9335_SLIM_PGD_RX_PORT_CFG(ch->port), in wcd9335_slim_set_hw_params()
1755 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1756 WCD9335_SLIM_PGD_TX_PORT_MULTI_CHNL_0(ch->port), in wcd9335_slim_set_hw_params()
1762 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1763 WCD9335_SLIM_PGD_TX_PORT_MULTI_CHNL_1(ch->port), in wcd9335_slim_set_hw_params()
1769 ret = regmap_write(wcd->if_regmap, in wcd9335_slim_set_hw_params()
1770 WCD9335_SLIM_PGD_TX_PORT_CFG(ch->port), in wcd9335_slim_set_hw_params()
1778 dai_data->sruntime = slim_stream_allocate(wcd->slim, "WCD9335-SLIM"); in wcd9335_slim_set_hw_params()
1783 dev_err(wcd->dev, "Error Setting slim hw params\n"); in wcd9335_slim_set_hw_params()
1784 kfree(cfg->chs); in wcd9335_slim_set_hw_params()
1785 cfg->chs = NULL; in wcd9335_slim_set_hw_params()
1793 struct snd_soc_component *comp = dai->component; in wcd9335_set_decimator_rate()
1798 int decimator = -1; in wcd9335_set_decimator_rate()
1800 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) { in wcd9335_set_decimator_rate()
1801 tx_port = ch->port; in wcd9335_set_decimator_rate()
1803 dev_err(wcd->dev, "Invalid SLIM TX%u port DAI ID:%d\n", in wcd9335_set_decimator_rate()
1804 tx_port, dai->id); in wcd9335_set_decimator_rate()
1805 return -EINVAL; in wcd9335_set_decimator_rate()
1807 /* Find the SB TX MUX input - which decimator is connected */ in wcd9335_set_decimator_rate()
1814 shift = ((tx_port - 4) << 1); in wcd9335_set_decimator_rate()
1818 shift = ((tx_port - 8) << 1); in wcd9335_set_decimator_rate()
1842 decimator = tx_mux_sel - 1; in wcd9335_set_decimator_rate()
1855 dev_err(wcd->dev, "RX_MIX_TX%u going to SLIM TX%u\n", in wcd9335_set_decimator_rate()
1858 dev_err(wcd->dev, "ERROR: Invalid decimator: %d\n", in wcd9335_set_decimator_rate()
1860 return -EINVAL; in wcd9335_set_decimator_rate()
1874 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_hw_params()
1876 switch (substream->stream) { in wcd9335_hw_params()
1880 dev_err(wcd->dev, "cannot set sample rate: %u\n", in wcd9335_hw_params()
1886 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd9335_hw_params()
1889 dev_err(wcd->dev, "%s: Invalid format 0x%x\n", in wcd9335_hw_params()
1891 return -EINVAL; in wcd9335_hw_params()
1919 dev_err(wcd->dev, "%s: Invalid TX sample rate: %d\n", in wcd9335_hw_params()
1921 return -EINVAL; in wcd9335_hw_params()
1928 dev_err(wcd->dev, "Cannot set TX Decimator rate\n"); in wcd9335_hw_params()
1933 wcd->dai[dai->id].sconfig.bps = params_width(params); in wcd9335_hw_params()
1936 dev_err(wcd->dev, "%s: Invalid format 0x%x\n", in wcd9335_hw_params()
1938 return -EINVAL; in wcd9335_hw_params()
1942 dev_err(wcd->dev, "Invalid stream type %d\n", in wcd9335_hw_params()
1943 substream->stream); in wcd9335_hw_params()
1944 return -EINVAL; in wcd9335_hw_params()
1947 wcd->dai[dai->id].sconfig.rate = params_rate(params); in wcd9335_hw_params()
1948 wcd9335_slim_set_hw_params(wcd, &wcd->dai[dai->id], substream->stream); in wcd9335_hw_params()
1960 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_trigger()
1962 dai_data = &wcd->dai[dai->id]; in wcd9335_trigger()
1968 cfg = &dai_data->sconfig; in wcd9335_trigger()
1969 slim_stream_prepare(dai_data->sruntime, cfg); in wcd9335_trigger()
1970 slim_stream_enable(dai_data->sruntime); in wcd9335_trigger()
1975 slim_stream_disable(dai_data->sruntime); in wcd9335_trigger()
1976 slim_stream_unprepare(dai_data->sruntime); in wcd9335_trigger()
1992 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_set_channel_map()
1995 dev_err(wcd->dev, "Invalid tx_slot=%p, rx_slot=%p\n", in wcd9335_set_channel_map()
1997 return -EINVAL; in wcd9335_set_channel_map()
2000 wcd->num_rx_port = rx_num; in wcd9335_set_channel_map()
2002 wcd->rx_chs[i].ch_num = rx_slot[i]; in wcd9335_set_channel_map()
2003 INIT_LIST_HEAD(&wcd->rx_chs[i].list); in wcd9335_set_channel_map()
2006 wcd->num_tx_port = tx_num; in wcd9335_set_channel_map()
2008 wcd->tx_chs[i].ch_num = tx_slot[i]; in wcd9335_set_channel_map()
2009 INIT_LIST_HEAD(&wcd->tx_chs[i].list); in wcd9335_set_channel_map()
2023 wcd = snd_soc_component_get_drvdata(dai->component); in wcd9335_get_channel_map()
2025 switch (dai->id) { in wcd9335_get_channel_map()
2031 dev_err(wcd->dev, "Invalid rx_slot %p or rx_num %p\n", in wcd9335_get_channel_map()
2033 return -EINVAL; in wcd9335_get_channel_map()
2036 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd9335_get_channel_map()
2037 rx_slot[i++] = ch->ch_num; in wcd9335_get_channel_map()
2045 dev_err(wcd->dev, "Invalid tx_slot %p or tx_num %p\n", in wcd9335_get_channel_map()
2047 return -EINVAL; in wcd9335_get_channel_map()
2049 list_for_each_entry(ch, &wcd->dai[dai->id].slim_ch_list, list) in wcd9335_get_channel_map()
2050 tx_slot[i++] = ch->ch_num; in wcd9335_get_channel_map()
2055 dev_err(wcd->dev, "Invalid DAI ID %x\n", dai->id); in wcd9335_get_channel_map()
2179 int comp = ((struct soc_mixer_control *)kc->private_value)->shift; in wcd9335_get_compander()
2180 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_get_compander()
2182 ucontrol->value.integer.value[0] = wcd->comp_enabled[comp]; in wcd9335_get_compander()
2190 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_set_compander()
2191 int comp = ((struct soc_mixer_control *) kc->private_value)->shift; in wcd9335_set_compander()
2192 int value = ucontrol->value.integer.value[0]; in wcd9335_set_compander()
2195 wcd->comp_enabled[comp] = value; in wcd9335_set_compander()
2229 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_rx_hph_mode_get()
2231 ucontrol->value.enumerated.item[0] = wcd->hph_mode; in wcd9335_rx_hph_mode_get()
2240 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_rx_hph_mode_put()
2243 mode_val = ucontrol->value.enumerated.item[0]; in wcd9335_rx_hph_mode_put()
2246 dev_err(wcd->dev, "Invalid HPH Mode, default to ClSH HiFi\n"); in wcd9335_rx_hph_mode_put()
2249 wcd->hph_mode = mode_val; in wcd9335_rx_hph_mode_put()
2255 /* -84dB min - 40dB max */
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),
2291 -84, 40, digital_gain),
2370 {"SLIM RX0 MUX", "AIF1_PB", "AIF1 PB"},
2371 {"SLIM RX1 MUX", "AIF1_PB", "AIF1 PB"},
2372 {"SLIM RX2 MUX", "AIF1_PB", "AIF1 PB"},
2373 {"SLIM RX3 MUX", "AIF1_PB", "AIF1 PB"},
2374 {"SLIM RX4 MUX", "AIF1_PB", "AIF1 PB"},
2375 {"SLIM RX5 MUX", "AIF1_PB", "AIF1 PB"},
2376 {"SLIM RX6 MUX", "AIF1_PB", "AIF1 PB"},
2377 {"SLIM RX7 MUX", "AIF1_PB", "AIF1 PB"},
2379 {"SLIM RX0 MUX", "AIF2_PB", "AIF2 PB"},
2380 {"SLIM RX1 MUX", "AIF2_PB", "AIF2 PB"},
2381 {"SLIM RX2 MUX", "AIF2_PB", "AIF2 PB"},
2382 {"SLIM RX3 MUX", "AIF2_PB", "AIF2 PB"},
2383 {"SLIM RX4 MUX", "AIF2_PB", "AIF2 PB"},
2384 {"SLIM RX5 MUX", "AIF2_PB", "AIF2 PB"},
2385 {"SLIM RX6 MUX", "AIF2_PB", "AIF2 PB"},
2386 {"SLIM RX7 MUX", "AIF2_PB", "AIF2 PB"},
2388 {"SLIM RX0 MUX", "AIF3_PB", "AIF3 PB"},
2389 {"SLIM RX1 MUX", "AIF3_PB", "AIF3 PB"},
2390 {"SLIM RX2 MUX", "AIF3_PB", "AIF3 PB"},
2391 {"SLIM RX3 MUX", "AIF3_PB", "AIF3 PB"},
2392 {"SLIM RX4 MUX", "AIF3_PB", "AIF3 PB"},
2393 {"SLIM RX5 MUX", "AIF3_PB", "AIF3 PB"},
2394 {"SLIM RX6 MUX", "AIF3_PB", "AIF3 PB"},
2395 {"SLIM RX7 MUX", "AIF3_PB", "AIF3 PB"},
2397 {"SLIM RX0 MUX", "AIF4_PB", "AIF4 PB"},
2398 {"SLIM RX1 MUX", "AIF4_PB", "AIF4 PB"},
2399 {"SLIM RX2 MUX", "AIF4_PB", "AIF4 PB"},
2400 {"SLIM RX3 MUX", "AIF4_PB", "AIF4 PB"},
2401 {"SLIM RX4 MUX", "AIF4_PB", "AIF4 PB"},
2402 {"SLIM RX5 MUX", "AIF4_PB", "AIF4 PB"},
2403 {"SLIM RX6 MUX", "AIF4_PB", "AIF4 PB"},
2404 {"SLIM RX7 MUX", "AIF4_PB", "AIF4 PB"},
2406 {"SLIM RX0", NULL, "SLIM RX0 MUX"},
2407 {"SLIM RX1", NULL, "SLIM RX1 MUX"},
2408 {"SLIM RX2", NULL, "SLIM RX2 MUX"},
2409 {"SLIM RX3", NULL, "SLIM RX3 MUX"},
2410 {"SLIM RX4", NULL, "SLIM RX4 MUX"},
2411 {"SLIM RX5", NULL, "SLIM RX5 MUX"},
2412 {"SLIM RX6", NULL, "SLIM RX6 MUX"},
2413 {"SLIM RX7", NULL, "SLIM RX7 MUX"},
2499 int micb_index = micb_num - 1; in wcd9335_micbias_control()
2502 if ((micb_index < 0) || (micb_index > WCD9335_MAX_MICBIAS - 1)) { in wcd9335_micbias_control()
2503 dev_err(wcd->dev, "Invalid micbias index, micb_ind:%d\n", in wcd9335_micbias_control()
2505 return -EINVAL; in wcd9335_micbias_control()
2522 dev_err(component->dev, "%s: Invalid micbias number: %d\n", in wcd9335_micbias_control()
2524 return -EINVAL; in wcd9335_micbias_control()
2529 wcd->pullup_ref[micb_index]++; in wcd9335_micbias_control()
2530 if ((wcd->pullup_ref[micb_index] == 1) && in wcd9335_micbias_control()
2531 (wcd->micb_ref[micb_index] == 0)) in wcd9335_micbias_control()
2536 wcd->pullup_ref[micb_index]--; in wcd9335_micbias_control()
2537 if ((wcd->pullup_ref[micb_index] == 0) && in wcd9335_micbias_control()
2538 (wcd->micb_ref[micb_index] == 0)) in wcd9335_micbias_control()
2543 wcd->micb_ref[micb_index]++; in wcd9335_micbias_control()
2544 if (wcd->micb_ref[micb_index] == 1) in wcd9335_micbias_control()
2549 wcd->micb_ref[micb_index]--; in wcd9335_micbias_control()
2550 if ((wcd->micb_ref[micb_index] == 0) && in wcd9335_micbias_control()
2551 (wcd->pullup_ref[micb_index] > 0)) in wcd9335_micbias_control()
2554 else if ((wcd->micb_ref[micb_index] == 0) && in wcd9335_micbias_control()
2555 (wcd->pullup_ref[micb_index] == 0)) { in wcd9335_micbias_control()
2568 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in __wcd9335_codec_enable_micbias()
2571 if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1"))) in __wcd9335_codec_enable_micbias()
2573 else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2"))) in __wcd9335_codec_enable_micbias()
2575 else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3"))) in __wcd9335_codec_enable_micbias()
2577 else if (strnstr(w->name, "MIC BIAS4", sizeof("MIC BIAS4"))) in __wcd9335_codec_enable_micbias()
2580 return -EINVAL; in __wcd9335_codec_enable_micbias()
2638 dev_err(comp->dev, "%s: invalid amic: %d\n", in wcd9335_codec_set_tx_hold()
2647 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_adc()
2651 wcd9335_codec_set_tx_hold(comp, w->reg, true); in wcd9335_codec_enable_adc()
2675 reg = WCD9335_CDC_TX_INP_MUX_ADC_MUX4_CFG0 + adc_mux_n - 4; in wcd9335_codec_find_amic_input()
2707 dev_err(comp->dev, "invalid amic: %d\n", amic); in wcd9335_codec_get_amic_pwlvl_reg()
2717 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_dec()
2728 widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL); in wcd9335_codec_enable_dec()
2730 return -ENOMEM; in wcd9335_codec_enable_dec()
2735 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd9335_codec_enable_dec()
2736 __func__, w->name); in wcd9335_codec_enable_dec()
2737 ret = -EINVAL; in wcd9335_codec_enable_dec()
2744 dev_err(comp->dev, "%s: decimator index not found\n", in wcd9335_codec_enable_dec()
2746 ret = -EINVAL; in wcd9335_codec_enable_dec()
2752 dev_err(comp->dev, "%s: Invalid decimator = %s\n", in wcd9335_codec_enable_dec()
2754 ret = -EINVAL; in wcd9335_codec_enable_dec()
2853 dev_err(component->dev, in wcd9335_get_dmic_clk_val()
2864 dev_err(component->dev, in wcd9335_get_dmic_clk_val()
2891 dev_err(component->dev, in wcd9335_get_dmic_clk_val()
2904 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_dmic()
2914 wname = strpbrk(w->name, "012345"); in wcd9335_codec_enable_dmic()
2916 dev_err(comp->dev, "%s: widget not found\n", __func__); in wcd9335_codec_enable_dmic()
2917 return -EINVAL; in wcd9335_codec_enable_dmic()
2922 dev_err(comp->dev, "%s: Invalid DMIC line on the codec\n", in wcd9335_codec_enable_dmic()
2924 return -EINVAL; in wcd9335_codec_enable_dmic()
2930 dmic_clk_cnt = &(wcd->dmic_0_1_clk_cnt); in wcd9335_codec_enable_dmic()
2935 dmic_clk_cnt = &(wcd->dmic_2_3_clk_cnt); in wcd9335_codec_enable_dmic()
2940 dmic_clk_cnt = &(wcd->dmic_4_5_clk_cnt); in wcd9335_codec_enable_dmic()
2944 dev_err(comp->dev, "%s: Invalid DMIC Selection\n", in wcd9335_codec_enable_dmic()
2946 return -EINVAL; in wcd9335_codec_enable_dmic()
2953 wcd->mclk_rate, in wcd9335_codec_enable_dmic()
2954 wcd->dmic_sample_rate); in wcd9335_codec_enable_dmic()
2969 wcd->mclk_rate, in wcd9335_codec_enable_dmic()
2970 wcd->mad_dmic_sample_rate); in wcd9335_codec_enable_dmic()
2971 (*dmic_clk_cnt)--; in wcd9335_codec_enable_dmic()
2991 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_enable_int_port()
2994 list_for_each_entry(ch, &dai->slim_ch_list, list) { in wcd9335_codec_enable_int_port()
2995 if (ch->port >= WCD9335_RX_START) { in wcd9335_codec_enable_int_port()
2996 port_num = ch->port - WCD9335_RX_START; in wcd9335_codec_enable_int_port()
2999 port_num = ch->port; in wcd9335_codec_enable_int_port()
3003 regmap_read(wcd->if_regmap, reg, &val); in wcd9335_codec_enable_int_port()
3005 regmap_write(wcd->if_regmap, reg, in wcd9335_codec_enable_int_port()
3014 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_slim()
3016 struct wcd_slim_codec_dai_data *dai = &wcd->dai[w->shift]; in wcd9335_codec_enable_slim()
3023 kfree(dai->sconfig.chs); in wcd9335_codec_enable_slim()
3034 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_mix_path()
3039 switch (w->reg) { in wcd9335_codec_enable_mix_path()
3068 dev_err(comp->dev, "%s: No gain register avail for %s\n", in wcd9335_codec_enable_mix_path()
3069 __func__, w->name); in wcd9335_codec_enable_mix_path()
3185 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_prim_interpolator()
3191 wcd->prim_int_users[ind]++; in wcd9335_codec_enable_prim_interpolator()
3192 if (wcd->prim_int_users[ind] == 1) { in wcd9335_codec_enable_prim_interpolator()
3210 wcd->prim_int_users[ind]--; in wcd9335_codec_enable_prim_interpolator()
3211 if (wcd->prim_int_users[ind] == 0) { in wcd9335_codec_enable_prim_interpolator()
3232 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_config_compander()
3240 comp = interp_n - 1; in wcd9335_config_compander()
3241 if (!wcd->comp_enabled[comp]) in wcd9335_config_compander()
3293 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_interpolator()
3299 if (!(strcmp(w->name, "RX INT0 INTERP"))) { in wcd9335_codec_enable_interpolator()
3302 } else if (!(strcmp(w->name, "RX INT1 INTERP"))) { in wcd9335_codec_enable_interpolator()
3305 } else if (!(strcmp(w->name, "RX INT2 INTERP"))) { in wcd9335_codec_enable_interpolator()
3308 } else if (!(strcmp(w->name, "RX INT3 INTERP"))) { in wcd9335_codec_enable_interpolator()
3311 } else if (!(strcmp(w->name, "RX INT4 INTERP"))) { in wcd9335_codec_enable_interpolator()
3314 } else if (!(strcmp(w->name, "RX INT5 INTERP"))) { in wcd9335_codec_enable_interpolator()
3317 } else if (!(strcmp(w->name, "RX INT6 INTERP"))) { in wcd9335_codec_enable_interpolator()
3320 } else if (!(strcmp(w->name, "RX INT7 INTERP"))) { in wcd9335_codec_enable_interpolator()
3323 } else if (!(strcmp(w->name, "RX INT8 INTERP"))) { in wcd9335_codec_enable_interpolator()
3327 dev_err(comp->dev, "%s: Interpolator reg not found\n", in wcd9335_codec_enable_interpolator()
3329 return -EINVAL; in wcd9335_codec_enable_interpolator()
3338 wcd9335_config_compander(comp, w->shift, event); in wcd9335_codec_enable_interpolator()
3344 wcd9335_config_compander(comp, w->shift, event); in wcd9335_codec_enable_interpolator()
3355 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_hph_mode_gain_opt()
3379 wcd->hph_l_gain = hph_l_en & 0x1F; in wcd9335_codec_hph_mode_gain_opt()
3384 wcd->hph_r_gain = hph_r_en & 0x1F; in wcd9335_codec_hph_mode_gain_opt()
3529 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_hphl_dac_event()
3530 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_hphl_dac_event()
3531 int hph_mode = wcd->hph_mode; in wcd9335_codec_hphl_dac_event()
3541 dev_err(comp->dev, "Incorrect DEM Input\n"); in wcd9335_codec_hphl_dac_event()
3542 return -EINVAL; in wcd9335_codec_hphl_dac_event()
3544 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_hphl_dac_event()
3561 if (!(wcd_clsh_ctrl_get_state(wcd->clsh_ctrl) & in wcd9335_codec_hphl_dac_event()
3565 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_hphl_dac_event()
3578 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_lineout_dac_event()
3579 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_lineout_dac_event()
3583 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_lineout_dac_event()
3587 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_lineout_dac_event()
3598 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_ear_dac_event()
3599 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_ear_dac_event()
3603 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_PRE_DAC, in wcd9335_codec_ear_dac_event()
3608 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_ear_dac_event()
3638 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3643 if (wcd->comp_enabled[COMPANDER_1] || in wcd9335_codec_hph_post_pa_config()
3644 wcd->comp_enabled[COMPANDER_2]) { in wcd9335_codec_hph_post_pa_config()
3646 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3650 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3654 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3659 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3662 wcd->hph_l_gain); in wcd9335_codec_hph_post_pa_config()
3663 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3666 wcd->hph_r_gain); in wcd9335_codec_hph_post_pa_config()
3670 snd_soc_component_update_bits(wcd->component, in wcd9335_codec_hph_post_pa_config()
3680 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_hphr_dac_event()
3681 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_hphr_dac_event()
3682 int hph_mode = wcd->hph_mode; in wcd9335_codec_hphr_dac_event()
3694 dev_err(comp->dev, "DEM Input not set correctly, hph_mode: %d\n", in wcd9335_codec_hphr_dac_event()
3696 return -EINVAL; in wcd9335_codec_hphr_dac_event()
3699 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, in wcd9335_codec_hphr_dac_event()
3712 if (!(wcd_clsh_ctrl_get_state(wcd->clsh_ctrl) & in wcd9335_codec_hphr_dac_event()
3716 wcd_clsh_ctrl_set_state(wcd->clsh_ctrl, WCD_CLSH_EVENT_POST_PA, in wcd9335_codec_hphr_dac_event()
3729 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_hphl_pa()
3730 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_hphl_pa()
3731 int hph_mode = wcd->hph_mode; in wcd9335_codec_enable_hphl_pa()
3777 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_lineout_pa()
3780 if (w->reg == WCD9335_ANA_LO_1_2) { in wcd9335_codec_enable_lineout_pa()
3781 if (w->shift == 7) { in wcd9335_codec_enable_lineout_pa()
3784 } else if (w->shift == 6) { in wcd9335_codec_enable_lineout_pa()
3788 } else if (w->reg == WCD9335_ANA_LO_3_4) { in wcd9335_codec_enable_lineout_pa()
3789 if (w->shift == 7) { in wcd9335_codec_enable_lineout_pa()
3792 } else if (w->shift == 6) { in wcd9335_codec_enable_lineout_pa()
3797 dev_err(comp->dev, "Error enabling lineout PA\n"); in wcd9335_codec_enable_lineout_pa()
3798 return -EINVAL; in wcd9335_codec_enable_lineout_pa()
3848 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_rx_bias()
3849 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_rx_bias()
3853 wcd->rx_bias_count++; in wcd9335_codec_enable_rx_bias()
3854 if (wcd->rx_bias_count == 1) { in wcd9335_codec_enable_rx_bias()
3863 wcd->rx_bias_count--; in wcd9335_codec_enable_rx_bias()
3864 if (!wcd->rx_bias_count) in wcd9335_codec_enable_rx_bias()
3878 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_hphr_pa()
3879 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_enable_hphr_pa()
3880 int hph_mode = wcd->hph_mode; in wcd9335_codec_enable_hphr_pa()
3924 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_ear_pa()
3969 regmap_read(wcd->if_regmap, i, &val); in wcd9335_slimbus_irq()
3975 port_id = (tx ? j - 16 : j); in wcd9335_slimbus_irq()
3976 regmap_read(wcd->if_regmap, in wcd9335_slimbus_irq()
3986 wcd->if_regmap, reg, &int_val); in wcd9335_slimbus_irq()
3996 dev_err_ratelimited(wcd->dev, in wcd9335_slimbus_irq()
4001 dev_err_ratelimited(wcd->dev, in wcd9335_slimbus_irq()
4014 wcd->if_regmap, reg, &int_val); in wcd9335_slimbus_irq()
4017 regmap_write(wcd->if_regmap, in wcd9335_slimbus_irq()
4022 regmap_write(wcd->if_regmap, in wcd9335_slimbus_irq()
4035 .name = "SLIM Slave",
4044 irq = regmap_irq_get_virq(wcd->irq_data, wcd9335_irqs[i].irq); in wcd9335_setup_irqs()
4046 dev_err(wcd->dev, "Failed to get %s\n", in wcd9335_setup_irqs()
4051 ret = devm_request_threaded_irq(wcd->dev, irq, NULL, in wcd9335_setup_irqs()
4057 dev_err(wcd->dev, "Failed to request %s\n", in wcd9335_setup_irqs()
4065 regmap_write(wcd->if_regmap, WCD9335_SLIM_PGD_PORT_INT_EN0 + i, in wcd9335_setup_irqs()
4077 regmap_write(wcd->if_regmap, WCD9335_SLIM_PGD_PORT_INT_EN0 + i, in wcd9335_teardown_irqs()
4084 struct snd_soc_component *comp = wcd->component; in wcd9335_cdc_sido_ccl_enable()
4087 if (++wcd->sido_ccl_cnt == 1) in wcd9335_cdc_sido_ccl_enable()
4091 if (wcd->sido_ccl_cnt == 0) { in wcd9335_cdc_sido_ccl_enable()
4092 dev_err(wcd->dev, "sido_ccl already disabled\n"); in wcd9335_cdc_sido_ccl_enable()
4095 if (--wcd->sido_ccl_cnt == 0) in wcd9335_cdc_sido_ccl_enable()
4103 wcd->master_bias_users++; in wcd9335_enable_master_bias()
4104 if (wcd->master_bias_users == 1) { in wcd9335_enable_master_bias()
4105 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4108 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4112 * 1ms delay is required after pre-charge is enabled in wcd9335_enable_master_bias()
4116 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4119 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_enable_master_bias()
4130 if (wcd->master_bias_users <= 0) in wcd9335_enable_mclk()
4131 return -EINVAL; in wcd9335_enable_mclk()
4133 if (((wcd->clk_mclk_users == 0) && (wcd->clk_type == WCD_CLK_MCLK)) || in wcd9335_enable_mclk()
4134 ((wcd->clk_mclk_users > 0) && (wcd->clk_type != WCD_CLK_MCLK))) { in wcd9335_enable_mclk()
4135 dev_err(wcd->dev, "Error enabling MCLK, clk_type: %d\n", in wcd9335_enable_mclk()
4136 wcd->clk_type); in wcd9335_enable_mclk()
4137 return -EINVAL; in wcd9335_enable_mclk()
4140 if (++wcd->clk_mclk_users == 1) { in wcd9335_enable_mclk()
4141 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4144 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4147 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_enable_mclk()
4150 regmap_update_bits(wcd->regmap, in wcd9335_enable_mclk()
4154 regmap_update_bits(wcd->regmap, in wcd9335_enable_mclk()
4165 wcd->clk_type = WCD_CLK_MCLK; in wcd9335_enable_mclk()
4172 if (wcd->clk_mclk_users <= 0) in wcd9335_disable_mclk()
4173 return -EINVAL; in wcd9335_disable_mclk()
4175 if (--wcd->clk_mclk_users == 0) { in wcd9335_disable_mclk()
4176 if (wcd->clk_rco_users > 0) { in wcd9335_disable_mclk()
4178 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4181 wcd->clk_type = WCD_CLK_RCO; in wcd9335_disable_mclk()
4183 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4186 wcd->clk_type = WCD_CLK_OFF; in wcd9335_disable_mclk()
4189 regmap_update_bits(wcd->regmap, WCD9335_ANA_CLK_TOP, in wcd9335_disable_mclk()
4199 if (wcd->master_bias_users <= 0) in wcd9335_disable_master_bias()
4200 return -EINVAL; in wcd9335_disable_master_bias()
4202 wcd->master_bias_users--; in wcd9335_disable_master_bias()
4203 if (wcd->master_bias_users == 0) { in wcd9335_disable_master_bias()
4204 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_disable_master_bias()
4207 regmap_update_bits(wcd->regmap, WCD9335_ANA_BIAS, in wcd9335_disable_master_bias()
4221 ret = clk_prepare_enable(wcd->mclk); in wcd9335_cdc_req_mclk_enable()
4223 dev_err(wcd->dev, "%s: ext clk enable failed\n", in wcd9335_cdc_req_mclk_enable()
4237 clk_disable_unprepare(wcd->mclk); in wcd9335_cdc_req_mclk_enable()
4247 struct snd_soc_component *comp = wcd->component; in wcd9335_codec_apply_sido_voltage()
4250 if (req_mv == wcd->sido_voltage) in wcd9335_codec_apply_sido_voltage()
4263 wcd->sido_voltage = req_mv; in wcd9335_codec_apply_sido_voltage()
4277 dev_err(wcd->dev, "Ext clk enable failed\n"); in wcd9335_codec_update_sido_voltage()
4291 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in _wcd9335_codec_enable_mclk()
4303 wcd->sido_voltage); in _wcd9335_codec_enable_mclk()
4313 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in wcd9335_codec_enable_mclk()
4346 SND_SOC_DAPM_MUX("SLIM RX0 MUX", SND_SOC_NOPM, WCD9335_RX0, 0,
4348 SND_SOC_DAPM_MUX("SLIM RX1 MUX", SND_SOC_NOPM, WCD9335_RX1, 0,
4350 SND_SOC_DAPM_MUX("SLIM RX2 MUX", SND_SOC_NOPM, WCD9335_RX2, 0,
4352 SND_SOC_DAPM_MUX("SLIM RX3 MUX", SND_SOC_NOPM, WCD9335_RX3, 0,
4354 SND_SOC_DAPM_MUX("SLIM RX4 MUX", SND_SOC_NOPM, WCD9335_RX4, 0,
4356 SND_SOC_DAPM_MUX("SLIM RX5 MUX", SND_SOC_NOPM, WCD9335_RX5, 0,
4358 SND_SOC_DAPM_MUX("SLIM RX6 MUX", SND_SOC_NOPM, WCD9335_RX6, 0,
4360 SND_SOC_DAPM_MUX("SLIM RX7 MUX", SND_SOC_NOPM, WCD9335_RX7, 0,
4362 SND_SOC_DAPM_MIXER("SLIM RX0", SND_SOC_NOPM, 0, 0, NULL, 0),
4363 SND_SOC_DAPM_MIXER("SLIM RX1", SND_SOC_NOPM, 0, 0, NULL, 0),
4364 SND_SOC_DAPM_MIXER("SLIM RX2", SND_SOC_NOPM, 0, 0, NULL, 0),
4365 SND_SOC_DAPM_MIXER("SLIM RX3", SND_SOC_NOPM, 0, 0, NULL, 0),
4366 SND_SOC_DAPM_MIXER("SLIM RX4", SND_SOC_NOPM, 0, 0, NULL, 0),
4367 SND_SOC_DAPM_MIXER("SLIM RX5", SND_SOC_NOPM, 0, 0, NULL, 0),
4368 SND_SOC_DAPM_MIXER("SLIM RX6", SND_SOC_NOPM, 0, 0, NULL, 0),
4369 SND_SOC_DAPM_MIXER("SLIM RX7", SND_SOC_NOPM, 0, 0, NULL, 0),
4715 SND_SOC_DAPM_MUX("SLIM TX0 MUX", SND_SOC_NOPM, WCD9335_TX0, 0,
4717 SND_SOC_DAPM_MUX("SLIM TX1 MUX", SND_SOC_NOPM, WCD9335_TX1, 0,
4719 SND_SOC_DAPM_MUX("SLIM TX2 MUX", SND_SOC_NOPM, WCD9335_TX2, 0,
4721 SND_SOC_DAPM_MUX("SLIM TX3 MUX", SND_SOC_NOPM, WCD9335_TX3, 0,
4723 SND_SOC_DAPM_MUX("SLIM TX4 MUX", SND_SOC_NOPM, WCD9335_TX4, 0,
4725 SND_SOC_DAPM_MUX("SLIM TX5 MUX", SND_SOC_NOPM, WCD9335_TX5, 0,
4727 SND_SOC_DAPM_MUX("SLIM TX6 MUX", SND_SOC_NOPM, WCD9335_TX6, 0,
4729 SND_SOC_DAPM_MUX("SLIM TX7 MUX", SND_SOC_NOPM, WCD9335_TX7, 0,
4731 SND_SOC_DAPM_MUX("SLIM TX8 MUX", SND_SOC_NOPM, WCD9335_TX8, 0,
4782 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_enable_sido_buck()
4797 wcd->sido_input_src = SIDO_SOURCE_RCO_BG; in wcd9335_enable_sido_buck()
4826 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_init()
4830 regmap_update_bits(wcd->regmap, WCD9335_CODEC_RPM_CLK_GATE, in wcd9335_codec_init()
4833 regmap_update_bits(wcd->regmap, WCD9335_CODEC_RPM_CLK_MCLK_CFG, in wcd9335_codec_init()
4848 struct wcd9335_codec *wcd = dev_get_drvdata(component->dev); in wcd9335_codec_probe()
4852 snd_soc_component_init_regmap(component, wcd->regmap); in wcd9335_codec_probe()
4853 /* Class-H Init*/ in wcd9335_codec_probe()
4854 wcd->clsh_ctrl = wcd_clsh_ctrl_alloc(component, WCD9335); in wcd9335_codec_probe()
4855 if (IS_ERR(wcd->clsh_ctrl)) in wcd9335_codec_probe()
4856 return PTR_ERR(wcd->clsh_ctrl); in wcd9335_codec_probe()
4858 /* Default HPH Mode to Class-H HiFi */ in wcd9335_codec_probe()
4859 wcd->hph_mode = CLS_H_HIFI; in wcd9335_codec_probe()
4860 wcd->component = component; in wcd9335_codec_probe()
4865 INIT_LIST_HEAD(&wcd->dai[i].slim_ch_list); in wcd9335_codec_probe()
4874 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd9335_codec_probe()
4880 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_remove()
4882 wcd_clsh_ctrl_free(wcd->clsh_ctrl); in wcd9335_codec_remove()
4890 struct wcd9335_codec *wcd = dev_get_drvdata(comp->dev); in wcd9335_codec_set_sysclk()
4892 wcd->mclk_rate = freq; in wcd9335_codec_set_sysclk()
4894 if (wcd->mclk_rate == WCD9335_MCLK_CLK_12P288MHZ) in wcd9335_codec_set_sysclk()
4899 else if (wcd->mclk_rate == WCD9335_MCLK_CLK_9P6MHZ) in wcd9335_codec_set_sysclk()
4905 return clk_set_rate(wcd->mclk, freq); in wcd9335_codec_set_sysclk()
4923 struct device *dev = wcd->dev; in wcd9335_probe() local
4925 memcpy(wcd->rx_chs, wcd9335_rx_chs, sizeof(wcd9335_rx_chs)); in wcd9335_probe()
4926 memcpy(wcd->tx_chs, wcd9335_tx_chs, sizeof(wcd9335_tx_chs)); in wcd9335_probe()
4928 wcd->sido_input_src = SIDO_SOURCE_INTERNAL; in wcd9335_probe()
4929 wcd->sido_voltage = SIDO_VOLTAGE_NOMINAL_MV; in wcd9335_probe()
4931 return devm_snd_soc_register_component(dev, &wcd9335_component_drv, in wcd9335_probe()
4949 static bool wcd9335_is_volatile_register(struct device *dev, unsigned int reg) in wcd9335_is_volatile_register() argument
4981 .name = "WCD9335-IFC-DEV",
5034 struct device *dev = wcd->dev; in wcd9335_parse_dt() local
5035 struct device_node *np = dev->of_node; in wcd9335_parse_dt()
5038 wcd->reset_gpio = of_get_named_gpio(np, "reset-gpios", 0); in wcd9335_parse_dt()
5039 if (wcd->reset_gpio < 0) { in wcd9335_parse_dt()
5040 dev_err(dev, "Reset GPIO missing from DT\n"); in wcd9335_parse_dt()
5041 return wcd->reset_gpio; in wcd9335_parse_dt()
5044 wcd->mclk = devm_clk_get(dev, "mclk"); in wcd9335_parse_dt()
5045 if (IS_ERR(wcd->mclk)) { in wcd9335_parse_dt()
5046 dev_err(dev, "mclk not found\n"); in wcd9335_parse_dt()
5047 return PTR_ERR(wcd->mclk); in wcd9335_parse_dt()
5050 wcd->native_clk = devm_clk_get(dev, "slimbus"); in wcd9335_parse_dt()
5051 if (IS_ERR(wcd->native_clk)) { in wcd9335_parse_dt()
5052 dev_err(dev, "slimbus clock not found\n"); in wcd9335_parse_dt()
5053 return PTR_ERR(wcd->native_clk); in wcd9335_parse_dt()
5056 wcd->supplies[0].supply = "vdd-buck"; in wcd9335_parse_dt()
5057 wcd->supplies[1].supply = "vdd-buck-sido"; in wcd9335_parse_dt()
5058 wcd->supplies[2].supply = "vdd-tx"; in wcd9335_parse_dt()
5059 wcd->supplies[3].supply = "vdd-rx"; in wcd9335_parse_dt()
5060 wcd->supplies[4].supply = "vdd-io"; in wcd9335_parse_dt()
5062 ret = regulator_bulk_get(dev, WCD9335_MAX_SUPPLY, wcd->supplies); in wcd9335_parse_dt()
5064 dev_err(dev, "Failed to get supplies: err = %d\n", ret); in wcd9335_parse_dt()
5073 struct device *dev = wcd->dev; in wcd9335_power_on_reset() local
5076 ret = regulator_bulk_enable(WCD9335_MAX_SUPPLY, wcd->supplies); in wcd9335_power_on_reset()
5078 dev_err(dev, "Failed to get supplies: err = %d\n", ret); in wcd9335_power_on_reset()
5091 gpio_direction_output(wcd->reset_gpio, 0); in wcd9335_power_on_reset()
5093 gpio_set_value(wcd->reset_gpio, 1); in wcd9335_power_on_reset()
5101 struct regmap *rm = wcd->regmap; in wcd9335_bring_up()
5108 dev_err(wcd->dev, "WCD9335 CODEC version detection fail!\n"); in wcd9335_bring_up()
5109 return -EINVAL; in wcd9335_bring_up()
5113 dev_info(wcd->dev, "WCD9335 CODEC version is v2.0\n"); in wcd9335_bring_up()
5114 wcd->version = WCD9335_VERSION_2_0; in wcd9335_bring_up()
5124 dev_err(wcd->dev, "WCD9335 CODEC version not supported\n"); in wcd9335_bring_up()
5125 return -EINVAL; in wcd9335_bring_up()
5140 wcd->intr1 = of_irq_get_byname(wcd->dev->of_node, "intr1"); in wcd9335_irq_init()
5141 if (wcd->intr1 < 0) in wcd9335_irq_init()
5142 return dev_err_probe(wcd->dev, wcd->intr1, in wcd9335_irq_init()
5145 ret = devm_regmap_add_irq_chip(wcd->dev, wcd->regmap, wcd->intr1, in wcd9335_irq_init()
5147 &wcd9335_regmap_irq1_chip, &wcd->irq_data); in wcd9335_irq_init()
5149 return dev_err_probe(wcd->dev, ret, "Failed to register IRQ chip\n"); in wcd9335_irq_init()
5154 static int wcd9335_slim_probe(struct slim_device *slim) in wcd9335_slim_probe() argument
5156 struct device *dev = &slim->dev; in wcd9335_slim_probe() local
5160 wcd = devm_kzalloc(dev, sizeof(*wcd), GFP_KERNEL); in wcd9335_slim_probe()
5162 return -ENOMEM; in wcd9335_slim_probe()
5164 wcd->dev = dev; in wcd9335_slim_probe()
5167 dev_err(dev, "Error parsing DT: %d\n", ret); in wcd9335_slim_probe()
5175 dev_set_drvdata(dev, wcd); in wcd9335_slim_probe()
5183 struct device *dev = &sdev->dev; in wcd9335_slim_status() local
5188 wcd = dev_get_drvdata(dev); in wcd9335_slim_status()
5190 ifc_dev_np = of_parse_phandle(dev->of_node, "slim-ifc-dev", 0); in wcd9335_slim_status()
5192 dev_err(dev, "No Interface device found\n"); in wcd9335_slim_status()
5193 return -EINVAL; in wcd9335_slim_status()
5196 wcd->slim = sdev; in wcd9335_slim_status()
5197 wcd->slim_ifc_dev = of_slim_get_device(sdev->ctrl, ifc_dev_np); in wcd9335_slim_status()
5199 if (!wcd->slim_ifc_dev) { in wcd9335_slim_status()
5200 dev_err(dev, "Unable to get SLIM Interface device\n"); in wcd9335_slim_status()
5201 return -EINVAL; in wcd9335_slim_status()
5204 slim_get_logical_addr(wcd->slim_ifc_dev); in wcd9335_slim_status()
5206 wcd->regmap = regmap_init_slimbus(sdev, &wcd9335_regmap_config); in wcd9335_slim_status()
5207 if (IS_ERR(wcd->regmap)) in wcd9335_slim_status()
5208 return dev_err_probe(dev, PTR_ERR(wcd->regmap), in wcd9335_slim_status()
5209 "Failed to allocate slim register map\n"); in wcd9335_slim_status()
5211 wcd->if_regmap = regmap_init_slimbus(wcd->slim_ifc_dev, in wcd9335_slim_status()
5213 if (IS_ERR(wcd->if_regmap)) in wcd9335_slim_status()
5214 return dev_err_probe(dev, PTR_ERR(wcd->if_regmap), in wcd9335_slim_status()
5215 "Failed to allocate ifc register map\n"); in wcd9335_slim_status()
5219 dev_err(dev, "Failed to bringup WCD9335\n"); in wcd9335_slim_status()
5236 MODULE_DEVICE_TABLE(slim, wcd9335_slim_id);
5240 .name = "wcd9335-slim",
5248 MODULE_DESCRIPTION("WCD9335 slim driver");
5250 MODULE_ALIAS("slim:217:1a0:*");