Lines Matching +full:ts +full:- +full:dbnc +full:- +full:rise
1 // SPDX-License-Identifier: GPL-2.0-only
3 * cs42l42.c -- CS42L42 ALSA SoC audio driver
31 #include <sound/soc-dapm.h>
34 #include <dt-bindings/sound/cs42l42.h>
400 static DECLARE_TLV_DB_SCALE(adc_tlv, -9700, 100, true);
401 static DECLARE_TLV_DB_SCALE(mixer_tlv, -6300, 100, true);
410 switch (ucontrol->value.integer.value[0]) { in cs42l42_slow_start_put()
418 return -EINVAL; in cs42l42_slow_start_put()
452 SOC_SINGLE_S8_TLV("ADC Volume", CS42L42_ADC_VOLUME, -97, 12, adc_tlv),
479 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs42l42_hp_adc_ev()
484 cs42l42->hp_adc_up_pending = true; in cs42l42_hp_adc_ev()
487 /* Only need one delay if HP and ADC are both powering-up */ in cs42l42_hp_adc_ev()
488 if (cs42l42->hp_adc_up_pending) { in cs42l42_hp_adc_ev()
491 cs42l42->hp_adc_up_pending = false; in cs42l42_hp_adc_ev()
564 mutex_lock(&cs42l42->irq_lock); in cs42l42_set_jack()
565 cs42l42->jack = jk; in cs42l42_set_jack()
568 switch (cs42l42->hs_type) { in cs42l42_set_jack()
580 mutex_unlock(&cs42l42->irq_lock); in cs42l42_set_jack()
631 * Table 4-5 from the Datasheet
661 if (cs42l42->stream_use) { in cs42l42_pll_config()
662 if (pll_ratio_table[cs42l42->pll_config].sclk == clk) in cs42l42_pll_config()
665 return -EBUSY; in cs42l42_pll_config()
670 cs42l42->pll_config = i; in cs42l42_pll_config()
682 fsync = clk / cs42l42->srate; in cs42l42_pll_config()
683 if (((fsync * cs42l42->srate) != clk) in cs42l42_pll_config()
685 dev_err(component->dev, in cs42l42_pll_config()
688 cs42l42->srate); in cs42l42_pll_config()
689 return -EINVAL; in cs42l42_pll_config()
695 CS42L42_FRAC0_VAL(fsync - 1) << in cs42l42_pll_config()
700 CS42L42_FRAC1_VAL(fsync - 1) << in cs42l42_pll_config()
707 CS42L42_FRAC0_VAL(fsync - 1) << in cs42l42_pll_config()
712 CS42L42_FRAC1_VAL(fsync - 1) << in cs42l42_pll_config()
720 /* Configure PLL per table 4-5 */ in cs42l42_pll_config()
769 return -EINVAL; in cs42l42_pll_config()
778 if (cs42l42->stream_use) in cs42l42_src_config()
807 struct snd_soc_component *component = codec_dai->component; in cs42l42_set_dai_fmt()
820 return -EINVAL; in cs42l42_set_dai_fmt()
840 return -EINVAL; in cs42l42_set_dai_fmt()
869 struct snd_soc_component *component = dai->component; in cs42l42_dai_startup()
873 * Sample rates < 44.1 kHz would produce an out-of-range SCLK with in cs42l42_dai_startup()
877 if (cs42l42->sclk) in cs42l42_dai_startup()
881 return snd_pcm_hw_constraint_minmax(substream->runtime, in cs42l42_dai_startup()
890 struct snd_soc_component *component = dai->component; in cs42l42_pcm_hw_params()
893 unsigned int width = (params_width(params) / 8) - 1; in cs42l42_pcm_hw_params()
899 cs42l42->srate = params_rate(params); in cs42l42_pcm_hw_params()
901 if (cs42l42->bclk_ratio) { in cs42l42_pcm_hw_params()
902 /* machine driver has set the BCLK/samp-rate ratio */ in cs42l42_pcm_hw_params()
903 bclk = cs42l42->bclk_ratio * params_rate(params); in cs42l42_pcm_hw_params()
904 } else if (cs42l42->sclk) { in cs42l42_pcm_hw_params()
906 bclk = cs42l42->sclk; in cs42l42_pcm_hw_params()
909 * Assume 24-bit samples are in 32-bit slots, to prevent SCLK being in cs42l42_pcm_hw_params()
919 switch (substream->stream) { in cs42l42_pcm_hw_params()
945 (channels - 1) << CS42L42_SP_RX_CHB_SEL_SHIFT); in cs42l42_pcm_hw_params()
969 struct snd_soc_component *component = dai->component; in cs42l42_set_sysclk()
974 cs42l42->sclk = 0; in cs42l42_set_sysclk()
980 cs42l42->sclk = freq; in cs42l42_set_sysclk()
985 dev_err(component->dev, "SCLK %u not supported\n", freq); in cs42l42_set_sysclk()
987 return -EINVAL; in cs42l42_set_sysclk()
993 struct snd_soc_component *component = dai->component; in cs42l42_set_bclk_ratio()
996 cs42l42->bclk_ratio = bclk_ratio; in cs42l42_set_bclk_ratio()
1003 struct snd_soc_component *component = dai->component; in cs42l42_mute_stream()
1017 cs42l42->stream_use &= ~(1 << stream); in cs42l42_mute_stream()
1018 if (!cs42l42->stream_use) { in cs42l42_mute_stream()
1024 regmap_multi_reg_write(cs42l42->regmap, cs42l42_to_osc_seq, in cs42l42_mute_stream()
1038 if (!cs42l42->stream_use) { in cs42l42_mute_stream()
1043 * DAPM widgets power-up before stream unmute so at least in cs42l42_mute_stream()
1045 * powered-up. in cs42l42_mute_stream()
1047 if (pll_ratio_table[cs42l42->pll_config].mclk_src_sel) { in cs42l42_mute_stream()
1051 if (pll_ratio_table[cs42l42->pll_config].n > 1) { in cs42l42_mute_stream()
1054 regval = pll_ratio_table[cs42l42->pll_config].pll_divout; in cs42l42_mute_stream()
1061 ret = regmap_read_poll_timeout(cs42l42->regmap, in cs42l42_mute_stream()
1068 dev_warn(component->dev, "PLL failed to lock: %d\n", ret); in cs42l42_mute_stream()
1078 regmap_multi_reg_write(cs42l42->regmap, cs42l42_to_sclk_seq, in cs42l42_mute_stream()
1081 cs42l42->stream_use |= 1 << stream; in cs42l42_mute_stream()
1084 /* Un-mute the headphone */ in cs42l42_mute_stream()
1138 regmap_update_bits(cs42l42->regmap, in cs42l42_manual_hs_type_detect()
1150 regmap_update_bits(cs42l42->regmap, in cs42l42_manual_hs_type_detect()
1158 regmap_write(cs42l42->regmap, CS42L42_HS_SWITCH_CTL, CS42L42_HSDET_SW_COMP1); in cs42l42_manual_hs_type_detect()
1162 regmap_read(cs42l42->regmap, CS42L42_HS_DET_STATUS, &hs_det_status); in cs42l42_manual_hs_type_detect()
1170 regmap_write(cs42l42->regmap, CS42L42_HS_SWITCH_CTL, CS42L42_HSDET_SW_COMP2); in cs42l42_manual_hs_type_detect()
1174 regmap_read(cs42l42->regmap, CS42L42_HS_DET_STATUS, &hs_det_status); in cs42l42_manual_hs_type_detect()
1184 cs42l42->hs_type = CS42L42_PLUG_CTIA; in cs42l42_manual_hs_type_detect()
1188 cs42l42->hs_type = CS42L42_PLUG_OMTP; in cs42l42_manual_hs_type_detect()
1195 cs42l42->hs_type = CS42L42_PLUG_CTIA; in cs42l42_manual_hs_type_detect()
1199 cs42l42->hs_type = CS42L42_PLUG_OMTP; in cs42l42_manual_hs_type_detect()
1204 cs42l42->hs_type = CS42L42_PLUG_HEADPHONE; in cs42l42_manual_hs_type_detect()
1211 regmap_write(cs42l42->regmap, CS42L42_HS_SWITCH_CTL, hs_det_sw); in cs42l42_manual_hs_type_detect()
1214 regmap_update_bits(cs42l42->regmap, in cs42l42_manual_hs_type_detect()
1226 regmap_update_bits(cs42l42->regmap, in cs42l42_manual_hs_type_detect()
1240 regmap_read(cs42l42->regmap, CS42L42_HS_DET_STATUS, &hs_det_status); in cs42l42_process_hs_type_detect()
1243 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1251 cs42l42->hs_type = (hs_det_status & CS42L42_HSDET_TYPE_MASK) >> in cs42l42_process_hs_type_detect()
1255 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1267 * We Re-Run with Manual Detection if the original detection was invalid or headphones, in cs42l42_process_hs_type_detect()
1270 if (cs42l42->hs_type == CS42L42_PLUG_INVALID || in cs42l42_process_hs_type_detect()
1271 cs42l42->hs_type == CS42L42_PLUG_HEADPHONE) { in cs42l42_process_hs_type_detect()
1272 dev_dbg(cs42l42->dev, "Running Manual Detection Fallback\n"); in cs42l42_process_hs_type_detect()
1277 if ((cs42l42->hs_type == CS42L42_PLUG_CTIA) || in cs42l42_process_hs_type_detect()
1278 (cs42l42->hs_type == CS42L42_PLUG_OMTP)) { in cs42l42_process_hs_type_detect()
1280 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1292 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1299 (cs42l42->bias_thresholds[0] << in cs42l42_process_hs_type_detect()
1303 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1309 (cs42l42->hs_bias_sense_en << CS42L42_HSBIAS_SENSE_EN_SHIFT) | in cs42l42_process_hs_type_detect()
1315 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1322 msleep(cs42l42->btn_det_init_dbnce); in cs42l42_process_hs_type_detect()
1325 regmap_read(cs42l42->regmap, CS42L42_DET_INT_STATUS2, in cs42l42_process_hs_type_detect()
1329 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1343 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1351 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1365 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1376 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1384 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1392 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1404 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1415 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1429 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1437 msleep(cs42l42->hs_bias_ramp_time); in cs42l42_init_hs_type_detect()
1440 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1448 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1463 regmap_update_bits(cs42l42->regmap, in cs42l42_cancel_hs_type_detect()
1477 regmap_update_bits(cs42l42->regmap, in cs42l42_cancel_hs_type_detect()
1485 regmap_update_bits(cs42l42->regmap, in cs42l42_cancel_hs_type_detect()
1497 regmap_update_bits(cs42l42->regmap, in cs42l42_cancel_hs_type_detect()
1515 regmap_update_bits(cs42l42->regmap, in cs42l42_handle_button_press()
1528 usleep_range(cs42l42->btn_det_event_dbnce * 1000, in cs42l42_handle_button_press()
1529 cs42l42->btn_det_event_dbnce * 2000); in cs42l42_handle_button_press()
1535 regmap_update_bits(cs42l42->regmap, in cs42l42_handle_button_press()
1542 (cs42l42->bias_thresholds[bias_level] << in cs42l42_handle_button_press()
1545 regmap_read(cs42l42->regmap, CS42L42_DET_STATUS2, in cs42l42_handle_button_press()
1553 dev_dbg(cs42l42->dev, "Function C button press\n"); in cs42l42_handle_button_press()
1557 dev_dbg(cs42l42->dev, "Function B button press\n"); in cs42l42_handle_button_press()
1561 dev_dbg(cs42l42->dev, "Function D button press\n"); in cs42l42_handle_button_press()
1565 dev_dbg(cs42l42->dev, "Function A button press\n"); in cs42l42_handle_button_press()
1573 regmap_update_bits(cs42l42->regmap, in cs42l42_handle_button_press()
1580 (cs42l42->bias_thresholds[0] << CS42L42_HS_DET_LEVEL_SHIFT)); in cs42l42_handle_button_press()
1583 regmap_read(cs42l42->regmap, CS42L42_DET_INT_STATUS2, in cs42l42_handle_button_press()
1587 regmap_update_bits(cs42l42->regmap, in cs42l42_handle_button_press()
1645 mutex_lock(&cs42l42->irq_lock); in cs42l42_irq_thread()
1646 if (cs42l42->suspended || !cs42l42->init_done) { in cs42l42_irq_thread()
1647 mutex_unlock(&cs42l42->irq_lock); in cs42l42_irq_thread()
1653 regmap_read(cs42l42->regmap, irq_params_table[i].status_addr, in cs42l42_irq_thread()
1655 regmap_read(cs42l42->regmap, irq_params_table[i].mask_addr, in cs42l42_irq_thread()
1673 * Check auto-detect status. Don't assume a previous unplug event has in cs42l42_irq_thread()
1680 switch (cs42l42->hs_type) { in cs42l42_irq_thread()
1683 snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADSET, in cs42l42_irq_thread()
1689 snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADPHONE, in cs42l42_irq_thread()
1697 dev_dbg(cs42l42->dev, "Auto detect done (%d)\n", cs42l42->hs_type); in cs42l42_irq_thread()
1705 if (cs42l42->plug_state != CS42L42_TS_PLUG) { in cs42l42_irq_thread()
1706 cs42l42->plug_state = CS42L42_TS_PLUG; in cs42l42_irq_thread()
1712 if (cs42l42->plug_state != CS42L42_TS_UNPLUG) { in cs42l42_irq_thread()
1713 cs42l42->plug_state = CS42L42_TS_UNPLUG; in cs42l42_irq_thread()
1716 snd_soc_jack_report(cs42l42->jack, 0, in cs42l42_irq_thread()
1721 dev_dbg(cs42l42->dev, "Unplug event\n"); in cs42l42_irq_thread()
1726 cs42l42->plug_state = CS42L42_TS_TRANS; in cs42l42_irq_thread()
1731 if (cs42l42->plug_state == CS42L42_TS_PLUG && ((~masks[7]) & irq_params_table[7].mask)) { in cs42l42_irq_thread()
1736 dev_dbg(cs42l42->dev, "Button released\n"); in cs42l42_irq_thread()
1737 snd_soc_jack_report(cs42l42->jack, 0, in cs42l42_irq_thread()
1741 snd_soc_jack_report(cs42l42->jack, in cs42l42_irq_thread()
1749 mutex_unlock(&cs42l42->irq_lock); in cs42l42_irq_thread()
1756 regmap_update_bits(cs42l42->regmap, CS42L42_ADC_OVFL_INT_MASK, in cs42l42_set_interrupt_masks()
1760 regmap_update_bits(cs42l42->regmap, CS42L42_MIXER_INT_MASK, in cs42l42_set_interrupt_masks()
1770 regmap_update_bits(cs42l42->regmap, CS42L42_SRC_INT_MASK, in cs42l42_set_interrupt_masks()
1780 regmap_update_bits(cs42l42->regmap, CS42L42_ASP_RX_INT_MASK, in cs42l42_set_interrupt_masks()
1792 regmap_update_bits(cs42l42->regmap, CS42L42_ASP_TX_INT_MASK, in cs42l42_set_interrupt_masks()
1802 regmap_update_bits(cs42l42->regmap, CS42L42_CODEC_INT_MASK, in cs42l42_set_interrupt_masks()
1808 regmap_update_bits(cs42l42->regmap, CS42L42_SRCPL_INT_MASK, in cs42l42_set_interrupt_masks()
1818 regmap_update_bits(cs42l42->regmap, CS42L42_DET_INT1_MASK, in cs42l42_set_interrupt_masks()
1826 regmap_update_bits(cs42l42->regmap, CS42L42_DET_INT2_MASK, in cs42l42_set_interrupt_masks()
1838 regmap_update_bits(cs42l42->regmap, CS42L42_VPMON_INT_MASK, in cs42l42_set_interrupt_masks()
1842 regmap_update_bits(cs42l42->regmap, CS42L42_PLL_LOCK_INT_MASK, in cs42l42_set_interrupt_masks()
1846 regmap_update_bits(cs42l42->regmap, CS42L42_TSRS_PLUG_INT_MASK, in cs42l42_set_interrupt_masks()
1861 cs42l42->hs_type = CS42L42_PLUG_INVALID; in cs42l42_setup_hs_type_detect()
1867 regmap_update_bits(cs42l42->regmap, CS42L42_MISC_DET_CTL, in cs42l42_setup_hs_type_detect()
1871 regmap_update_bits(cs42l42->regmap, CS42L42_MIC_DET_CTL1, in cs42l42_setup_hs_type_detect()
1877 (cs42l42->bias_thresholds[0] << in cs42l42_setup_hs_type_detect()
1880 /* Remove ground noise-suppression clamps */ in cs42l42_setup_hs_type_detect()
1881 regmap_update_bits(cs42l42->regmap, in cs42l42_setup_hs_type_detect()
1887 regmap_update_bits(cs42l42->regmap, CS42L42_TSENSE_CTL, in cs42l42_setup_hs_type_detect()
1890 regmap_update_bits(cs42l42->regmap, CS42L42_TIPSENSE_CTL, in cs42l42_setup_hs_type_detect()
1895 (!cs42l42->ts_inv << CS42L42_TIP_SENSE_INV_SHIFT) | in cs42l42_setup_hs_type_detect()
1899 regmap_read(cs42l42->regmap, in cs42l42_setup_hs_type_detect()
1902 cs42l42->plug_state = (((char) reg) & in cs42l42_setup_hs_type_detect()
1922 ret = device_property_read_u32(dev, "cirrus,ts-inv", &val); in cs42l42_handle_device_data()
1927 cs42l42->ts_inv = val; in cs42l42_handle_device_data()
1931 "Wrong cirrus,ts-inv DT value %d\n", in cs42l42_handle_device_data()
1933 cs42l42->ts_inv = CS42L42_TS_INV_DIS; in cs42l42_handle_device_data()
1936 cs42l42->ts_inv = CS42L42_TS_INV_DIS; in cs42l42_handle_device_data()
1939 ret = device_property_read_u32(dev, "cirrus,ts-dbnc-rise", &val); in cs42l42_handle_device_data()
1950 cs42l42->ts_dbnc_rise = val; in cs42l42_handle_device_data()
1954 "Wrong cirrus,ts-dbnc-rise DT value %d\n", in cs42l42_handle_device_data()
1956 cs42l42->ts_dbnc_rise = CS42L42_TS_DBNCE_1000; in cs42l42_handle_device_data()
1959 cs42l42->ts_dbnc_rise = CS42L42_TS_DBNCE_1000; in cs42l42_handle_device_data()
1962 regmap_update_bits(cs42l42->regmap, CS42L42_TSENSE_CTL, in cs42l42_handle_device_data()
1964 (cs42l42->ts_dbnc_rise << in cs42l42_handle_device_data()
1967 ret = device_property_read_u32(dev, "cirrus,ts-dbnc-fall", &val); in cs42l42_handle_device_data()
1978 cs42l42->ts_dbnc_fall = val; in cs42l42_handle_device_data()
1982 "Wrong cirrus,ts-dbnc-fall DT value %d\n", in cs42l42_handle_device_data()
1984 cs42l42->ts_dbnc_fall = CS42L42_TS_DBNCE_0; in cs42l42_handle_device_data()
1987 cs42l42->ts_dbnc_fall = CS42L42_TS_DBNCE_0; in cs42l42_handle_device_data()
1990 regmap_update_bits(cs42l42->regmap, CS42L42_TSENSE_CTL, in cs42l42_handle_device_data()
1992 (cs42l42->ts_dbnc_fall << in cs42l42_handle_device_data()
1995 ret = device_property_read_u32(dev, "cirrus,btn-det-init-dbnce", &val); in cs42l42_handle_device_data()
1998 cs42l42->btn_det_init_dbnce = val; in cs42l42_handle_device_data()
2001 "Wrong cirrus,btn-det-init-dbnce DT value %d\n", in cs42l42_handle_device_data()
2003 cs42l42->btn_det_init_dbnce = in cs42l42_handle_device_data()
2007 cs42l42->btn_det_init_dbnce = in cs42l42_handle_device_data()
2011 ret = device_property_read_u32(dev, "cirrus,btn-det-event-dbnce", &val); in cs42l42_handle_device_data()
2014 cs42l42->btn_det_event_dbnce = val; in cs42l42_handle_device_data()
2017 "Wrong cirrus,btn-det-event-dbnce DT value %d\n", val); in cs42l42_handle_device_data()
2018 cs42l42->btn_det_event_dbnce = in cs42l42_handle_device_data()
2022 cs42l42->btn_det_event_dbnce = in cs42l42_handle_device_data()
2026 ret = device_property_read_u32_array(dev, "cirrus,bias-lvls", in cs42l42_handle_device_data()
2031 cs42l42->bias_thresholds[i] = thresholds[i]; in cs42l42_handle_device_data()
2034 "Wrong cirrus,bias-lvls[%d] DT value %d\n", i, in cs42l42_handle_device_data()
2036 cs42l42->bias_thresholds[i] = threshold_defaults[i]; in cs42l42_handle_device_data()
2041 cs42l42->bias_thresholds[i] = threshold_defaults[i]; in cs42l42_handle_device_data()
2044 ret = device_property_read_u32(dev, "cirrus,hs-bias-ramp-rate", &val); in cs42l42_handle_device_data()
2048 cs42l42->hs_bias_ramp_rate = val; in cs42l42_handle_device_data()
2049 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME0; in cs42l42_handle_device_data()
2052 cs42l42->hs_bias_ramp_rate = val; in cs42l42_handle_device_data()
2053 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME1; in cs42l42_handle_device_data()
2056 cs42l42->hs_bias_ramp_rate = val; in cs42l42_handle_device_data()
2057 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME2; in cs42l42_handle_device_data()
2060 cs42l42->hs_bias_ramp_rate = val; in cs42l42_handle_device_data()
2061 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME3; in cs42l42_handle_device_data()
2065 "Wrong cirrus,hs-bias-ramp-rate DT value %d\n", in cs42l42_handle_device_data()
2067 cs42l42->hs_bias_ramp_rate = CS42L42_HSBIAS_RAMP_SLOW; in cs42l42_handle_device_data()
2068 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME2; in cs42l42_handle_device_data()
2071 cs42l42->hs_bias_ramp_rate = CS42L42_HSBIAS_RAMP_SLOW; in cs42l42_handle_device_data()
2072 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME2; in cs42l42_handle_device_data()
2075 regmap_update_bits(cs42l42->regmap, CS42L42_HS_BIAS_CTL, in cs42l42_handle_device_data()
2077 (cs42l42->hs_bias_ramp_rate << in cs42l42_handle_device_data()
2080 if (device_property_read_bool(dev, "cirrus,hs-bias-sense-disable")) in cs42l42_handle_device_data()
2081 cs42l42->hs_bias_sense_en = 0; in cs42l42_handle_device_data()
2083 cs42l42->hs_bias_sense_en = 1; in cs42l42_handle_device_data()
2133 mutex_lock(&cs42l42->irq_lock); in cs42l42_suspend()
2134 cs42l42->suspended = true; in cs42l42_suspend()
2138 regmap_read(cs42l42->regmap, cs42l42_shutdown_seq[i].reg, ®); in cs42l42_suspend()
2143 regmap_multi_reg_write(cs42l42->regmap, in cs42l42_suspend()
2148 mutex_unlock(&cs42l42->irq_lock); in cs42l42_suspend()
2150 /* Wait for power-down complete */ in cs42l42_suspend()
2152 ret = regmap_read_poll_timeout(cs42l42->regmap, in cs42l42_suspend()
2161 regmap_update_bits(cs42l42->regmap, CS42L42_PWR_CTL2, in cs42l42_suspend()
2165 regcache_cache_only(cs42l42->regmap, true); in cs42l42_suspend()
2166 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_suspend()
2167 regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); in cs42l42_suspend()
2171 regmap_write(cs42l42->regmap, cs42l42_shutdown_seq[i].reg, save_regs[i]); in cs42l42_suspend()
2174 regcache_drop_region(cs42l42->regmap, CS42L42_PAGE_REGISTER, CS42L42_PAGE_REGISTER); in cs42l42_suspend()
2189 * If jack was unplugged and re-plugged during suspend it could in cs42l42_resume()
2190 * have changed type but the tip-sense state hasn't changed. in cs42l42_resume()
2191 * Force a plugged state to be re-evaluated. in cs42l42_resume()
2193 if (cs42l42->plug_state != CS42L42_TS_UNPLUG) in cs42l42_resume()
2194 cs42l42->plug_state = CS42L42_TS_TRANS; in cs42l42_resume()
2196 ret = regulator_bulk_enable(ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); in cs42l42_resume()
2202 gpiod_set_value_cansleep(cs42l42->reset_gpio, 1); in cs42l42_resume()
2215 regcache_cache_only(cs42l42->regmap, false); in cs42l42_resume_restore()
2216 regcache_mark_dirty(cs42l42->regmap); in cs42l42_resume_restore()
2218 mutex_lock(&cs42l42->irq_lock); in cs42l42_resume_restore()
2220 regcache_sync_region(cs42l42->regmap, CS42L42_MIC_DET_CTL1, CS42L42_MIC_DET_CTL1); in cs42l42_resume_restore()
2221 regcache_sync(cs42l42->regmap); in cs42l42_resume_restore()
2223 cs42l42->suspended = false; in cs42l42_resume_restore()
2224 mutex_unlock(&cs42l42->irq_lock); in cs42l42_resume_restore()
2249 dev_set_drvdata(cs42l42->dev, cs42l42); in cs42l42_common_probe()
2250 mutex_init(&cs42l42->irq_lock); in cs42l42_common_probe()
2252 BUILD_BUG_ON(ARRAY_SIZE(cs42l42_supply_names) != ARRAY_SIZE(cs42l42->supplies)); in cs42l42_common_probe()
2253 for (i = 0; i < ARRAY_SIZE(cs42l42->supplies); i++) in cs42l42_common_probe()
2254 cs42l42->supplies[i].supply = cs42l42_supply_names[i]; in cs42l42_common_probe()
2256 ret = devm_regulator_bulk_get(cs42l42->dev, in cs42l42_common_probe()
2257 ARRAY_SIZE(cs42l42->supplies), in cs42l42_common_probe()
2258 cs42l42->supplies); in cs42l42_common_probe()
2260 dev_err(cs42l42->dev, in cs42l42_common_probe()
2265 ret = regulator_bulk_enable(ARRAY_SIZE(cs42l42->supplies), in cs42l42_common_probe()
2266 cs42l42->supplies); in cs42l42_common_probe()
2268 dev_err(cs42l42->dev, in cs42l42_common_probe()
2274 cs42l42->reset_gpio = devm_gpiod_get_optional(cs42l42->dev, in cs42l42_common_probe()
2276 if (IS_ERR(cs42l42->reset_gpio)) { in cs42l42_common_probe()
2277 ret = PTR_ERR(cs42l42->reset_gpio); in cs42l42_common_probe()
2281 if (cs42l42->reset_gpio) { in cs42l42_common_probe()
2282 dev_dbg(cs42l42->dev, "Found reset GPIO\n"); in cs42l42_common_probe()
2283 gpiod_set_value_cansleep(cs42l42->reset_gpio, 1); in cs42l42_common_probe()
2288 if (cs42l42->irq) { in cs42l42_common_probe()
2289 ret = request_threaded_irq(cs42l42->irq, in cs42l42_common_probe()
2294 dev_err_probe(cs42l42->dev, ret, in cs42l42_common_probe()
2301 ret = devm_snd_soc_register_component(cs42l42->dev, component_drv, dai, 1); in cs42l42_common_probe()
2308 if (cs42l42->irq) in cs42l42_common_probe()
2309 free_irq(cs42l42->irq, cs42l42); in cs42l42_common_probe()
2312 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_common_probe()
2314 regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); in cs42l42_common_probe()
2326 devid = cirrus_read_device_id(cs42l42->regmap, CS42L42_DEVID_AB); in cs42l42_init()
2329 dev_err(cs42l42->dev, "Failed to read device ID: %d\n", ret); in cs42l42_init()
2333 if (devid != cs42l42->devid) { in cs42l42_init()
2334 ret = -ENODEV; in cs42l42_init()
2335 dev_err(cs42l42->dev, in cs42l42_init()
2337 cs42l42->devid & 0xff, devid, cs42l42->devid); in cs42l42_init()
2341 ret = regmap_read(cs42l42->regmap, CS42L42_REVID, ®); in cs42l42_init()
2343 dev_err(cs42l42->dev, "Get Revision ID failed\n"); in cs42l42_init()
2347 dev_info(cs42l42->dev, in cs42l42_init()
2349 cs42l42->devid & 0xff, reg & 0xFF); in cs42l42_init()
2352 regmap_update_bits(cs42l42->regmap, CS42L42_PWR_CTL1, in cs42l42_init()
2368 ret = cs42l42_handle_device_data(cs42l42->dev, cs42l42); in cs42l42_init()
2379 cs42l42->init_done = true; in cs42l42_init()
2387 regmap_write(cs42l42->regmap, CS42L42_CODEC_INT_MASK, 0xff); in cs42l42_init()
2388 regmap_write(cs42l42->regmap, CS42L42_TSRS_PLUG_INT_MASK, 0xff); in cs42l42_init()
2389 regmap_write(cs42l42->regmap, CS42L42_PWR_CTL1, 0xff); in cs42l42_init()
2392 if (cs42l42->irq) in cs42l42_init()
2393 free_irq(cs42l42->irq, cs42l42); in cs42l42_init()
2395 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_init()
2396 regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), in cs42l42_init()
2397 cs42l42->supplies); in cs42l42_init()
2404 if (cs42l42->irq) in cs42l42_common_remove()
2405 free_irq(cs42l42->irq, cs42l42); in cs42l42_common_remove()
2411 if (cs42l42->init_done) { in cs42l42_common_remove()
2412 regmap_write(cs42l42->regmap, CS42L42_CODEC_INT_MASK, 0xff); in cs42l42_common_remove()
2413 regmap_write(cs42l42->regmap, CS42L42_TSRS_PLUG_INT_MASK, 0xff); in cs42l42_common_remove()
2414 regmap_write(cs42l42->regmap, CS42L42_PWR_CTL1, 0xff); in cs42l42_common_remove()
2417 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_common_remove()
2418 regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); in cs42l42_common_remove()