Lines Matching refs:cs42l42

480 	struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component);  in cs42l42_hp_adc_ev()  local
484 cs42l42->hp_adc_up_pending = true; 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()
565 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); in cs42l42_set_jack() local
568 mutex_lock(&cs42l42->irq_lock); in cs42l42_set_jack()
569 cs42l42->jack = jk; in cs42l42_set_jack()
572 switch (cs42l42->hs_type) { in cs42l42_set_jack()
584 mutex_unlock(&cs42l42->irq_lock); in cs42l42_set_jack()
667 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); in cs42l42_pll_config() local
671 if (cs42l42->stream_use) { in cs42l42_pll_config()
672 if (pll_ratio_table[cs42l42->pll_config].sclk == clk) in cs42l42_pll_config()
684 cs42l42->pll_config = i; in cs42l42_pll_config()
755 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); in cs42l42_src_config() local
759 if (cs42l42->stream_use) in cs42l42_src_config()
892 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); in cs42l42_dai_startup() local
899 if (cs42l42->sclk) in cs42l42_dai_startup()
913 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); in cs42l42_pcm_hw_params() local
922 if (cs42l42->bclk_ratio) { in cs42l42_pcm_hw_params()
924 bclk = cs42l42->bclk_ratio * params_rate(params); in cs42l42_pcm_hw_params()
925 } else if (cs42l42->sclk) { in cs42l42_pcm_hw_params()
927 bclk = cs42l42->sclk; in cs42l42_pcm_hw_params()
995 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); in cs42l42_set_sysclk() local
999 cs42l42->sclk = 0; in cs42l42_set_sysclk()
1005 cs42l42->sclk = freq; in cs42l42_set_sysclk()
1019 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); in cs42l42_set_bclk_ratio() local
1021 cs42l42->bclk_ratio = bclk_ratio; in cs42l42_set_bclk_ratio()
1029 struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); in cs42l42_mute_stream() local
1042 cs42l42->stream_use &= ~(1 << stream); in cs42l42_mute_stream()
1043 if (!cs42l42->stream_use) { in cs42l42_mute_stream()
1049 regmap_multi_reg_write(cs42l42->regmap, cs42l42_to_osc_seq, in cs42l42_mute_stream()
1063 if (!cs42l42->stream_use) { in cs42l42_mute_stream()
1072 if (pll_ratio_table[cs42l42->pll_config].mclk_src_sel) { in cs42l42_mute_stream()
1076 if (pll_ratio_table[cs42l42->pll_config].n > 1) { in cs42l42_mute_stream()
1079 regval = pll_ratio_table[cs42l42->pll_config].pll_divout; in cs42l42_mute_stream()
1086 ret = regmap_read_poll_timeout(cs42l42->regmap, in cs42l42_mute_stream()
1103 regmap_multi_reg_write(cs42l42->regmap, cs42l42_to_sclk_seq, in cs42l42_mute_stream()
1106 cs42l42->stream_use |= 1 << stream; in cs42l42_mute_stream()
1156 static void cs42l42_manual_hs_type_detect(struct cs42l42_private *cs42l42) in cs42l42_manual_hs_type_detect() argument
1164 regmap_update_bits(cs42l42->regmap, in cs42l42_manual_hs_type_detect()
1176 regmap_update_bits(cs42l42->regmap, in cs42l42_manual_hs_type_detect()
1184 regmap_write(cs42l42->regmap, CS42L42_HS_SWITCH_CTL, CS42L42_HSDET_SW_COMP1); in cs42l42_manual_hs_type_detect()
1188 regmap_read(cs42l42->regmap, CS42L42_HS_DET_STATUS, &hs_det_status); in cs42l42_manual_hs_type_detect()
1196 regmap_write(cs42l42->regmap, CS42L42_HS_SWITCH_CTL, CS42L42_HSDET_SW_COMP2); in cs42l42_manual_hs_type_detect()
1200 regmap_read(cs42l42->regmap, CS42L42_HS_DET_STATUS, &hs_det_status); in cs42l42_manual_hs_type_detect()
1210 cs42l42->hs_type = CS42L42_PLUG_CTIA; in cs42l42_manual_hs_type_detect()
1214 cs42l42->hs_type = CS42L42_PLUG_OMTP; in cs42l42_manual_hs_type_detect()
1221 cs42l42->hs_type = CS42L42_PLUG_CTIA; in cs42l42_manual_hs_type_detect()
1225 cs42l42->hs_type = CS42L42_PLUG_OMTP; in cs42l42_manual_hs_type_detect()
1230 cs42l42->hs_type = CS42L42_PLUG_HEADPHONE; in cs42l42_manual_hs_type_detect()
1237 regmap_write(cs42l42->regmap, CS42L42_HS_SWITCH_CTL, hs_det_sw); in cs42l42_manual_hs_type_detect()
1240 regmap_update_bits(cs42l42->regmap, in cs42l42_manual_hs_type_detect()
1252 regmap_update_bits(cs42l42->regmap, in cs42l42_manual_hs_type_detect()
1260 static void cs42l42_process_hs_type_detect(struct cs42l42_private *cs42l42) in cs42l42_process_hs_type_detect() argument
1266 regmap_read(cs42l42->regmap, CS42L42_HS_DET_STATUS, &hs_det_status); in cs42l42_process_hs_type_detect()
1269 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1277 cs42l42->hs_type = (hs_det_status & CS42L42_HSDET_TYPE_MASK) >> in cs42l42_process_hs_type_detect()
1281 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1296 if (cs42l42->hs_type == CS42L42_PLUG_INVALID || in cs42l42_process_hs_type_detect()
1297 cs42l42->hs_type == CS42L42_PLUG_HEADPHONE) { in cs42l42_process_hs_type_detect()
1298 dev_dbg(cs42l42->dev, "Running Manual Detection Fallback\n"); in cs42l42_process_hs_type_detect()
1299 cs42l42_manual_hs_type_detect(cs42l42); in cs42l42_process_hs_type_detect()
1303 if ((cs42l42->hs_type == CS42L42_PLUG_CTIA) || in cs42l42_process_hs_type_detect()
1304 (cs42l42->hs_type == CS42L42_PLUG_OMTP)) { in cs42l42_process_hs_type_detect()
1306 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1318 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1325 (cs42l42->bias_thresholds[0] << in cs42l42_process_hs_type_detect()
1329 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1335 (cs42l42->hs_bias_sense_en << CS42L42_HSBIAS_SENSE_EN_SHIFT) | in cs42l42_process_hs_type_detect()
1341 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1348 msleep(cs42l42->btn_det_init_dbnce); in cs42l42_process_hs_type_detect()
1351 regmap_read(cs42l42->regmap, CS42L42_DET_INT_STATUS2, in cs42l42_process_hs_type_detect()
1355 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1369 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1377 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1391 regmap_update_bits(cs42l42->regmap, in cs42l42_process_hs_type_detect()
1399 static void cs42l42_init_hs_type_detect(struct cs42l42_private *cs42l42) in cs42l42_init_hs_type_detect() argument
1402 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1410 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1418 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1430 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1441 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1455 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1463 msleep(cs42l42->hs_bias_ramp_time); in cs42l42_init_hs_type_detect()
1466 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1474 regmap_update_bits(cs42l42->regmap, in cs42l42_init_hs_type_detect()
1486 static void cs42l42_cancel_hs_type_detect(struct cs42l42_private *cs42l42) in cs42l42_cancel_hs_type_detect() argument
1489 regmap_update_bits(cs42l42->regmap, in cs42l42_cancel_hs_type_detect()
1503 regmap_update_bits(cs42l42->regmap, in cs42l42_cancel_hs_type_detect()
1511 regmap_update_bits(cs42l42->regmap, in cs42l42_cancel_hs_type_detect()
1523 regmap_update_bits(cs42l42->regmap, in cs42l42_cancel_hs_type_detect()
1535 static int cs42l42_handle_button_press(struct cs42l42_private *cs42l42) in cs42l42_handle_button_press() argument
1541 regmap_update_bits(cs42l42->regmap, in cs42l42_handle_button_press()
1554 usleep_range(cs42l42->btn_det_event_dbnce * 1000, in cs42l42_handle_button_press()
1555 cs42l42->btn_det_event_dbnce * 2000); in cs42l42_handle_button_press()
1561 regmap_update_bits(cs42l42->regmap, in cs42l42_handle_button_press()
1568 (cs42l42->bias_thresholds[bias_level] << in cs42l42_handle_button_press()
1571 regmap_read(cs42l42->regmap, CS42L42_DET_STATUS2, in cs42l42_handle_button_press()
1579 dev_dbg(cs42l42->dev, "Function C button press\n"); in cs42l42_handle_button_press()
1583 dev_dbg(cs42l42->dev, "Function B button press\n"); in cs42l42_handle_button_press()
1587 dev_dbg(cs42l42->dev, "Function D button press\n"); in cs42l42_handle_button_press()
1591 dev_dbg(cs42l42->dev, "Function A button press\n"); in cs42l42_handle_button_press()
1599 regmap_update_bits(cs42l42->regmap, in cs42l42_handle_button_press()
1606 (cs42l42->bias_thresholds[0] << CS42L42_HS_DET_LEVEL_SHIFT)); in cs42l42_handle_button_press()
1609 regmap_read(cs42l42->regmap, CS42L42_DET_INT_STATUS2, in cs42l42_handle_button_press()
1613 regmap_update_bits(cs42l42->regmap, in cs42l42_handle_button_press()
1664 struct cs42l42_private *cs42l42 = (struct cs42l42_private *)data; in cs42l42_irq_thread() local
1671 pm_runtime_get_sync(cs42l42->dev); in cs42l42_irq_thread()
1672 mutex_lock(&cs42l42->irq_lock); in cs42l42_irq_thread()
1673 if (cs42l42->suspended || !cs42l42->init_done) { in cs42l42_irq_thread()
1674 mutex_unlock(&cs42l42->irq_lock); in cs42l42_irq_thread()
1675 pm_runtime_put_autosuspend(cs42l42->dev); in cs42l42_irq_thread()
1681 regmap_read(cs42l42->regmap, irq_params_table[i].status_addr, in cs42l42_irq_thread()
1683 regmap_read(cs42l42->regmap, irq_params_table[i].mask_addr, in cs42l42_irq_thread()
1707 cs42l42_process_hs_type_detect(cs42l42); in cs42l42_irq_thread()
1708 switch (cs42l42->hs_type) { in cs42l42_irq_thread()
1711 snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADSET, in cs42l42_irq_thread()
1717 snd_soc_jack_report(cs42l42->jack, SND_JACK_HEADPHONE, in cs42l42_irq_thread()
1725 dev_dbg(cs42l42->dev, "Auto detect done (%d)\n", cs42l42->hs_type); in cs42l42_irq_thread()
1733 if (cs42l42->plug_state != CS42L42_TS_PLUG) { in cs42l42_irq_thread()
1734 cs42l42->plug_state = CS42L42_TS_PLUG; in cs42l42_irq_thread()
1735 cs42l42_init_hs_type_detect(cs42l42); in cs42l42_irq_thread()
1740 if (cs42l42->plug_state != CS42L42_TS_UNPLUG) { in cs42l42_irq_thread()
1741 cs42l42->plug_state = CS42L42_TS_UNPLUG; in cs42l42_irq_thread()
1742 cs42l42_cancel_hs_type_detect(cs42l42); in cs42l42_irq_thread()
1744 snd_soc_jack_report(cs42l42->jack, 0, in cs42l42_irq_thread()
1749 dev_dbg(cs42l42->dev, "Unplug event\n"); in cs42l42_irq_thread()
1754 cs42l42->plug_state = CS42L42_TS_TRANS; in cs42l42_irq_thread()
1759 if (cs42l42->plug_state == CS42L42_TS_PLUG && ((~masks[7]) & irq_params_table[7].mask)) { in cs42l42_irq_thread()
1764 dev_dbg(cs42l42->dev, "Button released\n"); in cs42l42_irq_thread()
1765 snd_soc_jack_report(cs42l42->jack, 0, in cs42l42_irq_thread()
1769 snd_soc_jack_report(cs42l42->jack, in cs42l42_irq_thread()
1770 cs42l42_handle_button_press(cs42l42), in cs42l42_irq_thread()
1777 mutex_unlock(&cs42l42->irq_lock); in cs42l42_irq_thread()
1778 pm_runtime_mark_last_busy(cs42l42->dev); in cs42l42_irq_thread()
1779 pm_runtime_put_autosuspend(cs42l42->dev); in cs42l42_irq_thread()
1785 static void cs42l42_set_interrupt_masks(struct cs42l42_private *cs42l42) in cs42l42_set_interrupt_masks() argument
1787 regmap_update_bits(cs42l42->regmap, CS42L42_ADC_OVFL_INT_MASK, in cs42l42_set_interrupt_masks()
1791 regmap_update_bits(cs42l42->regmap, CS42L42_MIXER_INT_MASK, in cs42l42_set_interrupt_masks()
1801 regmap_update_bits(cs42l42->regmap, CS42L42_SRC_INT_MASK, in cs42l42_set_interrupt_masks()
1811 regmap_update_bits(cs42l42->regmap, CS42L42_ASP_RX_INT_MASK, in cs42l42_set_interrupt_masks()
1823 regmap_update_bits(cs42l42->regmap, CS42L42_ASP_TX_INT_MASK, in cs42l42_set_interrupt_masks()
1833 regmap_update_bits(cs42l42->regmap, CS42L42_CODEC_INT_MASK, in cs42l42_set_interrupt_masks()
1839 regmap_update_bits(cs42l42->regmap, CS42L42_SRCPL_INT_MASK, in cs42l42_set_interrupt_masks()
1849 regmap_update_bits(cs42l42->regmap, CS42L42_DET_INT1_MASK, in cs42l42_set_interrupt_masks()
1857 regmap_update_bits(cs42l42->regmap, CS42L42_DET_INT2_MASK, in cs42l42_set_interrupt_masks()
1869 regmap_update_bits(cs42l42->regmap, CS42L42_VPMON_INT_MASK, in cs42l42_set_interrupt_masks()
1873 regmap_update_bits(cs42l42->regmap, CS42L42_PLL_LOCK_INT_MASK, in cs42l42_set_interrupt_masks()
1877 regmap_update_bits(cs42l42->regmap, CS42L42_TSRS_PLUG_INT_MASK, in cs42l42_set_interrupt_masks()
1888 static void cs42l42_setup_hs_type_detect(struct cs42l42_private *cs42l42) in cs42l42_setup_hs_type_detect() argument
1892 cs42l42->hs_type = CS42L42_PLUG_INVALID; in cs42l42_setup_hs_type_detect()
1898 regmap_update_bits(cs42l42->regmap, CS42L42_MISC_DET_CTL, in cs42l42_setup_hs_type_detect()
1902 regmap_update_bits(cs42l42->regmap, CS42L42_MIC_DET_CTL1, in cs42l42_setup_hs_type_detect()
1908 (cs42l42->bias_thresholds[0] << in cs42l42_setup_hs_type_detect()
1912 regmap_update_bits(cs42l42->regmap, in cs42l42_setup_hs_type_detect()
1918 regmap_update_bits(cs42l42->regmap, CS42L42_TSENSE_CTL, in cs42l42_setup_hs_type_detect()
1921 regmap_update_bits(cs42l42->regmap, CS42L42_TIPSENSE_CTL, in cs42l42_setup_hs_type_detect()
1926 (!cs42l42->ts_inv << CS42L42_TIP_SENSE_INV_SHIFT) | in cs42l42_setup_hs_type_detect()
1930 regmap_read(cs42l42->regmap, in cs42l42_setup_hs_type_detect()
1933 cs42l42->plug_state = (((char) reg) & in cs42l42_setup_hs_type_detect()
1946 struct cs42l42_private *cs42l42) in cs42l42_handle_device_data() argument
1958 cs42l42->ts_inv = val; in cs42l42_handle_device_data()
1964 cs42l42->ts_inv = CS42L42_TS_INV_DIS; in cs42l42_handle_device_data()
1967 cs42l42->ts_inv = CS42L42_TS_INV_DIS; in cs42l42_handle_device_data()
1981 cs42l42->ts_dbnc_rise = val; in cs42l42_handle_device_data()
1987 cs42l42->ts_dbnc_rise = CS42L42_TS_DBNCE_1000; in cs42l42_handle_device_data()
1990 cs42l42->ts_dbnc_rise = CS42L42_TS_DBNCE_1000; in cs42l42_handle_device_data()
1993 regmap_update_bits(cs42l42->regmap, CS42L42_TSENSE_CTL, in cs42l42_handle_device_data()
1995 (cs42l42->ts_dbnc_rise << in cs42l42_handle_device_data()
2009 cs42l42->ts_dbnc_fall = val; in cs42l42_handle_device_data()
2015 cs42l42->ts_dbnc_fall = CS42L42_TS_DBNCE_0; in cs42l42_handle_device_data()
2018 cs42l42->ts_dbnc_fall = CS42L42_TS_DBNCE_0; in cs42l42_handle_device_data()
2021 regmap_update_bits(cs42l42->regmap, CS42L42_TSENSE_CTL, in cs42l42_handle_device_data()
2023 (cs42l42->ts_dbnc_fall << in cs42l42_handle_device_data()
2029 cs42l42->btn_det_init_dbnce = val; in cs42l42_handle_device_data()
2034 cs42l42->btn_det_init_dbnce = in cs42l42_handle_device_data()
2038 cs42l42->btn_det_init_dbnce = in cs42l42_handle_device_data()
2045 cs42l42->btn_det_event_dbnce = val; in cs42l42_handle_device_data()
2049 cs42l42->btn_det_event_dbnce = in cs42l42_handle_device_data()
2053 cs42l42->btn_det_event_dbnce = in cs42l42_handle_device_data()
2062 cs42l42->bias_thresholds[i] = thresholds[i]; in cs42l42_handle_device_data()
2067 cs42l42->bias_thresholds[i] = threshold_defaults[i]; in cs42l42_handle_device_data()
2072 cs42l42->bias_thresholds[i] = threshold_defaults[i]; in cs42l42_handle_device_data()
2079 cs42l42->hs_bias_ramp_rate = val; in cs42l42_handle_device_data()
2080 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME0; in cs42l42_handle_device_data()
2083 cs42l42->hs_bias_ramp_rate = val; in cs42l42_handle_device_data()
2084 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME1; in cs42l42_handle_device_data()
2087 cs42l42->hs_bias_ramp_rate = val; in cs42l42_handle_device_data()
2088 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME2; in cs42l42_handle_device_data()
2091 cs42l42->hs_bias_ramp_rate = val; in cs42l42_handle_device_data()
2092 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME3; in cs42l42_handle_device_data()
2098 cs42l42->hs_bias_ramp_rate = CS42L42_HSBIAS_RAMP_SLOW; in cs42l42_handle_device_data()
2099 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME2; in cs42l42_handle_device_data()
2102 cs42l42->hs_bias_ramp_rate = CS42L42_HSBIAS_RAMP_SLOW; in cs42l42_handle_device_data()
2103 cs42l42->hs_bias_ramp_time = CS42L42_HSBIAS_RAMP_TIME2; in cs42l42_handle_device_data()
2106 regmap_update_bits(cs42l42->regmap, CS42L42_HS_BIAS_CTL, in cs42l42_handle_device_data()
2108 (cs42l42->hs_bias_ramp_rate << in cs42l42_handle_device_data()
2112 cs42l42->hs_bias_sense_en = 0; in cs42l42_handle_device_data()
2114 cs42l42->hs_bias_sense_en = 1; in cs42l42_handle_device_data()
2154 struct cs42l42_private *cs42l42 = dev_get_drvdata(dev); in cs42l42_suspend() local
2159 if (!cs42l42->init_done) in cs42l42_suspend()
2167 mutex_lock(&cs42l42->irq_lock); in cs42l42_suspend()
2168 cs42l42->suspended = true; in cs42l42_suspend()
2172 regmap_read(cs42l42->regmap, cs42l42_shutdown_seq[i].reg, &reg); in cs42l42_suspend()
2177 regmap_multi_reg_write(cs42l42->regmap, in cs42l42_suspend()
2182 mutex_unlock(&cs42l42->irq_lock); in cs42l42_suspend()
2186 ret = regmap_read_poll_timeout(cs42l42->regmap, in cs42l42_suspend()
2195 regmap_update_bits(cs42l42->regmap, CS42L42_PWR_CTL2, in cs42l42_suspend()
2198 regcache_cache_only(cs42l42->regmap, true); in cs42l42_suspend()
2199 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_suspend()
2200 regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); in cs42l42_suspend()
2204 regmap_write(cs42l42->regmap, cs42l42_shutdown_seq[i].reg, save_regs[i]); in cs42l42_suspend()
2207 regcache_drop_region(cs42l42->regmap, CS42L42_PAGE_REGISTER, CS42L42_PAGE_REGISTER); in cs42l42_suspend()
2218 struct cs42l42_private *cs42l42 = dev_get_drvdata(dev); in cs42l42_resume() local
2221 if (!cs42l42->init_done) in cs42l42_resume()
2229 if (cs42l42->plug_state != CS42L42_TS_UNPLUG) in cs42l42_resume()
2230 cs42l42->plug_state = CS42L42_TS_TRANS; in cs42l42_resume()
2232 ret = regulator_bulk_enable(ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); in cs42l42_resume()
2238 gpiod_set_value_cansleep(cs42l42->reset_gpio, 1); in cs42l42_resume()
2249 struct cs42l42_private *cs42l42 = dev_get_drvdata(dev); in cs42l42_resume_restore() local
2251 regcache_cache_only(cs42l42->regmap, false); in cs42l42_resume_restore()
2252 regcache_mark_dirty(cs42l42->regmap); in cs42l42_resume_restore()
2254 mutex_lock(&cs42l42->irq_lock); in cs42l42_resume_restore()
2256 regcache_sync_region(cs42l42->regmap, CS42L42_MIC_DET_CTL1, CS42L42_MIC_DET_CTL1); in cs42l42_resume_restore()
2257 regcache_sync(cs42l42->regmap); in cs42l42_resume_restore()
2259 cs42l42->suspended = false; in cs42l42_resume_restore()
2260 mutex_unlock(&cs42l42->irq_lock); in cs42l42_resume_restore()
2279 int cs42l42_common_probe(struct cs42l42_private *cs42l42, in cs42l42_common_probe() argument
2285 dev_set_drvdata(cs42l42->dev, cs42l42); in cs42l42_common_probe()
2286 mutex_init(&cs42l42->irq_lock); in cs42l42_common_probe()
2288 BUILD_BUG_ON(ARRAY_SIZE(cs42l42_supply_names) != ARRAY_SIZE(cs42l42->supplies)); in cs42l42_common_probe()
2289 for (i = 0; i < ARRAY_SIZE(cs42l42->supplies); i++) in cs42l42_common_probe()
2290 cs42l42->supplies[i].supply = cs42l42_supply_names[i]; in cs42l42_common_probe()
2292 ret = devm_regulator_bulk_get(cs42l42->dev, in cs42l42_common_probe()
2293 ARRAY_SIZE(cs42l42->supplies), in cs42l42_common_probe()
2294 cs42l42->supplies); in cs42l42_common_probe()
2296 dev_err(cs42l42->dev, in cs42l42_common_probe()
2301 ret = regulator_bulk_enable(ARRAY_SIZE(cs42l42->supplies), in cs42l42_common_probe()
2302 cs42l42->supplies); in cs42l42_common_probe()
2304 dev_err(cs42l42->dev, in cs42l42_common_probe()
2310 cs42l42->reset_gpio = devm_gpiod_get_optional(cs42l42->dev, in cs42l42_common_probe()
2312 if (IS_ERR(cs42l42->reset_gpio)) { in cs42l42_common_probe()
2313 ret = PTR_ERR(cs42l42->reset_gpio); in cs42l42_common_probe()
2317 if (cs42l42->reset_gpio) { in cs42l42_common_probe()
2318 dev_dbg(cs42l42->dev, "Found reset GPIO\n"); in cs42l42_common_probe()
2324 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_common_probe()
2335 if (cs42l42->sdw_peripheral) in cs42l42_common_probe()
2336 cs42l42->sdw_waiting_first_unattach = true; in cs42l42_common_probe()
2338 gpiod_set_value_cansleep(cs42l42->reset_gpio, 1); in cs42l42_common_probe()
2343 if (cs42l42->irq) { in cs42l42_common_probe()
2344 ret = request_threaded_irq(cs42l42->irq, in cs42l42_common_probe()
2347 "cs42l42", cs42l42); in cs42l42_common_probe()
2349 dev_err_probe(cs42l42->dev, ret, in cs42l42_common_probe()
2356 ret = devm_snd_soc_register_component(cs42l42->dev, component_drv, dai, 1); in cs42l42_common_probe()
2363 if (cs42l42->irq) in cs42l42_common_probe()
2364 free_irq(cs42l42->irq, cs42l42); in cs42l42_common_probe()
2367 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_common_probe()
2369 regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); in cs42l42_common_probe()
2375 int cs42l42_init(struct cs42l42_private *cs42l42) in cs42l42_init() argument
2381 devid = cirrus_read_device_id(cs42l42->regmap, CS42L42_DEVID_AB); in cs42l42_init()
2384 dev_err(cs42l42->dev, "Failed to read device ID: %d\n", ret); in cs42l42_init()
2388 if (devid != cs42l42->devid) { in cs42l42_init()
2390 dev_err(cs42l42->dev, in cs42l42_init()
2392 cs42l42->devid & 0xff, devid, cs42l42->devid); in cs42l42_init()
2396 ret = regmap_read(cs42l42->regmap, CS42L42_REVID, &reg); in cs42l42_init()
2398 dev_err(cs42l42->dev, "Get Revision ID failed\n"); in cs42l42_init()
2402 dev_info(cs42l42->dev, in cs42l42_init()
2404 cs42l42->devid & 0xff, reg & 0xFF); in cs42l42_init()
2407 regmap_update_bits(cs42l42->regmap, CS42L42_PWR_CTL1, in cs42l42_init()
2423 ret = cs42l42_handle_device_data(cs42l42->dev, cs42l42); in cs42l42_init()
2431 if (cs42l42->sdw_peripheral) { in cs42l42_init()
2432 regmap_update_bits(cs42l42->regmap, CS42L42_PWR_CTL2, in cs42l42_init()
2440 cs42l42_setup_hs_type_detect(cs42l42); in cs42l42_init()
2446 cs42l42->init_done = true; in cs42l42_init()
2449 cs42l42_set_interrupt_masks(cs42l42); in cs42l42_init()
2454 regmap_write(cs42l42->regmap, CS42L42_CODEC_INT_MASK, 0xff); in cs42l42_init()
2455 regmap_write(cs42l42->regmap, CS42L42_TSRS_PLUG_INT_MASK, 0xff); in cs42l42_init()
2456 regmap_write(cs42l42->regmap, CS42L42_PWR_CTL1, 0xff); in cs42l42_init()
2459 if (cs42l42->irq) in cs42l42_init()
2460 free_irq(cs42l42->irq, cs42l42); in cs42l42_init()
2462 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_init()
2463 regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), in cs42l42_init()
2464 cs42l42->supplies); in cs42l42_init()
2469 void cs42l42_common_remove(struct cs42l42_private *cs42l42) in cs42l42_common_remove() argument
2471 if (cs42l42->irq) in cs42l42_common_remove()
2472 free_irq(cs42l42->irq, cs42l42); in cs42l42_common_remove()
2478 if (cs42l42->init_done) { in cs42l42_common_remove()
2479 regmap_write(cs42l42->regmap, CS42L42_CODEC_INT_MASK, 0xff); in cs42l42_common_remove()
2480 regmap_write(cs42l42->regmap, CS42L42_TSRS_PLUG_INT_MASK, 0xff); in cs42l42_common_remove()
2481 regmap_write(cs42l42->regmap, CS42L42_PWR_CTL1, 0xff); in cs42l42_common_remove()
2484 gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); in cs42l42_common_remove()
2485 regulator_bulk_disable(ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); in cs42l42_common_remove()