Lines Matching full:wcd939x
33 #include "wcd939x.h"
293 .name = "wcd939x",
506 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_codec_hphl_dac_event() local
520 if (wcd939x->comp1_enable) { in wcd939x_codec_hphl_dac_event()
526 if (!wcd939x->comp2_enable || in wcd939x_codec_hphl_dac_event()
560 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_codec_hphr_dac_event() local
577 if (wcd939x->comp2_enable) { in wcd939x_codec_hphr_dac_event()
583 if (!wcd939x->comp1_enable || in wcd939x_codec_hphr_dac_event()
616 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_codec_ear_dac_event() local
628 wcd_clsh_ctrl_set_state(wcd939x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, in wcd939x_codec_ear_dac_event()
648 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_codec_enable_hphr_pa() local
649 int hph_mode = wcd939x->hph_mode; in wcd939x_codec_enable_hphr_pa()
653 if (wcd939x->ldoh) in wcd939x_codec_enable_hphr_pa()
657 wcd_clsh_ctrl_set_state(wcd939x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, in wcd939x_codec_enable_hphr_pa()
659 wcd_clsh_set_hph_mode(wcd939x->clsh_info, CLS_H_HIFI); in wcd939x_codec_enable_hphr_pa()
678 set_bit(HPH_PA_DELAY, &wcd939x->status_mask); in wcd939x_codec_enable_hphr_pa()
688 if (test_bit(HPH_PA_DELAY, &wcd939x->status_mask)) { in wcd939x_codec_enable_hphr_pa()
689 if (!wcd939x->comp2_enable) in wcd939x_codec_enable_hphr_pa()
700 clear_bit(HPH_PA_DELAY, &wcd939x->status_mask); in wcd939x_codec_enable_hphr_pa()
710 enable_irq(wcd939x->hphr_pdm_wd_int); in wcd939x_codec_enable_hphr_pa()
713 disable_irq_nosync(wcd939x->hphr_pdm_wd_int); in wcd939x_codec_enable_hphr_pa()
719 if (!wcd939x->comp2_enable) in wcd939x_codec_enable_hphr_pa()
727 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, in wcd939x_codec_enable_hphr_pa()
729 set_bit(HPH_PA_DELAY, &wcd939x->status_mask); in wcd939x_codec_enable_hphr_pa()
737 if (test_bit(HPH_PA_DELAY, &wcd939x->status_mask)) { in wcd939x_codec_enable_hphr_pa()
738 if (!wcd939x->comp2_enable) in wcd939x_codec_enable_hphr_pa()
742 clear_bit(HPH_PA_DELAY, &wcd939x->status_mask); in wcd939x_codec_enable_hphr_pa()
744 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, in wcd939x_codec_enable_hphr_pa()
752 wcd_clsh_ctrl_set_state(wcd939x->clsh_info, WCD_CLSH_EVENT_POST_PA, in wcd939x_codec_enable_hphr_pa()
754 if (wcd939x->ldoh) in wcd939x_codec_enable_hphr_pa()
768 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_codec_enable_hphl_pa() local
769 int hph_mode = wcd939x->hph_mode; in wcd939x_codec_enable_hphl_pa()
776 if (wcd939x->ldoh) in wcd939x_codec_enable_hphl_pa()
779 wcd_clsh_ctrl_set_state(wcd939x->clsh_info, WCD_CLSH_EVENT_PRE_DAC, in wcd939x_codec_enable_hphl_pa()
781 wcd_clsh_set_hph_mode(wcd939x->clsh_info, CLS_H_HIFI); in wcd939x_codec_enable_hphl_pa()
801 set_bit(HPH_PA_DELAY, &wcd939x->status_mask); in wcd939x_codec_enable_hphl_pa()
811 if (test_bit(HPH_PA_DELAY, &wcd939x->status_mask)) { in wcd939x_codec_enable_hphl_pa()
812 if (!wcd939x->comp1_enable) in wcd939x_codec_enable_hphl_pa()
822 clear_bit(HPH_PA_DELAY, &wcd939x->status_mask); in wcd939x_codec_enable_hphl_pa()
831 enable_irq(wcd939x->hphl_pdm_wd_int); in wcd939x_codec_enable_hphl_pa()
834 disable_irq_nosync(wcd939x->hphl_pdm_wd_int); in wcd939x_codec_enable_hphl_pa()
840 if (!wcd939x->comp1_enable) in wcd939x_codec_enable_hphl_pa()
848 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, WCD_EVENT_PRE_HPHL_PA_OFF); in wcd939x_codec_enable_hphl_pa()
849 set_bit(HPH_PA_DELAY, &wcd939x->status_mask); in wcd939x_codec_enable_hphl_pa()
857 if (test_bit(HPH_PA_DELAY, &wcd939x->status_mask)) { in wcd939x_codec_enable_hphl_pa()
858 if (!wcd939x->comp1_enable) in wcd939x_codec_enable_hphl_pa()
862 clear_bit(HPH_PA_DELAY, &wcd939x->status_mask); in wcd939x_codec_enable_hphl_pa()
864 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, in wcd939x_codec_enable_hphl_pa()
870 wcd_clsh_ctrl_set_state(wcd939x->clsh_info, WCD_CLSH_EVENT_POST_PA, in wcd939x_codec_enable_hphl_pa()
872 if (wcd939x->ldoh) in wcd939x_codec_enable_hphl_pa()
885 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_codec_enable_ear_pa() local
901 enable_irq(wcd939x->ear_pdm_wd_int); in wcd939x_codec_enable_ear_pa()
904 disable_irq_nosync(wcd939x->ear_pdm_wd_int); in wcd939x_codec_enable_ear_pa()
914 wcd_clsh_ctrl_set_state(wcd939x->clsh_info, WCD_CLSH_EVENT_POST_PA, in wcd939x_codec_enable_ear_pa()
1013 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_tx_swr_ctrl() local
1017 bank = wcd939x_swr_get_current_bank(wcd939x->sdw_priv[AIF1_CAP]->sdev); in wcd939x_tx_swr_ctrl()
1024 if (test_bit(WCD_ADC1, &wcd939x->status_mask)) in wcd939x_tx_swr_ctrl()
1025 mode |= tx_mode_bit[wcd939x->tx_mode[WCD_ADC1]]; in wcd939x_tx_swr_ctrl()
1026 if (test_bit(WCD_ADC2, &wcd939x->status_mask)) in wcd939x_tx_swr_ctrl()
1027 mode |= tx_mode_bit[wcd939x->tx_mode[WCD_ADC2]]; in wcd939x_tx_swr_ctrl()
1028 if (test_bit(WCD_ADC3, &wcd939x->status_mask)) in wcd939x_tx_swr_ctrl()
1029 mode |= tx_mode_bit[wcd939x->tx_mode[WCD_ADC3]]; in wcd939x_tx_swr_ctrl()
1030 if (test_bit(WCD_ADC4, &wcd939x->status_mask)) in wcd939x_tx_swr_ctrl()
1031 mode |= tx_mode_bit[wcd939x->tx_mode[WCD_ADC4]]; in wcd939x_tx_swr_ctrl()
1090 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_codec_enable_adc() local
1099 set_bit(w->shift, &wcd939x->status_mask); in wcd939x_codec_enable_adc()
1108 clear_bit(w->shift, &wcd939x->status_mask); in wcd939x_codec_enable_adc()
1148 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_adc_enable_req() local
1159 mode = wcd939x_get_adc_mode(wcd939x->tx_mode[w->shift]); in wcd939x_adc_enable_req()
1266 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_micbias_control() local
1291 wcd939x->pullup_ref[micb_index]++; in wcd939x_micbias_control()
1292 if (wcd939x->pullup_ref[micb_index] == 1 && in wcd939x_micbias_control()
1293 wcd939x->micb_ref[micb_index] == 0) in wcd939x_micbias_control()
1299 if (wcd939x->pullup_ref[micb_index] > 0) in wcd939x_micbias_control()
1300 wcd939x->pullup_ref[micb_index]--; in wcd939x_micbias_control()
1301 if (wcd939x->pullup_ref[micb_index] == 0 && in wcd939x_micbias_control()
1302 wcd939x->micb_ref[micb_index] == 0) in wcd939x_micbias_control()
1308 wcd939x->micb_ref[micb_index]++; in wcd939x_micbias_control()
1309 if (wcd939x->micb_ref[micb_index] == 1) { in wcd939x_micbias_control()
1346 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, in wcd939x_micbias_control()
1350 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, in wcd939x_micbias_control()
1354 if (wcd939x->micb_ref[micb_index] > 0) in wcd939x_micbias_control()
1355 wcd939x->micb_ref[micb_index]--; in wcd939x_micbias_control()
1357 if (wcd939x->micb_ref[micb_index] == 0 && in wcd939x_micbias_control()
1358 wcd939x->pullup_ref[micb_index] > 0) in wcd939x_micbias_control()
1362 else if (wcd939x->micb_ref[micb_index] == 0 && in wcd939x_micbias_control()
1363 wcd939x->pullup_ref[micb_index] == 0) { in wcd939x_micbias_control()
1365 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, in wcd939x_micbias_control()
1372 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, in wcd939x_micbias_control()
1376 wcd_mbhc_event_notify(wcd939x->wcd_mbhc, in wcd939x_micbias_control()
1436 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_tx_mode_get() local
1440 ucontrol->value.enumerated.item[0] = wcd939x->tx_mode[path]; in wcd939x_tx_mode_get()
1449 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_tx_mode_put() local
1453 if (wcd939x->tx_mode[path] == ucontrol->value.enumerated.item[0]) in wcd939x_tx_mode_put()
1456 wcd939x->tx_mode[path] = ucontrol->value.enumerated.item[0]; in wcd939x_tx_mode_put()
1467 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_rx_hph_mode_get() local
1469 ucontrol->value.integer.value[0] = wcd939x->hph_mode; in wcd939x_rx_hph_mode_get()
1478 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_rx_hph_mode_put() local
1483 if (mode_val == wcd939x->hph_mode) in wcd939x_rx_hph_mode_put()
1486 if (wcd939x->variant == WCD9390) { in wcd939x_rx_hph_mode_put()
1495 wcd939x->hph_mode = mode_val; in wcd939x_rx_hph_mode_put()
1509 wcd939x->hph_mode = mode_val; in wcd939x_rx_hph_mode_put()
1523 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_get_compander() local
1526 ucontrol->value.integer.value[0] = wcd939x->comp2_enable ? 1 : 0; in wcd939x_get_compander()
1528 ucontrol->value.integer.value[0] = wcd939x->comp1_enable ? 1 : 0; in wcd939x_get_compander()
1538 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_set_compander() local
1539 struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[AIF1_PB]; in wcd939x_set_compander()
1544 wcd939x->comp2_enable = value; in wcd939x_set_compander()
1546 wcd939x->comp1_enable = value; in wcd939x_set_compander()
1560 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_ldoh_get() local
1562 ucontrol->value.integer.value[0] = wcd939x->ldoh ? 1 : 0; in wcd939x_ldoh_get()
1571 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_ldoh_put() local
1573 if (wcd939x->ldoh == !!ucontrol->value.integer.value[0]) in wcd939x_ldoh_put()
1576 wcd939x->ldoh = !!ucontrol->value.integer.value[0]; in wcd939x_ldoh_put()
1792 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(comp); in wcd939x_get_swr_port() local
1793 struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[mixer->shift]; in wcd939x_get_swr_port()
1819 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(comp); in wcd939x_set_swr_port() local
1820 struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[mixer->shift]; in wcd939x_set_swr_port()
1933 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_mbhc_micb_adjust_voltage() local
1954 mutex_lock(&wcd939x->micb_lock); in wcd939x_mbhc_micb_adjust_voltage()
2004 mutex_unlock(&wcd939x->micb_lock); in wcd939x_mbhc_micb_adjust_voltage()
2011 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_mbhc_micb_ctrl_threshold_mic() local
2021 if (wcd939x->micb2_mv >= WCD_MBHC_THR_HS_MICB_MV) in wcd939x_mbhc_micb_ctrl_threshold_mic()
2024 micb_mv = req_en ? WCD_MBHC_THR_HS_MICB_MV : wcd939x->micb2_mv; in wcd939x_mbhc_micb_ctrl_threshold_mic()
2177 struct wcd939x_priv *wcd939x = dev_get_drvdata(component->dev); in wcd939x_wcd_mbhc_calc_impedance() local
2197 if (wcd939x->mbhc_cfg.hphl_swh) in wcd939x_wcd_mbhc_calc_impedance()
2256 wcd_mbhc_set_hph_type(wcd939x->wcd_mbhc, WCD_MBHC_HPH_MONO); in wcd939x_wcd_mbhc_calc_impedance()
2280 wcd_mbhc_set_hph_type(wcd939x->wcd_mbhc, WCD_MBHC_HPH_STEREO); in wcd939x_wcd_mbhc_calc_impedance()
2284 wcd_mbhc_set_hph_type(wcd939x->wcd_mbhc, WCD_MBHC_HPH_MONO); in wcd939x_wcd_mbhc_calc_impedance()
2303 if (wcd939x->mbhc_cfg.hphl_swh) in wcd939x_wcd_mbhc_calc_impedance()
2344 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_mbhc_moisture_config() local
2346 if (wcd939x->mbhc_cfg.moist_rref == R_OFF || wcd939x->typec_analog_mux) { in wcd939x_mbhc_moisture_config()
2353 if (!wcd939x->mbhc_cfg.hphl_swh) { in wcd939x_mbhc_moisture_config()
2362 WCD939X_CTL_2_M_RTH_CTL, wcd939x->mbhc_cfg.moist_rref); in wcd939x_mbhc_moisture_config()
2367 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_mbhc_moisture_detect_en() local
2372 wcd939x->mbhc_cfg.moist_rref); in wcd939x_mbhc_moisture_detect_en()
2380 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_mbhc_get_moisture_status() local
2383 if (wcd939x->mbhc_cfg.moist_rref == R_OFF || wcd939x->typec_analog_mux) { in wcd939x_mbhc_get_moisture_status()
2390 if (!wcd939x->mbhc_cfg.hphl_swh) { in wcd939x_mbhc_get_moisture_status()
2446 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_get_hph_type() local
2448 ucontrol->value.integer.value[0] = wcd_mbhc_get_hph_type(wcd939x->wcd_mbhc); in wcd939x_get_hph_type()
2458 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_hph_impedance_get() local
2462 wcd_mbhc_get_impedance(wcd939x->wcd_mbhc, &zl, &zr); in wcd939x_hph_impedance_get()
2483 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_mbhc_init() local
2484 struct wcd_mbhc_intr *intr_ids = &wcd939x->intr_ids; in wcd939x_mbhc_init()
2486 intr_ids->mbhc_sw_intr = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_mbhc_init()
2488 intr_ids->mbhc_btn_press_intr = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_mbhc_init()
2490 intr_ids->mbhc_btn_release_intr = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_mbhc_init()
2492 intr_ids->mbhc_hs_ins_intr = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_mbhc_init()
2494 intr_ids->mbhc_hs_rem_intr = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_mbhc_init()
2496 intr_ids->hph_left_ocp = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_mbhc_init()
2498 intr_ids->hph_right_ocp = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_mbhc_init()
2501 wcd939x->wcd_mbhc = wcd_mbhc_init(component, &mbhc_cb, intr_ids, wcd_mbhc_fields, true); in wcd939x_mbhc_init()
2502 if (IS_ERR(wcd939x->wcd_mbhc)) in wcd939x_mbhc_init()
2503 return PTR_ERR(wcd939x->wcd_mbhc); in wcd939x_mbhc_init()
2515 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_mbhc_deinit() local
2517 wcd_mbhc_deinit(wcd939x->wcd_mbhc); in wcd939x_mbhc_deinit()
2895 static int wcd939x_set_micbias_data(struct wcd939x_priv *wcd939x) in wcd939x_set_micbias_data() argument
2900 vout_ctl_1 = wcd939x_get_micb_vout_ctl_val(wcd939x->micb1_mv); in wcd939x_set_micbias_data()
2901 vout_ctl_2 = wcd939x_get_micb_vout_ctl_val(wcd939x->micb2_mv); in wcd939x_set_micbias_data()
2902 vout_ctl_3 = wcd939x_get_micb_vout_ctl_val(wcd939x->micb3_mv); in wcd939x_set_micbias_data()
2903 vout_ctl_4 = wcd939x_get_micb_vout_ctl_val(wcd939x->micb4_mv); in wcd939x_set_micbias_data()
2907 regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB1, in wcd939x_set_micbias_data()
2909 regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB2, in wcd939x_set_micbias_data()
2911 regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB3, in wcd939x_set_micbias_data()
2913 regmap_update_bits(wcd939x->regmap, WCD939X_ANA_MICB4, in wcd939x_set_micbias_data()
2959 .name = "WCD939x",
2992 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_soc_codec_probe() local
2993 struct sdw_slave *tx_sdw_dev = wcd939x->tx_sdw_dev; in wcd939x_soc_codec_probe()
3005 snd_soc_component_init_regmap(component, wcd939x->regmap); in wcd939x_soc_codec_probe()
3011 wcd939x->variant = snd_soc_component_read_field(component, in wcd939x_soc_codec_probe()
3015 wcd939x->clsh_info = wcd_clsh_ctrl_alloc(component, WCD939X); in wcd939x_soc_codec_probe()
3016 if (IS_ERR(wcd939x->clsh_info)) { in wcd939x_soc_codec_probe()
3018 return PTR_ERR(wcd939x->clsh_info); in wcd939x_soc_codec_probe()
3025 regmap_write(wcd939x->regmap, in wcd939x_soc_codec_probe()
3031 wcd939x->hphr_pdm_wd_int = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_soc_codec_probe()
3033 wcd939x->hphl_pdm_wd_int = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_soc_codec_probe()
3035 wcd939x->ear_pdm_wd_int = regmap_irq_get_virq(wcd939x->irq_chip, in wcd939x_soc_codec_probe()
3038 ret = request_threaded_irq(wcd939x->hphr_pdm_wd_int, NULL, wcd939x_wd_handle_irq, in wcd939x_soc_codec_probe()
3040 "HPHR PDM WD INT", wcd939x); in wcd939x_soc_codec_probe()
3046 ret = request_threaded_irq(wcd939x->hphl_pdm_wd_int, NULL, wcd939x_wd_handle_irq, in wcd939x_soc_codec_probe()
3048 "HPHL PDM WD INT", wcd939x); in wcd939x_soc_codec_probe()
3054 ret = request_threaded_irq(wcd939x->ear_pdm_wd_int, NULL, wcd939x_wd_handle_irq, in wcd939x_soc_codec_probe()
3056 "AUX PDM WD INT", wcd939x); in wcd939x_soc_codec_probe()
3063 disable_irq_nosync(wcd939x->hphr_pdm_wd_int); in wcd939x_soc_codec_probe()
3064 disable_irq_nosync(wcd939x->hphl_pdm_wd_int); in wcd939x_soc_codec_probe()
3065 disable_irq_nosync(wcd939x->ear_pdm_wd_int); in wcd939x_soc_codec_probe()
3067 switch (wcd939x->variant) { in wcd939x_soc_codec_probe()
3074 __func__, wcd939x->variant); in wcd939x_soc_codec_probe()
3084 __func__, wcd939x->variant); in wcd939x_soc_codec_probe()
3101 free_irq(wcd939x->ear_pdm_wd_int, wcd939x); in wcd939x_soc_codec_probe()
3103 free_irq(wcd939x->hphl_pdm_wd_int, wcd939x); in wcd939x_soc_codec_probe()
3105 free_irq(wcd939x->hphr_pdm_wd_int, wcd939x); in wcd939x_soc_codec_probe()
3107 wcd_clsh_ctrl_free(wcd939x->clsh_info); in wcd939x_soc_codec_probe()
3114 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_soc_codec_remove() local
3118 free_irq(wcd939x->ear_pdm_wd_int, wcd939x); in wcd939x_soc_codec_remove()
3119 free_irq(wcd939x->hphl_pdm_wd_int, wcd939x); in wcd939x_soc_codec_remove()
3120 free_irq(wcd939x->hphr_pdm_wd_int, wcd939x); in wcd939x_soc_codec_remove()
3122 wcd_clsh_ctrl_free(wcd939x->clsh_info); in wcd939x_soc_codec_remove()
3157 struct wcd939x_priv *wcd939x = typec_switch_get_drvdata(sw); in wcd939x_typec_switch_set() local
3159 wcd939x->typec_orientation = orientation; in wcd939x_typec_switch_set()
3167 struct wcd939x_priv *wcd939x = typec_mux_get_drvdata(mux); in wcd939x_typec_mux_set() local
3168 unsigned int previous_mode = wcd939x->typec_mode; in wcd939x_typec_mux_set()
3170 if (!wcd939x->wcd_mbhc) in wcd939x_typec_mux_set()
3173 if (wcd939x->typec_mode != state->mode) { in wcd939x_typec_mux_set()
3174 wcd939x->typec_mode = state->mode; in wcd939x_typec_mux_set()
3176 if (wcd939x->typec_mode == TYPEC_MODE_AUDIO) in wcd939x_typec_mux_set()
3177 return wcd_mbhc_typec_report_plug(wcd939x->wcd_mbhc); in wcd939x_typec_mux_set()
3179 return wcd_mbhc_typec_report_unplug(wcd939x->wcd_mbhc); in wcd939x_typec_mux_set()
3220 struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(component); in wcd939x_swap_gnd_mic() local
3222 if (!wcd939x->typec_analog_mux || !wcd939x->typec_switch) in wcd939x_swap_gnd_mic()
3226 typec_switch_set(wcd939x->typec_switch, in wcd939x_swap_gnd_mic()
3227 wcd939x->typec_orientation == TYPEC_ORIENTATION_REVERSE ? in wcd939x_swap_gnd_mic()
3234 static int wcd939x_populate_dt_data(struct wcd939x_priv *wcd939x, struct device *dev) in wcd939x_populate_dt_data() argument
3236 struct wcd_mbhc_config *cfg = &wcd939x->mbhc_cfg; in wcd939x_populate_dt_data()
3242 wcd939x->reset_gpio = of_get_named_gpio(dev->of_node, "reset-gpios", 0); in wcd939x_populate_dt_data()
3243 if (wcd939x->reset_gpio < 0) in wcd939x_populate_dt_data()
3244 return dev_err_probe(dev, wcd939x->reset_gpio, in wcd939x_populate_dt_data()
3247 wcd939x->supplies[0].supply = "vdd-rxtx"; in wcd939x_populate_dt_data()
3248 wcd939x->supplies[1].supply = "vdd-io"; in wcd939x_populate_dt_data()
3249 wcd939x->supplies[2].supply = "vdd-buck"; in wcd939x_populate_dt_data()
3250 wcd939x->supplies[3].supply = "vdd-mic-bias"; in wcd939x_populate_dt_data()
3252 ret = regulator_bulk_get(dev, WCD939X_MAX_SUPPLY, wcd939x->supplies); in wcd939x_populate_dt_data()
3256 ret = regulator_bulk_enable(WCD939X_MAX_SUPPLY, wcd939x->supplies); in wcd939x_populate_dt_data()
3258 regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); in wcd939x_populate_dt_data()
3262 wcd939x_dt_parse_micbias_info(dev, wcd939x); in wcd939x_populate_dt_data()
3268 cfg->micb_mv = wcd939x->micb2_mv; in wcd939x_populate_dt_data()
3282 wcd939x->typec_analog_mux = true; in wcd939x_populate_dt_data()
3291 static int wcd939x_reset(struct wcd939x_priv *wcd939x) in wcd939x_reset() argument
3293 gpio_direction_output(wcd939x->reset_gpio, 0); in wcd939x_reset()
3296 gpio_set_value(wcd939x->reset_gpio, 1); in wcd939x_reset()
3307 struct wcd939x_priv *wcd939x = dev_get_drvdata(dai->dev); in wcd939x_codec_hw_params() local
3308 struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[dai->id]; in wcd939x_codec_hw_params()
3316 struct wcd939x_priv *wcd939x = dev_get_drvdata(dai->dev); in wcd939x_codec_free() local
3317 struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[dai->id]; in wcd939x_codec_free()
3325 struct wcd939x_priv *wcd939x = dev_get_drvdata(dai->dev); in wcd939x_codec_set_sdw_stream() local
3326 struct wcd939x_sdw_priv *wcd = wcd939x->sdw_priv[dai->id]; in wcd939x_codec_set_sdw_stream()
3339 .name = "wcd939x-sdw-rx",
3352 .name = "wcd939x-sdw-tx",
3368 struct wcd939x_priv *wcd939x = dev_get_drvdata(dev); in wcd939x_bind() local
3378 if (wcd939x->typec_analog_mux) { in wcd939x_bind()
3379 wcd939x->typec_switch = fwnode_typec_switch_get(dev->fwnode); in wcd939x_bind()
3380 if (IS_ERR(wcd939x->typec_switch)) in wcd939x_bind()
3381 return dev_err_probe(dev, PTR_ERR(wcd939x->typec_switch), in wcd939x_bind()
3386 ret = component_bind_all(dev, wcd939x); in wcd939x_bind()
3393 wcd939x->rxdev = wcd939x_sdw_device_get(wcd939x->rxnode); in wcd939x_bind()
3394 if (!wcd939x->rxdev) { in wcd939x_bind()
3399 wcd939x->sdw_priv[AIF1_PB] = dev_get_drvdata(wcd939x->rxdev); in wcd939x_bind()
3400 wcd939x->sdw_priv[AIF1_PB]->wcd939x = wcd939x; in wcd939x_bind()
3402 wcd939x->txdev = wcd939x_sdw_device_get(wcd939x->txnode); in wcd939x_bind()
3403 if (!wcd939x->txdev) { in wcd939x_bind()
3408 wcd939x->sdw_priv[AIF1_CAP] = dev_get_drvdata(wcd939x->txdev); in wcd939x_bind()
3409 wcd939x->sdw_priv[AIF1_CAP]->wcd939x = wcd939x; in wcd939x_bind()
3410 wcd939x->tx_sdw_dev = dev_to_sdw_dev(wcd939x->txdev); in wcd939x_bind()
3416 if (!device_link_add(wcd939x->rxdev, wcd939x->txdev, DL_FLAG_STATELESS | in wcd939x_bind()
3423 if (!device_link_add(dev, wcd939x->txdev, DL_FLAG_STATELESS | in wcd939x_bind()
3430 if (!device_link_add(dev, wcd939x->rxdev, DL_FLAG_STATELESS | in wcd939x_bind()
3438 wcd939x->regmap = wcd939x_swr_get_regmap(wcd939x->sdw_priv[AIF1_CAP]); in wcd939x_bind()
3439 if (IS_ERR(wcd939x->regmap)) { in wcd939x_bind()
3441 ret = PTR_ERR(wcd939x->regmap); in wcd939x_bind()
3445 ret = wcd939x_irq_init(wcd939x, dev); in wcd939x_bind()
3451 wcd939x->sdw_priv[AIF1_PB]->slave_irq = wcd939x->virq; in wcd939x_bind()
3452 wcd939x->sdw_priv[AIF1_CAP]->slave_irq = wcd939x->virq; in wcd939x_bind()
3454 ret = wcd939x_set_micbias_data(wcd939x); in wcd939x_bind()
3461 regmap_read(wcd939x->regmap, WCD939X_DIGITAL_CHIP_ID1, &id1); in wcd939x_bind()
3462 regmap_read(wcd939x->regmap, WCD939X_EAR_STATUS_REG_1, &status1); in wcd939x_bind()
3469 dev_dbg(dev, "wcd939x version: %s\n", version_to_str(version)); in wcd939x_bind()
3482 device_link_remove(dev, wcd939x->rxdev); in wcd939x_bind()
3484 device_link_remove(dev, wcd939x->txdev); in wcd939x_bind()
3486 device_link_remove(wcd939x->rxdev, wcd939x->txdev); in wcd939x_bind()
3488 put_device(wcd939x->txdev); in wcd939x_bind()
3490 put_device(wcd939x->rxdev); in wcd939x_bind()
3492 component_unbind_all(dev, wcd939x); in wcd939x_bind()
3495 if (wcd939x->typec_analog_mux) in wcd939x_bind()
3496 typec_switch_put(wcd939x->typec_switch); in wcd939x_bind()
3504 struct wcd939x_priv *wcd939x = dev_get_drvdata(dev); in wcd939x_unbind() local
3507 device_link_remove(dev, wcd939x->txdev); in wcd939x_unbind()
3508 device_link_remove(dev, wcd939x->rxdev); in wcd939x_unbind()
3509 device_link_remove(wcd939x->rxdev, wcd939x->txdev); in wcd939x_unbind()
3510 put_device(wcd939x->txdev); in wcd939x_unbind()
3511 put_device(wcd939x->rxdev); in wcd939x_unbind()
3512 component_unbind_all(dev, wcd939x); in wcd939x_unbind()
3534 static int wcd939x_add_typec(struct wcd939x_priv *wcd939x, struct device *dev) in wcd939x_add_typec() argument
3541 .drvdata = wcd939x, in wcd939x_add_typec()
3546 .drvdata = wcd939x, in wcd939x_add_typec()
3555 if (!wcd939x->typec_analog_mux) in wcd939x_add_typec()
3582 static int wcd939x_add_slave_components(struct wcd939x_priv *wcd939x, in wcd939x_add_slave_components() argument
3588 wcd939x->rxnode = of_parse_phandle(np, "qcom,rx-device", 0); in wcd939x_add_slave_components()
3589 if (!wcd939x->rxnode) { in wcd939x_add_slave_components()
3594 of_node_get(wcd939x->rxnode); in wcd939x_add_slave_components()
3596 component_compare_of, wcd939x->rxnode); in wcd939x_add_slave_components()
3598 wcd939x->txnode = of_parse_phandle(np, "qcom,tx-device", 0); in wcd939x_add_slave_components()
3599 if (!wcd939x->txnode) { in wcd939x_add_slave_components()
3603 of_node_get(wcd939x->txnode); in wcd939x_add_slave_components()
3605 component_compare_of, wcd939x->txnode); in wcd939x_add_slave_components()
3612 struct wcd939x_priv *wcd939x = NULL; in wcd939x_probe() local
3616 wcd939x = devm_kzalloc(dev, sizeof(struct wcd939x_priv), in wcd939x_probe()
3618 if (!wcd939x) in wcd939x_probe()
3621 dev_set_drvdata(dev, wcd939x); in wcd939x_probe()
3622 mutex_init(&wcd939x->micb_lock); in wcd939x_probe()
3624 ret = wcd939x_populate_dt_data(wcd939x, dev); in wcd939x_probe()
3630 ret = wcd939x_add_typec(wcd939x, dev); in wcd939x_probe()
3634 ret = wcd939x_add_slave_components(wcd939x, dev, &match); in wcd939x_probe()
3638 wcd939x_reset(wcd939x); in wcd939x_probe()
3654 regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies); in wcd939x_probe()
3655 regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); in wcd939x_probe()
3663 struct wcd939x_priv *wcd939x = dev_get_drvdata(dev); in wcd939x_remove() local
3671 regulator_bulk_disable(WCD939X_MAX_SUPPLY, wcd939x->supplies); in wcd939x_remove()
3672 regulator_bulk_free(WCD939X_MAX_SUPPLY, wcd939x->supplies); in wcd939x_remove()
3695 MODULE_DESCRIPTION("WCD939X Codec driver");