Lines Matching +full:static +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0
9 #include <linux/dma-mapping.h>
17 static void set_playback_gpio(struct mt6357_priv *priv, bool enable) in set_playback_gpio() argument
19 regmap_write(priv->regmap, MT6357_GPIO_MODE2_CLR, MT6357_GPIO_MODE2_CLEAR_ALL); in set_playback_gpio()
20 if (enable) { in set_playback_gpio()
22 regmap_write(priv->regmap, MT6357_GPIO_MODE2_SET, in set_playback_gpio()
32 regmap_update_bits(priv->regmap, MT6357_GPIO_DIR0, in set_playback_gpio()
44 static void set_capture_gpio(struct mt6357_priv *priv, bool enable) in set_capture_gpio() argument
46 regmap_write(priv->regmap, MT6357_GPIO_MODE3_CLR, MT6357_GPIO_MODE3_CLEAR_ALL); in set_capture_gpio()
47 if (enable) { in set_capture_gpio()
49 regmap_write(priv->regmap, MT6357_GPIO_MODE3_SET, in set_capture_gpio()
61 regmap_update_bits(priv->regmap, MT6357_GPIO_DIR0, in set_capture_gpio()
73 static void hp_main_output_ramp(struct mt6357_priv *priv, bool up) in hp_main_output_ramp()
77 /* Enable/Reduce HPL/R main output stage step by step */ in hp_main_output_ramp()
79 stage = up ? i : MT6357_HPLOUT_STG_CTRL_VAUDP15_MAX - i; in hp_main_output_ramp()
80 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_output_ramp()
83 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_output_ramp()
90 static void hp_aux_feedback_loop_gain_ramp(struct mt6357_priv *priv, bool up) in hp_aux_feedback_loop_gain_ramp()
96 stage = up ? i : MT6357_HP_AUX_LOOP_GAIN_MAX - i; in hp_aux_feedback_loop_gain_ramp()
97 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in hp_aux_feedback_loop_gain_ramp()
104 static void hp_pull_down(struct mt6357_priv *priv, bool enable) in hp_pull_down() argument
106 if (enable) in hp_pull_down()
107 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON2, in hp_pull_down()
111 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON2, in hp_pull_down()
116 static bool is_valid_hp_pga_idx(int reg_idx) in is_valid_hp_pga_idx()
121 static void volume_ramp(struct mt6357_priv *priv, int lfrom, int lto, in volume_ramp()
137 lcount = -1; in volume_ramp()
142 rcount = -1; in volume_ramp()
148 regmap_update_bits(priv->regmap, reg_addr, in volume_ramp()
157 regmap_update_bits(priv->regmap, reg_addr, in volume_ramp()
168 static void lo_volume_ramp(struct mt6357_priv *priv, int lfrom, int lto, int rfrom, int rto) in lo_volume_ramp()
173 static void hp_volume_ramp(struct mt6357_priv *priv, int lfrom, int lto, int rfrom, int rto) in hp_volume_ramp()
178 static void hs_volume_ramp(struct mt6357_priv *priv, int from, int to) in hs_volume_ramp()
184 static const DECLARE_TLV_DB_SCALE(playback_tlv, -1000, 100, 0);
185 static const DECLARE_TLV_DB_SCALE(capture_tlv, 0, 600, 0);
186 static const DECLARE_TLV_DB_SCALE(hp_degain_tlv, -1200, 1200, 0);
188 static const struct snd_kcontrol_new mt6357_controls[] = {
228 static const char * const mic_type_mux_map[] = {
239 static SOC_ENUM_SINGLE_DECL(mic_type_mux_map_enum, SND_SOC_NOPM,
242 static const struct snd_kcontrol_new mic_type_mux_control =
245 static const char * const pga_mux_map[] = {
249 static SOC_ENUM_SINGLE_DECL(pga_left_mux_map_enum,
254 static const struct snd_kcontrol_new pga_left_mux_control =
257 static SOC_ENUM_SINGLE_DECL(pga_right_mux_map_enum,
262 static const struct snd_kcontrol_new pga_right_mux_control =
266 static const char * const hslo_mux_map[] = {
270 static SOC_ENUM_SINGLE_DECL(lo_mux_map_enum,
275 static const struct snd_kcontrol_new lo_mux_control =
278 static SOC_ENUM_SINGLE_DECL(hs_mux_map_enum,
283 static const struct snd_kcontrol_new hs_mux_control =
286 static const char * const hplr_mux_map[] = {
290 static SOC_ENUM_SINGLE_DECL(hpr_mux_map_enum,
295 static const struct snd_kcontrol_new hpr_mux_control =
298 static SOC_ENUM_SINGLE_DECL(hpl_mux_map_enum,
303 static const struct snd_kcontrol_new hpl_mux_control =
306 static const char * const dac_mux_map[] = {
310 static SOC_ENUM_SINGLE_DECL(dac_mux_map_enum,
315 static const struct snd_kcontrol_new dac_mux_control =
318 static int mt6357_set_dmic(struct mt6357_priv *priv, bool enable) in mt6357_set_dmic() argument
320 if (enable) { in mt6357_set_dmic()
321 /* DMIC enable */ in mt6357_set_dmic()
322 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON7, in mt6357_set_dmic()
325 /* enable aud_pad TX fifos */ in mt6357_set_dmic()
326 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in mt6357_set_dmic()
330 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_H, in mt6357_set_dmic()
334 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in mt6357_set_dmic()
338 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in mt6357_set_dmic()
345 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in mt6357_set_dmic()
349 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in mt6357_set_dmic()
353 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in mt6357_set_dmic()
357 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_H, in mt6357_set_dmic()
361 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON7, in mt6357_set_dmic()
368 static int mt6357_set_amic(struct mt6357_priv *priv, bool enable, unsigned int mic_type) in mt6357_set_amic() argument
370 if (enable) { in mt6357_set_amic()
372 regmap_update_bits(priv->regmap, MT6357_AFE_DCCLK_CFG0, in mt6357_set_amic()
374 regmap_update_bits(priv->regmap, MT6357_AFE_DCCLK_CFG0, in mt6357_set_amic()
376 regmap_update_bits(priv->regmap, MT6357_AFE_DCCLK_CFG0, in mt6357_set_amic()
378 regmap_update_bits(priv->regmap, MT6357_AFE_DCCLK_CFG1, in mt6357_set_amic()
385 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON8, in mt6357_set_amic()
390 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON8, in mt6357_set_amic()
395 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON8, in mt6357_set_amic()
403 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON9, in mt6357_set_amic()
408 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt6357_set_amic()
411 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt6357_set_amic()
415 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt6357_set_amic()
419 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt6357_set_amic()
424 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt6357_set_amic()
428 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt6357_set_amic()
432 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt6357_set_amic()
436 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt6357_set_amic()
442 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON8, in mt6357_set_amic()
446 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON9, in mt6357_set_amic()
450 regmap_update_bits(priv->regmap, MT6357_AFE_DCCLK_CFG0, in mt6357_set_amic()
452 regmap_update_bits(priv->regmap, MT6357_AFE_DCCLK_CFG0, in mt6357_set_amic()
454 regmap_update_bits(priv->regmap, MT6357_AFE_DCCLK_CFG0, in mt6357_set_amic()
462 static int mt6357_set_loopback(struct mt6357_priv *priv, bool enable) in mt6357_set_loopback() argument
464 if (enable) { in mt6357_set_loopback()
465 /* enable aud_pad TX fifos */ in mt6357_set_loopback()
466 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in mt6357_set_loopback()
469 /* enable aud_pad lpk TX fifos */ in mt6357_set_loopback()
470 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in mt6357_set_loopback()
473 /* Set UL Part: enable new lpbk 2 */ in mt6357_set_loopback()
474 regmap_update_bits(priv->regmap, MT6357_AFE_ADDA_MTKAIF_CFG0, in mt6357_set_loopback()
478 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in mt6357_set_loopback()
483 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in mt6357_set_loopback()
487 regmap_update_bits(priv->regmap, MT6357_AFE_ADDA_MTKAIF_CFG0, in mt6357_set_loopback()
491 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in mt6357_set_loopback()
495 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in mt6357_set_loopback()
503 static int mt6357_set_ul_sine_gen(struct mt6357_priv *priv, bool enable) in mt6357_set_ul_sine_gen() argument
505 if (enable) { in mt6357_set_ul_sine_gen()
506 /* enable aud_pad TX fifos */ in mt6357_set_ul_sine_gen()
507 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in mt6357_set_ul_sine_gen()
511 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in mt6357_set_ul_sine_gen()
516 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in mt6357_set_ul_sine_gen()
520 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in mt6357_set_ul_sine_gen()
528 static int mt_aif_out_event(struct snd_soc_dapm_widget *w, in mt_aif_out_event()
532 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_aif_out_event()
549 static int mt_adc_supply_event(struct snd_soc_dapm_widget *w, in mt_adc_supply_event()
553 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_adc_supply_event()
558 /* Enable audio ADC CLKGEN */ in mt_adc_supply_event()
559 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON11, in mt_adc_supply_event()
561 /* Enable LCLDO_ENC 2P8V */ in mt_adc_supply_event()
562 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON12, in mt_adc_supply_event()
565 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON12, in mt_adc_supply_event()
573 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON12, in mt_adc_supply_event()
579 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON12, in mt_adc_supply_event()
583 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON11, in mt_adc_supply_event()
594 static int mt_mic_type_event(struct snd_soc_dapm_widget *w, in mt_mic_type_event()
598 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_mic_type_event()
600 unsigned int mic_type = dapm_kcontrol_get_value(w->kcontrols[0]); in mt_mic_type_event()
642 static int mt_pga_left_event(struct snd_soc_dapm_widget *w, in mt_pga_left_event()
646 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_pga_left_event()
651 /* L preamplifier enable */ in mt_pga_left_event()
652 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
655 /* L ADC input sel : L PGA. Enable audio L ADC */ in mt_pga_left_event()
656 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
659 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
663 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
669 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
672 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
676 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
680 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
684 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_left_event()
695 static int mt_pga_right_event(struct snd_soc_dapm_widget *w, in mt_pga_right_event()
699 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_pga_right_event()
704 /* R preamplifier enable */ in mt_pga_right_event()
705 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt_pga_right_event()
707 /* R ADC input sel : R PGA. Enable audio R ADC */ in mt_pga_right_event()
708 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt_pga_right_event()
711 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt_pga_right_event()
714 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt_pga_right_event()
720 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt_pga_right_event()
722 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in mt_pga_right_event()
725 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt_pga_right_event()
728 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt_pga_right_event()
731 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in mt_pga_right_event()
742 static int adc_enable_event(struct snd_soc_dapm_widget *w, in adc_enable_event()
746 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in adc_enable_event()
752 regmap_read(priv->regmap, MT6357_AUDENC_ANA_CON0, &lgain); in adc_enable_event()
753 regmap_read(priv->regmap, MT6357_AUDENC_ANA_CON1, &rgain); in adc_enable_event()
755 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in adc_enable_event()
759 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in adc_enable_event()
762 /* enable aud_pad TX fifos */ in adc_enable_event()
763 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in adc_enable_event()
767 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in adc_enable_event()
772 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON0, in adc_enable_event()
774 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON1, in adc_enable_event()
779 regmap_update_bits(priv->regmap, MT6357_AFE_UL_SRC_CON0_L, in adc_enable_event()
782 regmap_update_bits(priv->regmap, MT6357_AFE_AUD_PAD_TOP, in adc_enable_event()
793 static void configure_downlinks(struct mt6357_priv *priv, bool enable) in configure_downlinks() argument
795 if (enable) { in configure_downlinks()
796 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ELR_0, in configure_downlinks()
799 /* Disable headphone short-circuit protection */ in configure_downlinks()
800 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in configure_downlinks()
804 /* Disable handset short-circuit protection */ in configure_downlinks()
805 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in configure_downlinks()
808 /* Disable lineout short-circuit protection */ in configure_downlinks()
809 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in configure_downlinks()
813 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON2, in configure_downlinks()
817 regmap_write(priv->regmap, MT6357_AUDNCP_CLKDIV_CON1, MT6357_DIVCKS_ON); in configure_downlinks()
819 regmap_write(priv->regmap, MT6357_AUDNCP_CLKDIV_CON2, 0x002c); in configure_downlinks()
821 regmap_write(priv->regmap, MT6357_AUDNCP_CLKDIV_CON0, MT6357_DIVCKS_CHG); in configure_downlinks()
823 regmap_write(priv->regmap, MT6357_AUDNCP_CLKDIV_CON4, in configure_downlinks()
825 /* Enable NCP */ in configure_downlinks()
826 regmap_write(priv->regmap, MT6357_AUDNCP_CLKDIV_CON3, in configure_downlinks()
829 /* Enable cap-less LDOs (1.5V) */ in configure_downlinks()
830 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON12, in configure_downlinks()
841 /* Enable NV regulator (-1.2V) */ in configure_downlinks()
842 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON13, in configure_downlinks()
845 /* Enable IBIST */ in configure_downlinks()
846 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON10, in configure_downlinks()
849 /* Enable AUD_CLK */ in configure_downlinks()
850 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON11, in configure_downlinks()
853 /* Enable low-noise mode of DAC */ in configure_downlinks()
854 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in configure_downlinks()
859 /* Disable low-noise mode of DAC */ in configure_downlinks()
860 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in configure_downlinks()
864 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON11, in configure_downlinks()
867 /* Enable linout short-circuit protection */ in configure_downlinks()
868 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in configure_downlinks()
871 /* Enable handset short-circuit protection */ in configure_downlinks()
872 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in configure_downlinks()
875 /* Enable headphone short-circuit protection */ in configure_downlinks()
876 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in configure_downlinks()
882 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON10, in configure_downlinks()
885 /* Disable NV regulator (-1.2V) */ in configure_downlinks()
886 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON13, in configure_downlinks()
889 /* Disable cap-less LDOs (1.5V) */ in configure_downlinks()
890 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON12, in configure_downlinks()
902 regmap_update_bits(priv->regmap, MT6357_AUDNCP_CLKDIV_CON3, in configure_downlinks()
907 static int mt_audio_in_event(struct snd_soc_dapm_widget *w, in mt_audio_in_event()
911 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_audio_in_event()
918 /* Pull-down HPL/R to AVSS28_AUD */ in mt_audio_in_event()
919 if (priv->pull_down_needed) in mt_audio_in_event()
923 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in mt_audio_in_event()
927 regmap_write(priv->regmap, MT6357_AFUNC_AUD_CON2, in mt_audio_in_event()
933 regmap_write(priv->regmap, MT6357_AFUNC_AUD_CON0, in mt_audio_in_event()
942 /* scrambler clock on enable */ in mt_audio_in_event()
943 regmap_write(priv->regmap, MT6357_AFUNC_AUD_CON2, in mt_audio_in_event()
949 regmap_write(priv->regmap, MT6357_AFUNC_AUD_CON2, in mt_audio_in_event()
960 regmap_write(priv->regmap, MT6357_AFUNC_AUD_CON2, in mt_audio_in_event()
965 regmap_write(priv->regmap, MT6357_AFUNC_AUD_CON0, in mt_audio_in_event()
977 /* disable Pull-down HPL/R to AVSS28_AUD */ in mt_audio_in_event()
978 if (priv->pull_down_needed) in mt_audio_in_event()
988 static int mt_delay_250_event(struct snd_soc_dapm_widget *w, in mt_delay_250_event()
1006 static int lo_mux_event(struct snd_soc_dapm_widget *w, in lo_mux_event()
1010 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in lo_mux_event()
1015 regmap_read(priv->regmap, MT6357_ZCD_CON1, &lgain); in lo_mux_event()
1020 /* Set -40dB before enable HS to avoid POP noise */ in lo_mux_event()
1021 regmap_update_bits(priv->regmap, MT6357_ZCD_CON1, in lo_mux_event()
1026 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in lo_mux_event()
1029 /* Enable LO driver bias circuits */ in lo_mux_event()
1030 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in lo_mux_event()
1033 /* Enable LO driver core circuits */ in lo_mux_event()
1034 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in lo_mux_event()
1047 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in lo_mux_event()
1051 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in lo_mux_event()
1055 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in lo_mux_event()
1059 regmap_update_bits(priv->regmap, MT6357_ZCD_CON1, in lo_mux_event()
1073 static int hs_mux_event(struct snd_soc_dapm_widget *w, in hs_mux_event()
1077 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in hs_mux_event()
1082 regmap_read(priv->regmap, MT6357_ZCD_CON3, &gain); in hs_mux_event()
1085 /* Set -40dB before enable HS to avoid POP noise */ in hs_mux_event()
1086 regmap_update_bits(priv->regmap, MT6357_ZCD_CON3, in hs_mux_event()
1091 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in hs_mux_event()
1094 /* Enable HS driver bias circuits */ in hs_mux_event()
1095 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in hs_mux_event()
1098 /* Enable HS driver core circuits */ in hs_mux_event()
1099 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in hs_mux_event()
1109 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in hs_mux_event()
1113 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in hs_mux_event()
1117 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in hs_mux_event()
1121 regmap_update_bits(priv->regmap, MT6357_ZCD_CON3, in hs_mux_event()
1131 static int hp_main_mux_event(struct snd_soc_dapm_widget *w, in hp_main_mux_event()
1135 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in hp_main_mux_event()
1140 regmap_read(priv->regmap, MT6357_ZCD_CON2, &lgain); in hp_main_mux_event()
1145 priv->hp_channel_number++; in hp_main_mux_event()
1146 if (priv->hp_channel_number > 1) in hp_main_mux_event()
1148 /* Set -40dB before enable HS to avoid POP noise */ in hp_main_mux_event()
1149 regmap_update_bits(priv->regmap, MT6357_ZCD_CON2, in hp_main_mux_event()
1154 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON2, in hp_main_mux_event()
1159 /* Enable HP aux output stage */ in hp_main_mux_event()
1160 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1165 /* Enable HP aux feedback loop */ in hp_main_mux_event()
1166 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1171 /* Enable HP aux CMFB loop */ in hp_main_mux_event()
1172 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in hp_main_mux_event()
1179 /* Enable HP driver bias circuits */ in hp_main_mux_event()
1180 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in hp_main_mux_event()
1185 /* Enable HP driver core circuits */ in hp_main_mux_event()
1186 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in hp_main_mux_event()
1192 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1197 /* Enable HP main CMFB loop */ in hp_main_mux_event()
1198 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in hp_main_mux_event()
1202 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in hp_main_mux_event()
1207 /* Enable HP main output stage */ in hp_main_mux_event()
1208 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1213 /* Enable HPR/L main output stage step by step */ in hp_main_mux_event()
1219 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1228 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1234 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1242 priv->hp_channel_number--; in hp_main_mux_event()
1243 if (priv->hp_channel_number > 0) in hp_main_mux_event()
1246 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1251 /* Enable HP aux output stage */ in hp_main_mux_event()
1252 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1260 /* Enable HP aux feedback loop */ in hp_main_mux_event()
1261 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1271 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1276 /* Enable HP aux CMFB loop */ in hp_main_mux_event()
1277 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in hp_main_mux_event()
1285 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in hp_main_mux_event()
1289 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1295 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in hp_main_mux_event()
1301 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in hp_main_mux_event()
1307 * Enable HP main CMFB for HP off state in hp_main_mux_event()
1309 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON6, in hp_main_mux_event()
1317 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1323 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON1, in hp_main_mux_event()
1329 regmap_update_bits(priv->regmap, MT6357_ZCD_CON2, in hp_main_mux_event()
1342 static int right_dac_event(struct snd_soc_dapm_widget *w, in right_dac_event()
1346 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in right_dac_event()
1351 /* Enable Audio DAC and control audio bias gen */ in right_dac_event()
1352 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in right_dac_event()
1359 /* disable Pull-down HPL/R to AVSS28_AUD */ in right_dac_event()
1360 if (priv->pull_down_needed) in right_dac_event()
1364 /* Pull-down HPL/R to AVSS28_AUD */ in right_dac_event()
1365 if (priv->pull_down_needed) in right_dac_event()
1368 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in right_dac_event()
1381 static int left_dac_event(struct snd_soc_dapm_widget *w, in left_dac_event()
1385 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in left_dac_event()
1390 /* Enable Audio DAC and control audio bias gen */ in left_dac_event()
1391 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in left_dac_event()
1398 /* disable Pull-down HPL/R to AVSS28_AUD */ in left_dac_event()
1399 if (priv->pull_down_needed) in left_dac_event()
1403 /* Pull-down HPL/R to AVSS28_AUD */ in left_dac_event()
1404 if (priv->pull_down_needed) in left_dac_event()
1407 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in left_dac_event()
1440 static const struct snd_soc_dapm_widget mt6357_dapm_widgets[] = {
1575 SND_SOC_DAPM_SUPPLY("SGEN UL Enable",
1577 SND_SOC_DAPM_SUPPLY("SGEN Enable",
1586 static const struct snd_soc_dapm_route mt6357_dapm_routes[] = {
1612 {"SGEN UL", NULL, "SGEN UL Enable"},
1614 {"SGEN UL", NULL, "SGEN Enable"},
1641 {"SGEN DL", NULL, "SGEN Enable"},
1689 static struct snd_soc_dai_driver mtk_6357_dai_codecs[] = {
1691 .name = "mt6357-snd-codec-aif1",
1709 static int mt6357_codec_probe(struct snd_soc_component *codec) in mt6357_codec_probe()
1713 snd_soc_component_init_regmap(codec, priv->regmap); in mt6357_codec_probe()
1715 /* Enable audio part */ in mt6357_codec_probe()
1716 regmap_update_bits(priv->regmap, MT6357_DCXO_CW14, in mt6357_codec_probe()
1719 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON0, in mt6357_codec_probe()
1725 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON3, in mt6357_codec_probe()
1729 regmap_update_bits(priv->regmap, MT6357_AUDDEC_ANA_CON4, in mt6357_codec_probe()
1736 regmap_update_bits(priv->regmap, MT6357_DCXO_CW14, in mt6357_codec_probe()
1743 static const struct snd_soc_component_driver mt6357_soc_component_driver = {
1755 static const u32 micbias_values[] = {
1760 static u32 mt6357_get_micbias_idx(struct device_node *np, const char *micbias) in mt6357_get_micbias_idx()
1776 static int mt6357_parse_dt(struct mt6357_priv *priv) in mt6357_parse_dt()
1779 struct device_node *np = priv->dev->parent->of_node; in mt6357_parse_dt()
1782 return -EINVAL; in mt6357_parse_dt()
1784 priv->pull_down_needed = false; in mt6357_parse_dt()
1785 if (of_property_read_bool(np, "mediatek,hp-pull-down")) in mt6357_parse_dt()
1786 priv->pull_down_needed = true; in mt6357_parse_dt()
1788 micbias_voltage_index = mt6357_get_micbias_idx(np, "mediatek,micbias0-microvolt"); in mt6357_parse_dt()
1789 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON8, in mt6357_parse_dt()
1793 micbias_voltage_index = mt6357_get_micbias_idx(np, "mediatek,micbias1-microvolt"); in mt6357_parse_dt()
1794 regmap_update_bits(priv->regmap, MT6357_AUDENC_ANA_CON9, in mt6357_parse_dt()
1801 static int mt6357_platform_driver_probe(struct platform_device *pdev) in mt6357_platform_driver_probe()
1803 struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent); in mt6357_platform_driver_probe()
1807 ret = devm_regulator_get_enable(&pdev->dev, "vaud28"); in mt6357_platform_driver_probe()
1809 return dev_err_probe(&pdev->dev, ret, "Failed to enable vaud28 regulator\n"); in mt6357_platform_driver_probe()
1811 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mt6357_platform_driver_probe()
1813 return -ENOMEM; in mt6357_platform_driver_probe()
1815 dev_set_drvdata(&pdev->dev, priv); in mt6357_platform_driver_probe()
1816 priv->dev = &pdev->dev; in mt6357_platform_driver_probe()
1818 priv->regmap = mt6397->regmap; in mt6357_platform_driver_probe()
1819 if (IS_ERR(priv->regmap)) in mt6357_platform_driver_probe()
1820 return PTR_ERR(priv->regmap); in mt6357_platform_driver_probe()
1824 return dev_err_probe(&pdev->dev, ret, "Failed to parse dts\n"); in mt6357_platform_driver_probe()
1826 pdev->dev.coherent_dma_mask = DMA_BIT_MASK(64); in mt6357_platform_driver_probe()
1827 if (!pdev->dev.dma_mask) in mt6357_platform_driver_probe()
1828 pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; in mt6357_platform_driver_probe()
1830 return devm_snd_soc_register_component(&pdev->dev, in mt6357_platform_driver_probe()
1836 static const struct platform_device_id mt6357_platform_ids[] = {
1837 {"mt6357-sound", 0},
1842 static struct platform_driver mt6357_platform_driver = {
1844 .name = "mt6357-sound",