Lines Matching +full:ch3 +full:- +full:0

1 // SPDX-License-Identifier: GPL-2.0
14 #include "mt8195-afe-clk.h"
15 #include "mt8195-afe-common.h"
16 #include "mt8195-reg.h"
24 MTK_DAI_ETDM_FORMAT_I2S = 0,
33 MTK_DAI_ETDM_DATA_ONE_PIN = 0,
61 COWORK_ETDM_NONE = 0,
117 int cowork_slv_id[MT8195_AFE_IO_ETDM_NUM - 1]; //dai_id
123 { .rate = 8000, .reg_value = 0, },
144 for (i = 0; i < ARRAY_SIZE(mt8195_etdm_rates); i++) in get_etdm_fs_timing()
148 return -EINVAL; in get_etdm_fs_timing()
169 etdm_reg->con0 = ETDM_IN1_CON0; in get_etdm_reg()
170 etdm_reg->con1 = ETDM_IN1_CON1; in get_etdm_reg()
171 etdm_reg->con2 = ETDM_IN1_CON2; in get_etdm_reg()
172 etdm_reg->con3 = ETDM_IN1_CON3; in get_etdm_reg()
173 etdm_reg->con4 = ETDM_IN1_CON4; in get_etdm_reg()
174 etdm_reg->con5 = ETDM_IN1_CON5; in get_etdm_reg()
177 etdm_reg->con0 = ETDM_IN2_CON0; in get_etdm_reg()
178 etdm_reg->con1 = ETDM_IN2_CON1; in get_etdm_reg()
179 etdm_reg->con2 = ETDM_IN2_CON2; in get_etdm_reg()
180 etdm_reg->con3 = ETDM_IN2_CON3; in get_etdm_reg()
181 etdm_reg->con4 = ETDM_IN2_CON4; in get_etdm_reg()
182 etdm_reg->con5 = ETDM_IN2_CON5; in get_etdm_reg()
185 etdm_reg->con0 = ETDM_OUT1_CON0; in get_etdm_reg()
186 etdm_reg->con1 = ETDM_OUT1_CON1; in get_etdm_reg()
187 etdm_reg->con2 = ETDM_OUT1_CON2; in get_etdm_reg()
188 etdm_reg->con3 = ETDM_OUT1_CON3; in get_etdm_reg()
189 etdm_reg->con4 = ETDM_OUT1_CON4; in get_etdm_reg()
190 etdm_reg->con5 = ETDM_OUT1_CON5; in get_etdm_reg()
193 etdm_reg->con0 = ETDM_OUT2_CON0; in get_etdm_reg()
194 etdm_reg->con1 = ETDM_OUT2_CON1; in get_etdm_reg()
195 etdm_reg->con2 = ETDM_OUT2_CON2; in get_etdm_reg()
196 etdm_reg->con3 = ETDM_OUT2_CON3; in get_etdm_reg()
197 etdm_reg->con4 = ETDM_OUT2_CON4; in get_etdm_reg()
198 etdm_reg->con5 = ETDM_OUT2_CON5; in get_etdm_reg()
202 etdm_reg->con0 = ETDM_OUT3_CON0; in get_etdm_reg()
203 etdm_reg->con1 = ETDM_OUT3_CON1; in get_etdm_reg()
204 etdm_reg->con2 = ETDM_OUT3_CON2; in get_etdm_reg()
205 etdm_reg->con3 = ETDM_OUT3_CON3; in get_etdm_reg()
206 etdm_reg->con4 = ETDM_OUT3_CON4; in get_etdm_reg()
207 etdm_reg->con5 = ETDM_OUT3_CON5; in get_etdm_reg()
210 return -EINVAL; in get_etdm_reg()
212 return 0; in get_etdm_reg()
226 return -EINVAL; in get_etdm_dir()
238 struct mt8195_afe_private *afe_priv = afe->platform_priv; in is_cowork_mode()
239 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; in is_cowork_mode()
241 return (etdm_data->cowork_slv_count > 0 || in is_cowork_mode()
242 etdm_data->cowork_source_id != COWORK_ETDM_NONE); in is_cowork_mode()
259 return 0; in sync_to_dai_id()
266 struct mt8195_afe_private *afe_priv = afe->platform_priv; in get_etdm_cowork_master_id()
267 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; in get_etdm_cowork_master_id()
268 int dai_id = etdm_data->cowork_source_id; in get_etdm_cowork_master_id()
271 dai_id = dai->id; in get_etdm_cowork_master_id()
277 SOC_DAPM_SINGLE_AUTODISABLE("I020 Switch", AFE_CONN48, 20, 1, 0),
278 SOC_DAPM_SINGLE_AUTODISABLE("I022 Switch", AFE_CONN48, 22, 1, 0),
279 SOC_DAPM_SINGLE_AUTODISABLE("I046 Switch", AFE_CONN48_1, 14, 1, 0),
280 SOC_DAPM_SINGLE_AUTODISABLE("I070 Switch", AFE_CONN48_2, 6, 1, 0),
284 SOC_DAPM_SINGLE_AUTODISABLE("I021 Switch", AFE_CONN49, 21, 1, 0),
285 SOC_DAPM_SINGLE_AUTODISABLE("I023 Switch", AFE_CONN49, 23, 1, 0),
286 SOC_DAPM_SINGLE_AUTODISABLE("I047 Switch", AFE_CONN49_1, 15, 1, 0),
287 SOC_DAPM_SINGLE_AUTODISABLE("I071 Switch", AFE_CONN49_2, 7, 1, 0),
291 SOC_DAPM_SINGLE_AUTODISABLE("I024 Switch", AFE_CONN50, 24, 1, 0),
292 SOC_DAPM_SINGLE_AUTODISABLE("I048 Switch", AFE_CONN50_1, 16, 1, 0),
296 SOC_DAPM_SINGLE_AUTODISABLE("I025 Switch", AFE_CONN51, 25, 1, 0),
297 SOC_DAPM_SINGLE_AUTODISABLE("I049 Switch", AFE_CONN51_1, 17, 1, 0),
301 SOC_DAPM_SINGLE_AUTODISABLE("I026 Switch", AFE_CONN52, 26, 1, 0),
302 SOC_DAPM_SINGLE_AUTODISABLE("I050 Switch", AFE_CONN52_1, 18, 1, 0),
306 SOC_DAPM_SINGLE_AUTODISABLE("I027 Switch", AFE_CONN53, 27, 1, 0),
307 SOC_DAPM_SINGLE_AUTODISABLE("I051 Switch", AFE_CONN53_1, 19, 1, 0),
311 SOC_DAPM_SINGLE_AUTODISABLE("I028 Switch", AFE_CONN54, 28, 1, 0),
312 SOC_DAPM_SINGLE_AUTODISABLE("I052 Switch", AFE_CONN54_1, 20, 1, 0),
316 SOC_DAPM_SINGLE_AUTODISABLE("I029 Switch", AFE_CONN55, 29, 1, 0),
317 SOC_DAPM_SINGLE_AUTODISABLE("I053 Switch", AFE_CONN55_1, 21, 1, 0),
321 SOC_DAPM_SINGLE_AUTODISABLE("I030 Switch", AFE_CONN56, 30, 1, 0),
322 SOC_DAPM_SINGLE_AUTODISABLE("I054 Switch", AFE_CONN56_1, 22, 1, 0),
326 SOC_DAPM_SINGLE_AUTODISABLE("I031 Switch", AFE_CONN57, 31, 1, 0),
327 SOC_DAPM_SINGLE_AUTODISABLE("I055 Switch", AFE_CONN57_1, 23, 1, 0),
331 SOC_DAPM_SINGLE_AUTODISABLE("I032 Switch", AFE_CONN58_1, 0, 1, 0),
332 SOC_DAPM_SINGLE_AUTODISABLE("I056 Switch", AFE_CONN58_1, 24, 1, 0),
336 SOC_DAPM_SINGLE_AUTODISABLE("I033 Switch", AFE_CONN59_1, 1, 1, 0),
337 SOC_DAPM_SINGLE_AUTODISABLE("I057 Switch", AFE_CONN59_1, 25, 1, 0),
341 SOC_DAPM_SINGLE_AUTODISABLE("I034 Switch", AFE_CONN60_1, 2, 1, 0),
342 SOC_DAPM_SINGLE_AUTODISABLE("I058 Switch", AFE_CONN60_1, 26, 1, 0),
346 SOC_DAPM_SINGLE_AUTODISABLE("I035 Switch", AFE_CONN61_1, 3, 1, 0),
347 SOC_DAPM_SINGLE_AUTODISABLE("I059 Switch", AFE_CONN61_1, 27, 1, 0),
351 SOC_DAPM_SINGLE_AUTODISABLE("I036 Switch", AFE_CONN62_1, 4, 1, 0),
352 SOC_DAPM_SINGLE_AUTODISABLE("I060 Switch", AFE_CONN62_1, 28, 1, 0),
356 SOC_DAPM_SINGLE_AUTODISABLE("I037 Switch", AFE_CONN63_1, 5, 1, 0),
357 SOC_DAPM_SINGLE_AUTODISABLE("I061 Switch", AFE_CONN63_1, 29, 1, 0),
361 SOC_DAPM_SINGLE_AUTODISABLE("I038 Switch", AFE_CONN64_1, 6, 1, 0),
362 SOC_DAPM_SINGLE_AUTODISABLE("I062 Switch", AFE_CONN64_1, 30, 1, 0),
366 SOC_DAPM_SINGLE_AUTODISABLE("I039 Switch", AFE_CONN65_1, 7, 1, 0),
367 SOC_DAPM_SINGLE_AUTODISABLE("I063 Switch", AFE_CONN65_1, 31, 1, 0),
371 SOC_DAPM_SINGLE_AUTODISABLE("I040 Switch", AFE_CONN66_1, 8, 1, 0),
372 SOC_DAPM_SINGLE_AUTODISABLE("I064 Switch", AFE_CONN66_2, 0, 1, 0),
376 SOC_DAPM_SINGLE_AUTODISABLE("I041 Switch", AFE_CONN67_1, 9, 1, 0),
377 SOC_DAPM_SINGLE_AUTODISABLE("I065 Switch", AFE_CONN67_2, 1, 1, 0),
381 SOC_DAPM_SINGLE_AUTODISABLE("I042 Switch", AFE_CONN68_1, 10, 1, 0),
382 SOC_DAPM_SINGLE_AUTODISABLE("I066 Switch", AFE_CONN68_2, 2, 1, 0),
386 SOC_DAPM_SINGLE_AUTODISABLE("I043 Switch", AFE_CONN69_1, 11, 1, 0),
387 SOC_DAPM_SINGLE_AUTODISABLE("I067 Switch", AFE_CONN69_2, 3, 1, 0),
391 SOC_DAPM_SINGLE_AUTODISABLE("I044 Switch", AFE_CONN70_1, 12, 1, 0),
392 SOC_DAPM_SINGLE_AUTODISABLE("I068 Switch", AFE_CONN70_2, 4, 1, 0),
396 SOC_DAPM_SINGLE_AUTODISABLE("I045 Switch", AFE_CONN71_1, 13, 1, 0),
397 SOC_DAPM_SINGLE_AUTODISABLE("I069 Switch", AFE_CONN71_2, 5, 1, 0),
401 SOC_DAPM_SINGLE_AUTODISABLE("I020 Switch", AFE_CONN72, 20, 1, 0),
402 SOC_DAPM_SINGLE_AUTODISABLE("I022 Switch", AFE_CONN72, 22, 1, 0),
403 SOC_DAPM_SINGLE_AUTODISABLE("I046 Switch", AFE_CONN72_1, 14, 1, 0),
404 SOC_DAPM_SINGLE_AUTODISABLE("I070 Switch", AFE_CONN72_2, 6, 1, 0),
408 SOC_DAPM_SINGLE_AUTODISABLE("I021 Switch", AFE_CONN73, 21, 1, 0),
409 SOC_DAPM_SINGLE_AUTODISABLE("I023 Switch", AFE_CONN73, 23, 1, 0),
410 SOC_DAPM_SINGLE_AUTODISABLE("I047 Switch", AFE_CONN73_1, 15, 1, 0),
411 SOC_DAPM_SINGLE_AUTODISABLE("I071 Switch", AFE_CONN73_2, 7, 1, 0),
415 SOC_DAPM_SINGLE_AUTODISABLE("I024 Switch", AFE_CONN74, 24, 1, 0),
416 SOC_DAPM_SINGLE_AUTODISABLE("I048 Switch", AFE_CONN74_1, 16, 1, 0),
420 SOC_DAPM_SINGLE_AUTODISABLE("I025 Switch", AFE_CONN75, 25, 1, 0),
421 SOC_DAPM_SINGLE_AUTODISABLE("I049 Switch", AFE_CONN75_1, 17, 1, 0),
425 SOC_DAPM_SINGLE_AUTODISABLE("I026 Switch", AFE_CONN76, 26, 1, 0),
426 SOC_DAPM_SINGLE_AUTODISABLE("I050 Switch", AFE_CONN76_1, 18, 1, 0),
430 SOC_DAPM_SINGLE_AUTODISABLE("I027 Switch", AFE_CONN77, 27, 1, 0),
431 SOC_DAPM_SINGLE_AUTODISABLE("I051 Switch", AFE_CONN77_1, 19, 1, 0),
435 SOC_DAPM_SINGLE_AUTODISABLE("I028 Switch", AFE_CONN78, 28, 1, 0),
436 SOC_DAPM_SINGLE_AUTODISABLE("I052 Switch", AFE_CONN78_1, 20, 1, 0),
440 SOC_DAPM_SINGLE_AUTODISABLE("I029 Switch", AFE_CONN79, 29, 1, 0),
441 SOC_DAPM_SINGLE_AUTODISABLE("I053 Switch", AFE_CONN79_1, 21, 1, 0),
445 SOC_DAPM_SINGLE_AUTODISABLE("I030 Switch", AFE_CONN80, 30, 1, 0),
446 SOC_DAPM_SINGLE_AUTODISABLE("I054 Switch", AFE_CONN80_1, 22, 1, 0),
450 SOC_DAPM_SINGLE_AUTODISABLE("I031 Switch", AFE_CONN81, 31, 1, 0),
451 SOC_DAPM_SINGLE_AUTODISABLE("I055 Switch", AFE_CONN81_1, 23, 1, 0),
455 SOC_DAPM_SINGLE_AUTODISABLE("I032 Switch", AFE_CONN82_1, 0, 1, 0),
456 SOC_DAPM_SINGLE_AUTODISABLE("I056 Switch", AFE_CONN82_1, 24, 1, 0),
460 SOC_DAPM_SINGLE_AUTODISABLE("I033 Switch", AFE_CONN83_1, 1, 1, 0),
461 SOC_DAPM_SINGLE_AUTODISABLE("I057 Switch", AFE_CONN83_1, 25, 1, 0),
465 SOC_DAPM_SINGLE_AUTODISABLE("I034 Switch", AFE_CONN84_1, 2, 1, 0),
466 SOC_DAPM_SINGLE_AUTODISABLE("I058 Switch", AFE_CONN84_1, 26, 1, 0),
470 SOC_DAPM_SINGLE_AUTODISABLE("I035 Switch", AFE_CONN85_1, 3, 1, 0),
471 SOC_DAPM_SINGLE_AUTODISABLE("I059 Switch", AFE_CONN85_1, 27, 1, 0),
475 SOC_DAPM_SINGLE_AUTODISABLE("I036 Switch", AFE_CONN86_1, 4, 1, 0),
476 SOC_DAPM_SINGLE_AUTODISABLE("I060 Switch", AFE_CONN86_1, 28, 1, 0),
480 SOC_DAPM_SINGLE_AUTODISABLE("I037 Switch", AFE_CONN87_1, 5, 1, 0),
481 SOC_DAPM_SINGLE_AUTODISABLE("I061 Switch", AFE_CONN87_1, 29, 1, 0),
485 SOC_DAPM_SINGLE_AUTODISABLE("I038 Switch", AFE_CONN88_1, 6, 1, 0),
486 SOC_DAPM_SINGLE_AUTODISABLE("I062 Switch", AFE_CONN88_1, 30, 1, 0),
490 SOC_DAPM_SINGLE_AUTODISABLE("I039 Switch", AFE_CONN89_1, 7, 1, 0),
491 SOC_DAPM_SINGLE_AUTODISABLE("I063 Switch", AFE_CONN89_1, 31, 1, 0),
495 SOC_DAPM_SINGLE_AUTODISABLE("I040 Switch", AFE_CONN90_1, 8, 1, 0),
496 SOC_DAPM_SINGLE_AUTODISABLE("I064 Switch", AFE_CONN90_2, 0, 1, 0),
500 SOC_DAPM_SINGLE_AUTODISABLE("I041 Switch", AFE_CONN91_1, 9, 1, 0),
501 SOC_DAPM_SINGLE_AUTODISABLE("I065 Switch", AFE_CONN91_2, 1, 1, 0),
505 SOC_DAPM_SINGLE_AUTODISABLE("I042 Switch", AFE_CONN92_1, 10, 1, 0),
506 SOC_DAPM_SINGLE_AUTODISABLE("I066 Switch", AFE_CONN92_2, 2, 1, 0),
510 SOC_DAPM_SINGLE_AUTODISABLE("I043 Switch", AFE_CONN93_1, 11, 1, 0),
511 SOC_DAPM_SINGLE_AUTODISABLE("I067 Switch", AFE_CONN93_2, 3, 1, 0),
515 SOC_DAPM_SINGLE_AUTODISABLE("I044 Switch", AFE_CONN94_1, 12, 1, 0),
516 SOC_DAPM_SINGLE_AUTODISABLE("I068 Switch", AFE_CONN94_2, 4, 1, 0),
520 SOC_DAPM_SINGLE_AUTODISABLE("I045 Switch", AFE_CONN95_1, 13, 1, 0),
521 SOC_DAPM_SINGLE_AUTODISABLE("I069 Switch", AFE_CONN95_2, 5, 1, 0),
539 0, 1,
545 0,
556 0,
566 "CH0", "CH1", "CH2", "CH3", "CH4", "CH5", "CH6", "CH7",
570 0, 1, 2, 3, 4, 5, 6, 7,
575 0,
576 0xf,
586 0xf,
596 0xf,
606 0xf,
616 0xf,
626 0xf,
636 0xf,
646 0xf,
657 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in mt8195_etdm_clk_src_sel_put()
659 unsigned int source = ucontrol->value.enumerated.item[0]; in mt8195_etdm_clk_src_sel_put()
664 if (source >= e->items) in mt8195_etdm_clk_src_sel_put()
665 return -EINVAL; in mt8195_etdm_clk_src_sel_put()
667 reg = 0; in mt8195_etdm_clk_src_sel_put()
668 if (!strcmp(kcontrol->id.name, "ETDM_OUT1_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
672 } else if (!strcmp(kcontrol->id.name, "ETDM_OUT2_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
676 } else if (!strcmp(kcontrol->id.name, "ETDM_OUT3_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
680 } else if (!strcmp(kcontrol->id.name, "ETDM_IN1_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
684 } else if (!strcmp(kcontrol->id.name, "ETDM_IN2_Clock_Source")) { in mt8195_etdm_clk_src_sel_put()
691 regmap_update_bits(afe->regmap, reg, mask, val); in mt8195_etdm_clk_src_sel_put()
693 return 0; in mt8195_etdm_clk_src_sel_put()
702 unsigned int value = 0; in mt8195_etdm_clk_src_sel_get()
703 unsigned int reg = 0; in mt8195_etdm_clk_src_sel_get()
704 unsigned int mask = 0; in mt8195_etdm_clk_src_sel_get()
705 unsigned int shift = 0; in mt8195_etdm_clk_src_sel_get()
707 if (!strcmp(kcontrol->id.name, "ETDM_OUT1_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
711 } else if (!strcmp(kcontrol->id.name, "ETDM_OUT2_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
715 } else if (!strcmp(kcontrol->id.name, "ETDM_OUT3_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
719 } else if (!strcmp(kcontrol->id.name, "ETDM_IN1_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
723 } else if (!strcmp(kcontrol->id.name, "ETDM_IN2_Clock_Source")) { in mt8195_etdm_clk_src_sel_get()
730 regmap_read(afe->regmap, reg, &value); in mt8195_etdm_clk_src_sel_get()
734 ucontrol->value.enumerated.item[0] = value; in mt8195_etdm_clk_src_sel_get()
735 return 0; in mt8195_etdm_clk_src_sel_get()
763 SND_SOC_DAPM_MIXER("I012", SND_SOC_NOPM, 0, 0, NULL, 0),
764 SND_SOC_DAPM_MIXER("I013", SND_SOC_NOPM, 0, 0, NULL, 0),
765 SND_SOC_DAPM_MIXER("I014", SND_SOC_NOPM, 0, 0, NULL, 0),
766 SND_SOC_DAPM_MIXER("I015", SND_SOC_NOPM, 0, 0, NULL, 0),
767 SND_SOC_DAPM_MIXER("I016", SND_SOC_NOPM, 0, 0, NULL, 0),
768 SND_SOC_DAPM_MIXER("I017", SND_SOC_NOPM, 0, 0, NULL, 0),
769 SND_SOC_DAPM_MIXER("I018", SND_SOC_NOPM, 0, 0, NULL, 0),
770 SND_SOC_DAPM_MIXER("I019", SND_SOC_NOPM, 0, 0, NULL, 0),
773 SND_SOC_DAPM_MIXER("I072", SND_SOC_NOPM, 0, 0, NULL, 0),
774 SND_SOC_DAPM_MIXER("I073", SND_SOC_NOPM, 0, 0, NULL, 0),
775 SND_SOC_DAPM_MIXER("I074", SND_SOC_NOPM, 0, 0, NULL, 0),
776 SND_SOC_DAPM_MIXER("I075", SND_SOC_NOPM, 0, 0, NULL, 0),
777 SND_SOC_DAPM_MIXER("I076", SND_SOC_NOPM, 0, 0, NULL, 0),
778 SND_SOC_DAPM_MIXER("I077", SND_SOC_NOPM, 0, 0, NULL, 0),
779 SND_SOC_DAPM_MIXER("I078", SND_SOC_NOPM, 0, 0, NULL, 0),
780 SND_SOC_DAPM_MIXER("I079", SND_SOC_NOPM, 0, 0, NULL, 0),
781 SND_SOC_DAPM_MIXER("I080", SND_SOC_NOPM, 0, 0, NULL, 0),
782 SND_SOC_DAPM_MIXER("I081", SND_SOC_NOPM, 0, 0, NULL, 0),
783 SND_SOC_DAPM_MIXER("I082", SND_SOC_NOPM, 0, 0, NULL, 0),
784 SND_SOC_DAPM_MIXER("I083", SND_SOC_NOPM, 0, 0, NULL, 0),
785 SND_SOC_DAPM_MIXER("I084", SND_SOC_NOPM, 0, 0, NULL, 0),
786 SND_SOC_DAPM_MIXER("I085", SND_SOC_NOPM, 0, 0, NULL, 0),
787 SND_SOC_DAPM_MIXER("I086", SND_SOC_NOPM, 0, 0, NULL, 0),
788 SND_SOC_DAPM_MIXER("I087", SND_SOC_NOPM, 0, 0, NULL, 0),
789 SND_SOC_DAPM_MIXER("I088", SND_SOC_NOPM, 0, 0, NULL, 0),
790 SND_SOC_DAPM_MIXER("I089", SND_SOC_NOPM, 0, 0, NULL, 0),
791 SND_SOC_DAPM_MIXER("I090", SND_SOC_NOPM, 0, 0, NULL, 0),
792 SND_SOC_DAPM_MIXER("I091", SND_SOC_NOPM, 0, 0, NULL, 0),
793 SND_SOC_DAPM_MIXER("I092", SND_SOC_NOPM, 0, 0, NULL, 0),
794 SND_SOC_DAPM_MIXER("I093", SND_SOC_NOPM, 0, 0, NULL, 0),
795 SND_SOC_DAPM_MIXER("I094", SND_SOC_NOPM, 0, 0, NULL, 0),
796 SND_SOC_DAPM_MIXER("I095", SND_SOC_NOPM, 0, 0, NULL, 0),
799 SND_SOC_DAPM_MIXER("O048", SND_SOC_NOPM, 0, 0,
802 SND_SOC_DAPM_MIXER("O049", SND_SOC_NOPM, 0, 0,
805 SND_SOC_DAPM_MIXER("O050", SND_SOC_NOPM, 0, 0,
808 SND_SOC_DAPM_MIXER("O051", SND_SOC_NOPM, 0, 0,
811 SND_SOC_DAPM_MIXER("O052", SND_SOC_NOPM, 0, 0,
814 SND_SOC_DAPM_MIXER("O053", SND_SOC_NOPM, 0, 0,
817 SND_SOC_DAPM_MIXER("O054", SND_SOC_NOPM, 0, 0,
820 SND_SOC_DAPM_MIXER("O055", SND_SOC_NOPM, 0, 0,
823 SND_SOC_DAPM_MIXER("O056", SND_SOC_NOPM, 0, 0,
826 SND_SOC_DAPM_MIXER("O057", SND_SOC_NOPM, 0, 0,
829 SND_SOC_DAPM_MIXER("O058", SND_SOC_NOPM, 0, 0,
832 SND_SOC_DAPM_MIXER("O059", SND_SOC_NOPM, 0, 0,
835 SND_SOC_DAPM_MIXER("O060", SND_SOC_NOPM, 0, 0,
838 SND_SOC_DAPM_MIXER("O061", SND_SOC_NOPM, 0, 0,
841 SND_SOC_DAPM_MIXER("O062", SND_SOC_NOPM, 0, 0,
844 SND_SOC_DAPM_MIXER("O063", SND_SOC_NOPM, 0, 0,
847 SND_SOC_DAPM_MIXER("O064", SND_SOC_NOPM, 0, 0,
850 SND_SOC_DAPM_MIXER("O065", SND_SOC_NOPM, 0, 0,
853 SND_SOC_DAPM_MIXER("O066", SND_SOC_NOPM, 0, 0,
856 SND_SOC_DAPM_MIXER("O067", SND_SOC_NOPM, 0, 0,
859 SND_SOC_DAPM_MIXER("O068", SND_SOC_NOPM, 0, 0,
862 SND_SOC_DAPM_MIXER("O069", SND_SOC_NOPM, 0, 0,
865 SND_SOC_DAPM_MIXER("O070", SND_SOC_NOPM, 0, 0,
868 SND_SOC_DAPM_MIXER("O071", SND_SOC_NOPM, 0, 0,
873 SND_SOC_DAPM_MIXER("O072", SND_SOC_NOPM, 0, 0,
876 SND_SOC_DAPM_MIXER("O073", SND_SOC_NOPM, 0, 0,
879 SND_SOC_DAPM_MIXER("O074", SND_SOC_NOPM, 0, 0,
882 SND_SOC_DAPM_MIXER("O075", SND_SOC_NOPM, 0, 0,
885 SND_SOC_DAPM_MIXER("O076", SND_SOC_NOPM, 0, 0,
888 SND_SOC_DAPM_MIXER("O077", SND_SOC_NOPM, 0, 0,
891 SND_SOC_DAPM_MIXER("O078", SND_SOC_NOPM, 0, 0,
894 SND_SOC_DAPM_MIXER("O079", SND_SOC_NOPM, 0, 0,
897 SND_SOC_DAPM_MIXER("O080", SND_SOC_NOPM, 0, 0,
900 SND_SOC_DAPM_MIXER("O081", SND_SOC_NOPM, 0, 0,
903 SND_SOC_DAPM_MIXER("O082", SND_SOC_NOPM, 0, 0,
906 SND_SOC_DAPM_MIXER("O083", SND_SOC_NOPM, 0, 0,
909 SND_SOC_DAPM_MIXER("O084", SND_SOC_NOPM, 0, 0,
912 SND_SOC_DAPM_MIXER("O085", SND_SOC_NOPM, 0, 0,
915 SND_SOC_DAPM_MIXER("O086", SND_SOC_NOPM, 0, 0,
918 SND_SOC_DAPM_MIXER("O087", SND_SOC_NOPM, 0, 0,
921 SND_SOC_DAPM_MIXER("O088", SND_SOC_NOPM, 0, 0,
924 SND_SOC_DAPM_MIXER("O089", SND_SOC_NOPM, 0, 0,
927 SND_SOC_DAPM_MIXER("O090", SND_SOC_NOPM, 0, 0,
930 SND_SOC_DAPM_MIXER("O091", SND_SOC_NOPM, 0, 0,
933 SND_SOC_DAPM_MIXER("O092", SND_SOC_NOPM, 0, 0,
936 SND_SOC_DAPM_MIXER("O093", SND_SOC_NOPM, 0, 0,
939 SND_SOC_DAPM_MIXER("O094", SND_SOC_NOPM, 0, 0,
942 SND_SOC_DAPM_MIXER("O095", SND_SOC_NOPM, 0, 0,
947 SND_SOC_DAPM_MUX("HDMI_OUT_MUX", SND_SOC_NOPM, 0, 0,
949 SND_SOC_DAPM_MUX("DPTX_OUT_MUX", SND_SOC_NOPM, 0, 0,
952 SND_SOC_DAPM_MUX("HDMI_CH0_MUX", SND_SOC_NOPM, 0, 0,
954 SND_SOC_DAPM_MUX("HDMI_CH1_MUX", SND_SOC_NOPM, 0, 0,
956 SND_SOC_DAPM_MUX("HDMI_CH2_MUX", SND_SOC_NOPM, 0, 0,
958 SND_SOC_DAPM_MUX("HDMI_CH3_MUX", SND_SOC_NOPM, 0, 0,
960 SND_SOC_DAPM_MUX("HDMI_CH4_MUX", SND_SOC_NOPM, 0, 0,
962 SND_SOC_DAPM_MUX("HDMI_CH5_MUX", SND_SOC_NOPM, 0, 0,
964 SND_SOC_DAPM_MUX("HDMI_CH6_MUX", SND_SOC_NOPM, 0, 0,
966 SND_SOC_DAPM_MUX("HDMI_CH7_MUX", SND_SOC_NOPM, 0, 0,
1176 {"HDMI_CH0_MUX", "CH3", "DL10"},
1185 {"HDMI_CH1_MUX", "CH3", "DL10"},
1194 {"HDMI_CH2_MUX", "CH3", "DL10"},
1203 {"HDMI_CH3_MUX", "CH3", "DL10"},
1212 {"HDMI_CH4_MUX", "CH3", "DL10"},
1221 {"HDMI_CH5_MUX", "CH3", "DL10"},
1230 {"HDMI_CH6_MUX", "CH3", "DL10"},
1239 {"HDMI_CH7_MUX", "CH3", "DL10"},
1276 int ret = 0; in mt8195_afe_enable_etdm()
1278 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_afe_enable_etdm()
1279 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_afe_enable_etdm()
1282 spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags); in mt8195_afe_enable_etdm()
1283 etdm_data->en_ref_cnt++; in mt8195_afe_enable_etdm()
1284 if (etdm_data->en_ref_cnt == 1) { in mt8195_afe_enable_etdm()
1286 if (ret < 0) in mt8195_afe_enable_etdm()
1289 regmap_update_bits(afe->regmap, etdm_reg.con0, in mt8195_afe_enable_etdm()
1293 spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags); in mt8195_afe_enable_etdm()
1299 int ret = 0; in mt8195_afe_disable_etdm()
1301 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_afe_disable_etdm()
1302 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_afe_disable_etdm()
1305 spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags); in mt8195_afe_disable_etdm()
1306 if (etdm_data->en_ref_cnt > 0) { in mt8195_afe_disable_etdm()
1307 etdm_data->en_ref_cnt--; in mt8195_afe_disable_etdm()
1308 if (etdm_data->en_ref_cnt == 0) { in mt8195_afe_disable_etdm()
1310 if (ret < 0) in mt8195_afe_disable_etdm()
1313 regmap_update_bits(afe->regmap, etdm_reg.con0, in mt8195_afe_disable_etdm()
1314 ETDM_CON0_EN, 0); in mt8195_afe_disable_etdm()
1318 spin_unlock_irqrestore(&afe_priv->afe_ctrl_lock, flags); in mt8195_afe_disable_etdm()
1337 return -EINVAL; in etdm_cowork_slv_sel()
1352 return -EINVAL; in etdm_cowork_slv_sel()
1359 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_etdm_sync_mode_configure()
1360 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_etdm_sync_mode_configure()
1361 unsigned int reg = 0; in mt8195_etdm_sync_mode_configure()
1366 if (etdm_data->cowork_source_id == COWORK_ETDM_NONE) in mt8195_etdm_sync_mode_configure()
1367 return 0; in mt8195_etdm_sync_mode_configure()
1369 cowork_source_sel = etdm_cowork_slv_sel(etdm_data->cowork_source_id, in mt8195_etdm_sync_mode_configure()
1370 etdm_data->slave_mode); in mt8195_etdm_sync_mode_configure()
1371 if (cowork_source_sel < 0) in mt8195_etdm_sync_mode_configure()
1401 return 0; in mt8195_etdm_sync_mode_configure()
1404 regmap_update_bits(afe->regmap, reg, mask, val); in mt8195_etdm_sync_mode_configure()
1406 return 0; in mt8195_etdm_sync_mode_configure()
1411 int cg_id = -1; in mtk_dai_etdm_get_cg_id_by_dai_id()
1441 int clk_id = -1; in mtk_dai_etdm_get_clk_id_by_dai_id()
1469 int clk_id = -1; in mtk_dai_etdm_get_clkdiv_id_by_dai_id()
1497 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_enable_mclk()
1500 if (clkdiv_id < 0) in mtk_dai_etdm_enable_mclk()
1501 return -EINVAL; in mtk_dai_etdm_enable_mclk()
1503 mt8195_afe_enable_clk(afe, afe_priv->clk[clkdiv_id]); in mtk_dai_etdm_enable_mclk()
1505 return 0; in mtk_dai_etdm_enable_mclk()
1510 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_disable_mclk()
1513 if (clkdiv_id < 0) in mtk_dai_etdm_disable_mclk()
1514 return -EINVAL; in mtk_dai_etdm_disable_mclk()
1516 mt8195_afe_disable_clk(afe, afe_priv->clk[clkdiv_id]); in mtk_dai_etdm_disable_mclk()
1518 return 0; in mtk_dai_etdm_disable_mclk()
1526 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_startup()
1538 if (cg_id >= 0) in mtk_dai_etdm_startup()
1539 mt8195_afe_enable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_etdm_startup()
1541 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_startup()
1543 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_startup()
1544 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_startup()
1546 if (cg_id >= 0) in mtk_dai_etdm_startup()
1548 afe_priv->clk[cg_id]); in mtk_dai_etdm_startup()
1551 mtk_dai_etdm_enable_mclk(afe, dai->id); in mtk_dai_etdm_startup()
1553 cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id); in mtk_dai_etdm_startup()
1554 if (cg_id >= 0) in mtk_dai_etdm_startup()
1555 mt8195_afe_enable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_etdm_startup()
1558 return 0; in mtk_dai_etdm_startup()
1565 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_shutdown()
1575 if (cg_id >= 0) in mtk_dai_etdm_shutdown()
1576 mt8195_afe_disable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_etdm_shutdown()
1578 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_shutdown()
1579 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_shutdown()
1580 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_shutdown()
1582 if (cg_id >= 0) in mtk_dai_etdm_shutdown()
1584 afe_priv->clk[cg_id]); in mtk_dai_etdm_shutdown()
1588 cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id); in mtk_dai_etdm_shutdown()
1589 if (cg_id >= 0) in mtk_dai_etdm_shutdown()
1590 mt8195_afe_disable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_etdm_shutdown()
1592 mtk_dai_etdm_disable_mclk(afe, dai->id); in mtk_dai_etdm_shutdown()
1599 unsigned int mode = 0; in mtk_dai_etdm_fifo_mode()
1600 unsigned int reg = 0; in mtk_dai_etdm_fifo_mode()
1601 unsigned int val = 0; in mtk_dai_etdm_fifo_mode()
1604 if (rate != 0) in mtk_dai_etdm_fifo_mode()
1610 if (rate == 0) in mtk_dai_etdm_fifo_mode()
1615 if (rate == 0) in mtk_dai_etdm_fifo_mode()
1619 return -EINVAL; in mtk_dai_etdm_fifo_mode()
1624 regmap_update_bits(afe->regmap, reg, mask, val); in mtk_dai_etdm_fifo_mode()
1625 return 0; in mtk_dai_etdm_fifo_mode()
1633 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_in_configure()
1634 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_in_configure()
1636 bool slave_mode = etdm_data->slave_mode; in mtk_dai_etdm_in_configure()
1637 unsigned int data_mode = etdm_data->data_mode; in mtk_dai_etdm_in_configure()
1638 unsigned int lrck_width = etdm_data->lrck_width; in mtk_dai_etdm_in_configure()
1639 unsigned int val = 0; in mtk_dai_etdm_in_configure()
1640 unsigned int mask = 0; in mtk_dai_etdm_in_configure()
1644 dev_dbg(afe->dev, "%s rate %u channels %u, id %d\n", in mtk_dai_etdm_in_configure()
1648 if (ret < 0) in mtk_dai_etdm_in_configure()
1651 if (etdm_data->cowork_source_id != COWORK_ETDM_NONE) in mtk_dai_etdm_in_configure()
1656 mtk_dai_etdm_fifo_mode(afe, dai_id, 0); in mtk_dai_etdm_in_configure()
1661 if (lrck_width > 0) { in mtk_dai_etdm_in_configure()
1666 regmap_update_bits(afe->regmap, etdm_reg.con1, mask, val); in mtk_dai_etdm_in_configure()
1668 mask = 0; in mtk_dai_etdm_in_configure()
1669 val = 0; in mtk_dai_etdm_in_configure()
1685 regmap_update_bits(afe->regmap, etdm_reg.con2, mask, val); in mtk_dai_etdm_in_configure()
1687 mask = 0; in mtk_dai_etdm_in_configure()
1688 val = 0; in mtk_dai_etdm_in_configure()
1692 for (i = 0; i < channels; i += 2) { in mtk_dai_etdm_in_configure()
1693 if (etdm_data->in_disable_ch[i] && in mtk_dai_etdm_in_configure()
1694 etdm_data->in_disable_ch[i + 1]) in mtk_dai_etdm_in_configure()
1701 regmap_update_bits(afe->regmap, etdm_reg.con3, mask, val); in mtk_dai_etdm_in_configure()
1703 mask = 0; in mtk_dai_etdm_in_configure()
1704 val = 0; in mtk_dai_etdm_in_configure()
1710 if (etdm_data->lrck_inv) in mtk_dai_etdm_in_configure()
1712 if (etdm_data->bck_inv) in mtk_dai_etdm_in_configure()
1715 if (etdm_data->lrck_inv) in mtk_dai_etdm_in_configure()
1717 if (etdm_data->bck_inv) in mtk_dai_etdm_in_configure()
1720 regmap_update_bits(afe->regmap, etdm_reg.con4, mask, val); in mtk_dai_etdm_in_configure()
1722 mask = 0; in mtk_dai_etdm_in_configure()
1723 val = 0; in mtk_dai_etdm_in_configure()
1728 for (i = 0; i < channels; i += 2) { in mtk_dai_etdm_in_configure()
1729 if (etdm_data->in_disable_ch[i] && in mtk_dai_etdm_in_configure()
1730 !etdm_data->in_disable_ch[i + 1]) { in mtk_dai_etdm_in_configure()
1731 if (i == (channels - 2)) in mtk_dai_etdm_in_configure()
1736 } else if (!etdm_data->in_disable_ch[i] && in mtk_dai_etdm_in_configure()
1737 etdm_data->in_disable_ch[i + 1]) { in mtk_dai_etdm_in_configure()
1741 regmap_update_bits(afe->regmap, etdm_reg.con5, mask, val); in mtk_dai_etdm_in_configure()
1742 return 0; in mtk_dai_etdm_in_configure()
1750 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_out_configure()
1751 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_out_configure()
1753 bool slave_mode = etdm_data->slave_mode; in mtk_dai_etdm_out_configure()
1754 unsigned int lrck_width = etdm_data->lrck_width; in mtk_dai_etdm_out_configure()
1755 unsigned int val = 0; in mtk_dai_etdm_out_configure()
1756 unsigned int mask = 0; in mtk_dai_etdm_out_configure()
1758 int fs = 0; in mtk_dai_etdm_out_configure()
1760 dev_dbg(afe->dev, "%s rate %u channels %u, id %d\n", in mtk_dai_etdm_out_configure()
1764 if (ret < 0) in mtk_dai_etdm_out_configure()
1767 if (etdm_data->cowork_source_id != COWORK_ETDM_NONE) in mtk_dai_etdm_out_configure()
1773 regmap_update_bits(afe->regmap, etdm_reg.con0, mask, val); in mtk_dai_etdm_out_configure()
1775 mask = 0; in mtk_dai_etdm_out_configure()
1776 val = 0; in mtk_dai_etdm_out_configure()
1779 if (lrck_width > 0) { in mtk_dai_etdm_out_configure()
1784 regmap_update_bits(afe->regmap, etdm_reg.con1, mask, val); in mtk_dai_etdm_out_configure()
1786 mask = 0; in mtk_dai_etdm_out_configure()
1787 val = 0; in mtk_dai_etdm_out_configure()
1795 regmap_update_bits(afe->regmap, etdm_reg.con2, in mtk_dai_etdm_out_configure()
1797 mask = 0; in mtk_dai_etdm_out_configure()
1798 val = 0; in mtk_dai_etdm_out_configure()
1813 regmap_update_bits(afe->regmap, etdm_reg.con4, mask, val); in mtk_dai_etdm_out_configure()
1815 mask = 0; in mtk_dai_etdm_out_configure()
1816 val = 0; in mtk_dai_etdm_out_configure()
1822 if (etdm_data->lrck_inv) in mtk_dai_etdm_out_configure()
1824 if (etdm_data->bck_inv) in mtk_dai_etdm_out_configure()
1827 if (etdm_data->lrck_inv) in mtk_dai_etdm_out_configure()
1829 if (etdm_data->bck_inv) in mtk_dai_etdm_out_configure()
1832 regmap_update_bits(afe->regmap, etdm_reg.con5, mask, val); in mtk_dai_etdm_out_configure()
1834 return 0; in mtk_dai_etdm_out_configure()
1839 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_mclk_configure()
1840 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_mclk_configure()
1846 unsigned int val = 0; in mtk_dai_etdm_mclk_configure()
1847 unsigned int mask = 0; in mtk_dai_etdm_mclk_configure()
1848 int ret = 0; in mtk_dai_etdm_mclk_configure()
1850 if (clk_id < 0 || clkdiv_id < 0) in mtk_dai_etdm_mclk_configure()
1851 return 0; in mtk_dai_etdm_mclk_configure()
1854 if (ret < 0) in mtk_dai_etdm_mclk_configure()
1858 if (etdm_data->mclk_dir == SND_SOC_CLOCK_OUT) in mtk_dai_etdm_mclk_configure()
1860 regmap_update_bits(afe->regmap, etdm_reg.con1, mask, val); in mtk_dai_etdm_mclk_configure()
1862 if (etdm_data->mclk_freq) { in mtk_dai_etdm_mclk_configure()
1863 apll = etdm_data->mclk_apll; in mtk_dai_etdm_mclk_configure()
1865 if (apll_clk_id < 0) in mtk_dai_etdm_mclk_configure()
1869 ret = mt8195_afe_set_clk_parent(afe, afe_priv->clk[clk_id], in mtk_dai_etdm_mclk_configure()
1870 afe_priv->clk[apll_clk_id]); in mtk_dai_etdm_mclk_configure()
1875 ret = mt8195_afe_set_clk_rate(afe, afe_priv->clk[clkdiv_id], in mtk_dai_etdm_mclk_configure()
1876 etdm_data->mclk_freq); in mtk_dai_etdm_mclk_configure()
1878 if (etdm_data->mclk_dir == SND_SOC_CLOCK_OUT) in mtk_dai_etdm_mclk_configure()
1879 dev_dbg(afe->dev, "%s mclk freq = 0\n", __func__); in mtk_dai_etdm_mclk_configure()
1890 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_configure()
1891 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_configure()
1893 bool slave_mode = etdm_data->slave_mode; in mtk_dai_etdm_configure()
1895 unsigned int val = 0; in mtk_dai_etdm_configure()
1896 unsigned int mask = 0; in mtk_dai_etdm_configure()
1902 if (ret < 0) in mtk_dai_etdm_configure()
1905 if (etdm_data->cowork_source_id != COWORK_ETDM_NONE) in mtk_dai_etdm_configure()
1908 dev_dbg(afe->dev, "%s fmt %u data %u lrck %d-%u bck %d, clock %u slv %u\n", in mtk_dai_etdm_configure()
1909 __func__, etdm_data->format, etdm_data->data_mode, in mtk_dai_etdm_configure()
1910 etdm_data->lrck_inv, etdm_data->lrck_width, etdm_data->bck_inv, in mtk_dai_etdm_configure()
1911 etdm_data->clock_mode, etdm_data->slave_mode); in mtk_dai_etdm_configure()
1912 dev_dbg(afe->dev, "%s rate %u channels %u bitwidth %u, id %d\n", in mtk_dai_etdm_configure()
1915 etdm_channels = (etdm_data->data_mode == MTK_DAI_ETDM_DATA_ONE_PIN) ? in mtk_dai_etdm_configure()
1920 dev_info(afe->dev, "%s bck rate %u not support\n", in mtk_dai_etdm_configure()
1922 return -EINVAL; in mtk_dai_etdm_configure()
1931 val |= ETDM_CON0_FORMAT(etdm_data->format); in mtk_dai_etdm_configure()
1938 etdm_data->cowork_source_id == COWORK_ETDM_NONE) { in mtk_dai_etdm_configure()
1939 dev_info(afe->dev, "%s id %d only support master mode\n", in mtk_dai_etdm_configure()
1941 return -EINVAL; in mtk_dai_etdm_configure()
1945 regmap_update_bits(afe->regmap, etdm_reg.con0, mask, val); in mtk_dai_etdm_configure()
1952 return 0; in mtk_dai_etdm_configure()
1959 int ret = 0; in mtk_dai_etdm_hw_params()
1964 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_hw_params()
1970 dev_dbg(afe->dev, "%s '%s' period %u-%u\n", in mtk_dai_etdm_hw_params()
1986 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_hw_params()
1987 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_hw_params()
1988 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_hw_params()
1999 ret = mtk_dai_etdm_mclk_configure(afe, dai->id); in mtk_dai_etdm_hw_params()
2004 bit_width, dai->id); in mtk_dai_etdm_hw_params()
2013 int ret = 0; in mtk_dai_etdm_trigger()
2015 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_trigger()
2021 dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id); in mtk_dai_etdm_trigger()
2027 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_trigger()
2031 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_trigger()
2032 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_trigger()
2036 ret = mt8195_afe_enable_etdm(afe, dai->id); in mtk_dai_etdm_trigger()
2043 mst_etdm_data = afe_priv->dai_priv[mst_dai_id]; in mtk_dai_etdm_trigger()
2045 for (i = 0; i < mst_etdm_data->cowork_slv_count; i++) { in mtk_dai_etdm_trigger()
2046 slv_dai_id = mst_etdm_data->cowork_slv_id[i]; in mtk_dai_etdm_trigger()
2052 ret = mt8195_afe_disable_etdm(afe, dai->id); in mtk_dai_etdm_trigger()
2063 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_cal_mclk()
2064 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_cal_mclk()
2068 if (freq == 0) { in mtk_dai_etdm_cal_mclk()
2069 etdm_data->mclk_freq = freq; in mtk_dai_etdm_cal_mclk()
2070 return 0; in mtk_dai_etdm_cal_mclk()
2077 dev_info(afe->dev, "freq %d > apll rate %d\n", freq, apll_rate); in mtk_dai_etdm_cal_mclk()
2078 return -EINVAL; in mtk_dai_etdm_cal_mclk()
2081 if (apll_rate % freq != 0) { in mtk_dai_etdm_cal_mclk()
2082 dev_info(afe->dev, "APLL%d cannot generate freq Hz\n", apll); in mtk_dai_etdm_cal_mclk()
2083 return -EINVAL; in mtk_dai_etdm_cal_mclk()
2086 etdm_data->mclk_apll = apll; in mtk_dai_etdm_cal_mclk()
2087 etdm_data->mclk_freq = freq; in mtk_dai_etdm_cal_mclk()
2089 return 0; in mtk_dai_etdm_cal_mclk()
2096 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_set_sysclk()
2100 dev_dbg(dai->dev, "%s id %d freq %u, dir %d\n", in mtk_dai_etdm_set_sysclk()
2101 __func__, dai->id, freq, dir); in mtk_dai_etdm_set_sysclk()
2105 dai_id = dai->id; in mtk_dai_etdm_set_sysclk()
2107 etdm_data = afe_priv->dai_priv[dai_id]; in mtk_dai_etdm_set_sysclk()
2108 etdm_data->mclk_dir = dir; in mtk_dai_etdm_set_sysclk()
2117 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_set_tdm_slot()
2118 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_etdm_set_tdm_slot()
2120 dev_dbg(dai->dev, "%s id %d slot_width %d\n", in mtk_dai_etdm_set_tdm_slot()
2121 __func__, dai->id, slot_width); in mtk_dai_etdm_set_tdm_slot()
2123 etdm_data->slots = slots; in mtk_dai_etdm_set_tdm_slot()
2124 etdm_data->lrck_width = slot_width; in mtk_dai_etdm_set_tdm_slot()
2125 return 0; in mtk_dai_etdm_set_tdm_slot()
2131 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_set_fmt()
2132 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_etdm_set_fmt()
2136 etdm_data->format = MTK_DAI_ETDM_FORMAT_I2S; in mtk_dai_etdm_set_fmt()
2139 etdm_data->format = MTK_DAI_ETDM_FORMAT_LJ; in mtk_dai_etdm_set_fmt()
2142 etdm_data->format = MTK_DAI_ETDM_FORMAT_RJ; in mtk_dai_etdm_set_fmt()
2145 etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPA; in mtk_dai_etdm_set_fmt()
2148 etdm_data->format = MTK_DAI_ETDM_FORMAT_DSPB; in mtk_dai_etdm_set_fmt()
2151 return -EINVAL; in mtk_dai_etdm_set_fmt()
2156 etdm_data->bck_inv = false; in mtk_dai_etdm_set_fmt()
2157 etdm_data->lrck_inv = false; in mtk_dai_etdm_set_fmt()
2160 etdm_data->bck_inv = false; in mtk_dai_etdm_set_fmt()
2161 etdm_data->lrck_inv = true; in mtk_dai_etdm_set_fmt()
2164 etdm_data->bck_inv = true; in mtk_dai_etdm_set_fmt()
2165 etdm_data->lrck_inv = false; in mtk_dai_etdm_set_fmt()
2168 etdm_data->bck_inv = true; in mtk_dai_etdm_set_fmt()
2169 etdm_data->lrck_inv = true; in mtk_dai_etdm_set_fmt()
2172 return -EINVAL; in mtk_dai_etdm_set_fmt()
2177 etdm_data->slave_mode = true; in mtk_dai_etdm_set_fmt()
2180 etdm_data->slave_mode = false; in mtk_dai_etdm_set_fmt()
2183 return -EINVAL; in mtk_dai_etdm_set_fmt()
2186 return 0; in mtk_dai_etdm_set_fmt()
2193 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_hdmitx_dptx_startup()
2194 int cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id); in mtk_dai_hdmitx_dptx_startup()
2196 if (cg_id >= 0) in mtk_dai_hdmitx_dptx_startup()
2197 mt8195_afe_enable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_hdmitx_dptx_startup()
2199 mtk_dai_etdm_enable_mclk(afe, dai->id); in mtk_dai_hdmitx_dptx_startup()
2201 return 0; in mtk_dai_hdmitx_dptx_startup()
2208 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_hdmitx_dptx_shutdown()
2209 int cg_id = mtk_dai_etdm_get_cg_id_by_dai_id(dai->id); in mtk_dai_hdmitx_dptx_shutdown()
2211 mtk_dai_etdm_disable_mclk(afe, dai->id); in mtk_dai_hdmitx_dptx_shutdown()
2213 if (cg_id >= 0) in mtk_dai_hdmitx_dptx_shutdown()
2214 mt8195_afe_disable_clk(afe, afe_priv->clk[cg_id]); in mtk_dai_hdmitx_dptx_shutdown()
2250 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_hdmitx_dptx_hw_params()
2251 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_hdmitx_dptx_hw_params()
2256 int ret = 0; in mtk_dai_hdmitx_dptx_hw_params()
2259 if (dai->id == MT8195_AFE_IO_DPTX) { in mtk_dai_hdmitx_dptx_hw_params()
2260 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_hw_params()
2263 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_hw_params()
2266 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_hw_params()
2271 etdm_data->data_mode = MTK_DAI_ETDM_DATA_ONE_PIN; in mtk_dai_hdmitx_dptx_hw_params()
2277 etdm_data->data_mode = MTK_DAI_ETDM_DATA_MULTI_PIN; in mtk_dai_hdmitx_dptx_hw_params()
2280 ret = mtk_dai_etdm_mclk_configure(afe, dai->id); in mtk_dai_hdmitx_dptx_hw_params()
2284 ret = mtk_dai_etdm_configure(afe, rate, channels, width, dai->id); in mtk_dai_hdmitx_dptx_hw_params()
2294 int ret = 0; in mtk_dai_hdmitx_dptx_trigger()
2296 dev_dbg(afe->dev, "%s(), cmd %d, dai id %d\n", __func__, cmd, dai->id); in mtk_dai_hdmitx_dptx_trigger()
2302 if (dai->id == MT8195_AFE_IO_DPTX) in mtk_dai_hdmitx_dptx_trigger()
2303 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_trigger()
2308 ret = mt8195_afe_enable_etdm(afe, dai->id); in mtk_dai_hdmitx_dptx_trigger()
2313 ret = mt8195_afe_disable_etdm(afe, dai->id); in mtk_dai_hdmitx_dptx_trigger()
2316 if (dai->id == MT8195_AFE_IO_DPTX) in mtk_dai_hdmitx_dptx_trigger()
2317 regmap_update_bits(afe->regmap, AFE_DPTX_CON, in mtk_dai_hdmitx_dptx_trigger()
2318 AFE_DPTX_CON_ON_MASK, 0); in mtk_dai_hdmitx_dptx_trigger()
2321 return -EINVAL; in mtk_dai_hdmitx_dptx_trigger()
2333 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_hdmitx_dptx_set_sysclk()
2334 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_hdmitx_dptx_set_sysclk()
2336 dev_dbg(dai->dev, "%s id %d freq %u, dir %d\n", in mtk_dai_hdmitx_dptx_set_sysclk()
2337 __func__, dai->id, freq, dir); in mtk_dai_hdmitx_dptx_set_sysclk()
2339 etdm_data->mclk_dir = dir; in mtk_dai_hdmitx_dptx_set_sysclk()
2340 return mtk_dai_etdm_cal_mclk(afe, freq, dai->id); in mtk_dai_hdmitx_dptx_set_sysclk()
2372 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mtk_dai_etdm_probe()
2373 struct mtk_dai_etdm_priv *etdm_data = afe_priv->dai_priv[dai->id]; in mtk_dai_etdm_probe()
2375 dev_dbg(dai->dev, "%s id %d\n", __func__, dai->id); in mtk_dai_etdm_probe()
2377 if (etdm_data->mclk_freq) { in mtk_dai_etdm_probe()
2378 dev_dbg(afe->dev, "MCLK always on, rate %d\n", in mtk_dai_etdm_probe()
2379 etdm_data->mclk_freq); in mtk_dai_etdm_probe()
2380 pm_runtime_get_sync(afe->dev); in mtk_dai_etdm_probe()
2381 mtk_dai_etdm_mclk_configure(afe, dai->id); in mtk_dai_etdm_probe()
2382 mtk_dai_etdm_enable_mclk(afe, dai->id); in mtk_dai_etdm_probe()
2383 pm_runtime_put_sync(afe->dev); in mtk_dai_etdm_probe()
2385 return 0; in mtk_dai_etdm_probe()
2470 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_etdm_update_sync_info()
2477 etdm_data = afe_priv->dai_priv[i]; in mt8195_etdm_update_sync_info()
2478 if (etdm_data->cowork_source_id != COWORK_ETDM_NONE) { in mt8195_etdm_update_sync_info()
2479 mst_dai_id = etdm_data->cowork_source_id; in mt8195_etdm_update_sync_info()
2480 mst_data = afe_priv->dai_priv[mst_dai_id]; in mt8195_etdm_update_sync_info()
2481 if (mst_data->cowork_source_id != COWORK_ETDM_NONE) in mt8195_etdm_update_sync_info()
2482 dev_info(afe->dev, "%s [%d] wrong sync source\n" in mt8195_etdm_update_sync_info()
2484 mst_data->cowork_slv_id[mst_data->cowork_slv_count] = i; in mt8195_etdm_update_sync_info()
2485 mst_data->cowork_slv_count++; in mt8195_etdm_update_sync_info()
2492 const struct device_node *of_node = afe->dev->of_node; in mt8195_dai_etdm_parse_of()
2493 struct mt8195_afe_private *afe_priv = afe->platform_priv; in mt8195_dai_etdm_parse_of()
2507 {"etdm-in1", ETDM_SYNC_FROM_IN1}, in mt8195_dai_etdm_parse_of()
2508 {"etdm-in2", ETDM_SYNC_FROM_IN2}, in mt8195_dai_etdm_parse_of()
2509 {"etdm-out1", ETDM_SYNC_FROM_OUT1}, in mt8195_dai_etdm_parse_of()
2510 {"etdm-out2", ETDM_SYNC_FROM_OUT2}, in mt8195_dai_etdm_parse_of()
2511 {"etdm-out3", ETDM_SYNC_FROM_OUT3}, in mt8195_dai_etdm_parse_of()
2514 for (i = 0; i < MT8195_AFE_IO_ETDM_NUM; i++) { in mt8195_dai_etdm_parse_of()
2516 etdm_data = afe_priv->dai_priv[dai_id]; in mt8195_dai_etdm_parse_of()
2519 "mediatek,%s-mclk-always-on-rate", in mt8195_dai_etdm_parse_of()
2521 if (ret < 0) { in mt8195_dai_etdm_parse_of()
2522 dev_info(afe->dev, "%s snprintf err=%d\n", in mt8195_dai_etdm_parse_of()
2527 if (ret == 0) { in mt8195_dai_etdm_parse_of()
2528 etdm_data->mclk_dir = SND_SOC_CLOCK_OUT; in mt8195_dai_etdm_parse_of()
2530 dev_info(afe->dev, "%s unsupported mclk %uHz\n", in mt8195_dai_etdm_parse_of()
2535 "mediatek,%s-multi-pin-mode", in mt8195_dai_etdm_parse_of()
2537 if (ret < 0) { in mt8195_dai_etdm_parse_of()
2538 dev_info(afe->dev, "%s snprintf err=%d\n", in mt8195_dai_etdm_parse_of()
2542 etdm_data->data_mode = of_property_read_bool(of_node, prop); in mt8195_dai_etdm_parse_of()
2545 "mediatek,%s-cowork-source", in mt8195_dai_etdm_parse_of()
2547 if (ret < 0) { in mt8195_dai_etdm_parse_of()
2548 dev_info(afe->dev, "%s snprintf err=%d\n", in mt8195_dai_etdm_parse_of()
2553 if (ret == 0) { in mt8195_dai_etdm_parse_of()
2555 dev_info(afe->dev, "%s invalid id=%d\n", in mt8195_dai_etdm_parse_of()
2557 etdm_data->cowork_source_id = COWORK_ETDM_NONE; in mt8195_dai_etdm_parse_of()
2560 etdm_data->cowork_source_id = in mt8195_dai_etdm_parse_of()
2564 etdm_data->cowork_source_id = COWORK_ETDM_NONE; in mt8195_dai_etdm_parse_of()
2569 for (i = 0; i < 2; i++) { in mt8195_dai_etdm_parse_of()
2571 "mediatek,%s-chn-disabled", in mt8195_dai_etdm_parse_of()
2573 if (ret < 0) { in mt8195_dai_etdm_parse_of()
2574 dev_info(afe->dev, "%s snprintf err=%d\n", in mt8195_dai_etdm_parse_of()
2581 if (ret < 0) in mt8195_dai_etdm_parse_of()
2584 for (j = 0; j < ret; j++) { in mt8195_dai_etdm_parse_of()
2586 dev_info(afe->dev, "%s [%d] invalid chn %u\n", in mt8195_dai_etdm_parse_of()
2589 etdm_data->in_disable_ch[disable_chn[j]] = true; in mt8195_dai_etdm_parse_of()
2597 struct mt8195_afe_private *afe_priv = afe->platform_priv; in init_etdm_priv_data()
2602 etdm_priv = devm_kzalloc(afe->dev, in init_etdm_priv_data()
2606 return -ENOMEM; in init_etdm_priv_data()
2608 afe_priv->dai_priv[i] = etdm_priv; in init_etdm_priv_data()
2611 afe_priv->dai_priv[MT8195_AFE_IO_DPTX] = in init_etdm_priv_data()
2612 afe_priv->dai_priv[MT8195_AFE_IO_ETDM3_OUT]; in init_etdm_priv_data()
2615 return 0; in init_etdm_priv_data()
2622 dai = devm_kzalloc(afe->dev, sizeof(*dai), GFP_KERNEL); in mt8195_dai_etdm_register()
2624 return -ENOMEM; in mt8195_dai_etdm_register()
2626 list_add(&dai->list, &afe->sub_dais); in mt8195_dai_etdm_register()
2628 dai->dai_drivers = mtk_dai_etdm_driver; in mt8195_dai_etdm_register()
2629 dai->num_dai_drivers = ARRAY_SIZE(mtk_dai_etdm_driver); in mt8195_dai_etdm_register()
2631 dai->dapm_widgets = mtk_dai_etdm_widgets; in mt8195_dai_etdm_register()
2632 dai->num_dapm_widgets = ARRAY_SIZE(mtk_dai_etdm_widgets); in mt8195_dai_etdm_register()
2633 dai->dapm_routes = mtk_dai_etdm_routes; in mt8195_dai_etdm_register()
2634 dai->num_dapm_routes = ARRAY_SIZE(mtk_dai_etdm_routes); in mt8195_dai_etdm_register()
2635 dai->controls = mtk_dai_etdm_controls; in mt8195_dai_etdm_register()
2636 dai->num_controls = ARRAY_SIZE(mtk_dai_etdm_controls); in mt8195_dai_etdm_register()