Lines Matching +full:micbias2 +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0
3 // mt6359.c -- mt6359 ALSA SoC audio codec driver
24 regmap_write(priv->regmap, MT6359_GPIO_MODE2_CLR, 0x0ffe); in mt6359_set_playback_gpio()
25 regmap_write(priv->regmap, MT6359_GPIO_MODE2_SET, 0x0249); in mt6359_set_playback_gpio()
28 regmap_write(priv->regmap, MT6359_GPIO_MODE3_CLR, 0x6); in mt6359_set_playback_gpio()
29 regmap_write(priv->regmap, MT6359_GPIO_MODE3_SET, 0x1); in mt6359_set_playback_gpio()
39 regmap_write(priv->regmap, MT6359_GPIO_MODE2_CLR, 0x0ff8); in mt6359_reset_playback_gpio()
40 regmap_update_bits(priv->regmap, MT6359_GPIO_DIR0, 0x7 << 9, 0x0); in mt6359_reset_playback_gpio()
46 regmap_write(priv->regmap, MT6359_GPIO_MODE3_CLR, 0x0e00); in mt6359_set_capture_gpio()
47 regmap_write(priv->regmap, MT6359_GPIO_MODE3_SET, 0x0200); in mt6359_set_capture_gpio()
49 regmap_write(priv->regmap, MT6359_GPIO_MODE4_CLR, 0x003f); in mt6359_set_capture_gpio()
50 regmap_write(priv->regmap, MT6359_GPIO_MODE4_SET, 0x0009); in mt6359_set_capture_gpio()
61 regmap_write(priv->regmap, MT6359_GPIO_MODE3_CLR, 0x0e00); in mt6359_reset_capture_gpio()
63 regmap_write(priv->regmap, MT6359_GPIO_MODE4_CLR, 0x003f); in mt6359_reset_capture_gpio()
65 regmap_update_bits(priv->regmap, MT6359_GPIO_DIR0, in mt6359_reset_capture_gpio()
67 regmap_update_bits(priv->regmap, MT6359_GPIO_DIR1, in mt6359_reset_capture_gpio()
73 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON13, in mt6359_set_decoder_clk()
80 switch (priv->mtkaif_protocol) { in mt6359_mtkaif_tx_enable()
83 regmap_update_bits(priv->regmap, in mt6359_mtkaif_tx_enable()
87 regmap_update_bits(priv->regmap, in mt6359_mtkaif_tx_enable()
90 regmap_update_bits(priv->regmap, in mt6359_mtkaif_tx_enable()
96 regmap_update_bits(priv->regmap, in mt6359_mtkaif_tx_enable()
100 regmap_update_bits(priv->regmap, in mt6359_mtkaif_tx_enable()
107 regmap_update_bits(priv->regmap, in mt6359_mtkaif_tx_enable()
111 regmap_update_bits(priv->regmap, in mt6359_mtkaif_tx_enable()
121 regmap_update_bits(priv->regmap, MT6359_AFE_AUD_PAD_TOP, in mt6359_mtkaif_tx_disable()
127 regmap_write(priv->regmap, MT6359_ZCD_CON0, 0x0000); in zcd_disable()
137 stage = up ? i : target - i; in hp_main_output_ramp()
138 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON1, in hp_main_output_ramp()
141 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON1, in hp_main_output_ramp()
155 stage = up ? i : target - i; in hp_aux_feedback_loop_gain_ramp()
156 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON9, in hp_aux_feedback_loop_gain_ramp()
167 /* Set input diff pair bias select (Hi-Fi mode) */ in hp_in_pair_current()
168 if (priv->hp_hifi_mode) { in hp_in_pair_current()
171 stage = increase ? i : target - i; in hp_in_pair_current()
172 regmap_update_bits(priv->regmap, in hp_in_pair_current()
186 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON2, in hp_pull_down()
192 for (i = 0x7; i >= 0x0; i--) { in hp_pull_down()
193 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON2, in hp_pull_down()
213 dev_warn(priv->dev, "%s(), volume index is not valid, from %d, to %d\n", in headset_volume_ramp()
218 dev_dbg(priv->dev, "%s(), from %d, to %d\n", __func__, from, to); in headset_volume_ramp()
221 offset = to - from; in headset_volume_ramp()
223 offset = from - to; in headset_volume_ramp()
229 reg_idx = from - count; in headset_volume_ramp()
232 regmap_update_bits(priv->regmap, in headset_volume_ramp()
238 offset--; in headset_volume_ramp()
250 (struct soc_mixer_control *)kcontrol->private_value; in mt6359_put_volsw()
252 int index = ucontrol->value.integer.value[0]; in mt6359_put_volsw()
259 switch (mc->reg) { in mt6359_put_volsw()
261 regmap_read(priv->regmap, MT6359_ZCD_CON2, &reg); in mt6359_put_volsw()
262 priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL] = in mt6359_put_volsw()
264 priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTR] = in mt6359_put_volsw()
268 regmap_read(priv->regmap, MT6359_ZCD_CON1, &reg); in mt6359_put_volsw()
269 priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTL] = in mt6359_put_volsw()
271 priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTR] = in mt6359_put_volsw()
275 regmap_read(priv->regmap, MT6359_ZCD_CON3, &reg); in mt6359_put_volsw()
276 priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTL] = in mt6359_put_volsw()
280 regmap_read(priv->regmap, MT6359_AUDENC_ANA_CON0, &reg); in mt6359_put_volsw()
281 priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1] = in mt6359_put_volsw()
285 regmap_read(priv->regmap, MT6359_AUDENC_ANA_CON1, &reg); in mt6359_put_volsw()
286 priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2] = in mt6359_put_volsw()
290 regmap_read(priv->regmap, MT6359_AUDENC_ANA_CON2, &reg); in mt6359_put_volsw()
291 priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP3] = in mt6359_put_volsw()
296 dev_dbg(priv->dev, "%s(), name %s, reg(0x%x) = 0x%x, set index = %x\n", in mt6359_put_volsw()
297 __func__, kcontrol->id.name, mc->reg, reg, index); in mt6359_put_volsw()
621 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_sgen_event()
624 dev_dbg(priv->dev, "%s(), event = 0x%x\n", __func__, event); in mt_sgen_event()
629 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON2, 0x0006); in mt_sgen_event()
631 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON0, 0xcba1); in mt_sgen_event()
633 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON2, 0x0003); in mt_sgen_event()
635 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON2, 0x000b); in mt_sgen_event()
637 regmap_update_bits(priv->regmap, MT6359_AFE_SGEN_CFG0, in mt_sgen_event()
640 regmap_update_bits(priv->regmap, MT6359_AFE_SGEN_CFG1, in mt_sgen_event()
646 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON2, 0x0000); in mt_sgen_event()
647 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON0, 0xcba0); in mt_sgen_event()
658 if (priv->hp_hifi_mode) { in mtk_hp_enable()
660 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON11, in mtk_hp_enable()
665 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON12, in mtk_hp_enable()
668 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON12, in mtk_hp_enable()
673 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON11, in mtk_hp_enable()
678 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON12, in mtk_hp_enable()
681 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON12, in mtk_hp_enable()
688 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON10, 0x0087); in mtk_hp_enable()
692 if (priv->dl_rate[MT6359_AIF_1] >= 96000) in mtk_hp_enable()
693 regmap_update_bits(priv->regmap, in mtk_hp_enable()
698 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON4, 0x0000); in mtk_hp_enable()
701 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON2, 0xf133); in mtk_hp_enable()
704 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x000c); in mtk_hp_enable()
706 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x003c); in mtk_hp_enable()
708 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0x0c00); in mtk_hp_enable()
710 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON0, 0x30c0); in mtk_hp_enable()
712 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON0, 0x30f0); in mtk_hp_enable()
714 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x00fc); in mtk_hp_enable()
720 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0x0e00); in mtk_hp_enable()
722 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0x0200); in mtk_hp_enable()
725 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x00ff); in mtk_hp_enable()
732 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x77cf); in mtk_hp_enable()
737 priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL]); in mtk_hp_enable()
740 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x77c3); in mtk_hp_enable()
742 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x7703); in mtk_hp_enable()
749 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON0, 0x30ff); in mtk_hp_enable()
750 if (priv->hp_hifi_mode) { in mtk_hp_enable()
751 /* Enable low-noise mode of DAC */ in mtk_hp_enable()
752 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0xf201); in mtk_hp_enable()
754 /* Disable low-noise mode of DAC */ in mtk_hp_enable()
755 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0xf200); in mtk_hp_enable()
760 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON0, 0x32ff); in mtk_hp_enable()
762 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON0, 0x3aff); in mtk_hp_enable()
764 /* Disable Pull-down HPL/R to AVSS28_AUD */ in mtk_hp_enable()
770 /* Pull-down HPL/R to AVSS28_AUD */ in mtk_hp_disable()
774 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON0, in mtk_hp_disable()
777 /* Disable low-noise mode of DAC */ in mtk_hp_disable()
778 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON9, in mtk_hp_disable()
782 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON0, in mtk_hp_disable()
789 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x77c3); in mtk_hp_disable()
791 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x77cf); in mtk_hp_disable()
795 priv->ana_gain[AUDIO_ANALOG_VOLUME_HPOUTL], in mtk_hp_disable()
799 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x77ff); in mtk_hp_disable()
808 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON1, 0x3, 0x0); in mtk_hp_disable()
811 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0x0e01); in mtk_hp_disable()
814 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0x0c01); in mtk_hp_disable()
820 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON1, in mtk_hp_disable()
824 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON0, in mtk_hp_disable()
828 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON0, in mtk_hp_disable()
832 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0x201); in mtk_hp_disable()
835 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON1, in mtk_hp_disable()
839 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON1, in mtk_hp_disable()
847 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_hp_event()
849 unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); in mt_hp_event()
852 dev_dbg(priv->dev, "%s(), event 0x%x, dev_counter[DEV_HP] %d, mux %u\n", in mt_hp_event()
853 __func__, event, priv->dev_counter[device], mux); in mt_hp_event()
857 priv->dev_counter[device]++; in mt_hp_event()
862 priv->dev_counter[device]--; in mt_hp_event()
877 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_rcv_event()
880 dev_dbg(priv->dev, "%s(), event 0x%x, mux %u\n", in mt_rcv_event()
881 __func__, event, dapm_kcontrol_get_value(w->kcontrols[0])); in mt_rcv_event()
885 /* Disable handset short-circuit protection */ in mt_rcv_event()
886 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON6, 0x0010); in mt_rcv_event()
889 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON11, in mt_rcv_event()
894 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON12, in mt_rcv_event()
897 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON12, in mt_rcv_event()
902 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON6, 0x0090); in mt_rcv_event()
905 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON10, 0x7000); in mt_rcv_event()
908 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON6, 0x0092); in mt_rcv_event()
910 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON6, 0x0093); in mt_rcv_event()
913 regmap_write(priv->regmap, MT6359_ZCD_CON3, in mt_rcv_event()
914 priv->ana_gain[AUDIO_ANALOG_VOLUME_HSOUTL]); in mt_rcv_event()
920 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON0, 0x0009); in mt_rcv_event()
921 /* Enable low-noise mode of DAC */ in mt_rcv_event()
922 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON9, 0x0001); in mt_rcv_event()
924 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON6, 0x009b); in mt_rcv_event()
928 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON6, in mt_rcv_event()
933 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON0, in mt_rcv_event()
940 regmap_write(priv->regmap, MT6359_ZCD_CON3, DL_GAIN_N_40DB); in mt_rcv_event()
943 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON6, in mt_rcv_event()
947 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON6, in mt_rcv_event()
961 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_lo_event()
964 dev_dbg(priv->dev, "%s(), event 0x%x, mux %u\n", in mt_lo_event()
965 __func__, event, dapm_kcontrol_get_value(w->kcontrols[0])); in mt_lo_event()
969 /* Disable handset short-circuit protection */ in mt_lo_event()
970 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON7, 0x0010); in mt_lo_event()
973 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON11, in mt_lo_event()
978 if (priv->dev_counter[DEVICE_HP] == 0) in mt_lo_event()
979 regmap_update_bits(priv->regmap, in mt_lo_event()
984 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON12, in mt_lo_event()
989 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON7, 0x0110); in mt_lo_event()
992 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON7, 0x0112); in mt_lo_event()
994 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON7, 0x0113); in mt_lo_event()
997 regmap_write(priv->regmap, MT6359_ZCD_CON1, in mt_lo_event()
998 priv->ana_gain[AUDIO_ANALOG_VOLUME_LINEOUTL]); in mt_lo_event()
1004 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON7, 0x3113); in mt_lo_event()
1005 /* Enable low-noise mode of DAC */ in mt_lo_event()
1006 if (priv->dev_counter[DEVICE_HP] == 0) in mt_lo_event()
1007 regmap_write(priv->regmap, in mt_lo_event()
1010 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON7, 0x311b); in mt_lo_event()
1014 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON7, in mt_lo_event()
1019 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON0, in mt_lo_event()
1026 regmap_write(priv->regmap, MT6359_ZCD_CON1, DL_GAIN_N_40DB); in mt_lo_event()
1029 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON7, in mt_lo_event()
1033 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON7, in mt_lo_event()
1047 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_adc_clk_gen_event()
1050 dev_dbg(priv->dev, "%s(), event 0x%x\n", __func__, event); in mt_adc_clk_gen_event()
1055 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON5, in mt_adc_clk_gen_event()
1058 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON5, in mt_adc_clk_gen_event()
1060 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON5, in mt_adc_clk_gen_event()
1062 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON5, in mt_adc_clk_gen_event()
1067 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON5, in mt_adc_clk_gen_event()
1069 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON5, in mt_adc_clk_gen_event()
1071 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON5, in mt_adc_clk_gen_event()
1073 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON5, in mt_adc_clk_gen_event()
1087 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_dcc_clk_event()
1090 dev_dbg(priv->dev, "%s(), event 0x%x\n", __func__, event); in mt_dcc_clk_event()
1096 regmap_update_bits(priv->regmap, MT6359_AFE_DCCLK_CFG0, in mt_dcc_clk_event()
1098 regmap_update_bits(priv->regmap, MT6359_AFE_DCCLK_CFG0, in mt_dcc_clk_event()
1100 regmap_update_bits(priv->regmap, MT6359_AFE_DCCLK_CFG0, in mt_dcc_clk_event()
1103 regmap_write(priv->regmap, MT6359_AFE_DCCLK_CFG1, 0x0100); in mt_dcc_clk_event()
1106 regmap_update_bits(priv->regmap, MT6359_AFE_DCCLK_CFG0, in mt_dcc_clk_event()
1108 regmap_update_bits(priv->regmap, MT6359_AFE_DCCLK_CFG0, in mt_dcc_clk_event()
1122 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_mic_bias_0_event()
1124 unsigned int mic_type = priv->mux_select[MUX_MIC_TYPE_0]; in mt_mic_bias_0_event()
1126 dev_dbg(priv->dev, "%s(), event 0x%x, mic_type %d\n", in mt_mic_bias_0_event()
1133 regmap_update_bits(priv->regmap, in mt_mic_bias_0_event()
1138 regmap_update_bits(priv->regmap, in mt_mic_bias_0_event()
1143 regmap_update_bits(priv->regmap, in mt_mic_bias_0_event()
1150 regmap_write(priv->regmap, in mt_mic_bias_0_event()
1153 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON15, in mt_mic_bias_0_event()
1157 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON15, in mt_mic_bias_0_event()
1163 regmap_write(priv->regmap, MT6359_AUDENC_ANA_CON15, 0x0000); in mt_mic_bias_0_event()
1176 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_mic_bias_1_event()
1178 unsigned int mic_type = priv->mux_select[MUX_MIC_TYPE_1]; in mt_mic_bias_1_event()
1180 dev_dbg(priv->dev, "%s(), event 0x%x, mic_type %d\n", in mt_mic_bias_1_event()
1187 regmap_write(priv->regmap, in mt_mic_bias_1_event()
1190 regmap_write(priv->regmap, in mt_mic_bias_1_event()
1194 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON16, in mt_mic_bias_1_event()
1209 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_mic_bias_2_event()
1211 unsigned int mic_type = priv->mux_select[MUX_MIC_TYPE_2]; in mt_mic_bias_2_event()
1213 dev_dbg(priv->dev, "%s(), event 0x%x, mic_type %d\n", in mt_mic_bias_2_event()
1220 regmap_update_bits(priv->regmap, in mt_mic_bias_2_event()
1225 regmap_update_bits(priv->regmap, in mt_mic_bias_2_event()
1230 regmap_update_bits(priv->regmap, in mt_mic_bias_2_event()
1237 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON17, in mt_mic_bias_2_event()
1241 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON17, in mt_mic_bias_2_event()
1246 /* Disable MICBIAS2, MISBIAS0 = 1P7V */ in mt_mic_bias_2_event()
1247 regmap_write(priv->regmap, MT6359_AUDENC_ANA_CON17, 0x0000); in mt_mic_bias_2_event()
1260 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_mtkaif_tx_event()
1263 dev_dbg(priv->dev, "%s(), event = 0x%x\n", __func__, event); in mt_mtkaif_tx_event()
1283 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_ul_src_dmic_event()
1286 dev_dbg(priv->dev, "%s(), event = 0x%x\n", __func__, event); in mt_ul_src_dmic_event()
1291 if (priv->dmic_one_wire_mode) in mt_ul_src_dmic_event()
1292 regmap_write(priv->regmap, MT6359_AFE_UL_SRC_CON0_H, in mt_ul_src_dmic_event()
1295 regmap_write(priv->regmap, MT6359_AFE_UL_SRC_CON0_H, in mt_ul_src_dmic_event()
1298 regmap_update_bits(priv->regmap, MT6359_AFE_UL_SRC_CON0_L, in mt_ul_src_dmic_event()
1302 regmap_write(priv->regmap, in mt_ul_src_dmic_event()
1316 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_ul_src_34_dmic_event()
1319 dev_dbg(priv->dev, "%s(), event = 0x%x\n", __func__, event); in mt_ul_src_34_dmic_event()
1324 regmap_write(priv->regmap, in mt_ul_src_34_dmic_event()
1326 regmap_update_bits(priv->regmap, MT6359_AFE_ADDA6_UL_SRC_CON0_L, in mt_ul_src_34_dmic_event()
1330 regmap_write(priv->regmap, in mt_ul_src_34_dmic_event()
1344 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_adc_l_event()
1347 dev_dbg(priv->dev, "%s(), event = 0x%x\n", __func__, event); in mt_adc_l_event()
1353 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON0, in mt_adc_l_event()
1368 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_adc_r_event()
1371 dev_dbg(priv->dev, "%s(), event = 0x%x\n", __func__, event); in mt_adc_r_event()
1377 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON1, in mt_adc_r_event()
1392 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_adc_3_event()
1395 dev_dbg(priv->dev, "%s(), event = 0x%x\n", __func__, event); in mt_adc_3_event()
1401 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON2, in mt_adc_3_event()
1416 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_pga_l_mux_event()
1418 unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); in mt_pga_l_mux_event()
1420 dev_dbg(priv->dev, "%s(), mux %d\n", __func__, mux); in mt_pga_l_mux_event()
1421 priv->mux_select[MUX_PGA_L] = mux >> RG_AUDPREAMPLINPUTSEL_SFT; in mt_pga_l_mux_event()
1429 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_pga_r_mux_event()
1431 unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); in mt_pga_r_mux_event()
1433 dev_dbg(priv->dev, "%s(), mux %d\n", __func__, mux); in mt_pga_r_mux_event()
1434 priv->mux_select[MUX_PGA_R] = mux >> RG_AUDPREAMPRINPUTSEL_SFT; in mt_pga_r_mux_event()
1442 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_pga_3_mux_event()
1444 unsigned int mux = dapm_kcontrol_get_value(w->kcontrols[0]); in mt_pga_3_mux_event()
1446 dev_dbg(priv->dev, "%s(), mux %d\n", __func__, mux); in mt_pga_3_mux_event()
1447 priv->mux_select[MUX_PGA_3] = mux >> RG_AUDPREAMP3INPUTSEL_SFT; in mt_pga_3_mux_event()
1455 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_pga_l_event()
1457 int mic_gain_l = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP1]; in mt_pga_l_event()
1458 unsigned int mux_pga = priv->mux_select[MUX_PGA_L]; in mt_pga_l_event()
1463 mic_type = priv->mux_select[MUX_MIC_TYPE_0]; in mt_pga_l_event()
1466 mic_type = priv->mux_select[MUX_MIC_TYPE_1]; in mt_pga_l_event()
1469 dev_err(priv->dev, "%s(), invalid pga mux %d\n", in mt_pga_l_event()
1471 return -EINVAL; in mt_pga_l_event()
1478 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON0, in mt_pga_l_event()
1485 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON0, in mt_pga_l_event()
1491 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON0, in mt_pga_l_event()
1498 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON0, in mt_pga_l_event()
1513 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_pga_r_event()
1515 int mic_gain_r = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP2]; in mt_pga_r_event()
1516 unsigned int mux_pga = priv->mux_select[MUX_PGA_R]; in mt_pga_r_event()
1521 mic_type = priv->mux_select[MUX_MIC_TYPE_0]; in mt_pga_r_event()
1525 mic_type = priv->mux_select[MUX_MIC_TYPE_2]; in mt_pga_r_event()
1528 dev_err(priv->dev, "%s(), invalid pga mux %d\n", in mt_pga_r_event()
1530 return -EINVAL; in mt_pga_r_event()
1537 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON1, in mt_pga_r_event()
1544 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON1, in mt_pga_r_event()
1550 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON1, in mt_pga_r_event()
1557 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON1, in mt_pga_r_event()
1572 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_pga_3_event()
1574 int mic_gain_3 = priv->ana_gain[AUDIO_ANALOG_VOLUME_MICAMP3]; in mt_pga_3_event()
1575 unsigned int mux_pga = priv->mux_select[MUX_PGA_3]; in mt_pga_3_event()
1581 mic_type = priv->mux_select[MUX_MIC_TYPE_2]; in mt_pga_3_event()
1584 dev_err(priv->dev, "%s(), invalid pga mux %d\n", in mt_pga_3_event()
1586 return -EINVAL; in mt_pga_3_event()
1593 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON2, in mt_pga_3_event()
1600 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON2, in mt_pga_3_event()
1606 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON2, in mt_pga_3_event()
1613 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON2, in mt_pga_3_event()
1661 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_hp_pull_down_event()
1682 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_hp_mute_event()
1687 /* Set HPR/HPL gain to -22dB */ in mt_hp_mute_event()
1688 regmap_write(priv->regmap, MT6359_ZCD_CON2, DL_GAIN_N_22DB_REG); in mt_hp_mute_event()
1692 regmap_write(priv->regmap, MT6359_ZCD_CON2, DL_GAIN_N_40DB_REG); in mt_hp_mute_event()
1705 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_hp_damp_event()
1712 regmap_write(priv->regmap, MT6359_AUDDEC_ANA_CON10, 0x0000); in mt_hp_damp_event()
1725 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_esd_resist_event()
1731 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON2, in mt_esd_resist_event()
1738 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON2, in mt_esd_resist_event()
1752 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_sdm_event()
1758 regmap_update_bits(priv->regmap, MT6359_AFUNC_AUD_CON2, in mt_sdm_event()
1761 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON0, 0xcba1); in mt_sdm_event()
1763 regmap_update_bits(priv->regmap, MT6359_AFUNC_AUD_CON2, in mt_sdm_event()
1766 regmap_update_bits(priv->regmap, MT6359_AFUNC_AUD_CON2, in mt_sdm_event()
1771 regmap_update_bits(priv->regmap, MT6359_AFUNC_AUD_CON2, in mt_sdm_event()
1773 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON0, 0xcba0); in mt_sdm_event()
1786 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_sdm_3rd_event()
1792 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON11, 0x0006); in mt_sdm_3rd_event()
1794 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON9, 0xcba1); in mt_sdm_3rd_event()
1796 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON11, 0x0003); in mt_sdm_3rd_event()
1798 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON11, 0x000b); in mt_sdm_3rd_event()
1802 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON11, 0x0000); in mt_sdm_3rd_event()
1803 regmap_write(priv->regmap, MT6359_AFUNC_AUD_CON9, 0xcba0); in mt_sdm_3rd_event()
1816 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_ncp_event()
1821 regmap_write(priv->regmap, MT6359_AFE_NCP_CFG0, 0xc800); in mt_ncp_event()
1832 /* Global Supply*/
1931 /* DL Supply */
1932 SND_SOC_DAPM_SUPPLY("DL Power Supply", SND_SOC_NOPM,
2193 struct snd_soc_component *cmpnt = snd_soc_dapm_to_component(w->dapm); in mt_dcc_clk_connect()
2196 if (IS_DCC_BASE(priv->mux_select[MUX_MIC_TYPE_0]) || in mt_dcc_clk_connect()
2197 IS_DCC_BASE(priv->mux_select[MUX_MIC_TYPE_1]) || in mt_dcc_clk_connect()
2198 IS_DCC_BASE(priv->mux_select[MUX_MIC_TYPE_2])) in mt_dcc_clk_connect()
2333 /* DL Supply */
2334 {"DL Power Supply", NULL, "CLK_BUF"},
2335 {"DL Power Supply", NULL, "LDO_VAUD18"},
2336 {"DL Power Supply", NULL, "AUDGLB"},
2337 {"DL Power Supply", NULL, "CLKSQ Audio"},
2338 {"DL Power Supply", NULL, "AUDNCP_CK"},
2339 {"DL Power Supply", NULL, "ZCD13M_CK"},
2340 {"DL Power Supply", NULL, "AUD_CK"},
2341 {"DL Power Supply", NULL, "AUDIF_CK"},
2342 {"DL Power Supply", NULL, "ESD_RESIST"},
2343 {"DL Power Supply", NULL, "LDO"},
2344 {"DL Power Supply", NULL, "LDO_REMOTE"},
2345 {"DL Power Supply", NULL, "NV_REGULATOR"},
2346 {"DL Power Supply", NULL, "IBIST"},
2348 /* DL Digital Supply */
2379 {"DACL", NULL, "DL Power Supply"},
2382 {"DACR", NULL, "DL Power Supply"},
2387 {"DAC_3RD", NULL, "DL Power Supply"},
2420 struct snd_soc_component *cmpnt = dai->component; in mt6359_codec_dai_hw_params()
2423 int id = dai->id; in mt6359_codec_dai_hw_params()
2425 dev_dbg(priv->dev, "%s(), id %d, substream->stream %d, rate %d, number %d\n", in mt6359_codec_dai_hw_params()
2426 __func__, id, substream->stream, rate, substream->number); in mt6359_codec_dai_hw_params()
2428 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in mt6359_codec_dai_hw_params()
2429 priv->dl_rate[id] = rate; in mt6359_codec_dai_hw_params()
2430 else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in mt6359_codec_dai_hw_params()
2431 priv->ul_rate[id] = rate; in mt6359_codec_dai_hw_params()
2439 struct snd_soc_component *cmpnt = dai->component; in mt6359_codec_dai_startup()
2442 dev_dbg(priv->dev, "%s stream %d\n", __func__, substream->stream); in mt6359_codec_dai_startup()
2443 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in mt6359_codec_dai_startup()
2445 else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in mt6359_codec_dai_startup()
2454 struct snd_soc_component *cmpnt = dai->component; in mt6359_codec_dai_shutdown()
2457 dev_dbg(priv->dev, "%s stream %d\n", __func__, substream->stream); in mt6359_codec_dai_shutdown()
2458 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in mt6359_codec_dai_shutdown()
2460 else if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) in mt6359_codec_dai_shutdown()
2480 .name = "mt6359-snd-codec-aif1",
2506 .name = "mt6359-snd-codec-aif2",
2535 regmap_update_bits(priv->regmap, MT6359_DCXO_CW12, in mt6359_codec_init_reg()
2542 regmap_update_bits(priv->regmap, MT6359_AUDENC_ANA_CON23, in mt6359_codec_init_reg()
2547 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON0, in mt6359_codec_init_reg()
2550 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON0, in mt6359_codec_init_reg()
2554 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON6, in mt6359_codec_init_reg()
2558 regmap_update_bits(priv->regmap, MT6359_AUDDEC_ANA_CON7, in mt6359_codec_init_reg()
2567 priv->hp_hifi_mode = 0; in mt6359_codec_init_reg()
2573 regmap_update_bits(priv->regmap, MT6359_DCXO_CW12, in mt6359_codec_init_reg()
2584 snd_soc_component_init_regmap(cmpnt, priv->regmap); in mt6359_codec_probe()
2594 static const DECLARE_TLV_DB_SCALE(hp_playback_tlv, -2200, 100, 0);
2595 static const DECLARE_TLV_DB_SCALE(playback_tlv, -1000, 100, 0);
2638 struct device *dev = priv->dev; in mt6359_parse_dt()
2641 np = of_get_child_by_name(dev->parent->of_node, "mt6359codec"); in mt6359_parse_dt()
2643 return -EINVAL; in mt6359_parse_dt()
2645 ret = of_property_read_u32(np, "mediatek,dmic-mode", in mt6359_parse_dt()
2646 &priv->dmic_one_wire_mode); in mt6359_parse_dt()
2648 dev_warn(priv->dev, "%s() failed to read dmic-mode\n", in mt6359_parse_dt()
2650 priv->dmic_one_wire_mode = 0; in mt6359_parse_dt()
2653 ret = of_property_read_u32(np, "mediatek,mic-type-0", in mt6359_parse_dt()
2654 &priv->mux_select[MUX_MIC_TYPE_0]); in mt6359_parse_dt()
2656 dev_warn(priv->dev, "%s() failed to read mic-type-0\n", in mt6359_parse_dt()
2658 priv->mux_select[MUX_MIC_TYPE_0] = MIC_TYPE_MUX_IDLE; in mt6359_parse_dt()
2661 ret = of_property_read_u32(np, "mediatek,mic-type-1", in mt6359_parse_dt()
2662 &priv->mux_select[MUX_MIC_TYPE_1]); in mt6359_parse_dt()
2664 dev_warn(priv->dev, "%s() failed to read mic-type-1\n", in mt6359_parse_dt()
2666 priv->mux_select[MUX_MIC_TYPE_1] = MIC_TYPE_MUX_IDLE; in mt6359_parse_dt()
2669 ret = of_property_read_u32(np, "mediatek,mic-type-2", in mt6359_parse_dt()
2670 &priv->mux_select[MUX_MIC_TYPE_2]); in mt6359_parse_dt()
2672 dev_warn(priv->dev, "%s() failed to read mic-type-2\n", in mt6359_parse_dt()
2674 priv->mux_select[MUX_MIC_TYPE_2] = MIC_TYPE_MUX_IDLE; in mt6359_parse_dt()
2684 struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent); in mt6359_platform_driver_probe()
2686 dev_dbg(&pdev->dev, "%s(), dev name %s\n", in mt6359_platform_driver_probe()
2687 __func__, dev_name(&pdev->dev)); in mt6359_platform_driver_probe()
2689 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in mt6359_platform_driver_probe()
2691 return -ENOMEM; in mt6359_platform_driver_probe()
2693 priv->regmap = mt6397->regmap; in mt6359_platform_driver_probe()
2694 if (IS_ERR(priv->regmap)) in mt6359_platform_driver_probe()
2695 return PTR_ERR(priv->regmap); in mt6359_platform_driver_probe()
2697 dev_set_drvdata(&pdev->dev, priv); in mt6359_platform_driver_probe()
2698 priv->dev = &pdev->dev; in mt6359_platform_driver_probe()
2700 priv->avdd_reg = devm_regulator_get(&pdev->dev, "vaud18"); in mt6359_platform_driver_probe()
2701 if (IS_ERR(priv->avdd_reg)) { in mt6359_platform_driver_probe()
2702 dev_err(&pdev->dev, "%s(), have no vaud18 supply: %ld", in mt6359_platform_driver_probe()
2703 __func__, PTR_ERR(priv->avdd_reg)); in mt6359_platform_driver_probe()
2704 return PTR_ERR(priv->avdd_reg); in mt6359_platform_driver_probe()
2707 ret = regulator_enable(priv->avdd_reg); in mt6359_platform_driver_probe()
2709 dev_err(&pdev->dev, "%s(), failed to enable regulator!\n", in mt6359_platform_driver_probe()
2716 dev_warn(&pdev->dev, "%s() failed to parse dts\n", __func__); in mt6359_platform_driver_probe()
2720 return devm_snd_soc_register_component(&pdev->dev, in mt6359_platform_driver_probe()
2728 struct mt6359_priv *priv = dev_get_drvdata(&pdev->dev); in mt6359_platform_driver_remove()
2731 dev_dbg(&pdev->dev, "%s(), dev name %s\n", in mt6359_platform_driver_remove()
2732 __func__, dev_name(&pdev->dev)); in mt6359_platform_driver_remove()
2734 ret = regulator_disable(priv->avdd_reg); in mt6359_platform_driver_remove()
2736 dev_err(&pdev->dev, "%s(), failed to disable regulator!\n", in mt6359_platform_driver_remove()
2746 .name = "mt6359-sound",