Lines Matching +full:headset +full:- +full:micbias +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0-only
3 // es8326.c -- es8326 ALSA SoC audio driver
6 // Authors: David Yang <yangxiaohua@everest-semi.com>
17 #include <sound/soc-dapm.h>
56 regmap_read(es8326->regmap, ES8326_DAC_RAMPRATE, &crosstalk_h); in es8326_crosstalk1_get()
57 regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l); in es8326_crosstalk1_get()
61 ucontrol->value.integer.value[0] = crosstalk; in es8326_crosstalk1_get()
74 crosstalk = ucontrol->value.integer.value[0]; in es8326_crosstalk1_set()
75 regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l); in es8326_crosstalk1_set()
79 regmap_update_bits(es8326->regmap, ES8326_DAC_RAMPRATE, in es8326_crosstalk1_set()
81 regmap_write(es8326->regmap, ES8326_DAC_CROSSTALK, crosstalk_l); in es8326_crosstalk1_set()
94 regmap_read(es8326->regmap, ES8326_DAC_RAMPRATE, &crosstalk_h); in es8326_crosstalk2_get()
95 regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l); in es8326_crosstalk2_get()
99 ucontrol->value.integer.value[0] = crosstalk; in es8326_crosstalk2_get()
112 crosstalk = ucontrol->value.integer.value[0]; in es8326_crosstalk2_set()
113 regmap_read(es8326->regmap, ES8326_DAC_CROSSTALK, &crosstalk_l); in es8326_crosstalk2_set()
117 regmap_update_bits(es8326->regmap, ES8326_DAC_RAMPRATE, in es8326_crosstalk2_set()
119 regmap_write(es8326->regmap, ES8326_DAC_CROSSTALK, crosstalk_l); in es8326_crosstalk2_set()
130 ucontrol->value.integer.value[0] = es8326->hpl_vol; in es8326_hplvol_get()
142 hp_vol = ucontrol->value.integer.value[0]; in es8326_hplvol_set()
144 return -EINVAL; in es8326_hplvol_set()
145 if (es8326->hpl_vol != hp_vol) { in es8326_hplvol_set()
146 es8326->hpl_vol = hp_vol; in es8326_hplvol_set()
149 regmap_update_bits(es8326->regmap, ES8326_HP_VOL, in es8326_hplvol_set()
163 ucontrol->value.integer.value[0] = es8326->hpr_vol; in es8326_hprvol_get()
175 hp_vol = ucontrol->value.integer.value[0]; in es8326_hprvol_set()
177 return -EINVAL; in es8326_hprvol_set()
178 if (es8326->hpr_vol != hp_vol) { in es8326_hprvol_set()
179 es8326->hpr_vol = hp_vol; in es8326_hprvol_set()
182 regmap_update_bits(es8326->regmap, ES8326_HP_VOL, in es8326_hprvol_set()
190 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(dac_vol_tlv, -9550, 50, 0);
191 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_vol_tlv, -9550, 50, 0);
195 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(drc_target_tlv, -3200, 200, 0);
196 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(drc_recovery_tlv, -125, 250, 0);
286 /* Analog Power Supply*/
480 return -EINVAL; in get_coeff()
486 struct snd_soc_component *codec = codec_dai->component; in es8326_set_dai_sysclk()
489 es8326->sysclk = freq; in es8326_set_dai_sysclk()
496 struct snd_soc_component *component = codec_dai->component; in es8326_set_dai_fmt()
507 return -EINVAL; in es8326_set_dai_fmt()
515 dev_err(component->dev, "Codec driver does not support right justified\n"); in es8326_set_dai_fmt()
516 return -EINVAL; in es8326_set_dai_fmt()
527 return -EINVAL; in es8326_set_dai_fmt()
539 struct snd_soc_component *component = dai->component; in es8326_pcm_hw_params()
545 if (es8326->version == 0) { in es8326_pcm_hw_params()
552 coeff = get_coeff(es8326->sysclk, params_rate(params), array, coeff_div); in es8326_pcm_hw_params()
571 return -EINVAL; in es8326_pcm_hw_params()
578 regmap_write(es8326->regmap, ES8326_CLK_DIV1, in es8326_pcm_hw_params()
580 regmap_write(es8326->regmap, ES8326_CLK_DIV2, in es8326_pcm_hw_params()
582 regmap_write(es8326->regmap, ES8326_CLK_DLL, in es8326_pcm_hw_params()
584 regmap_write(es8326->regmap, ES8326_CLK_MUX, in es8326_pcm_hw_params()
586 regmap_write(es8326->regmap, ES8326_CLK_ADC_SEL, in es8326_pcm_hw_params()
588 regmap_write(es8326->regmap, ES8326_CLK_DAC_SEL, in es8326_pcm_hw_params()
590 regmap_write(es8326->regmap, ES8326_CLK_ADC_OSR, in es8326_pcm_hw_params()
592 regmap_write(es8326->regmap, ES8326_CLK_DAC_OSR, in es8326_pcm_hw_params()
595 dev_warn(component->dev, "Clock coefficients do not match"); in es8326_pcm_hw_params()
603 struct snd_soc_component *component = dai->component; in es8326_mute()
609 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); in es8326_mute()
610 regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, in es8326_mute()
612 regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, in es8326_mute()
615 regmap_update_bits(es8326->regmap, ES8326_ADC_MUTE, in es8326_mute()
619 if (!es8326->calibrated) { in es8326_mute()
620 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_FORCE_CAL); in es8326_mute()
622 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); in es8326_mute()
623 regmap_read(es8326->regmap, ES8326_HPL_OFFSET_INI, &offset_l); in es8326_mute()
624 regmap_read(es8326->regmap, ES8326_HPR_OFFSET_INI, &offset_r); in es8326_mute()
625 regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); in es8326_mute()
626 regmap_write(es8326->regmap, ES8326_HPL_OFFSET_INI, offset_l); in es8326_mute()
627 regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r); in es8326_mute()
628 es8326->calibrated = true; in es8326_mute()
631 regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x01); in es8326_mute()
633 regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00); in es8326_mute()
635 regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x20); in es8326_mute()
636 regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x30, 0x30); in es8326_mute()
637 regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1); in es8326_mute()
638 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_ON); in es8326_mute()
639 regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, in es8326_mute()
643 regmap_update_bits(es8326->regmap, ES8326_ADC_MUTE, in es8326_mute()
658 ret = clk_prepare_enable(es8326->mclk); in es8326_set_bias_level()
662 regmap_update_bits(es8326->regmap, ES8326_RESET, 0x02, 0x02); in es8326_set_bias_level()
664 regmap_write(es8326->regmap, ES8326_INTOUT_IO, es8326->interrupt_clk); in es8326_set_bias_level()
665 regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, in es8326_set_bias_level()
667 regmap_write(es8326->regmap, ES8326_PGA_PDN, 0x40); in es8326_set_bias_level()
668 regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x00); in es8326_set_bias_level()
669 regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x20); in es8326_set_bias_level()
670 regmap_update_bits(es8326->regmap, ES8326_RESET, 0x02, 0x00); in es8326_set_bias_level()
675 regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b); in es8326_set_bias_level()
676 regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x00); in es8326_set_bias_level()
677 regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, ES8326_IO_INPUT); in es8326_set_bias_level()
680 clk_disable_unprepare(es8326->mclk); in es8326_set_bias_level()
742 * snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
743 * snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
744 * snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
750 struct snd_soc_component *comp = es8326->component; in es8326_jack_button_handler()
755 if (!(es8326->jack->status & SND_JACK_HEADSET)) /* Jack unplugged */ in es8326_jack_button_handler()
758 mutex_lock(&es8326->lock); in es8326_jack_button_handler()
787 snd_soc_jack_report(es8326->jack, cur_button, in es8326_jack_button_handler()
792 queue_delayed_work(system_wq, &es8326->button_press_work, in es8326_jack_button_handler()
797 queue_delayed_work(system_wq, &es8326->button_press_work, in es8326_jack_button_handler()
802 snd_soc_jack_report(es8326->jack, button_to_report, in es8326_jack_button_handler()
804 snd_soc_jack_report(es8326->jack, 0, in es8326_jack_button_handler()
808 es8326_disable_micbias(es8326->component); in es8326_jack_button_handler()
810 mutex_unlock(&es8326->lock); in es8326_jack_button_handler()
817 struct snd_soc_component *comp = es8326->component; in es8326_jack_detect_handler()
820 mutex_lock(&es8326->lock); in es8326_jack_detect_handler()
822 dev_dbg(comp->dev, "gpio flag %#04x", iface); in es8326_jack_detect_handler()
824 if ((es8326->jack_remove_retry == 1) && (es8326->version != ES8326_VERSION_B)) { in es8326_jack_detect_handler()
826 es8326->jack_remove_retry = 2; in es8326_jack_detect_handler()
828 es8326->jack_remove_retry = 0; in es8326_jack_detect_handler()
830 dev_dbg(comp->dev, "remove event check, set HPJACK_POL normal, cnt = %d\n", in es8326_jack_detect_handler()
831 es8326->jack_remove_retry); in es8326_jack_detect_handler()
835 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, in es8326_jack_detect_handler()
836 ES8326_HP_DET_JACK_POL, (es8326->jd_inverted ? in es8326_jack_detect_handler()
837 ~es8326->jack_pol : es8326->jack_pol)); in es8326_jack_detect_handler()
843 dev_dbg(comp->dev, "No headset detected\n"); in es8326_jack_detect_handler()
844 es8326_disable_micbias(es8326->component); in es8326_jack_detect_handler()
845 if (es8326->jack->status & SND_JACK_HEADPHONE) { in es8326_jack_detect_handler()
846 dev_dbg(comp->dev, "Report hp remove event\n"); in es8326_jack_detect_handler()
847 snd_soc_jack_report(es8326->jack, 0, in es8326_jack_detect_handler()
849 snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET); in es8326_jack_detect_handler()
851 regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x44); in es8326_jack_detect_handler()
852 regmap_write(es8326->regmap, ES8326_ADC2_SRC, 0x66); in es8326_jack_detect_handler()
854 es8326->hp = 0; in es8326_jack_detect_handler()
855 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); in es8326_jack_detect_handler()
856 regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x0a); in es8326_jack_detect_handler()
857 regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x0f, 0x03); in es8326_jack_detect_handler()
858 regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9); in es8326_jack_detect_handler()
862 if ((es8326->jack_remove_retry == 0) && (es8326->version != ES8326_VERSION_B)) { in es8326_jack_detect_handler()
863 es8326->jack_remove_retry = 1; in es8326_jack_detect_handler()
864 dev_dbg(comp->dev, "remove event check, invert HPJACK_POL, cnt = %d\n", in es8326_jack_detect_handler()
865 es8326->jack_remove_retry); in es8326_jack_detect_handler()
866 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, in es8326_jack_detect_handler()
867 ES8326_HP_DET_JACK_POL, (es8326->jd_inverted ? in es8326_jack_detect_handler()
868 es8326->jack_pol : ~es8326->jack_pol)); in es8326_jack_detect_handler()
871 es8326->jack_remove_retry = 0; in es8326_jack_detect_handler()
874 es8326->jack_remove_retry = 0; in es8326_jack_detect_handler()
875 if (es8326->hp == 0) { in es8326_jack_detect_handler()
876 dev_dbg(comp->dev, "First insert, start OMTP/CTIA type check\n"); in es8326_jack_detect_handler()
878 * set auto-check mode, then restart jack_detect_work after 400ms. in es8326_jack_detect_handler()
881 regmap_write(es8326->regmap, ES8326_INT_SOURCE, 0x00); in es8326_jack_detect_handler()
882 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); in es8326_jack_detect_handler()
883 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x10, 0x00); in es8326_jack_detect_handler()
885 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); in es8326_jack_detect_handler()
886 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x10, 0x10); in es8326_jack_detect_handler()
888 regmap_write(es8326->regmap, ES8326_INT_SOURCE, in es8326_jack_detect_handler()
890 regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x1f); in es8326_jack_detect_handler()
891 regmap_update_bits(es8326->regmap, ES8326_HP_DRIVER_REF, 0x0f, 0x08); in es8326_jack_detect_handler()
892 queue_delayed_work(system_wq, &es8326->jack_detect_work, in es8326_jack_detect_handler()
894 es8326->hp = 1; in es8326_jack_detect_handler()
897 if (es8326->jack->status & SND_JACK_HEADSET) { in es8326_jack_detect_handler()
899 dev_dbg(comp->dev, "button pressed\n"); in es8326_jack_detect_handler()
900 regmap_write(es8326->regmap, ES8326_INT_SOURCE, in es8326_jack_detect_handler()
902 es8326_enable_micbias(es8326->component); in es8326_jack_detect_handler()
903 queue_delayed_work(system_wq, &es8326->button_press_work, 10); in es8326_jack_detect_handler()
907 dev_dbg(comp->dev, "Headphone detected\n"); in es8326_jack_detect_handler()
908 snd_soc_jack_report(es8326->jack, in es8326_jack_detect_handler()
911 dev_dbg(comp->dev, "Headset detected\n"); in es8326_jack_detect_handler()
912 snd_soc_jack_report(es8326->jack, in es8326_jack_detect_handler()
915 regmap_update_bits(es8326->regmap, ES8326_PGA_PDN, in es8326_jack_detect_handler()
917 regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, in es8326_jack_detect_handler()
919 regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x00); in es8326_jack_detect_handler()
920 regmap_write(es8326->regmap, ES8326_ADC2_SRC, 0x00); in es8326_jack_detect_handler()
921 regmap_update_bits(es8326->regmap, ES8326_PGA_PDN, in es8326_jack_detect_handler()
927 mutex_unlock(&es8326->lock); in es8326_jack_detect_handler()
934 if (!es8326->jack) in es8326_irq()
937 if (es8326->jack->status & SND_JACK_HEADSET) in es8326_irq()
938 queue_delayed_work(system_wq, &es8326->jack_detect_work, in es8326_irq()
941 queue_delayed_work(system_wq, &es8326->jack_detect_work, in es8326_irq()
954 regmap_read(es8326->regmap, ES8326_CHIP_VERSION, ®); in es8326_calibrate()
955 es8326->version = reg; in es8326_calibrate()
957 if ((es8326->version == ES8326_VERSION_B) && (es8326->calibrated == false)) { in es8326_calibrate()
958 dev_dbg(component->dev, "ES8326_VERSION_B, calibrating\n"); in es8326_calibrate()
959 regmap_write(es8326->regmap, ES8326_CLK_INV, 0xc0); in es8326_calibrate()
960 regmap_write(es8326->regmap, ES8326_CLK_DIV1, 0x03); in es8326_calibrate()
961 regmap_write(es8326->regmap, ES8326_CLK_DLL, 0x30); in es8326_calibrate()
962 regmap_write(es8326->regmap, ES8326_CLK_MUX, 0xed); in es8326_calibrate()
963 regmap_write(es8326->regmap, ES8326_CLK_DAC_SEL, 0x08); in es8326_calibrate()
964 regmap_write(es8326->regmap, ES8326_CLK_TRI, 0xc1); in es8326_calibrate()
965 regmap_write(es8326->regmap, ES8326_DAC_MUTE, 0x03); in es8326_calibrate()
966 regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7f); in es8326_calibrate()
967 regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x23); in es8326_calibrate()
968 regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x88); in es8326_calibrate()
970 regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); in es8326_calibrate()
972 regmap_write(es8326->regmap, ES8326_RESET, 0xc0); in es8326_calibrate()
975 regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, ES8326_HP_OFF); in es8326_calibrate()
976 regmap_read(es8326->regmap, ES8326_CSM_MUTE_STA, ®); in es8326_calibrate()
980 regmap_write(es8326->regmap, ES8326_HP_CAL, 0xd4); in es8326_calibrate()
982 regmap_write(es8326->regmap, ES8326_HP_CAL, 0x4d); in es8326_calibrate()
984 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); in es8326_calibrate()
985 regmap_read(es8326->regmap, ES8326_HPL_OFFSET_INI, &offset_l); in es8326_calibrate()
986 regmap_read(es8326->regmap, ES8326_HPR_OFFSET_INI, &offset_r); in es8326_calibrate()
987 regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); in es8326_calibrate()
988 regmap_write(es8326->regmap, ES8326_HPL_OFFSET_INI, offset_l); in es8326_calibrate()
989 regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r); in es8326_calibrate()
990 regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00); in es8326_calibrate()
992 es8326->calibrated = true; in es8326_calibrate()
1002 regmap_write(es8326->regmap, ES8326_RESET, 0x1f); in es8326_init()
1003 regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E); in es8326_init()
1004 regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0); in es8326_init()
1006 regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0xd9); in es8326_init()
1007 regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0xd8); in es8326_init()
1009 regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x83); in es8326_init()
1010 regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05); in es8326_init()
1013 regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x89); in es8326_init()
1014 regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON); in es8326_init()
1016 regmap_write(es8326->regmap, ES8326_RESET, 0x17); in es8326_init()
1018 regmap_write(es8326->regmap, ES8326_HP_MISC, 0x3d); in es8326_init()
1019 regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x00); in es8326_init()
1022 regmap_write(es8326->regmap, ES8326_HP_VOL, 0xc4); in es8326_init()
1023 regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa7); in es8326_init()
1025 regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0x23); in es8326_init()
1026 regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0x33); in es8326_init()
1027 regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1); in es8326_init()
1029 regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00); in es8326_init()
1030 regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xc4); in es8326_init()
1031 regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x81); in es8326_init()
1032 regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x00); in es8326_init()
1035 regmap_write(es8326->regmap, ES8326_DAC_CROSSTALK, 0xaa); in es8326_init()
1036 regmap_write(es8326->regmap, ES8326_DAC_RAMPRATE, 0x00); in es8326_init()
1038 regmap_write(es8326->regmap, ES8326_HP_CAL, 0x00); in es8326_init()
1040 regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0); in es8326_init()
1042 regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7F); in es8326_init()
1043 /* select vdda as micbias source */ in es8326_init()
1044 regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x03); in es8326_init()
1046 regmap_write(es8326->regmap, ES8326_DAC_DSM, 0x08); in es8326_init()
1047 regmap_write(es8326->regmap, ES8326_DAC_VPPSCALE, 0x15); in es8326_init()
1049 regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x80 | in es8326_init()
1050 ((es8326->version == ES8326_VERSION_B) ? in es8326_init()
1051 (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol) : in es8326_init()
1052 (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol | 0x04))); in es8326_init()
1054 es8326_enable_micbias(es8326->component); in es8326_init()
1056 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); in es8326_init()
1057 regmap_write(es8326->regmap, ES8326_INTOUT_IO, in es8326_init()
1058 es8326->interrupt_clk); in es8326_init()
1059 regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, in es8326_init()
1061 regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT); in es8326_init()
1063 regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x00); in es8326_init()
1064 regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON); in es8326_init()
1065 regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, ES8326_MIC_SEL_MASK, in es8326_init()
1068 regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK, in es8326_init()
1071 regmap_write(es8326->regmap, ES8326_ADC_MUTE, 0x0f); in es8326_init()
1072 regmap_write(es8326->regmap, ES8326_CLK_DIV_LRCK, 0xff); in es8326_init()
1073 regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x44); in es8326_init()
1074 regmap_write(es8326->regmap, ES8326_ADC2_SRC, 0x66); in es8326_init()
1075 es8326_disable_micbias(es8326->component); in es8326_init()
1078 regmap_write(es8326->regmap, ES8326_INT_SOURCE, ES8326_INT_SRC_PIN9); in es8326_init()
1086 regcache_cache_only(es8326->regmap, false); in es8326_resume()
1087 regcache_cache_bypass(es8326->regmap, true); in es8326_resume()
1088 regmap_read(es8326->regmap, ES8326_CLK_RESAMPLE, ®); in es8326_resume()
1089 regcache_cache_bypass(es8326->regmap, false); in es8326_resume()
1092 regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON); in es8326_resume()
1096 regcache_sync(es8326->regmap); in es8326_resume()
1098 es8326_irq(es8326->irq, es8326); in es8326_resume()
1106 cancel_delayed_work_sync(&es8326->jack_detect_work); in es8326_suspend()
1108 es8326->calibrated = false; in es8326_suspend()
1109 regmap_write(es8326->regmap, ES8326_CLK_MUX, 0x2d); in es8326_suspend()
1110 regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x00); in es8326_suspend()
1111 regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b); in es8326_suspend()
1112 regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_OFF); in es8326_suspend()
1113 regcache_cache_only(es8326->regmap, true); in es8326_suspend()
1116 regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x01); in es8326_suspend()
1118 regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x00); in es8326_suspend()
1120 regcache_mark_dirty(es8326->regmap); in es8326_suspend()
1129 es8326->component = component; in es8326_probe()
1130 es8326->jd_inverted = device_property_read_bool(component->dev, in es8326_probe()
1131 "everest,jack-detect-inverted"); in es8326_probe()
1133 ret = device_property_read_u8(component->dev, "everest,jack-pol", &es8326->jack_pol); in es8326_probe()
1135 dev_dbg(component->dev, "jack-pol return %d", ret); in es8326_probe()
1136 es8326->jack_pol = ES8326_HP_TYPE_AUTO; in es8326_probe()
1138 dev_dbg(component->dev, "jack-pol %x", es8326->jack_pol); in es8326_probe()
1140 ret = device_property_read_u8(component->dev, "everest,interrupt-src", in es8326_probe()
1141 &es8326->interrupt_src); in es8326_probe()
1143 dev_dbg(component->dev, "interrupt-src return %d", ret); in es8326_probe()
1144 es8326->interrupt_src = ES8326_HP_DET_SRC_PIN9; in es8326_probe()
1146 dev_dbg(component->dev, "interrupt-src %x", es8326->interrupt_src); in es8326_probe()
1148 ret = device_property_read_u8(component->dev, "everest,interrupt-clk", in es8326_probe()
1149 &es8326->interrupt_clk); in es8326_probe()
1151 dev_dbg(component->dev, "interrupt-clk return %d", ret); in es8326_probe()
1152 es8326->interrupt_clk = 0x00; in es8326_probe()
1154 dev_dbg(component->dev, "interrupt-clk %x", es8326->interrupt_clk); in es8326_probe()
1165 mutex_lock(&es8326->lock); in es8326_enable_jack_detect()
1166 if (es8326->jd_inverted) in es8326_enable_jack_detect()
1168 ES8326_HP_DET_JACK_POL, ~es8326->jack_pol); in es8326_enable_jack_detect()
1169 es8326->jack = jack; in es8326_enable_jack_detect()
1171 mutex_unlock(&es8326->lock); in es8326_enable_jack_detect()
1172 es8326_irq(es8326->irq, es8326); in es8326_enable_jack_detect()
1179 dev_dbg(component->dev, "Enter into %s\n", __func__); in es8326_disable_jack_detect()
1180 if (!es8326->jack) in es8326_disable_jack_detect()
1182 cancel_delayed_work_sync(&es8326->jack_detect_work); in es8326_disable_jack_detect()
1184 mutex_lock(&es8326->lock); in es8326_disable_jack_detect()
1185 if (es8326->jack->status & SND_JACK_MICROPHONE) { in es8326_disable_jack_detect()
1187 snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET); in es8326_disable_jack_detect()
1189 es8326->jack = NULL; in es8326_disable_jack_detect()
1190 mutex_unlock(&es8326->lock); in es8326_disable_jack_detect()
1210 regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x01); in es8326_remove()
1212 regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x00); in es8326_remove()
1237 es8326 = devm_kzalloc(&i2c->dev, sizeof(struct es8326_priv), GFP_KERNEL); in es8326_i2c_probe()
1239 return -ENOMEM; in es8326_i2c_probe()
1242 es8326->i2c = i2c; in es8326_i2c_probe()
1243 mutex_init(&es8326->lock); in es8326_i2c_probe()
1244 es8326->regmap = devm_regmap_init_i2c(i2c, &es8326_regmap_config); in es8326_i2c_probe()
1245 if (IS_ERR(es8326->regmap)) { in es8326_i2c_probe()
1246 ret = PTR_ERR(es8326->regmap); in es8326_i2c_probe()
1247 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); in es8326_i2c_probe()
1251 es8326->irq = i2c->irq; in es8326_i2c_probe()
1252 es8326->jack_remove_retry = 0; in es8326_i2c_probe()
1253 es8326->hp = 0; in es8326_i2c_probe()
1254 es8326->hpl_vol = 0x03; in es8326_i2c_probe()
1255 es8326->hpr_vol = 0x03; in es8326_i2c_probe()
1256 INIT_DELAYED_WORK(&es8326->jack_detect_work, in es8326_i2c_probe()
1258 INIT_DELAYED_WORK(&es8326->button_press_work, in es8326_i2c_probe()
1260 /* ES8316 is level-based while ES8326 is edge-based */ in es8326_i2c_probe()
1261 ret = devm_request_threaded_irq(&i2c->dev, es8326->irq, NULL, es8326_irq, in es8326_i2c_probe()
1265 dev_warn(&i2c->dev, "Failed to request IRQ: %d: %d\n", in es8326_i2c_probe()
1266 es8326->irq, ret); in es8326_i2c_probe()
1267 es8326->irq = -ENXIO; in es8326_i2c_probe()
1270 es8326->mclk = devm_clk_get_optional(&i2c->dev, "mclk"); in es8326_i2c_probe()
1271 if (IS_ERR(es8326->mclk)) { in es8326_i2c_probe()
1272 dev_err(&i2c->dev, "unable to get mclk\n"); in es8326_i2c_probe()
1273 return PTR_ERR(es8326->mclk); in es8326_i2c_probe()
1275 if (!es8326->mclk) in es8326_i2c_probe()
1276 dev_warn(&i2c->dev, "assuming static mclk\n"); in es8326_i2c_probe()
1278 ret = clk_prepare_enable(es8326->mclk); in es8326_i2c_probe()
1280 dev_err(&i2c->dev, "unable to enable mclk\n"); in es8326_i2c_probe()
1283 return devm_snd_soc_register_component(&i2c->dev, in es8326_i2c_probe()
1295 component = es8326->component; in es8326_i2c_shutdown()
1296 dev_dbg(component->dev, "Enter into %s\n", __func__); in es8326_i2c_shutdown()
1297 cancel_delayed_work_sync(&es8326->jack_detect_work); in es8326_i2c_shutdown()
1298 cancel_delayed_work_sync(&es8326->button_press_work); in es8326_i2c_shutdown()
1300 regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x01); in es8326_i2c_shutdown()
1302 regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x00); in es8326_i2c_shutdown()
1347 MODULE_AUTHOR("David Yang <yangxiaohua@everest-semi.com>");