Lines Matching +full:mic1 +full:- +full:src
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>
48 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(dac_vol_tlv, -9550, 50, 0);
49 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(adc_vol_tlv, -9550, 50, 0);
53 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(drc_target_tlv, -3200, 200, 0);
54 static const SNDRV_CTL_TLVD_DECLARE_DB_SCALE(drc_recovery_tlv, -125, 250, 0);
108 SND_SOC_DAPM_INPUT("MIC1"),
140 {"ADC L1", NULL, "MIC1"},
276 return -EINVAL; in get_coeff()
282 struct snd_soc_component *codec = codec_dai->component; in es8326_set_dai_sysclk()
285 es8326->sysclk = freq; in es8326_set_dai_sysclk()
292 struct snd_soc_component *component = codec_dai->component; in es8326_set_dai_fmt()
303 return -EINVAL; in es8326_set_dai_fmt()
311 dev_err(component->dev, "Codec driver does not support right justified\n"); in es8326_set_dai_fmt()
312 return -EINVAL; in es8326_set_dai_fmt()
323 return -EINVAL; in es8326_set_dai_fmt()
335 struct snd_soc_component *component = dai->component; in es8326_pcm_hw_params()
340 coeff = get_coeff(es8326->sysclk, params_rate(params)); in es8326_pcm_hw_params()
359 return -EINVAL; in es8326_pcm_hw_params()
366 regmap_write(es8326->regmap, ES8326_CLK_DIV1, in es8326_pcm_hw_params()
368 regmap_write(es8326->regmap, ES8326_CLK_DIV2, in es8326_pcm_hw_params()
370 regmap_write(es8326->regmap, ES8326_CLK_DLL, in es8326_pcm_hw_params()
372 regmap_write(es8326->regmap, ES8326_CLK_MUX, in es8326_pcm_hw_params()
374 regmap_write(es8326->regmap, ES8326_CLK_ADC_SEL, in es8326_pcm_hw_params()
376 regmap_write(es8326->regmap, ES8326_CLK_DAC_SEL, in es8326_pcm_hw_params()
378 regmap_write(es8326->regmap, ES8326_CLK_ADC_OSR, in es8326_pcm_hw_params()
380 regmap_write(es8326->regmap, ES8326_CLK_DAC_OSR, in es8326_pcm_hw_params()
383 dev_warn(component->dev, "Clock coefficients do not match"); in es8326_pcm_hw_params()
391 struct snd_soc_component *component = dai->component; in es8326_mute()
396 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); in es8326_mute()
397 regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, in es8326_mute()
399 regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xf0); in es8326_mute()
401 if (!es8326->calibrated) { in es8326_mute()
402 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_FORCE_CAL); in es8326_mute()
404 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); in es8326_mute()
405 regmap_read(es8326->regmap, ES8326_HPL_OFFSET_INI, &offset_l); in es8326_mute()
406 regmap_read(es8326->regmap, ES8326_HPR_OFFSET_INI, &offset_r); in es8326_mute()
407 regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); in es8326_mute()
408 regmap_write(es8326->regmap, ES8326_HPL_OFFSET_INI, offset_l); in es8326_mute()
409 regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r); in es8326_mute()
410 es8326->calibrated = true; in es8326_mute()
412 regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa0); in es8326_mute()
413 regmap_write(es8326->regmap, ES8326_HP_VOL, 0x80); in es8326_mute()
414 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_ON); in es8326_mute()
415 regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, in es8326_mute()
429 ret = clk_prepare_enable(es8326->mclk); in es8326_set_bias_level()
433 regmap_write(es8326->regmap, ES8326_RESET, 0x9f); in es8326_set_bias_level()
435 regmap_update_bits(es8326->regmap, ES8326_DAC_DSM, 0x01, 0x00); in es8326_set_bias_level()
436 regmap_write(es8326->regmap, ES8326_INTOUT_IO, es8326->interrupt_clk); in es8326_set_bias_level()
437 regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, in es8326_set_bias_level()
439 regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E); in es8326_set_bias_level()
440 regmap_write(es8326->regmap, ES8326_PGA_PDN, 0x40); in es8326_set_bias_level()
441 regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x00); in es8326_set_bias_level()
442 regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x20); in es8326_set_bias_level()
443 regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON); in es8326_set_bias_level()
450 clk_disable_unprepare(es8326->mclk); in es8326_set_bias_level()
451 regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b); in es8326_set_bias_level()
452 regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x00); in es8326_set_bias_level()
453 regmap_update_bits(es8326->regmap, ES8326_CLK_CTL, 0x20, 0x00); in es8326_set_bias_level()
454 regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, ES8326_IO_INPUT); in es8326_set_bias_level()
516 * snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_PLAYPAUSE);
517 * snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP);
518 * snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN);
524 struct snd_soc_component *comp = es8326->component; in es8326_jack_button_handler()
529 if (!(es8326->jack->status & SND_JACK_HEADSET)) /* Jack unplugged */ in es8326_jack_button_handler()
532 mutex_lock(&es8326->lock); in es8326_jack_button_handler()
561 snd_soc_jack_report(es8326->jack, cur_button, in es8326_jack_button_handler()
566 queue_delayed_work(system_wq, &es8326->button_press_work, in es8326_jack_button_handler()
571 queue_delayed_work(system_wq, &es8326->button_press_work, in es8326_jack_button_handler()
576 snd_soc_jack_report(es8326->jack, button_to_report, in es8326_jack_button_handler()
578 snd_soc_jack_report(es8326->jack, 0, in es8326_jack_button_handler()
583 mutex_unlock(&es8326->lock); in es8326_jack_button_handler()
590 struct snd_soc_component *comp = es8326->component; in es8326_jack_detect_handler()
593 mutex_lock(&es8326->lock); in es8326_jack_detect_handler()
595 dev_dbg(comp->dev, "gpio flag %#04x", iface); in es8326_jack_detect_handler()
597 if (es8326->jack_remove_retry == 1) { in es8326_jack_detect_handler()
599 es8326->jack_remove_retry = 2; in es8326_jack_detect_handler()
601 es8326->jack_remove_retry = 0; in es8326_jack_detect_handler()
603 dev_dbg(comp->dev, "remove event check, set HPJACK_POL normal, cnt = %d\n", in es8326_jack_detect_handler()
604 es8326->jack_remove_retry); in es8326_jack_detect_handler()
608 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, in es8326_jack_detect_handler()
609 ES8326_HP_DET_JACK_POL, (es8326->jd_inverted ? in es8326_jack_detect_handler()
610 ~es8326->jack_pol : es8326->jack_pol)); in es8326_jack_detect_handler()
616 dev_dbg(comp->dev, "No headset detected\n"); in es8326_jack_detect_handler()
617 es8326_disable_micbias(es8326->component); in es8326_jack_detect_handler()
618 if (es8326->jack->status & SND_JACK_HEADPHONE) { in es8326_jack_detect_handler()
619 dev_dbg(comp->dev, "Report hp remove event\n"); in es8326_jack_detect_handler()
620 snd_soc_jack_report(es8326->jack, 0, in es8326_jack_detect_handler()
622 snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET); in es8326_jack_detect_handler()
624 regmap_write(es8326->regmap, ES8326_ADC_SCALE, 0x33); in es8326_jack_detect_handler()
625 regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x44); in es8326_jack_detect_handler()
626 regmap_write(es8326->regmap, ES8326_ADC2_SRC, 0x66); in es8326_jack_detect_handler()
627 es8326->hp = 0; in es8326_jack_detect_handler()
629 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); in es8326_jack_detect_handler()
633 if (es8326->jack_remove_retry == 0) { in es8326_jack_detect_handler()
634 es8326->jack_remove_retry = 1; in es8326_jack_detect_handler()
635 dev_dbg(comp->dev, "remove event check, invert HPJACK_POL, cnt = %d\n", in es8326_jack_detect_handler()
636 es8326->jack_remove_retry); in es8326_jack_detect_handler()
637 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, in es8326_jack_detect_handler()
638 ES8326_HP_DET_JACK_POL, (es8326->jd_inverted ? in es8326_jack_detect_handler()
639 es8326->jack_pol : ~es8326->jack_pol)); in es8326_jack_detect_handler()
642 es8326->jack_remove_retry = 0; in es8326_jack_detect_handler()
645 es8326->jack_remove_retry = 0; in es8326_jack_detect_handler()
646 if (es8326->hp == 0) { in es8326_jack_detect_handler()
647 dev_dbg(comp->dev, "First insert, start OMTP/CTIA type check\n"); in es8326_jack_detect_handler()
649 * set auto-check mode, then restart jack_detect_work after 100ms. in es8326_jack_detect_handler()
652 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x01); in es8326_jack_detect_handler()
654 regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE, 0x03, 0x00); in es8326_jack_detect_handler()
655 queue_delayed_work(system_wq, &es8326->jack_detect_work, in es8326_jack_detect_handler()
657 es8326->hp = 1; in es8326_jack_detect_handler()
660 if (es8326->jack->status & SND_JACK_HEADSET) { in es8326_jack_detect_handler()
662 dev_dbg(comp->dev, "button pressed\n"); in es8326_jack_detect_handler()
663 queue_delayed_work(system_wq, &es8326->button_press_work, 10); in es8326_jack_detect_handler()
667 dev_dbg(comp->dev, "Headphone detected\n"); in es8326_jack_detect_handler()
668 snd_soc_jack_report(es8326->jack, in es8326_jack_detect_handler()
671 dev_dbg(comp->dev, "Headset detected\n"); in es8326_jack_detect_handler()
672 snd_soc_jack_report(es8326->jack, in es8326_jack_detect_handler()
675 regmap_write(es8326->regmap, ES8326_ADC_SCALE, 0x33); in es8326_jack_detect_handler()
676 regmap_update_bits(es8326->regmap, ES8326_PGA_PDN, in es8326_jack_detect_handler()
678 regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, in es8326_jack_detect_handler()
680 regmap_write(es8326->regmap, ES8326_ADC1_SRC, 0x00); in es8326_jack_detect_handler()
681 regmap_write(es8326->regmap, ES8326_ADC2_SRC, 0x00); in es8326_jack_detect_handler()
682 regmap_update_bits(es8326->regmap, ES8326_PGA_PDN, in es8326_jack_detect_handler()
688 mutex_unlock(&es8326->lock); in es8326_jack_detect_handler()
694 struct snd_soc_component *comp = es8326->component; in es8326_irq()
696 if (!es8326->jack) in es8326_irq()
701 if (es8326->jack->status & SND_JACK_HEADSET) in es8326_irq()
702 queue_delayed_work(system_wq, &es8326->jack_detect_work, in es8326_irq()
705 queue_delayed_work(system_wq, &es8326->jack_detect_work, in es8326_irq()
718 regmap_read(es8326->regmap, ES8326_CHIP_VERSION, ®); in es8326_calibrate()
719 es8326->version = reg; in es8326_calibrate()
721 if ((es8326->version == ES8326_VERSION_B) && (es8326->calibrated == false)) { in es8326_calibrate()
722 dev_dbg(component->dev, "ES8326_VERSION_B, calibrating\n"); in es8326_calibrate()
723 regmap_write(es8326->regmap, ES8326_CLK_INV, 0xc0); in es8326_calibrate()
724 regmap_write(es8326->regmap, ES8326_CLK_DIV1, 0x01); in es8326_calibrate()
725 regmap_write(es8326->regmap, ES8326_CLK_DLL, 0x30); in es8326_calibrate()
726 regmap_write(es8326->regmap, ES8326_CLK_MUX, 0xed); in es8326_calibrate()
727 regmap_write(es8326->regmap, ES8326_CLK_TRI, 0xc1); in es8326_calibrate()
728 regmap_write(es8326->regmap, ES8326_DAC_MUTE, 0x03); in es8326_calibrate()
729 regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7f); in es8326_calibrate()
730 regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x33); in es8326_calibrate()
731 regmap_write(es8326->regmap, ES8326_DAC2HPMIX, 0x88); in es8326_calibrate()
732 regmap_write(es8326->regmap, ES8326_HP_VOL, 0x80); in es8326_calibrate()
733 regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); in es8326_calibrate()
734 regmap_write(es8326->regmap, ES8326_RESET, 0xc0); in es8326_calibrate()
737 regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, ES8326_HP_OFF); in es8326_calibrate()
738 regmap_read(es8326->regmap, ES8326_CSM_MUTE_STA, ®); in es8326_calibrate()
742 regmap_write(es8326->regmap, ES8326_HP_CAL, 0xd4); in es8326_calibrate()
744 regmap_write(es8326->regmap, ES8326_HP_CAL, 0x4d); in es8326_calibrate()
746 regmap_write(es8326->regmap, ES8326_HP_CAL, ES8326_HP_OFF); in es8326_calibrate()
747 regmap_read(es8326->regmap, ES8326_HPL_OFFSET_INI, &offset_l); in es8326_calibrate()
748 regmap_read(es8326->regmap, ES8326_HPR_OFFSET_INI, &offset_r); in es8326_calibrate()
749 regmap_write(es8326->regmap, ES8326_HP_OFFSET_CAL, 0x8c); in es8326_calibrate()
750 regmap_write(es8326->regmap, ES8326_HPL_OFFSET_INI, offset_l); in es8326_calibrate()
751 regmap_write(es8326->regmap, ES8326_HPR_OFFSET_INI, offset_r); in es8326_calibrate()
752 regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00); in es8326_calibrate()
754 es8326->calibrated = true; in es8326_calibrate()
764 regcache_cache_only(es8326->regmap, false); in es8326_resume()
765 regcache_sync(es8326->regmap); in es8326_resume()
768 regmap_write(es8326->regmap, ES8326_RESET, 0x1f); in es8326_resume()
769 regmap_write(es8326->regmap, ES8326_VMIDSEL, 0x0E); in es8326_resume()
771 regmap_write(es8326->regmap, ES8326_HPJACK_TIMER, 0x88); in es8326_resume()
773 regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x81); in es8326_resume()
774 regmap_write(es8326->regmap, ES8326_CLK_RESAMPLE, 0x05); in es8326_resume()
777 regmap_write(es8326->regmap, ES8326_CLK_DIV_CPC, 0x84); in es8326_resume()
778 regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_ON); in es8326_resume()
780 regmap_write(es8326->regmap, ES8326_RESET, 0x17); in es8326_resume()
782 regmap_write(es8326->regmap, ES8326_HP_MISC, 0x08); in es8326_resume()
783 regmap_write(es8326->regmap, ES8326_PULLUP_CTL, 0x00); in es8326_resume()
786 regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa7); in es8326_resume()
788 regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xab); in es8326_resume()
790 regmap_write(es8326->regmap, ES8326_HP_DRIVER_REF, 0xbb); in es8326_resume()
792 regmap_write(es8326->regmap, ES8326_HP_DRIVER, 0xa1); in es8326_resume()
794 regmap_write(es8326->regmap, ES8326_CLK_INV, 0x00); in es8326_resume()
795 regmap_write(es8326->regmap, ES8326_CLK_VMIDS1, 0xc4); in es8326_resume()
796 regmap_write(es8326->regmap, ES8326_CLK_VMIDS2, 0x81); in es8326_resume()
797 regmap_write(es8326->regmap, ES8326_CLK_CAL_TIME, 0x00); in es8326_resume()
801 regmap_write(es8326->regmap, ES8326_HP_CAL, 0x00); in es8326_resume()
803 regmap_write(es8326->regmap, ES8326_ANA_LP, 0xf0); in es8326_resume()
806 regmap_write(es8326->regmap, ES8326_ANA_MICBIAS, 0x4f); in es8326_resume()
807 regmap_write(es8326->regmap, ES8326_SYS_BIAS, 0x08); in es8326_resume()
808 regmap_write(es8326->regmap, ES8326_ANA_VSEL, 0x7F); in es8326_resume()
810 regmap_write(es8326->regmap, ES8326_VMIDLOW, 0x23); in es8326_resume()
812 regmap_write(es8326->regmap, ES8326_DAC_DSM, 0x08); in es8326_resume()
813 regmap_write(es8326->regmap, ES8326_DAC_VPPSCALE, 0x15); in es8326_resume()
815 regmap_write(es8326->regmap, ES8326_INT_SOURCE, in es8326_resume()
817 regmap_write(es8326->regmap, ES8326_INTOUT_IO, in es8326_resume()
818 es8326->interrupt_clk); in es8326_resume()
819 regmap_write(es8326->regmap, ES8326_SDINOUT1_IO, in es8326_resume()
821 regmap_write(es8326->regmap, ES8326_SDINOUT23_IO, ES8326_IO_INPUT); in es8326_resume()
823 regmap_write(es8326->regmap, ES8326_ANA_PDN, 0x3b); in es8326_resume()
824 regmap_write(es8326->regmap, ES8326_RESET, ES8326_CSM_ON); in es8326_resume()
825 regmap_update_bits(es8326->regmap, ES8326_PGAGAIN, ES8326_MIC_SEL_MASK, in es8326_resume()
828 regmap_update_bits(es8326->regmap, ES8326_DAC_MUTE, ES8326_MUTE_MASK, in es8326_resume()
831 regmap_write(es8326->regmap, ES8326_HPDET_TYPE, 0x80 | in es8326_resume()
832 ((es8326->version == ES8326_VERSION_B) ? in es8326_resume()
833 (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol) : in es8326_resume()
834 (ES8326_HP_DET_SRC_PIN9 | es8326->jack_pol | 0x04))); in es8326_resume()
836 es8326->jack_remove_retry = 0; in es8326_resume()
837 es8326->hp = 0; in es8326_resume()
845 cancel_delayed_work_sync(&es8326->jack_detect_work); in es8326_suspend()
847 es8326->calibrated = false; in es8326_suspend()
848 regmap_write(es8326->regmap, ES8326_CLK_CTL, ES8326_CLK_OFF); in es8326_suspend()
849 regcache_cache_only(es8326->regmap, true); in es8326_suspend()
850 regcache_mark_dirty(es8326->regmap); in es8326_suspend()
853 regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x01); in es8326_suspend()
855 regmap_write(es8326->regmap, ES8326_CSM_I2C_STA, 0x00); in es8326_suspend()
864 es8326->component = component; in es8326_probe()
865 es8326->jd_inverted = device_property_read_bool(component->dev, in es8326_probe()
866 "everest,jack-detect-inverted"); in es8326_probe()
868 ret = device_property_read_u8(component->dev, "everest,mic1-src", &es8326->mic1_src); in es8326_probe()
870 dev_dbg(component->dev, "mic1-src return %d", ret); in es8326_probe()
871 es8326->mic1_src = ES8326_ADC_AMIC; in es8326_probe()
873 dev_dbg(component->dev, "mic1-src %x", es8326->mic1_src); in es8326_probe()
875 ret = device_property_read_u8(component->dev, "everest,mic2-src", &es8326->mic2_src); in es8326_probe()
877 dev_dbg(component->dev, "mic2-src return %d", ret); in es8326_probe()
878 es8326->mic2_src = ES8326_ADC_DMIC; in es8326_probe()
880 dev_dbg(component->dev, "mic2-src %x", es8326->mic2_src); in es8326_probe()
882 ret = device_property_read_u8(component->dev, "everest,jack-pol", &es8326->jack_pol); in es8326_probe()
884 dev_dbg(component->dev, "jack-pol return %d", ret); in es8326_probe()
885 es8326->jack_pol = ES8326_HP_TYPE_AUTO; in es8326_probe()
887 dev_dbg(component->dev, "jack-pol %x", es8326->jack_pol); in es8326_probe()
889 ret = device_property_read_u8(component->dev, "everest,interrupt-src", in es8326_probe()
890 &es8326->interrupt_src); in es8326_probe()
892 dev_dbg(component->dev, "interrupt-src return %d", ret); in es8326_probe()
893 es8326->interrupt_src = ES8326_HP_DET_SRC_PIN9; in es8326_probe()
895 dev_dbg(component->dev, "interrupt-src %x", es8326->interrupt_src); in es8326_probe()
897 ret = device_property_read_u8(component->dev, "everest,interrupt-clk", in es8326_probe()
898 &es8326->interrupt_clk); in es8326_probe()
900 dev_dbg(component->dev, "interrupt-clk return %d", ret); in es8326_probe()
901 es8326->interrupt_clk = 0x45; in es8326_probe()
903 dev_dbg(component->dev, "interrupt-clk %x", es8326->interrupt_clk); in es8326_probe()
914 mutex_lock(&es8326->lock); in es8326_enable_jack_detect()
915 if (es8326->jd_inverted) in es8326_enable_jack_detect()
917 ES8326_HP_DET_JACK_POL, ~es8326->jack_pol); in es8326_enable_jack_detect()
918 es8326->jack = jack; in es8326_enable_jack_detect()
920 mutex_unlock(&es8326->lock); in es8326_enable_jack_detect()
921 es8326_irq(es8326->irq, es8326); in es8326_enable_jack_detect()
928 dev_dbg(component->dev, "Enter into %s\n", __func__); in es8326_disable_jack_detect()
929 if (!es8326->jack) in es8326_disable_jack_detect()
931 cancel_delayed_work_sync(&es8326->jack_detect_work); in es8326_disable_jack_detect()
933 mutex_lock(&es8326->lock); in es8326_disable_jack_detect()
934 if (es8326->jack->status & SND_JACK_MICROPHONE) { in es8326_disable_jack_detect()
936 snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET); in es8326_disable_jack_detect()
938 es8326->jack = NULL; in es8326_disable_jack_detect()
939 mutex_unlock(&es8326->lock); in es8326_disable_jack_detect()
981 es8326 = devm_kzalloc(&i2c->dev, sizeof(struct es8326_priv), GFP_KERNEL); in es8326_i2c_probe()
983 return -ENOMEM; in es8326_i2c_probe()
986 es8326->i2c = i2c; in es8326_i2c_probe()
987 mutex_init(&es8326->lock); in es8326_i2c_probe()
988 es8326->regmap = devm_regmap_init_i2c(i2c, &es8326_regmap_config); in es8326_i2c_probe()
989 if (IS_ERR(es8326->regmap)) { in es8326_i2c_probe()
990 ret = PTR_ERR(es8326->regmap); in es8326_i2c_probe()
991 dev_err(&i2c->dev, "Failed to init regmap: %d\n", ret); in es8326_i2c_probe()
995 es8326->irq = i2c->irq; in es8326_i2c_probe()
996 INIT_DELAYED_WORK(&es8326->jack_detect_work, in es8326_i2c_probe()
998 INIT_DELAYED_WORK(&es8326->button_press_work, in es8326_i2c_probe()
1000 /* ES8316 is level-based while ES8326 is edge-based */ in es8326_i2c_probe()
1001 ret = devm_request_threaded_irq(&i2c->dev, es8326->irq, NULL, es8326_irq, in es8326_i2c_probe()
1005 dev_warn(&i2c->dev, "Failed to request IRQ: %d: %d\n", in es8326_i2c_probe()
1006 es8326->irq, ret); in es8326_i2c_probe()
1007 es8326->irq = -ENXIO; in es8326_i2c_probe()
1010 es8326->mclk = devm_clk_get_optional(&i2c->dev, "mclk"); in es8326_i2c_probe()
1011 if (IS_ERR(es8326->mclk)) { in es8326_i2c_probe()
1012 dev_err(&i2c->dev, "unable to get mclk\n"); in es8326_i2c_probe()
1013 return PTR_ERR(es8326->mclk); in es8326_i2c_probe()
1015 if (!es8326->mclk) in es8326_i2c_probe()
1016 dev_warn(&i2c->dev, "assuming static mclk\n"); in es8326_i2c_probe()
1018 ret = clk_prepare_enable(es8326->mclk); in es8326_i2c_probe()
1020 dev_err(&i2c->dev, "unable to enable mclk\n"); in es8326_i2c_probe()
1023 return devm_snd_soc_register_component(&i2c->dev, in es8326_i2c_probe()
1062 MODULE_AUTHOR("David Yang <yangxiaohua@everest-semi.com>");