Lines Matching +full:spk +full:- +full:shutdown

1 // SPDX-License-Identifier: GPL-2.0-only
3 * cs35l35.c -- CS35L35 ALSA SoC audio driver
26 #include <sound/soc-dapm.h>
160 gpiod_set_value_cansleep(cs35l35->reset_gpio, 0); in cs35l35_reset()
162 gpiod_set_value_cansleep(cs35l35->reset_gpio, 1); in cs35l35_reset()
170 if (cs35l35->pdata.ext_bst) { in cs35l35_wait_for_pdn()
175 reinit_completion(&cs35l35->pdn_done); in cs35l35_wait_for_pdn()
177 ret = wait_for_completion_timeout(&cs35l35->pdn_done, in cs35l35_wait_for_pdn()
180 dev_err(cs35l35->dev, "PDN_DONE did not complete\n"); in cs35l35_wait_for_pdn()
181 return -ETIMEDOUT; in cs35l35_wait_for_pdn()
190 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs35l35_sdin_event()
196 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_sdin_event()
199 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_sdin_event()
202 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_sdin_event()
206 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_sdin_event()
209 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_sdin_event()
212 /* Already muted, so disable volume ramp for faster shutdown */ in cs35l35_sdin_event()
213 regmap_update_bits(cs35l35->regmap, CS35L35_AMP_DIG_VOL_CTL, in cs35l35_sdin_event()
218 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_sdin_event()
222 regmap_update_bits(cs35l35->regmap, CS35L35_AMP_DIG_VOL_CTL, in cs35l35_sdin_event()
227 dev_err(component->dev, "Invalid event = 0x%x\n", event); in cs35l35_sdin_event()
228 ret = -EINVAL; in cs35l35_sdin_event()
236 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs35l35_main_amp_event()
243 if (cs35l35->pdata.bst_pdn_fet_on) in cs35l35_main_amp_event()
244 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_main_amp_event()
248 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_main_amp_event()
255 if (cs35l35->pdm_mode) in cs35l35_main_amp_event()
256 regmap_update_bits(cs35l35->regmap, in cs35l35_main_amp_event()
261 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, in cs35l35_main_amp_event()
265 regmap_bulk_read(cs35l35->regmap, CS35L35_INT_STATUS_1, in cs35l35_main_amp_event()
270 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, in cs35l35_main_amp_event()
273 if (cs35l35->pdata.bst_pdn_fet_on) in cs35l35_main_amp_event()
274 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_main_amp_event()
278 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_main_amp_event()
288 if (cs35l35->pdm_mode) in cs35l35_main_amp_event()
289 regmap_update_bits(cs35l35->regmap, in cs35l35_main_amp_event()
292 cs35l35->pdata.bst_vctl in cs35l35_main_amp_event()
297 dev_err(component->dev, "Invalid event = 0x%x\n", event); in cs35l35_main_amp_event()
303 static DECLARE_TLV_DB_SCALE(dig_vol_tlv, -10200, 50, 0);
327 SND_SOC_DAPM_OUTPUT("SPK"),
360 {"SPK", NULL, "Main AMP"},
365 struct snd_soc_component *component = codec_dai->component; in cs35l35_set_dai_fmt()
370 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_set_dai_fmt()
372 cs35l35->clock_consumer = false; in cs35l35_set_dai_fmt()
375 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_set_dai_fmt()
377 cs35l35->clock_consumer = true; in cs35l35_set_dai_fmt()
380 return -EINVAL; in cs35l35_set_dai_fmt()
385 cs35l35->i2s_mode = true; in cs35l35_set_dai_fmt()
386 cs35l35->pdm_mode = false; in cs35l35_set_dai_fmt()
389 cs35l35->pdm_mode = true; in cs35l35_set_dai_fmt()
390 cs35l35->i2s_mode = false; in cs35l35_set_dai_fmt()
393 return -EINVAL; in cs35l35_set_dai_fmt()
459 return -EINVAL; in cs35l35_get_clk_config()
466 struct snd_soc_component *component = dai->component; in cs35l35_hw_params()
468 struct classh_cfg *classh = &cs35l35->pdata.classh_algo; in cs35l35_hw_params()
475 int clk_ctl = cs35l35_get_clk_config(cs35l35->sysclk, srate); in cs35l35_hw_params()
478 dev_err(component->dev, "Invalid CLK:Rate %d:%d\n", in cs35l35_hw_params()
479 cs35l35->sysclk, srate); in cs35l35_hw_params()
480 return -EINVAL; in cs35l35_hw_params()
483 ret = regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL2, in cs35l35_hw_params()
486 dev_err(component->dev, "Failed to set port config %d\n", ret); in cs35l35_hw_params()
492 * When configured for the weak-drive detection path (CH_WKFET_DIS = 0) in cs35l35_hw_params()
493 * the Class H algorithm does not enable weak-drive operation for in cs35l35_hw_params()
498 if (classh->classh_wk_fet_disable == 0x00 && in cs35l35_hw_params()
500 ret = regmap_update_bits(cs35l35->regmap, in cs35l35_hw_params()
505 dev_err(component->dev, "Failed to set fet config %d\n", in cs35l35_hw_params()
515 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in cs35l35_hw_params()
527 dev_err(component->dev, "Unsupported Width %d\n", in cs35l35_hw_params()
529 return -EINVAL; in cs35l35_hw_params()
531 regmap_update_bits(cs35l35->regmap, in cs35l35_hw_params()
536 if (cs35l35->pdata.stereo) { in cs35l35_hw_params()
537 regmap_update_bits(cs35l35->regmap, in cs35l35_hw_params()
545 if (cs35l35->i2s_mode) { in cs35l35_hw_params()
549 if ((cs35l35->sclk / srate) % 4) { in cs35l35_hw_params()
550 dev_err(component->dev, "Unsupported sclk/fs ratio %d:%d\n", in cs35l35_hw_params()
551 cs35l35->sclk, srate); in cs35l35_hw_params()
552 return -EINVAL; in cs35l35_hw_params()
554 sp_sclks = ((cs35l35->sclk / srate) / 4) - 1; in cs35l35_hw_params()
557 if (cs35l35->clock_consumer) { in cs35l35_hw_params()
564 dev_err(component->dev, "ratio not supported\n"); in cs35l35_hw_params()
565 return -EINVAL; in cs35l35_hw_params()
574 dev_err(component->dev, "ratio not supported\n"); in cs35l35_hw_params()
575 return -EINVAL; in cs35l35_hw_params()
578 ret = regmap_update_bits(cs35l35->regmap, in cs35l35_hw_params()
583 dev_err(component->dev, "Failed to set fsclk %d\n", ret); in cs35l35_hw_params()
603 struct snd_soc_component *component = dai->component; in cs35l35_pcm_startup()
606 if (!substream->runtime) in cs35l35_pcm_startup()
609 snd_pcm_hw_constraint_list(substream->runtime, 0, in cs35l35_pcm_startup()
612 regmap_update_bits(cs35l35->regmap, CS35L35_AMP_INP_DRV_CTL, in cs35l35_pcm_startup()
631 struct snd_soc_component *component = dai->component; in cs35l35_pdm_startup()
634 if (!substream->runtime) in cs35l35_pdm_startup()
637 snd_pcm_hw_constraint_list(substream->runtime, 0, in cs35l35_pdm_startup()
641 regmap_update_bits(cs35l35->regmap, CS35L35_AMP_INP_DRV_CTL, in cs35l35_pdm_startup()
651 struct snd_soc_component *component = dai->component; in cs35l35_dai_set_sysclk()
655 cs35l35->sclk = freq; in cs35l35_dai_set_sysclk()
675 .name = "cs35l35-pcm",
695 .name = "cs35l35-pdm",
727 dev_err(component->dev, "Invalid CLK Source\n"); in cs35l35_component_set_sysclk()
728 return -EINVAL; in cs35l35_component_set_sysclk()
742 cs35l35->sysclk = freq; in cs35l35_component_set_sysclk()
745 dev_err(component->dev, "Invalid CLK Frequency Input : %d\n", freq); in cs35l35_component_set_sysclk()
746 return -EINVAL; in cs35l35_component_set_sysclk()
749 ret = regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_component_set_sysclk()
753 dev_err(component->dev, "Failed to set sysclk %d\n", ret); in cs35l35_component_set_sysclk()
763 struct regmap *regmap = cs35l35->regmap; in cs35l35_boost_inductor()
823 dev_err(cs35l35->dev, "Invalid Inductor Value %d uH\n", in cs35l35_boost_inductor()
825 return -EINVAL; in cs35l35_boost_inductor()
833 struct classh_cfg *classh = &cs35l35->pdata.classh_algo; in cs35l35_component_probe()
834 struct monitor_cfg *monitor_config = &cs35l35->pdata.mon_cfg; in cs35l35_component_probe()
838 if (cs35l35->pdata.bst_vctl) in cs35l35_component_probe()
839 regmap_update_bits(cs35l35->regmap, CS35L35_BST_CVTR_V_CTL, in cs35l35_component_probe()
841 cs35l35->pdata.bst_vctl); in cs35l35_component_probe()
843 if (cs35l35->pdata.bst_ipk) in cs35l35_component_probe()
844 regmap_update_bits(cs35l35->regmap, CS35L35_BST_PEAK_I, in cs35l35_component_probe()
846 cs35l35->pdata.bst_ipk << in cs35l35_component_probe()
849 ret = cs35l35_boost_inductor(cs35l35, cs35l35->pdata.boost_ind); in cs35l35_component_probe()
853 if (cs35l35->pdata.gain_zc) in cs35l35_component_probe()
854 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, in cs35l35_component_probe()
856 cs35l35->pdata.gain_zc << in cs35l35_component_probe()
859 if (cs35l35->pdata.aud_channel) in cs35l35_component_probe()
860 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
863 cs35l35->pdata.aud_channel << in cs35l35_component_probe()
866 if (cs35l35->pdata.stereo) { in cs35l35_component_probe()
867 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
870 cs35l35->pdata.adv_channel << in cs35l35_component_probe()
872 if (cs35l35->pdata.shared_bst) in cs35l35_component_probe()
873 regmap_update_bits(cs35l35->regmap, CS35L35_CLASS_H_CTL, in cs35l35_component_probe()
882 if (cs35l35->pdata.sp_drv_str) in cs35l35_component_probe()
883 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_component_probe()
885 cs35l35->pdata.sp_drv_str << in cs35l35_component_probe()
887 if (cs35l35->pdata.sp_drv_unused) in cs35l35_component_probe()
888 regmap_update_bits(cs35l35->regmap, CS35L35_SP_FMT_CTL3, in cs35l35_component_probe()
890 cs35l35->pdata.sp_drv_unused << in cs35l35_component_probe()
893 if (classh->classh_algo_enable) { in cs35l35_component_probe()
894 if (classh->classh_bst_override) in cs35l35_component_probe()
895 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
898 classh->classh_bst_override << in cs35l35_component_probe()
900 if (classh->classh_bst_max_limit) in cs35l35_component_probe()
901 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
904 classh->classh_bst_max_limit << in cs35l35_component_probe()
906 if (classh->classh_mem_depth) in cs35l35_component_probe()
907 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
910 classh->classh_mem_depth << in cs35l35_component_probe()
912 if (classh->classh_headroom) in cs35l35_component_probe()
913 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
916 classh->classh_headroom << in cs35l35_component_probe()
918 if (classh->classh_release_rate) in cs35l35_component_probe()
919 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
922 classh->classh_release_rate << in cs35l35_component_probe()
924 if (classh->classh_wk_fet_disable) in cs35l35_component_probe()
925 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
928 classh->classh_wk_fet_disable << in cs35l35_component_probe()
930 if (classh->classh_wk_fet_delay) in cs35l35_component_probe()
931 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
934 classh->classh_wk_fet_delay << in cs35l35_component_probe()
936 if (classh->classh_wk_fet_thld) in cs35l35_component_probe()
937 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
940 classh->classh_wk_fet_thld << in cs35l35_component_probe()
942 if (classh->classh_vpch_auto) in cs35l35_component_probe()
943 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
946 classh->classh_vpch_auto << in cs35l35_component_probe()
948 if (classh->classh_vpch_rate) in cs35l35_component_probe()
949 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
952 classh->classh_vpch_rate << in cs35l35_component_probe()
954 if (classh->classh_vpch_man) in cs35l35_component_probe()
955 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
958 classh->classh_vpch_man << in cs35l35_component_probe()
962 if (monitor_config->is_present) { in cs35l35_component_probe()
963 if (monitor_config->vmon_specs) { in cs35l35_component_probe()
964 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
967 monitor_config->vmon_dpth << in cs35l35_component_probe()
969 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
972 monitor_config->vmon_loc << in cs35l35_component_probe()
974 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
977 monitor_config->vmon_frm << in cs35l35_component_probe()
980 if (monitor_config->imon_specs) { in cs35l35_component_probe()
981 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
984 monitor_config->imon_dpth << in cs35l35_component_probe()
986 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
989 monitor_config->imon_loc << in cs35l35_component_probe()
991 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
994 monitor_config->imon_frm << in cs35l35_component_probe()
996 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
999 monitor_config->imon_scale << in cs35l35_component_probe()
1002 if (monitor_config->vpmon_specs) { in cs35l35_component_probe()
1003 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1006 monitor_config->vpmon_dpth << in cs35l35_component_probe()
1008 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1011 monitor_config->vpmon_loc << in cs35l35_component_probe()
1013 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1016 monitor_config->vpmon_frm << in cs35l35_component_probe()
1019 if (monitor_config->vbstmon_specs) { in cs35l35_component_probe()
1020 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1023 monitor_config->vpmon_dpth << in cs35l35_component_probe()
1025 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1028 monitor_config->vbstmon_loc << in cs35l35_component_probe()
1030 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1033 monitor_config->vbstmon_frm << in cs35l35_component_probe()
1036 if (monitor_config->vpbrstat_specs) { in cs35l35_component_probe()
1037 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1040 monitor_config->vpbrstat_dpth << in cs35l35_component_probe()
1042 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1045 monitor_config->vpbrstat_loc << in cs35l35_component_probe()
1047 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1050 monitor_config->vpbrstat_frm << in cs35l35_component_probe()
1053 if (monitor_config->zerofill_specs) { in cs35l35_component_probe()
1054 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1057 monitor_config->zerofill_dpth << in cs35l35_component_probe()
1059 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1062 monitor_config->zerofill_loc << in cs35l35_component_probe()
1064 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1067 monitor_config->zerofill_frm << in cs35l35_component_probe()
1111 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_4, &sticky4); in cs35l35_irq()
1112 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_3, &sticky3); in cs35l35_irq()
1113 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_2, &sticky2); in cs35l35_irq()
1114 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_1, &sticky1); in cs35l35_irq()
1116 regmap_read(cs35l35->regmap, CS35L35_INT_MASK_4, &mask4); in cs35l35_irq()
1117 regmap_read(cs35l35->regmap, CS35L35_INT_MASK_3, &mask3); in cs35l35_irq()
1118 regmap_read(cs35l35->regmap, CS35L35_INT_MASK_2, &mask2); in cs35l35_irq()
1119 regmap_read(cs35l35->regmap, CS35L35_INT_MASK_1, &mask1); in cs35l35_irq()
1127 complete(&cs35l35->pdn_done); in cs35l35_irq()
1130 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_1, &current1); in cs35l35_irq()
1134 dev_crit(cs35l35->dev, "Calibration Error\n"); in cs35l35_irq()
1139 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1142 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1146 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1153 dev_crit(cs35l35->dev, "AMP Short Error\n"); in cs35l35_irq()
1156 dev_dbg(cs35l35->dev, "Amp short error release\n"); in cs35l35_irq()
1157 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1160 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1164 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1171 dev_warn(cs35l35->dev, "Over temperature warning\n"); in cs35l35_irq()
1175 dev_dbg(cs35l35->dev, "Over temperature warn release\n"); in cs35l35_irq()
1176 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1179 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1183 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1190 dev_crit(cs35l35->dev, "Over temperature error\n"); in cs35l35_irq()
1193 dev_dbg(cs35l35->dev, "Over temperature error release\n"); in cs35l35_irq()
1194 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1197 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1201 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1208 dev_crit(cs35l35->dev, "VBST error: powering off!\n"); in cs35l35_irq()
1209 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_irq()
1211 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_irq()
1216 dev_crit(cs35l35->dev, "LBST error: powering off!\n"); in cs35l35_irq()
1217 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_irq()
1219 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_irq()
1224 dev_dbg(cs35l35->dev, "Error: Reactive Brownout\n"); in cs35l35_irq()
1227 dev_dbg(cs35l35->dev, "Error: VMON overflow\n"); in cs35l35_irq()
1230 dev_dbg(cs35l35->dev, "Error: IMON overflow\n"); in cs35l35_irq()
1239 struct device_node *np = i2c_client->dev.of_node; in cs35l35_handle_of_data()
1241 struct classh_cfg *classh_config = &pdata->classh_algo; in cs35l35_handle_of_data()
1242 struct monitor_cfg *monitor_config = &pdata->mon_cfg; in cs35l35_handle_of_data()
1246 const int mon_array_size = imon_array_size - 1; in cs35l35_handle_of_data()
1252 pdata->bst_pdn_fet_on = of_property_read_bool(np, in cs35l35_handle_of_data()
1253 "cirrus,boost-pdn-fet-on"); in cs35l35_handle_of_data()
1255 ret = of_property_read_u32(np, "cirrus,boost-ctl-millivolt", &val32); in cs35l35_handle_of_data()
1258 dev_err(&i2c_client->dev, in cs35l35_handle_of_data()
1260 return -EINVAL; in cs35l35_handle_of_data()
1262 pdata->bst_vctl = ((val32 - 2600) / 100) + 1; in cs35l35_handle_of_data()
1265 ret = of_property_read_u32(np, "cirrus,boost-peak-milliamp", &val32); in cs35l35_handle_of_data()
1268 dev_err(&i2c_client->dev, in cs35l35_handle_of_data()
1270 return -EINVAL; in cs35l35_handle_of_data()
1273 pdata->bst_ipk = ((val32 - 1680) / 110) | CS35L35_VALID_PDATA; in cs35l35_handle_of_data()
1276 ret = of_property_read_u32(np, "cirrus,boost-ind-nanohenry", &val32); in cs35l35_handle_of_data()
1278 pdata->boost_ind = val32; in cs35l35_handle_of_data()
1280 dev_err(&i2c_client->dev, "Inductor not specified.\n"); in cs35l35_handle_of_data()
1281 return -EINVAL; in cs35l35_handle_of_data()
1284 if (of_property_read_u32(np, "cirrus,sp-drv-strength", &val32) >= 0) in cs35l35_handle_of_data()
1285 pdata->sp_drv_str = val32; in cs35l35_handle_of_data()
1286 if (of_property_read_u32(np, "cirrus,sp-drv-unused", &val32) >= 0) in cs35l35_handle_of_data()
1287 pdata->sp_drv_unused = val32 | CS35L35_VALID_PDATA; in cs35l35_handle_of_data()
1289 pdata->stereo = of_property_read_bool(np, "cirrus,stereo-config"); in cs35l35_handle_of_data()
1291 if (pdata->stereo) { in cs35l35_handle_of_data()
1292 ret = of_property_read_u32(np, "cirrus,audio-channel", &val32); in cs35l35_handle_of_data()
1294 pdata->aud_channel = val32; in cs35l35_handle_of_data()
1296 ret = of_property_read_u32(np, "cirrus,advisory-channel", in cs35l35_handle_of_data()
1299 pdata->adv_channel = val32; in cs35l35_handle_of_data()
1301 pdata->shared_bst = of_property_read_bool(np, in cs35l35_handle_of_data()
1302 "cirrus,shared-boost"); in cs35l35_handle_of_data()
1305 pdata->ext_bst = of_property_read_bool(np, "cirrus,external-boost"); in cs35l35_handle_of_data()
1307 pdata->gain_zc = of_property_read_bool(np, "cirrus,amp-gain-zc"); in cs35l35_handle_of_data()
1309 classh = of_get_child_by_name(np, "cirrus,classh-internal-algo"); in cs35l35_handle_of_data()
1310 classh_config->classh_algo_enable = (classh != NULL); in cs35l35_handle_of_data()
1312 if (classh_config->classh_algo_enable) { in cs35l35_handle_of_data()
1313 classh_config->classh_bst_override = in cs35l35_handle_of_data()
1314 of_property_read_bool(np, "cirrus,classh-bst-overide"); in cs35l35_handle_of_data()
1317 "cirrus,classh-bst-max-limit", in cs35l35_handle_of_data()
1321 classh_config->classh_bst_max_limit = val32; in cs35l35_handle_of_data()
1325 "cirrus,classh-bst-max-limit", in cs35l35_handle_of_data()
1329 classh_config->classh_bst_max_limit = val32; in cs35l35_handle_of_data()
1332 ret = of_property_read_u32(classh, "cirrus,classh-mem-depth", in cs35l35_handle_of_data()
1336 classh_config->classh_mem_depth = val32; in cs35l35_handle_of_data()
1339 ret = of_property_read_u32(classh, "cirrus,classh-release-rate", in cs35l35_handle_of_data()
1342 classh_config->classh_release_rate = val32; in cs35l35_handle_of_data()
1344 ret = of_property_read_u32(classh, "cirrus,classh-headroom", in cs35l35_handle_of_data()
1348 classh_config->classh_headroom = val32; in cs35l35_handle_of_data()
1352 "cirrus,classh-wk-fet-disable", in cs35l35_handle_of_data()
1355 classh_config->classh_wk_fet_disable = val32; in cs35l35_handle_of_data()
1357 ret = of_property_read_u32(classh, "cirrus,classh-wk-fet-delay", in cs35l35_handle_of_data()
1361 classh_config->classh_wk_fet_delay = val32; in cs35l35_handle_of_data()
1364 ret = of_property_read_u32(classh, "cirrus,classh-wk-fet-thld", in cs35l35_handle_of_data()
1367 classh_config->classh_wk_fet_thld = val32; in cs35l35_handle_of_data()
1369 ret = of_property_read_u32(classh, "cirrus,classh-vpch-auto", in cs35l35_handle_of_data()
1373 classh_config->classh_vpch_auto = val32; in cs35l35_handle_of_data()
1376 ret = of_property_read_u32(classh, "cirrus,classh-vpch-rate", in cs35l35_handle_of_data()
1380 classh_config->classh_vpch_rate = val32; in cs35l35_handle_of_data()
1383 ret = of_property_read_u32(classh, "cirrus,classh-vpch-man", in cs35l35_handle_of_data()
1386 classh_config->classh_vpch_man = val32; in cs35l35_handle_of_data()
1391 signal_format = of_get_child_by_name(np, "cirrus,monitor-signal-format"); in cs35l35_handle_of_data()
1392 monitor_config->is_present = signal_format ? true : false; in cs35l35_handle_of_data()
1393 if (monitor_config->is_present) { in cs35l35_handle_of_data()
1397 monitor_config->imon_specs = true; in cs35l35_handle_of_data()
1398 monitor_config->imon_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1399 monitor_config->imon_loc = monitor_array[1]; in cs35l35_handle_of_data()
1400 monitor_config->imon_frm = monitor_array[2]; in cs35l35_handle_of_data()
1401 monitor_config->imon_scale = monitor_array[3]; in cs35l35_handle_of_data()
1406 monitor_config->vmon_specs = true; in cs35l35_handle_of_data()
1407 monitor_config->vmon_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1408 monitor_config->vmon_loc = monitor_array[1]; in cs35l35_handle_of_data()
1409 monitor_config->vmon_frm = monitor_array[2]; in cs35l35_handle_of_data()
1414 monitor_config->vpmon_specs = true; in cs35l35_handle_of_data()
1415 monitor_config->vpmon_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1416 monitor_config->vpmon_loc = monitor_array[1]; in cs35l35_handle_of_data()
1417 monitor_config->vpmon_frm = monitor_array[2]; in cs35l35_handle_of_data()
1422 monitor_config->vbstmon_specs = true; in cs35l35_handle_of_data()
1423 monitor_config->vbstmon_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1424 monitor_config->vbstmon_loc = monitor_array[1]; in cs35l35_handle_of_data()
1425 monitor_config->vbstmon_frm = monitor_array[2]; in cs35l35_handle_of_data()
1430 monitor_config->vpbrstat_specs = true; in cs35l35_handle_of_data()
1431 monitor_config->vpbrstat_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1432 monitor_config->vpbrstat_loc = monitor_array[1]; in cs35l35_handle_of_data()
1433 monitor_config->vpbrstat_frm = monitor_array[2]; in cs35l35_handle_of_data()
1438 monitor_config->zerofill_specs = true; in cs35l35_handle_of_data()
1439 monitor_config->zerofill_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1440 monitor_config->zerofill_loc = monitor_array[1]; in cs35l35_handle_of_data()
1441 monitor_config->zerofill_frm = monitor_array[2]; in cs35l35_handle_of_data()
1468 struct device *dev = &i2c_client->dev; in cs35l35_i2c_probe()
1476 return -ENOMEM; in cs35l35_i2c_probe()
1478 cs35l35->dev = dev; in cs35l35_i2c_probe()
1481 cs35l35->regmap = devm_regmap_init_i2c(i2c_client, &cs35l35_regmap); in cs35l35_i2c_probe()
1482 if (IS_ERR(cs35l35->regmap)) { in cs35l35_i2c_probe()
1483 ret = PTR_ERR(cs35l35->regmap); in cs35l35_i2c_probe()
1489 cs35l35->supplies[i].supply = cs35l35_supplies[i]; in cs35l35_i2c_probe()
1491 cs35l35->num_supplies = ARRAY_SIZE(cs35l35_supplies); in cs35l35_i2c_probe()
1493 ret = devm_regulator_bulk_get(dev, cs35l35->num_supplies, in cs35l35_i2c_probe()
1494 cs35l35->supplies); in cs35l35_i2c_probe()
1501 cs35l35->pdata = *pdata; in cs35l35_i2c_probe()
1506 return -ENOMEM; in cs35l35_i2c_probe()
1507 if (i2c_client->dev.of_node) { in cs35l35_i2c_probe()
1513 cs35l35->pdata = *pdata; in cs35l35_i2c_probe()
1516 ret = regulator_bulk_enable(cs35l35->num_supplies, in cs35l35_i2c_probe()
1517 cs35l35->supplies); in cs35l35_i2c_probe()
1524 cs35l35->reset_gpio = devm_gpiod_get_optional(dev, "reset", in cs35l35_i2c_probe()
1526 if (IS_ERR(cs35l35->reset_gpio)) { in cs35l35_i2c_probe()
1527 ret = PTR_ERR(cs35l35->reset_gpio); in cs35l35_i2c_probe()
1528 cs35l35->reset_gpio = NULL; in cs35l35_i2c_probe()
1529 if (ret == -EBUSY) { in cs35l35_i2c_probe()
1540 init_completion(&cs35l35->pdn_done); in cs35l35_i2c_probe()
1542 ret = devm_request_threaded_irq(dev, i2c_client->irq, NULL, cs35l35_irq, in cs35l35_i2c_probe()
1550 devid = cirrus_read_device_id(cs35l35->regmap, CS35L35_DEVID_AB); in cs35l35_i2c_probe()
1560 ret = -ENODEV; in cs35l35_i2c_probe()
1564 ret = regmap_read(cs35l35->regmap, CS35L35_REV_ID, &reg); in cs35l35_i2c_probe()
1570 ret = regmap_register_patch(cs35l35->regmap, cs35l35_errata_patch, in cs35l35_i2c_probe()
1581 regmap_write(cs35l35->regmap, CS35L35_INT_MASK_1, in cs35l35_i2c_probe()
1583 regmap_write(cs35l35->regmap, CS35L35_INT_MASK_2, in cs35l35_i2c_probe()
1585 regmap_write(cs35l35->regmap, CS35L35_INT_MASK_3, in cs35l35_i2c_probe()
1587 regmap_write(cs35l35->regmap, CS35L35_INT_MASK_4, in cs35l35_i2c_probe()
1590 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_i2c_probe()
1594 if (cs35l35->pdata.bst_pdn_fet_on) in cs35l35_i2c_probe()
1595 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_i2c_probe()
1599 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_i2c_probe()
1603 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL3, in cs35l35_i2c_probe()
1607 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, in cs35l35_i2c_probe()
1620 regulator_bulk_disable(cs35l35->num_supplies, in cs35l35_i2c_probe()
1621 cs35l35->supplies); in cs35l35_i2c_probe()
1622 gpiod_set_value_cansleep(cs35l35->reset_gpio, 0); in cs35l35_i2c_probe()
1631 regulator_bulk_disable(cs35l35->num_supplies, cs35l35->supplies); in cs35l35_i2c_remove()
1632 gpiod_set_value_cansleep(cs35l35->reset_gpio, 0); in cs35l35_i2c_remove()