Lines Matching +full:- +full:chn +full:- +full:disabled

1 // SPDX-License-Identifier: GPL-2.0
14 #include "mt8195-afe-clk.h"
15 #include "mt8195-afe-common.h"
16 #include "mt8195-reg.h"
117 int cowork_slv_id[MT8195_AFE_IO_ETDM_NUM - 1]; //dai_id
180 return -EINVAL; in get_etdm_fs_timing()
201 etdm_reg->con0 = ETDM_IN1_CON0; in get_etdm_reg()
202 etdm_reg->con1 = ETDM_IN1_CON1; in get_etdm_reg()
203 etdm_reg->con2 = ETDM_IN1_CON2; in get_etdm_reg()
204 etdm_reg->con3 = ETDM_IN1_CON3; in get_etdm_reg()
205 etdm_reg->con4 = ETDM_IN1_CON4; in get_etdm_reg()
206 etdm_reg->con5 = ETDM_IN1_CON5; in get_etdm_reg()
209 etdm_reg->con0 = ETDM_IN2_CON0; in get_etdm_reg()
210 etdm_reg->con1 = ETDM_IN2_CON1; in get_etdm_reg()
211 etdm_reg->con2 = ETDM_IN2_CON2; in get_etdm_reg()
212 etdm_reg->con3 = ETDM_IN2_CON3; in get_etdm_reg()
213 etdm_reg->con4 = ETDM_IN2_CON4; in get_etdm_reg()
214 etdm_reg->con5 = ETDM_IN2_CON5; in get_etdm_reg()
217 etdm_reg->con0 = ETDM_OUT1_CON0; in get_etdm_reg()
218 etdm_reg->con1 = ETDM_OUT1_CON1; in get_etdm_reg()
219 etdm_reg->con2 = ETDM_OUT1_CON2; in get_etdm_reg()
220 etdm_reg->con3 = ETDM_OUT1_CON3; in get_etdm_reg()
221 etdm_reg->con4 = ETDM_OUT1_CON4; in get_etdm_reg()
222 etdm_reg->con5 = ETDM_OUT1_CON5; in get_etdm_reg()
225 etdm_reg->con0 = ETDM_OUT2_CON0; in get_etdm_reg()
226 etdm_reg->con1 = ETDM_OUT2_CON1; in get_etdm_reg()
227 etdm_reg->con2 = ETDM_OUT2_CON2; in get_etdm_reg()
228 etdm_reg->con3 = ETDM_OUT2_CON3; in get_etdm_reg()
229 etdm_reg->con4 = ETDM_OUT2_CON4; in get_etdm_reg()
230 etdm_reg->con5 = ETDM_OUT2_CON5; in get_etdm_reg()
234 etdm_reg->con0 = ETDM_OUT3_CON0; in get_etdm_reg()
235 etdm_reg->con1 = ETDM_OUT3_CON1; in get_etdm_reg()
236 etdm_reg->con2 = ETDM_OUT3_CON2; in get_etdm_reg()
237 etdm_reg->con3 = ETDM_OUT3_CON3; in get_etdm_reg()
238 etdm_reg->con4 = ETDM_OUT3_CON4; in get_etdm_reg()
239 etdm_reg->con5 = ETDM_OUT3_CON5; in get_etdm_reg()
242 return -EINVAL; in get_etdm_reg()
258 return -EINVAL; in get_etdm_dir()
270 struct mt8195_afe_private *afe_priv = afe->platform_priv; in is_cowork_mode()
273 if (!mt8195_afe_etdm_is_valid(dai->id)) in is_cowork_mode()
274 return -EINVAL; in is_cowork_mode()
276 etdm_data = afe_priv->dai_priv[dai->id]; in is_cowork_mode()
277 return (etdm_data->cowork_slv_count > 0 || in is_cowork_mode()
278 etdm_data->cowork_source_id != COWORK_ETDM_NONE); in is_cowork_mode()
302 struct mt8195_afe_private *afe_priv = afe->platform_priv; in get_etdm_cowork_master_id()
306 if (!mt8195_afe_etdm_is_valid(dai->id)) in get_etdm_cowork_master_id()
307 return -EINVAL; in get_etdm_cowork_master_id()
309 etdm_data = afe_priv->dai_priv[dai->id]; in get_etdm_cowork_master_id()
310 dai_id = etdm_data->cowork_source_id; in get_etdm_cowork_master_id()
313 dai_id = dai->id; in get_etdm_cowork_master_id()
699 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in mt8195_etdm_clk_src_sel_put()
701 unsigned int source = ucontrol->value.enumerated.item[0]; in mt8195_etdm_clk_src_sel_put()
706 if (source >= e->items) in mt8195_etdm_clk_src_sel_put()
707 return -EINVAL; in mt8195_etdm_clk_src_sel_put()
710 if (!strcmp(kcontrol->id.name, "ETDM_OUT1_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
714 } else if (!strcmp(kcontrol->id.name, "ETDM_OUT2_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
718 } else if (!strcmp(kcontrol->id.name, "ETDM_OUT3_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
722 } else if (!strcmp(kcontrol->id.name, "ETDM_IN1_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
726 } else if (!strcmp(kcontrol->id.name, "ETDM_IN2_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
733 regmap_update_bits(afe->regmap, reg, mask, val); in mt8195_etdm_clk_src_sel_put()
749 if (!strcmp(kcontrol->id.name, "ETDM_OUT1_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
753 } else if (!strcmp(kcontrol->id.name, "ETDM_OUT2_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
757 } else if (!strcmp(kcontrol->id.name, "ETDM_OUT3_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
761 } else if (!strcmp(kcontrol->id.name, "ETDM_IN1_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
765 } else if (!strcmp(kcontrol->id.name, "ETDM_IN2_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
772 regmap_read(afe->regmap, reg, &value); in mt8195_etdm_clk_src_sel_get()
776 ucontrol->value.enumerated.item[0] = value; in mt8195_etdm_clk_src_sel_get()
1320 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_afe_enable_etdm()
1325 return -EINVAL; in mt8195_afe_enable_etdm()
1327 etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_afe_enable_etdm()
1328 spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags); in mt8195_afe_enable_etdm()
1329 etdm_data->en_ref_cnt++; in mt8195_afe_enable_etdm()
1330 if (etdm_data->en_ref_cnt == 1) { in mt8195_afe_enable_etdm()
1335 regmap_update_bits(afe->regmap, etdm_reg.con0, in mt8195_afe_enable_etdm()
1339 spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags); in mt8195_afe_enable_etdm()
1347 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_afe_disable_etdm()
1352 return -EINVAL; in mt8195_afe_disable_etdm()
1354 etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_afe_disable_etdm()
1355 spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags); in mt8195_afe_disable_etdm()
1356 if (etdm_data->en_ref_cnt > 0) { in mt8195_afe_disable_etdm()
1357 etdm_data->en_ref_cnt--; in mt8195_afe_disable_etdm()
1358 if (etdm_data->en_ref_cnt == 0) { in mt8195_afe_disable_etdm()
1363 regmap_update_bits(afe->regmap, etdm_reg.con0, in mt8195_afe_disable_etdm()
1368 spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags); in mt8195_afe_disable_etdm()
1387 return -EINVAL; in etdm_cowork_slv_sel()
1402 return -EINVAL; in etdm_cowork_slv_sel()
1409 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_etdm_sync_mode_configure()
1417 return -EINVAL; in mt8195_etdm_sync_mode_configure()
1419 etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_etdm_sync_mode_configure()
1420 if (etdm_data->cowork_source_id == COWORK_ETDM_NONE) in mt8195_etdm_sync_mode_configure()
1423 cowork_source_sel = etdm_cowork_slv_sel(etdm_data->cowork_source_id, in mt8195_etdm_sync_mode_configure()
1424 etdm_data->slave_mode); in mt8195_etdm_sync_mode_configure()
1458 regmap_update_bits(afe->regmap, reg, mask, val); in mt8195_etdm_sync_mode_configure()
1465 int cg_id = -1; in mtk_dai_etdm_get_cg_id_by_dai_id()
1495 int clk_id = -1; in mtk_dai_etdm_get_clk_id_by_dai_id()
1523 int clk_id = -1; in mtk_dai_etdm_get_clkdiv_id_by_dai_id()
1551 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_enable_mclk()
1555 return -EINVAL; in mtk_dai_etdm_enable_mclk()
1557 mt8195_afe_enable_clk(afe, afe_priv->clk[clkdiv_id]); in mtk_dai_etdm_enable_mclk()
1564 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_disable_mclk()
1568 return -EINVAL; in mtk_dai_etdm_disable_mclk()
1570 mt8195_afe_disable_clk(afe, afe_priv->clk[clkdiv_id]); in mtk_dai_etdm_disable_mclk()
1580 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_startup()
1590 return -EINVAL; in mtk_dai_etdm_startup()
1595 mt8195_afe_enable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_etdm_startup()
1597 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_startup()
1599 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_startup()
1600 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_startup()
1604 afe_priv->clk[cg_id]); in mtk_dai_etdm_startup()
1607 mtk_dai_etdm_enable_mclk(afe, dai->id); in mtk_dai_etdm_startup()
1609 cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id); in mtk_dai_etdm_startup()
1611 mt8195_afe_enable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_etdm_startup()
1621 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_shutdown()
1635 mt8195_afe_disable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_etdm_shutdown()
1637 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_shutdown()
1638 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_shutdown()
1639 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_shutdown()
1643 afe_priv->clk[cg_id]); in mtk_dai_etdm_shutdown()
1647 cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id); in mtk_dai_etdm_shutdown()
1649 mt8195_afe_disable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_etdm_shutdown()
1651 mtk_dai_etdm_disable_mclk(afe, dai->id); in mtk_dai_etdm_shutdown()
1678 return -EINVAL; in mtk_dai_etdm_fifo_mode()
1683 regmap_update_bits(afe->regmap, reg, mask, val); in mtk_dai_etdm_fifo_mode()
1692 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_in_configure()
1704 return -EINVAL; in mtk_dai_etdm_in_configure()
1706 etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_in_configure()
1707 slave_mode = etdm_data->slave_mode; in mtk_dai_etdm_in_configure()
1708 data_mode = etdm_data->data_mode; in mtk_dai_etdm_in_configure()
1709 lrck_width = etdm_data->lrck_width; in mtk_dai_etdm_in_configure()
1711 dev_dbg(afe->dev, "%s rate %u channels %u, id %d\n", in mtk_dai_etdm_in_configure()
1718 if (etdm_data->cowork_source_id != COWORK_ETDM_NONE) in mtk_dai_etdm_in_configure()
1733 regmap_update_bits(afe->regmap, etdm_reg.con1, mask, val); in mtk_dai_etdm_in_configure()
1752 regmap_update_bits(afe->regmap, etdm_reg.con2, mask, val); in mtk_dai_etdm_in_configure()
1760 if (etdm_data->in_disable_ch[i] && in mtk_dai_etdm_in_configure()
1761 etdm_data->in_disable_ch[i + 1]) in mtk_dai_etdm_in_configure()
1768 regmap_update_bits(afe->regmap, etdm_reg.con3, mask, val); in mtk_dai_etdm_in_configure()
1777 if (etdm_data->lrck_inv) in mtk_dai_etdm_in_configure()
1779 if (etdm_data->bck_inv) in mtk_dai_etdm_in_configure()
1782 if (etdm_data->lrck_inv) in mtk_dai_etdm_in_configure()
1784 if (etdm_data->bck_inv) in mtk_dai_etdm_in_configure()
1787 regmap_update_bits(afe->regmap, etdm_reg.con4, mask, val); in mtk_dai_etdm_in_configure()
1796 if (etdm_data->in_disable_ch[i] && in mtk_dai_etdm_in_configure()
1797 !etdm_data->in_disable_ch[i + 1]) { in mtk_dai_etdm_in_configure()
1798 if (i == (channels - 2)) in mtk_dai_etdm_in_configure()
1803 } else if (!etdm_data->in_disable_ch[i] && in mtk_dai_etdm_in_configure()
1804 etdm_data->in_disable_ch[i + 1]) { in mtk_dai_etdm_in_configure()
1808 regmap_update_bits(afe->regmap, etdm_reg.con5, mask, val); in mtk_dai_etdm_in_configure()
1817 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_out_configure()
1828 return -EINVAL; in mtk_dai_etdm_out_configure()
1830 etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_out_configure()
1831 slave_mode = etdm_data->slave_mode; in mtk_dai_etdm_out_configure()
1832 lrck_width = etdm_data->lrck_width; in mtk_dai_etdm_out_configure()
1834 dev_dbg(afe->dev, "%s rate %u channels %u, id %d\n", in mtk_dai_etdm_out_configure()
1841 if (etdm_data->cowork_source_id != COWORK_ETDM_NONE) in mtk_dai_etdm_out_configure()
1847 regmap_update_bits(afe->regmap, etdm_reg.con0, mask, val); in mtk_dai_etdm_out_configure()
1858 regmap_update_bits(afe->regmap, etdm_reg.con1, mask, val); in mtk_dai_etdm_out_configure()
1869 regmap_update_bits(afe->regmap, etdm_reg.con2, in mtk_dai_etdm_out_configure()
1887 regmap_update_bits(afe->regmap, etdm_reg.con4, mask, val); in mtk_dai_etdm_out_configure()
1896 if (etdm_data->lrck_inv) in mtk_dai_etdm_out_configure()
1898 if (etdm_data->bck_inv) in mtk_dai_etdm_out_configure()
1901 if (etdm_data->lrck_inv) in mtk_dai_etdm_out_configure()
1903 if (etdm_data->bck_inv) in mtk_dai_etdm_out_configure()
1906 regmap_update_bits(afe->regmap, etdm_reg.con5, mask, val); in mtk_dai_etdm_out_configure()
1913 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_mclk_configure()
1928 return -EINVAL; in mtk_dai_etdm_mclk_configure()
1930 etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_mclk_configure()
1936 if (etdm_data->mclk_dir == SND_SOC_CLOCK_OUT) in mtk_dai_etdm_mclk_configure()
1938 regmap_update_bits(afe->regmap, etdm_reg.con1, mask, val); in mtk_dai_etdm_mclk_configure()
1940 if (etdm_data->mclk_freq) { in mtk_dai_etdm_mclk_configure()
1941 apll = etdm_data->mclk_apll; in mtk_dai_etdm_mclk_configure()
1947 ret = mt8195_afe_set_clk_parent(afe, afe_priv->clk[clk_id], in mtk_dai_etdm_mclk_configure()
1948 afe_priv->clk[apll_clk_id]); in mtk_dai_etdm_mclk_configure()
1953 ret = mt8195_afe_set_clk_rate(afe, afe_priv->clk[clkdiv_id], in mtk_dai_etdm_mclk_configure()
1954 etdm_data->mclk_freq); in mtk_dai_etdm_mclk_configure()
1956 if (etdm_data->mclk_dir == SND_SOC_CLOCK_OUT) in mtk_dai_etdm_mclk_configure()
1957 dev_dbg(afe->dev, "%s mclk freq = 0\n", __func__); in mtk_dai_etdm_mclk_configure()
1968 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_configure()
1980 return -EINVAL; in mtk_dai_etdm_configure()
1982 etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_configure()
1983 slave_mode = etdm_data->slave_mode; in mtk_dai_etdm_configure()
1988 if (etdm_data->cowork_source_id != COWORK_ETDM_NONE) in mtk_dai_etdm_configure()
1991 dev_dbg(afe->dev, "%s fmt %u data %u lrck %d-%u bck %d, clock %u slv %u\n", in mtk_dai_etdm_configure()
1992 __func__, etdm_data->format, etdm_data->data_mode, in mtk_dai_etdm_configure()
1993 etdm_data->lrck_inv, etdm_data->lrck_width, etdm_data->bck_inv, in mtk_dai_etdm_configure()
1994 etdm_data->clock_mode, etdm_data->slave_mode); in mtk_dai_etdm_configure()
1995 dev_dbg(afe->dev, "%s rate %u channels %u bitwidth %u, id %d\n", in mtk_dai_etdm_configure()
1998 etdm_channels = (etdm_data->data_mode == MTK_DAI_ETDM_DATA_ONE_PIN) ? in mtk_dai_etdm_configure()
2003 dev_info(afe->dev, "%s bck rate %u not support\n", in mtk_dai_etdm_configure()
2005 return -EINVAL; in mtk_dai_etdm_configure()
2014 val |= ETDM_CON0_FORMAT(etdm_data->format); in mtk_dai_etdm_configure()
2021 etdm_data->cowork_source_id == COWORK_ETDM_NONE) { in mtk_dai_etdm_configure()
2022 dev_info(afe->dev, "%s id %d only support master mode\n", in mtk_dai_etdm_configure()
2024 return -EINVAL; in mtk_dai_etdm_configure()
2028 regmap_update_bits(afe->regmap, etdm_reg.con0, mask, val); in mtk_dai_etdm_configure()
2047 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_hw_params()
2053 dev_dbg(afe->dev, "%s '%s' period %u-%u\n", in mtk_dai_etdm_hw_params()
2060 return -EINVAL; in mtk_dai_etdm_hw_params()
2071 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_hw_params()
2072 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_hw_params()
2073 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_hw_params()
2084 ret = mtk_dai_etdm_mclk_configure(afe, dai->id); in mtk_dai_etdm_hw_params()
2089 bit_width, dai->id); in mtk_dai_etdm_hw_params()
2100 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_trigger()
2106 dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id); in mtk_dai_etdm_trigger()
2113 return -EINVAL; in mtk_dai_etdm_trigger()
2115 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_trigger()
2119 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_trigger()
2120 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_trigger()
2124 ret = mt8195_afe_enable_etdm(afe, dai->id); in mtk_dai_etdm_trigger()
2132 return -EINVAL; in mtk_dai_etdm_trigger()
2134 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_trigger()
2136 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_trigger()
2137 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_trigger()
2143 ret = mt8195_afe_disable_etdm(afe, dai->id); in mtk_dai_etdm_trigger()
2154 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_cal_mclk()
2160 return -EINVAL; in mtk_dai_etdm_cal_mclk()
2162 etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_cal_mclk()
2164 etdm_data->mclk_freq = freq; in mtk_dai_etdm_cal_mclk()
2172 dev_info(afe->dev, "freq %d > apll rate %d\n", freq, apll_rate); in mtk_dai_etdm_cal_mclk()
2173 return -EINVAL; in mtk_dai_etdm_cal_mclk()
2177 dev_info(afe->dev, "APLL%d cannot generate freq Hz\n", apll); in mtk_dai_etdm_cal_mclk()
2178 return -EINVAL; in mtk_dai_etdm_cal_mclk()
2181 etdm_data->mclk_apll = apll; in mtk_dai_etdm_cal_mclk()
2182 etdm_data->mclk_freq = freq; in mtk_dai_etdm_cal_mclk()
2191 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_set_sysclk()
2195 dev_dbg(dai->dev, "%s id %d freq %u, dir %d\n", in mtk_dai_etdm_set_sysclk()
2196 __func__, dai->id, freq, dir); in mtk_dai_etdm_set_sysclk()
2200 dai_id = dai->id; in mtk_dai_etdm_set_sysclk()
2203 return -EINVAL; in mtk_dai_etdm_set_sysclk()
2205 etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_set_sysclk()
2206 etdm_data->mclk_dir = dir; in mtk_dai_etdm_set_sysclk()
2215 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_set_tdm_slot()
2218 if (!mt8195_afe_etdm_is_valid(dai->id)) in mtk_dai_etdm_set_tdm_slot()
2219 return -EINVAL; in mtk_dai_etdm_set_tdm_slot()
2221 etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_etdm_set_tdm_slot()
2222 dev_dbg(dai->dev, "%s id %d slot_width %d\n", in mtk_dai_etdm_set_tdm_slot()
2223 __func__, dai->id, slot_width); in mtk_dai_etdm_set_tdm_slot()
2225 etdm_data->slots = slots; in mtk_dai_etdm_set_tdm_slot()
2226 etdm_data->lrck_width = slot_width; in mtk_dai_etdm_set_tdm_slot()
2233 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_set_fmt()
2236 if (!mt8195_afe_etdm_is_valid(dai->id)) in mtk_dai_etdm_set_fmt()
2237 return -EINVAL; in mtk_dai_etdm_set_fmt()
2239 etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_etdm_set_fmt()
2242 etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S; in mtk_dai_etdm_set_fmt()
2245 etdm_data->format = MTK_DAI_ETDM_FORMAT_LJ; in mtk_dai_etdm_set_fmt()
2248 etdm_data->format = MTK_DAI_ETDM_FORMAT_RJ; in mtk_dai_etdm_set_fmt()
2251 etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA; in mtk_dai_etdm_set_fmt()
2254 etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB; in mtk_dai_etdm_set_fmt()
2257 return -EINVAL; in mtk_dai_etdm_set_fmt()
2262 etdm_data->bck_inv = false; in mtk_dai_etdm_set_fmt()
2263 etdm_data->lrck_inv = false; in mtk_dai_etdm_set_fmt()
2266 etdm_data->bck_inv = false; in mtk_dai_etdm_set_fmt()
2267 etdm_data->lrck_inv = true; in mtk_dai_etdm_set_fmt()
2270 etdm_data->bck_inv = true; in mtk_dai_etdm_set_fmt()
2271 etdm_data->lrck_inv = false; in mtk_dai_etdm_set_fmt()
2274 etdm_data->bck_inv = true; in mtk_dai_etdm_set_fmt()
2275 etdm_data->lrck_inv = true; in mtk_dai_etdm_set_fmt()
2278 return -EINVAL; in mtk_dai_etdm_set_fmt()
2283 etdm_data->slave_mode = true; in mtk_dai_etdm_set_fmt()
2286 etdm_data->slave_mode = false; in mtk_dai_etdm_set_fmt()
2289 return -EINVAL; in mtk_dai_etdm_set_fmt()
2299 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_hdmitx_dptx_startup()
2300 int cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id); in mtk_dai_hdmitx_dptx_startup()
2303 mt8195_afe_enable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_hdmitx_dptx_startup()
2305 mtk_dai_etdm_enable_mclk(afe, dai->id); in mtk_dai_hdmitx_dptx_startup()
2314 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_hdmitx_dptx_shutdown()
2315 int cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id); in mtk_dai_hdmitx_dptx_shutdown()
2317 mtk_dai_etdm_disable_mclk(afe, dai->id); in mtk_dai_hdmitx_dptx_shutdown()
2320 mt8195_afe_disable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_hdmitx_dptx_shutdown()
2356 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_hdmitx_dptx_hw_params()
2364 if (!mt8195_afe_hdmitx_dptx_is_valid(dai->id)) in mtk_dai_hdmitx_dptx_hw_params()
2365 return -EINVAL; in mtk_dai_hdmitx_dptx_hw_params()
2367 etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_hdmitx_dptx_hw_params()
2370 if (dai->id == MT8195_AFE_IO_DPTX) { in mtk_dai_hdmitx_dptx_hw_params()
2371 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_hw_params()
2374 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_hw_params()
2377 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_hw_params()
2382 etdm_data->data_mode = MTK_DAI_ETDM_DATA_ONE_PIN; in mtk_dai_hdmitx_dptx_hw_params()
2388 etdm_data->data_mode = MTK_DAI_ETDM_DATA_MULTI_PIN; in mtk_dai_hdmitx_dptx_hw_params()
2391 ret = mtk_dai_etdm_mclk_configure(afe, dai->id); in mtk_dai_hdmitx_dptx_hw_params()
2395 ret = mtk_dai_etdm_configure(afe, rate, channels, width, dai->id); in mtk_dai_hdmitx_dptx_hw_params()
2407 dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id); in mtk_dai_hdmitx_dptx_trigger()
2413 if (dai->id == MT8195_AFE_IO_DPTX) in mtk_dai_hdmitx_dptx_trigger()
2414 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_trigger()
2419 ret = mt8195_afe_enable_etdm(afe, dai->id); in mtk_dai_hdmitx_dptx_trigger()
2424 ret = mt8195_afe_disable_etdm(afe, dai->id); in mtk_dai_hdmitx_dptx_trigger()
2427 if (dai->id == MT8195_AFE_IO_DPTX) in mtk_dai_hdmitx_dptx_trigger()
2428 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_trigger()
2432 return -EINVAL; in mtk_dai_hdmitx_dptx_trigger()
2444 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_hdmitx_dptx_set_sysclk()
2447 if (!mt8195_afe_hdmitx_dptx_is_valid(dai->id)) in mtk_dai_hdmitx_dptx_set_sysclk()
2448 return -EINVAL; in mtk_dai_hdmitx_dptx_set_sysclk()
2450 etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_hdmitx_dptx_set_sysclk()
2452 dev_dbg(dai->dev, "%s id %d freq %u, dir %d\n", in mtk_dai_hdmitx_dptx_set_sysclk()
2453 __func__, dai->id, freq, dir); in mtk_dai_hdmitx_dptx_set_sysclk()
2455 etdm_data->mclk_dir = dir; in mtk_dai_hdmitx_dptx_set_sysclk()
2456 return mtk_dai_etdm_cal_mclk(afe, freq, dai->id); in mtk_dai_hdmitx_dptx_set_sysclk()
2469 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_probe()
2472 dev_dbg(dai->dev, "%s id %d\n", __func__, dai->id); in mtk_dai_etdm_probe()
2474 if (!mt8195_afe_etdm_is_valid(dai->id)) in mtk_dai_etdm_probe()
2475 return -EINVAL; in mtk_dai_etdm_probe()
2477 etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_etdm_probe()
2478 if (etdm_data->mclk_freq) { in mtk_dai_etdm_probe()
2479 dev_dbg(afe->dev, "MCLK always on, rate %d\n", in mtk_dai_etdm_probe()
2480 etdm_data->mclk_freq); in mtk_dai_etdm_probe()
2481 pm_runtime_get_sync(afe->dev); in mtk_dai_etdm_probe()
2482 mtk_dai_etdm_mclk_configure(afe, dai->id); in mtk_dai_etdm_probe()
2483 mtk_dai_etdm_enable_mclk(afe, dai->id); in mtk_dai_etdm_probe()
2484 pm_runtime_put_sync(afe->dev); in mtk_dai_etdm_probe()
2596 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_etdm_update_sync_info()
2603 etdm_data = afe_priv->dai_priv[i]; in mt8195_etdm_update_sync_info()
2604 if (etdm_data->cowork_source_id != COWORK_ETDM_NONE) { in mt8195_etdm_update_sync_info()
2605 mst_dai_id = etdm_data->cowork_source_id; in mt8195_etdm_update_sync_info()
2607 dev_err(afe->dev, "%s invalid dai id %d\n", in mt8195_etdm_update_sync_info()
2611 mst_data = afe_priv->dai_priv[mst_dai_id]; in mt8195_etdm_update_sync_info()
2612 if (mst_data->cowork_source_id != COWORK_ETDM_NONE) in mt8195_etdm_update_sync_info()
2613 dev_info(afe->dev, "%s [%d] wrong sync source\n" in mt8195_etdm_update_sync_info()
2615 mst_data->cowork_slv_id[mst_data->cowork_slv_count] = i; in mt8195_etdm_update_sync_info()
2616 mst_data->cowork_slv_count++; in mt8195_etdm_update_sync_info()
2623 const struct device_node *of_node = afe->dev->of_node; in mt8195_dai_etdm_parse_of()
2624 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_dai_etdm_parse_of()
2638 {"etdm-in1", ETDM_SYNC_FROM_IN1}, in mt8195_dai_etdm_parse_of()
2639 {"etdm-in2", ETDM_SYNC_FROM_IN2}, in mt8195_dai_etdm_parse_of()
2640 {"etdm-out1", ETDM_SYNC_FROM_OUT1}, in mt8195_dai_etdm_parse_of()
2641 {"etdm-out2", ETDM_SYNC_FROM_OUT2}, in mt8195_dai_etdm_parse_of()
2642 {"etdm-out3", ETDM_SYNC_FROM_OUT3}, in mt8195_dai_etdm_parse_of()
2648 dev_err(afe->dev, "%s invalid dai id %d\n", in mt8195_dai_etdm_parse_of()
2653 etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_dai_etdm_parse_of()
2656 "mediatek,%s-mclk-always-on-rate", in mt8195_dai_etdm_parse_of()
2659 dev_info(afe->dev, "%s snprintf err=%d\n", in mt8195_dai_etdm_parse_of()
2665 etdm_data->mclk_dir = SND_SOC_CLOCK_OUT; in mt8195_dai_etdm_parse_of()
2667 dev_info(afe->dev, "%s unsupported mclk %uHz\n", in mt8195_dai_etdm_parse_of()
2672 "mediatek,%s-multi-pin-mode", in mt8195_dai_etdm_parse_of()
2675 dev_info(afe->dev, "%s snprintf err=%d\n", in mt8195_dai_etdm_parse_of()
2679 etdm_data->data_mode = of_property_read_bool(of_node, prop); in mt8195_dai_etdm_parse_of()
2682 "mediatek,%s-cowork-source", in mt8195_dai_etdm_parse_of()
2685 dev_info(afe->dev, "%s snprintf err=%d\n", in mt8195_dai_etdm_parse_of()
2692 dev_info(afe->dev, "%s invalid id=%d\n", in mt8195_dai_etdm_parse_of()
2694 etdm_data->cowork_source_id = COWORK_ETDM_NONE; in mt8195_dai_etdm_parse_of()
2697 etdm_data->cowork_source_id = in mt8195_dai_etdm_parse_of()
2701 etdm_data->cowork_source_id = COWORK_ETDM_NONE; in mt8195_dai_etdm_parse_of()
2708 etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_dai_etdm_parse_of()
2711 "mediatek,%s-chn-disabled", in mt8195_dai_etdm_parse_of()
2714 dev_info(afe->dev, "%s snprintf err=%d\n", in mt8195_dai_etdm_parse_of()
2726 dev_info(afe->dev, "%s [%d] invalid chn %u\n", in mt8195_dai_etdm_parse_of()
2729 etdm_data->in_disable_ch[disable_chn[j]] = true; in mt8195_dai_etdm_parse_of()
2737 struct mt8195_afe_private *afe_priv = afe->platform_priv; in init_etdm_priv_data()
2742 etdm_priv = devm_kzalloc(afe->dev, in init_etdm_priv_data()
2746 return -ENOMEM; in init_etdm_priv_data()
2748 afe_priv->dai_priv[i] = etdm_priv; in init_etdm_priv_data()
2751 afe_priv->dai_priv[MT8195_AFE_IO_DPTX] = in init_etdm_priv_data()
2752 afe_priv->dai_priv[MT8195_AFE_IO_ETDM3_OUT]; in init_etdm_priv_data()
2762 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8195_dai_etdm_register()
2764 return -ENOMEM; in mt8195_dai_etdm_register()
2766 list_add(&dai->list, &afe->sub_dais); in mt8195_dai_etdm_register()
2768 dai->dai_drivers = mtk_dai_etdm_driver; in mt8195_dai_etdm_register()
2769 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver); in mt8195_dai_etdm_register()
2771 dai->dapm_widgets = mtk_dai_etdm_widgets; in mt8195_dai_etdm_register()
2772 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets); in mt8195_dai_etdm_register()
2773 dai->dapm_routes = mtk_dai_etdm_routes; in mt8195_dai_etdm_register()
2774 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes); in mt8195_dai_etdm_register()
2775 dai->controls = mtk_dai_etdm_controls; in mt8195_dai_etdm_register()
2776 dai->num_controls = ARRAY_SIZE(mtk_dai_etdm_controls); in mt8195_dai_etdm_register()