Lines Matching full:wcd938x
26 #include "wcd938x.h"
281 .name = "wcd938x",
348 static int wcd938x_io_init(struct wcd938x_priv *wcd938x) in wcd938x_io_init() argument
350 struct regmap *rm = wcd938x->regmap; in wcd938x_io_init()
473 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_hphl_dac_event() local
491 if (wcd938x->comp1_enable) { in wcd938x_codec_hphl_dac_event()
496 if (!wcd938x->comp2_enable || (snd_soc_component_read(component, in wcd938x_codec_hphl_dac_event()
527 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_hphr_dac_event() local
545 if (wcd938x->comp2_enable) { in wcd938x_codec_hphr_dac_event()
550 if (!wcd938x->comp1_enable || in wcd938x_codec_hphr_dac_event()
581 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_ear_dac_event() local
585 wcd938x->ear_rx_path = in wcd938x_codec_ear_dac_event()
588 if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) { in wcd938x_codec_ear_dac_event()
608 if (wcd938x->comp1_enable) in wcd938x_codec_ear_dac_event()
615 if (wcd938x->flyback_cur_det_disable == 0) in wcd938x_codec_ear_dac_event()
618 wcd938x->flyback_cur_det_disable++; in wcd938x_codec_ear_dac_event()
619 wcd_clsh_ctrl_set_state(wcd938x->clsh_info, in wcd938x_codec_ear_dac_event()
622 wcd938x->hph_mode); in wcd938x_codec_ear_dac_event()
625 if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) { in wcd938x_codec_ear_dac_event()
639 if (wcd938x->comp1_enable) in wcd938x_codec_ear_dac_event()
660 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_aux_dac_event() local
673 if (wcd938x->flyback_cur_det_disable == 0) in wcd938x_codec_aux_dac_event()
676 wcd938x->flyback_cur_det_disable++; in wcd938x_codec_aux_dac_event()
677 wcd_clsh_ctrl_set_state(wcd938x->clsh_info, in wcd938x_codec_aux_dac_event()
680 wcd938x->hph_mode); in wcd938x_codec_aux_dac_event()
696 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_enable_hphr_pa() local
697 int hph_mode = wcd938x->hph_mode; in wcd938x_codec_enable_hphr_pa()
701 if (wcd938x->ldoh) in wcd938x_codec_enable_hphr_pa()
704 wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, in wcd938x_codec_enable_hphr_pa()
706 wcd_clsh_set_hph_mode(wcd938x->clsh_info, CLS_H_HIFI); in wcd938x_codec_enable_hphr_pa()
716 wcd_clsh_set_hph_mode(wcd938x->clsh_info, hph_mode); in wcd938x_codec_enable_hphr_pa()
719 set_bit(HPH_PA_DELAY, &wcd938x->status_mask); in wcd938x_codec_enable_hphr_pa()
730 if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { in wcd938x_codec_enable_hphr_pa()
731 if (!wcd938x->comp2_enable) in wcd938x_codec_enable_hphr_pa()
741 clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); in wcd938x_codec_enable_hphr_pa()
750 enable_irq(wcd938x->hphr_pdm_wd_int); in wcd938x_codec_enable_hphr_pa()
753 disable_irq_nosync(wcd938x->hphr_pdm_wd_int); in wcd938x_codec_enable_hphr_pa()
759 if (!wcd938x->comp2_enable) in wcd938x_codec_enable_hphr_pa()
765 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, in wcd938x_codec_enable_hphr_pa()
767 set_bit(HPH_PA_DELAY, &wcd938x->status_mask); in wcd938x_codec_enable_hphr_pa()
775 if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { in wcd938x_codec_enable_hphr_pa()
776 if (!wcd938x->comp2_enable) in wcd938x_codec_enable_hphr_pa()
780 clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); in wcd938x_codec_enable_hphr_pa()
782 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, in wcd938x_codec_enable_hphr_pa()
788 wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, in wcd938x_codec_enable_hphr_pa()
790 if (wcd938x->ldoh) in wcd938x_codec_enable_hphr_pa()
803 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_enable_hphl_pa() local
804 int hph_mode = wcd938x->hph_mode; in wcd938x_codec_enable_hphl_pa()
808 if (wcd938x->ldoh) in wcd938x_codec_enable_hphl_pa()
811 wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, in wcd938x_codec_enable_hphl_pa()
813 wcd_clsh_set_hph_mode(wcd938x->clsh_info, CLS_H_HIFI); in wcd938x_codec_enable_hphl_pa()
822 wcd_clsh_set_hph_mode(wcd938x->clsh_info, hph_mode); in wcd938x_codec_enable_hphl_pa()
825 set_bit(HPH_PA_DELAY, &wcd938x->status_mask); in wcd938x_codec_enable_hphl_pa()
836 if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { in wcd938x_codec_enable_hphl_pa()
837 if (!wcd938x->comp1_enable) in wcd938x_codec_enable_hphl_pa()
846 clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); in wcd938x_codec_enable_hphl_pa()
856 enable_irq(wcd938x->hphl_pdm_wd_int); in wcd938x_codec_enable_hphl_pa()
859 disable_irq_nosync(wcd938x->hphl_pdm_wd_int); in wcd938x_codec_enable_hphl_pa()
865 if (!wcd938x->comp1_enable) in wcd938x_codec_enable_hphl_pa()
871 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, WCD_EVENT_PRE_HPHL_PA_OFF); in wcd938x_codec_enable_hphl_pa()
872 set_bit(HPH_PA_DELAY, &wcd938x->status_mask); in wcd938x_codec_enable_hphl_pa()
880 if (test_bit(HPH_PA_DELAY, &wcd938x->status_mask)) { in wcd938x_codec_enable_hphl_pa()
881 if (!wcd938x->comp1_enable) in wcd938x_codec_enable_hphl_pa()
885 clear_bit(HPH_PA_DELAY, &wcd938x->status_mask); in wcd938x_codec_enable_hphl_pa()
887 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, in wcd938x_codec_enable_hphl_pa()
893 wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, in wcd938x_codec_enable_hphl_pa()
895 if (wcd938x->ldoh) in wcd938x_codec_enable_hphl_pa()
908 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_enable_aux_pa() local
909 int hph_mode = wcd938x->hph_mode; in wcd938x_codec_enable_aux_pa()
924 enable_irq(wcd938x->aux_pdm_wd_int); in wcd938x_codec_enable_aux_pa()
927 disable_irq_nosync(wcd938x->aux_pdm_wd_int); in wcd938x_codec_enable_aux_pa()
934 wcd_clsh_ctrl_set_state(wcd938x->clsh_info, in wcd938x_codec_enable_aux_pa()
939 wcd938x->flyback_cur_det_disable--; in wcd938x_codec_enable_aux_pa()
940 if (wcd938x->flyback_cur_det_disable == 0) in wcd938x_codec_enable_aux_pa()
952 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_enable_ear_pa() local
953 int hph_mode = wcd938x->hph_mode; in wcd938x_codec_enable_ear_pa()
961 wcd938x->ear_rx_path = snd_soc_component_read(component, in wcd938x_codec_enable_ear_pa()
963 if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) in wcd938x_codec_enable_ear_pa()
970 if (!wcd938x->comp1_enable) in wcd938x_codec_enable_ear_pa()
984 if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) in wcd938x_codec_enable_ear_pa()
985 enable_irq(wcd938x->aux_pdm_wd_int); in wcd938x_codec_enable_ear_pa()
987 enable_irq(wcd938x->hphl_pdm_wd_int); in wcd938x_codec_enable_ear_pa()
990 if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) in wcd938x_codec_enable_ear_pa()
991 disable_irq_nosync(wcd938x->aux_pdm_wd_int); in wcd938x_codec_enable_ear_pa()
993 disable_irq_nosync(wcd938x->hphl_pdm_wd_int); in wcd938x_codec_enable_ear_pa()
996 if (!wcd938x->comp1_enable) in wcd938x_codec_enable_ear_pa()
1001 if (wcd938x->ear_rx_path & EAR_RX_PATH_AUX) in wcd938x_codec_enable_ear_pa()
1008 wcd_clsh_ctrl_set_state(wcd938x->clsh_info, WCD_CLSH_EVENT_POST_PA, in wcd938x_codec_enable_ear_pa()
1011 wcd938x->flyback_cur_det_disable--; in wcd938x_codec_enable_ear_pa()
1012 if (wcd938x->flyback_cur_det_disable == 0) in wcd938x_codec_enable_ear_pa()
1097 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_tx_swr_ctrl() local
1101 bank = (wcd938x_swr_get_current_bank(wcd938x->sdw_priv[AIF1_CAP]->sdev)) ? 0 : 1; in wcd938x_tx_swr_ctrl()
1109 if (test_bit(WCD_ADC1, &wcd938x->status_mask)) in wcd938x_tx_swr_ctrl()
1110 mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC1]]; in wcd938x_tx_swr_ctrl()
1111 if (test_bit(WCD_ADC2, &wcd938x->status_mask)) in wcd938x_tx_swr_ctrl()
1112 mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC2]]; in wcd938x_tx_swr_ctrl()
1113 if (test_bit(WCD_ADC3, &wcd938x->status_mask)) in wcd938x_tx_swr_ctrl()
1114 mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC3]]; in wcd938x_tx_swr_ctrl()
1115 if (test_bit(WCD_ADC4, &wcd938x->status_mask)) in wcd938x_tx_swr_ctrl()
1116 mode |= tx_mode_bit[wcd938x->tx_mode[WCD_ADC4]]; in wcd938x_tx_swr_ctrl()
1181 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_codec_enable_adc() local
1191 set_bit(w->shift, &wcd938x->status_mask); in wcd938x_codec_enable_adc()
1196 clear_bit(w->shift, &wcd938x->status_mask); in wcd938x_codec_enable_adc()
1236 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_adc_enable_req() local
1248 mode = wcd938x_get_adc_mode(wcd938x->tx_mode[w->shift]); in wcd938x_adc_enable_req()
1341 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_micbias_control() local
1366 wcd938x->pullup_ref[micb_index]++; in wcd938x_micbias_control()
1367 if ((wcd938x->pullup_ref[micb_index] == 1) && in wcd938x_micbias_control()
1368 (wcd938x->micb_ref[micb_index] == 0)) in wcd938x_micbias_control()
1374 if (wcd938x->pullup_ref[micb_index] > 0) in wcd938x_micbias_control()
1375 wcd938x->pullup_ref[micb_index]--; in wcd938x_micbias_control()
1377 if ((wcd938x->pullup_ref[micb_index] == 0) && in wcd938x_micbias_control()
1378 (wcd938x->micb_ref[micb_index] == 0)) in wcd938x_micbias_control()
1383 wcd938x->micb_ref[micb_index]++; in wcd938x_micbias_control()
1384 if (wcd938x->micb_ref[micb_index] == 1) { in wcd938x_micbias_control()
1399 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, in wcd938x_micbias_control()
1403 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, in wcd938x_micbias_control()
1409 if (wcd938x->micb_ref[micb_index] > 0) in wcd938x_micbias_control()
1410 wcd938x->micb_ref[micb_index]--; in wcd938x_micbias_control()
1412 if ((wcd938x->micb_ref[micb_index] == 0) && in wcd938x_micbias_control()
1413 (wcd938x->pullup_ref[micb_index] > 0)) in wcd938x_micbias_control()
1417 else if ((wcd938x->micb_ref[micb_index] == 0) && in wcd938x_micbias_control()
1418 (wcd938x->pullup_ref[micb_index] == 0)) { in wcd938x_micbias_control()
1420 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, in wcd938x_micbias_control()
1426 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, in wcd938x_micbias_control()
1430 wcd_mbhc_event_notify(wcd938x->wcd_mbhc, in wcd938x_micbias_control()
1490 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_tx_mode_get() local
1494 ucontrol->value.enumerated.item[0] = wcd938x->tx_mode[path]; in wcd938x_tx_mode_get()
1503 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_tx_mode_put() local
1507 if (wcd938x->tx_mode[path] == ucontrol->value.enumerated.item[0]) in wcd938x_tx_mode_put()
1510 wcd938x->tx_mode[path] = ucontrol->value.enumerated.item[0]; in wcd938x_tx_mode_put()
1519 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_rx_hph_mode_get() local
1521 ucontrol->value.enumerated.item[0] = wcd938x->hph_mode; in wcd938x_rx_hph_mode_get()
1530 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_rx_hph_mode_put() local
1532 if (wcd938x->hph_mode == ucontrol->value.enumerated.item[0]) in wcd938x_rx_hph_mode_put()
1535 wcd938x->hph_mode = ucontrol->value.enumerated.item[0]; in wcd938x_rx_hph_mode_put()
1544 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_ear_pa_put_gain() local
1546 if (wcd938x->comp1_enable) { in wcd938x_ear_pa_put_gain()
1563 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_get_compander() local
1571 ucontrol->value.integer.value[0] = wcd938x->comp2_enable; in wcd938x_get_compander()
1573 ucontrol->value.integer.value[0] = wcd938x->comp1_enable; in wcd938x_get_compander()
1582 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_set_compander() local
1592 wcd = wcd938x->sdw_priv[AIF1_PB]; in wcd938x_set_compander()
1595 wcd938x->comp2_enable = value; in wcd938x_set_compander()
1597 wcd938x->comp1_enable = value; in wcd938x_set_compander()
1613 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_ldoh_get() local
1615 ucontrol->value.integer.value[0] = wcd938x->ldoh; in wcd938x_ldoh_get()
1624 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_ldoh_put() local
1626 if (wcd938x->ldoh == ucontrol->value.integer.value[0]) in wcd938x_ldoh_put()
1629 wcd938x->ldoh = ucontrol->value.integer.value[0]; in wcd938x_ldoh_put()
1854 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(comp); in wcd938x_get_swr_port() local
1861 wcd = wcd938x->sdw_priv[dai_id]; in wcd938x_get_swr_port()
1873 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(comp); in wcd938x_set_swr_port() local
1882 wcd = wcd938x->sdw_priv[dai_id]; in wcd938x_set_swr_port()
1994 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_micb_adjust_voltage() local
2013 mutex_lock(&wcd938x->micb_lock); in wcd938x_mbhc_micb_adjust_voltage()
2058 mutex_unlock(&wcd938x->micb_lock); in wcd938x_mbhc_micb_adjust_voltage()
2065 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_micb_ctrl_threshold_mic() local
2075 if (wcd938x->micb2_mv >= WCD_MBHC_THR_HS_MICB_MV) in wcd938x_mbhc_micb_ctrl_threshold_mic()
2078 micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : wcd938x->micb2_mv; in wcd938x_mbhc_micb_ctrl_threshold_mic()
2087 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_get_result_params() local
2097 regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MBHC_ZDET, 0x20, 0x20); in wcd938x_mbhc_get_result_params()
2099 regmap_read(wcd938x->regmap, WCD938X_ANA_MBHC_RESULT_2, &val); in wcd938x_mbhc_get_result_params()
2104 regmap_read(wcd938x->regmap, WCD938X_ANA_MBHC_RESULT_1, &val1); in wcd938x_mbhc_get_result_params()
2106 regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MBHC_ZDET, 0x20, 0x00); in wcd938x_mbhc_get_result_params()
2130 regmap_read(wcd938x->regmap, in wcd938x_mbhc_get_result_params()
2132 regmap_read(wcd938x->regmap, in wcd938x_mbhc_get_result_params()
2147 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_zdet_ramp() local
2166 regmap_update_bits(wcd938x->regmap, in wcd938x_mbhc_zdet_ramp()
2171 regmap_update_bits(wcd938x->regmap, in wcd938x_mbhc_zdet_ramp()
2180 regmap_update_bits(wcd938x->regmap, in wcd938x_mbhc_zdet_ramp()
2185 regmap_update_bits(wcd938x->regmap, in wcd938x_mbhc_zdet_ramp()
2214 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_wcd_mbhc_calc_impedance() local
2242 regmap_update_bits(wcd938x->regmap, in wcd938x_wcd_mbhc_calc_impedance()
2247 if (wcd938x->mbhc_cfg.hphl_swh) in wcd938x_wcd_mbhc_calc_impedance()
2248 regmap_update_bits(wcd938x->regmap, in wcd938x_wcd_mbhc_calc_impedance()
2252 regmap_update_bits(wcd938x->regmap, in wcd938x_wcd_mbhc_calc_impedance()
2258 regmap_update_bits(wcd938x->regmap, in wcd938x_wcd_mbhc_calc_impedance()
2345 wcd_mbhc_set_hph_type(wcd938x->wcd_mbhc, WCD_MBHC_HPH_MONO); in wcd938x_wcd_mbhc_calc_impedance()
2369 wcd_mbhc_set_hph_type(wcd938x->wcd_mbhc, WCD_MBHC_HPH_STEREO); in wcd938x_wcd_mbhc_calc_impedance()
2373 wcd_mbhc_set_hph_type(wcd938x->wcd_mbhc, WCD_MBHC_HPH_MONO); in wcd938x_wcd_mbhc_calc_impedance()
2377 regmap_update_bits(wcd938x->regmap, in wcd938x_wcd_mbhc_calc_impedance()
2384 regmap_update_bits(wcd938x->regmap, in wcd938x_wcd_mbhc_calc_impedance()
2388 if (wcd938x->mbhc_cfg.hphl_swh) in wcd938x_wcd_mbhc_calc_impedance()
2389 regmap_update_bits(wcd938x->regmap, in wcd938x_wcd_mbhc_calc_impedance()
2395 regmap_update_bits(wcd938x->regmap, in wcd938x_wcd_mbhc_calc_impedance()
2426 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_moisture_config() local
2428 if (wcd938x->mbhc_cfg.moist_rref == R_OFF) { in wcd938x_mbhc_moisture_config()
2435 if (!wcd938x->mbhc_cfg.hphl_swh) { in wcd938x_mbhc_moisture_config()
2444 WCD938X_M_RTH_CTL_MASK, wcd938x->mbhc_cfg.moist_rref); in wcd938x_mbhc_moisture_config()
2449 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_moisture_detect_en() local
2453 WCD938X_M_RTH_CTL_MASK, wcd938x->mbhc_cfg.moist_rref); in wcd938x_mbhc_moisture_detect_en()
2461 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_get_moisture_status() local
2464 if (wcd938x->mbhc_cfg.moist_rref == R_OFF) { in wcd938x_mbhc_get_moisture_status()
2471 if (!wcd938x->mbhc_cfg.hphl_swh) { in wcd938x_mbhc_get_moisture_status()
2526 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_get_hph_type() local
2528 ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd938x->wcd_mbhc); in wcd938x_get_hph_type()
2541 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_hph_impedance_get() local
2545 wcd_mbhc_get_impedance(wcd938x->wcd_mbhc, &zl, &zr); in wcd938x_hph_impedance_get()
2566 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_init() local
2567 struct wcd_mbhc_intr *intr_ids = &wcd938x->intr_ids; in wcd938x_mbhc_init()
2569 intr_ids->mbhc_sw_intr = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_mbhc_init()
2571 intr_ids->mbhc_btn_press_intr = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_mbhc_init()
2573 intr_ids->mbhc_btn_release_intr = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_mbhc_init()
2575 intr_ids->mbhc_hs_ins_intr = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_mbhc_init()
2577 intr_ids->mbhc_hs_rem_intr = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_mbhc_init()
2579 intr_ids->hph_left_ocp = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_mbhc_init()
2581 intr_ids->hph_right_ocp = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_mbhc_init()
2584 wcd938x->wcd_mbhc = wcd_mbhc_init(component, &mbhc_cb, intr_ids, wcd_mbhc_fields, true); in wcd938x_mbhc_init()
2585 if (IS_ERR(wcd938x->wcd_mbhc)) in wcd938x_mbhc_init()
2586 return PTR_ERR(wcd938x->wcd_mbhc); in wcd938x_mbhc_init()
2598 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_mbhc_deinit() local
2600 wcd_mbhc_deinit(wcd938x->wcd_mbhc); in wcd938x_mbhc_deinit()
2983 static int wcd938x_set_micbias_data(struct wcd938x_priv *wcd938x) in wcd938x_set_micbias_data() argument
2988 vout_ctl_1 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb1_mv); in wcd938x_set_micbias_data()
2989 vout_ctl_2 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb2_mv); in wcd938x_set_micbias_data()
2990 vout_ctl_3 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb3_mv); in wcd938x_set_micbias_data()
2991 vout_ctl_4 = wcd938x_get_micb_vout_ctl_val(wcd938x->micb4_mv); in wcd938x_set_micbias_data()
2995 regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB1, in wcd938x_set_micbias_data()
2997 regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB2, in wcd938x_set_micbias_data()
2999 regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB3, in wcd938x_set_micbias_data()
3001 regmap_update_bits(wcd938x->regmap, WCD938X_ANA_MICB4, in wcd938x_set_micbias_data()
3013 .name = "WCD938x",
3047 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_soc_codec_probe() local
3048 struct sdw_slave *tx_sdw_dev = wcd938x->tx_sdw_dev; in wcd938x_soc_codec_probe()
3060 snd_soc_component_init_regmap(component, wcd938x->regmap); in wcd938x_soc_codec_probe()
3066 wcd938x->variant = snd_soc_component_read_field(component, in wcd938x_soc_codec_probe()
3070 wcd938x->clsh_info = wcd_clsh_ctrl_alloc(component, WCD938X); in wcd938x_soc_codec_probe()
3071 if (IS_ERR(wcd938x->clsh_info)) { in wcd938x_soc_codec_probe()
3073 return PTR_ERR(wcd938x->clsh_info); in wcd938x_soc_codec_probe()
3076 wcd938x_io_init(wcd938x); in wcd938x_soc_codec_probe()
3079 regmap_write(wcd938x->regmap, in wcd938x_soc_codec_probe()
3085 wcd938x->hphr_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_soc_codec_probe()
3087 wcd938x->hphl_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_soc_codec_probe()
3089 wcd938x->aux_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, in wcd938x_soc_codec_probe()
3093 ret = request_threaded_irq(wcd938x->hphr_pdm_wd_int, NULL, wcd938x_wd_handle_irq, in wcd938x_soc_codec_probe()
3095 "HPHR PDM WD INT", wcd938x); in wcd938x_soc_codec_probe()
3101 ret = request_threaded_irq(wcd938x->hphl_pdm_wd_int, NULL, wcd938x_wd_handle_irq, in wcd938x_soc_codec_probe()
3103 "HPHL PDM WD INT", wcd938x); in wcd938x_soc_codec_probe()
3109 ret = request_threaded_irq(wcd938x->aux_pdm_wd_int, NULL, wcd938x_wd_handle_irq, in wcd938x_soc_codec_probe()
3111 "AUX PDM WD INT", wcd938x); in wcd938x_soc_codec_probe()
3118 disable_irq_nosync(wcd938x->hphr_pdm_wd_int); in wcd938x_soc_codec_probe()
3119 disable_irq_nosync(wcd938x->hphl_pdm_wd_int); in wcd938x_soc_codec_probe()
3120 disable_irq_nosync(wcd938x->aux_pdm_wd_int); in wcd938x_soc_codec_probe()
3122 switch (wcd938x->variant) { in wcd938x_soc_codec_probe()
3129 __func__, wcd938x->variant); in wcd938x_soc_codec_probe()
3139 __func__, wcd938x->variant); in wcd938x_soc_codec_probe()
3156 free_irq(wcd938x->aux_pdm_wd_int, wcd938x); in wcd938x_soc_codec_probe()
3158 free_irq(wcd938x->hphl_pdm_wd_int, wcd938x); in wcd938x_soc_codec_probe()
3160 free_irq(wcd938x->hphr_pdm_wd_int, wcd938x); in wcd938x_soc_codec_probe()
3162 wcd_clsh_ctrl_free(wcd938x->clsh_info); in wcd938x_soc_codec_probe()
3169 struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_soc_codec_remove() local
3173 free_irq(wcd938x->aux_pdm_wd_int, wcd938x); in wcd938x_soc_codec_remove()
3174 free_irq(wcd938x->hphl_pdm_wd_int, wcd938x); in wcd938x_soc_codec_remove()
3175 free_irq(wcd938x->hphr_pdm_wd_int, wcd938x); in wcd938x_soc_codec_remove()
3177 wcd_clsh_ctrl_free(wcd938x->clsh_info); in wcd938x_soc_codec_remove()
3242 struct wcd938x_priv *wcd938x; in wcd938x_swap_gnd_mic() local
3244 wcd938x = snd_soc_component_get_drvdata(component); in wcd938x_swap_gnd_mic()
3246 value = gpiod_get_value(wcd938x->us_euro_gpio); in wcd938x_swap_gnd_mic()
3248 gpiod_set_value(wcd938x->us_euro_gpio, !value); in wcd938x_swap_gnd_mic()
3254 static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device *dev) in wcd938x_populate_dt_data() argument
3256 struct wcd_mbhc_config *cfg = &wcd938x->mbhc_cfg; in wcd938x_populate_dt_data()
3259 wcd938x->reset_gpio = of_get_named_gpio(dev->of_node, "reset-gpios", 0); in wcd938x_populate_dt_data()
3260 if (wcd938x->reset_gpio < 0) in wcd938x_populate_dt_data()
3261 return dev_err_probe(dev, wcd938x->reset_gpio, in wcd938x_populate_dt_data()
3264 wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", in wcd938x_populate_dt_data()
3266 if (IS_ERR(wcd938x->us_euro_gpio)) in wcd938x_populate_dt_data()
3267 return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio), in wcd938x_populate_dt_data()
3272 wcd938x->supplies[0].supply = "vdd-rxtx"; in wcd938x_populate_dt_data()
3273 wcd938x->supplies[1].supply = "vdd-io"; in wcd938x_populate_dt_data()
3274 wcd938x->supplies[2].supply = "vdd-buck"; in wcd938x_populate_dt_data()
3275 wcd938x->supplies[3].supply = "vdd-mic-bias"; in wcd938x_populate_dt_data()
3277 ret = regulator_bulk_get(dev, WCD938X_MAX_SUPPLY, wcd938x->supplies); in wcd938x_populate_dt_data()
3281 ret = regulator_bulk_enable(WCD938X_MAX_SUPPLY, wcd938x->supplies); in wcd938x_populate_dt_data()
3283 regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); in wcd938x_populate_dt_data()
3287 wcd938x_dt_parse_micbias_info(dev, wcd938x); in wcd938x_populate_dt_data()
3293 cfg->micb_mv = wcd938x->micb2_mv; in wcd938x_populate_dt_data()
3303 static int wcd938x_reset(struct wcd938x_priv *wcd938x) in wcd938x_reset() argument
3305 gpio_direction_output(wcd938x->reset_gpio, 0); in wcd938x_reset()
3308 gpio_set_value(wcd938x->reset_gpio, 1); in wcd938x_reset()
3319 struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); in wcd938x_codec_hw_params() local
3320 struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; in wcd938x_codec_hw_params()
3328 struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); in wcd938x_codec_free() local
3329 struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; in wcd938x_codec_free()
3337 struct wcd938x_priv *wcd938x = dev_get_drvdata(dai->dev); in wcd938x_codec_set_sdw_stream() local
3338 struct wcd938x_sdw_priv *wcd = wcd938x->sdw_priv[dai->id]; in wcd938x_codec_set_sdw_stream()
3352 .name = "wcd938x-sdw-rx",
3365 .name = "wcd938x-sdw-tx",
3381 struct wcd938x_priv *wcd938x = dev_get_drvdata(dev); in wcd938x_bind() local
3384 ret = component_bind_all(dev, wcd938x); in wcd938x_bind()
3391 wcd938x->rxdev = wcd938x_sdw_device_get(wcd938x->rxnode); in wcd938x_bind()
3392 if (!wcd938x->rxdev) { in wcd938x_bind()
3397 wcd938x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd938x->rxdev); in wcd938x_bind()
3398 wcd938x->sdw_priv[AIF1_PB]->wcd938x = wcd938x; in wcd938x_bind()
3400 wcd938x->txdev = wcd938x_sdw_device_get(wcd938x->txnode); in wcd938x_bind()
3401 if (!wcd938x->txdev) { in wcd938x_bind()
3406 wcd938x->sdw_priv[AIF1_CAP] = dev_get_drvdata(wcd938x->txdev); in wcd938x_bind()
3407 wcd938x->sdw_priv[AIF1_CAP]->wcd938x = wcd938x; in wcd938x_bind()
3408 wcd938x->tx_sdw_dev = dev_to_sdw_dev(wcd938x->txdev); in wcd938x_bind()
3412 if (!device_link_add(wcd938x->rxdev, wcd938x->txdev, DL_FLAG_STATELESS | in wcd938x_bind()
3419 if (!device_link_add(dev, wcd938x->txdev, DL_FLAG_STATELESS | in wcd938x_bind()
3426 if (!device_link_add(dev, wcd938x->rxdev, DL_FLAG_STATELESS | in wcd938x_bind()
3433 wcd938x->regmap = dev_get_regmap(&wcd938x->tx_sdw_dev->dev, NULL); in wcd938x_bind()
3434 if (!wcd938x->regmap) { in wcd938x_bind()
3440 ret = wcd938x_irq_init(wcd938x, dev); in wcd938x_bind()
3446 wcd938x->sdw_priv[AIF1_PB]->slave_irq = wcd938x->virq; in wcd938x_bind()
3447 wcd938x->sdw_priv[AIF1_CAP]->slave_irq = wcd938x->virq; in wcd938x_bind()
3449 ret = wcd938x_set_micbias_data(wcd938x); in wcd938x_bind()
3466 device_link_remove(dev, wcd938x->rxdev); in wcd938x_bind()
3468 device_link_remove(dev, wcd938x->txdev); in wcd938x_bind()
3470 device_link_remove(wcd938x->rxdev, wcd938x->txdev); in wcd938x_bind()
3472 put_device(wcd938x->txdev); in wcd938x_bind()
3474 put_device(wcd938x->rxdev); in wcd938x_bind()
3476 component_unbind_all(dev, wcd938x); in wcd938x_bind()
3483 struct wcd938x_priv *wcd938x = dev_get_drvdata(dev); in wcd938x_unbind() local
3486 device_link_remove(dev, wcd938x->txdev); in wcd938x_unbind()
3487 device_link_remove(dev, wcd938x->rxdev); in wcd938x_unbind()
3488 device_link_remove(wcd938x->rxdev, wcd938x->txdev); in wcd938x_unbind()
3489 put_device(wcd938x->txdev); in wcd938x_unbind()
3490 put_device(wcd938x->rxdev); in wcd938x_unbind()
3491 component_unbind_all(dev, wcd938x); in wcd938x_unbind()
3499 static int wcd938x_add_slave_components(struct wcd938x_priv *wcd938x, in wcd938x_add_slave_components() argument
3507 wcd938x->rxnode = of_parse_phandle(np, "qcom,rx-device", 0); in wcd938x_add_slave_components()
3508 if (!wcd938x->rxnode) { in wcd938x_add_slave_components()
3513 of_node_get(wcd938x->rxnode); in wcd938x_add_slave_components()
3515 component_compare_of, wcd938x->rxnode); in wcd938x_add_slave_components()
3517 wcd938x->txnode = of_parse_phandle(np, "qcom,tx-device", 0); in wcd938x_add_slave_components()
3518 if (!wcd938x->txnode) { in wcd938x_add_slave_components()
3522 of_node_get(wcd938x->txnode); in wcd938x_add_slave_components()
3524 component_compare_of, wcd938x->txnode); in wcd938x_add_slave_components()
3531 struct wcd938x_priv *wcd938x = NULL; in wcd938x_probe() local
3535 wcd938x = devm_kzalloc(dev, sizeof(struct wcd938x_priv), in wcd938x_probe()
3537 if (!wcd938x) in wcd938x_probe()
3540 dev_set_drvdata(dev, wcd938x); in wcd938x_probe()
3541 mutex_init(&wcd938x->micb_lock); in wcd938x_probe()
3543 ret = wcd938x_populate_dt_data(wcd938x, dev); in wcd938x_probe()
3547 ret = wcd938x_add_slave_components(wcd938x, dev, &match); in wcd938x_probe()
3551 wcd938x_reset(wcd938x); in wcd938x_probe()
3567 regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies); in wcd938x_probe()
3568 regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); in wcd938x_probe()
3576 struct wcd938x_priv *wcd938x = dev_get_drvdata(dev); in wcd938x_remove() local
3584 regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies); in wcd938x_remove()
3585 regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); in wcd938x_remove()
3608 MODULE_DESCRIPTION("WCD938X Codec driver");