Lines Matching +full:sclk +full:- +full:strength
1 // SPDX-License-Identifier: GPL-2.0-only
3 * cs35l35.c -- CS35L35 ALSA SoC audio driver
28 #include <sound/soc-dapm.h>
163 gpiod_set_value_cansleep(cs35l35->reset_gpio, 0); in cs35l35_reset()
165 gpiod_set_value_cansleep(cs35l35->reset_gpio, 1); in cs35l35_reset()
173 if (cs35l35->pdata.ext_bst) { in cs35l35_wait_for_pdn()
178 reinit_completion(&cs35l35->pdn_done); in cs35l35_wait_for_pdn()
180 ret = wait_for_completion_timeout(&cs35l35->pdn_done, in cs35l35_wait_for_pdn()
183 dev_err(cs35l35->dev, "PDN_DONE did not complete\n"); in cs35l35_wait_for_pdn()
184 return -ETIMEDOUT; in cs35l35_wait_for_pdn()
193 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs35l35_sdin_event()
199 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_sdin_event()
202 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_sdin_event()
205 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_sdin_event()
209 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_sdin_event()
212 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_sdin_event()
216 regmap_update_bits(cs35l35->regmap, CS35L35_AMP_DIG_VOL_CTL, in cs35l35_sdin_event()
221 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_sdin_event()
225 regmap_update_bits(cs35l35->regmap, CS35L35_AMP_DIG_VOL_CTL, in cs35l35_sdin_event()
230 dev_err(component->dev, "Invalid event = 0x%x\n", event); in cs35l35_sdin_event()
231 ret = -EINVAL; in cs35l35_sdin_event()
239 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs35l35_main_amp_event()
246 if (cs35l35->pdata.bst_pdn_fet_on) in cs35l35_main_amp_event()
247 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_main_amp_event()
251 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_main_amp_event()
258 if (cs35l35->pdm_mode) in cs35l35_main_amp_event()
259 regmap_update_bits(cs35l35->regmap, in cs35l35_main_amp_event()
264 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, in cs35l35_main_amp_event()
268 regmap_bulk_read(cs35l35->regmap, CS35L35_INT_STATUS_1, in cs35l35_main_amp_event()
273 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, in cs35l35_main_amp_event()
276 if (cs35l35->pdata.bst_pdn_fet_on) in cs35l35_main_amp_event()
277 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_main_amp_event()
281 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_main_amp_event()
291 if (cs35l35->pdm_mode) in cs35l35_main_amp_event()
292 regmap_update_bits(cs35l35->regmap, in cs35l35_main_amp_event()
295 cs35l35->pdata.bst_vctl in cs35l35_main_amp_event()
300 dev_err(component->dev, "Invalid event = 0x%x\n", event); in cs35l35_main_amp_event()
306 static DECLARE_TLV_DB_SCALE(dig_vol_tlv, -10200, 50, 0);
368 struct snd_soc_component *component = codec_dai->component; in cs35l35_set_dai_fmt()
373 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_set_dai_fmt()
375 cs35l35->slave_mode = false; in cs35l35_set_dai_fmt()
378 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_set_dai_fmt()
380 cs35l35->slave_mode = true; in cs35l35_set_dai_fmt()
383 return -EINVAL; in cs35l35_set_dai_fmt()
388 cs35l35->i2s_mode = true; in cs35l35_set_dai_fmt()
389 cs35l35->pdm_mode = false; in cs35l35_set_dai_fmt()
392 cs35l35->pdm_mode = true; in cs35l35_set_dai_fmt()
393 cs35l35->i2s_mode = false; in cs35l35_set_dai_fmt()
396 return -EINVAL; in cs35l35_set_dai_fmt()
462 return -EINVAL; in cs35l35_get_clk_config()
469 struct snd_soc_component *component = dai->component; in cs35l35_hw_params()
471 struct classh_cfg *classh = &cs35l35->pdata.classh_algo; in cs35l35_hw_params()
478 int clk_ctl = cs35l35_get_clk_config(cs35l35->sysclk, srate); in cs35l35_hw_params()
481 dev_err(component->dev, "Invalid CLK:Rate %d:%d\n", in cs35l35_hw_params()
482 cs35l35->sysclk, srate); in cs35l35_hw_params()
483 return -EINVAL; in cs35l35_hw_params()
486 ret = regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL2, in cs35l35_hw_params()
489 dev_err(component->dev, "Failed to set port config %d\n", ret); in cs35l35_hw_params()
495 * When configured for the weak-drive detection path (CH_WKFET_DIS = 0) in cs35l35_hw_params()
496 * the Class H algorithm does not enable weak-drive operation for in cs35l35_hw_params()
501 if (classh->classh_wk_fet_disable == 0x00 && in cs35l35_hw_params()
503 ret = regmap_update_bits(cs35l35->regmap, in cs35l35_hw_params()
508 dev_err(component->dev, "Failed to set fet config %d\n", in cs35l35_hw_params()
516 * Just make sure your SCLK is fast enough to fill the frame in cs35l35_hw_params()
518 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in cs35l35_hw_params()
530 dev_err(component->dev, "Unsupported Width %d\n", in cs35l35_hw_params()
532 return -EINVAL; in cs35l35_hw_params()
534 regmap_update_bits(cs35l35->regmap, in cs35l35_hw_params()
539 if (cs35l35->pdata.stereo) { in cs35l35_hw_params()
540 regmap_update_bits(cs35l35->regmap, in cs35l35_hw_params()
548 if (cs35l35->i2s_mode) { in cs35l35_hw_params()
549 /* We have to take the SCLK to derive num sclks in cs35l35_hw_params()
552 if ((cs35l35->sclk / srate) % 4) { in cs35l35_hw_params()
553 dev_err(component->dev, "Unsupported sclk/fs ratio %d:%d\n", in cs35l35_hw_params()
554 cs35l35->sclk, srate); in cs35l35_hw_params()
555 return -EINVAL; in cs35l35_hw_params()
557 sp_sclks = ((cs35l35->sclk / srate) / 4) - 1; in cs35l35_hw_params()
560 if (cs35l35->slave_mode) { in cs35l35_hw_params()
567 dev_err(component->dev, "ratio not supported\n"); in cs35l35_hw_params()
568 return -EINVAL; in cs35l35_hw_params()
577 dev_err(component->dev, "ratio not supported\n"); in cs35l35_hw_params()
578 return -EINVAL; in cs35l35_hw_params()
581 ret = regmap_update_bits(cs35l35->regmap, in cs35l35_hw_params()
586 dev_err(component->dev, "Failed to set fsclk %d\n", ret); in cs35l35_hw_params()
606 struct snd_soc_component *component = dai->component; in cs35l35_pcm_startup()
609 if (!substream->runtime) in cs35l35_pcm_startup()
612 snd_pcm_hw_constraint_list(substream->runtime, 0, in cs35l35_pcm_startup()
615 regmap_update_bits(cs35l35->regmap, CS35L35_AMP_INP_DRV_CTL, in cs35l35_pcm_startup()
634 struct snd_soc_component *component = dai->component; in cs35l35_pdm_startup()
637 if (!substream->runtime) in cs35l35_pdm_startup()
640 snd_pcm_hw_constraint_list(substream->runtime, 0, in cs35l35_pdm_startup()
644 regmap_update_bits(cs35l35->regmap, CS35L35_AMP_INP_DRV_CTL, in cs35l35_pdm_startup()
654 struct snd_soc_component *component = dai->component; in cs35l35_dai_set_sysclk()
657 /* Need the SCLK Frequency regardless of sysclk source for I2S */ in cs35l35_dai_set_sysclk()
658 cs35l35->sclk = freq; in cs35l35_dai_set_sysclk()
678 .name = "cs35l35-pcm",
698 .name = "cs35l35-pdm",
730 dev_err(component->dev, "Invalid CLK Source\n"); in cs35l35_component_set_sysclk()
731 return -EINVAL; in cs35l35_component_set_sysclk()
745 cs35l35->sysclk = freq; in cs35l35_component_set_sysclk()
748 dev_err(component->dev, "Invalid CLK Frequency Input : %d\n", freq); in cs35l35_component_set_sysclk()
749 return -EINVAL; in cs35l35_component_set_sysclk()
752 ret = regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_component_set_sysclk()
756 dev_err(component->dev, "Failed to set sysclk %d\n", ret); in cs35l35_component_set_sysclk()
766 struct regmap *regmap = cs35l35->regmap; in cs35l35_boost_inductor()
826 dev_err(cs35l35->dev, "Invalid Inductor Value %d uH\n", in cs35l35_boost_inductor()
828 return -EINVAL; in cs35l35_boost_inductor()
836 struct classh_cfg *classh = &cs35l35->pdata.classh_algo; in cs35l35_component_probe()
837 struct monitor_cfg *monitor_config = &cs35l35->pdata.mon_cfg; in cs35l35_component_probe()
841 if (cs35l35->pdata.bst_vctl) in cs35l35_component_probe()
842 regmap_update_bits(cs35l35->regmap, CS35L35_BST_CVTR_V_CTL, in cs35l35_component_probe()
844 cs35l35->pdata.bst_vctl); in cs35l35_component_probe()
846 if (cs35l35->pdata.bst_ipk) in cs35l35_component_probe()
847 regmap_update_bits(cs35l35->regmap, CS35L35_BST_PEAK_I, in cs35l35_component_probe()
849 cs35l35->pdata.bst_ipk << in cs35l35_component_probe()
852 ret = cs35l35_boost_inductor(cs35l35, cs35l35->pdata.boost_ind); in cs35l35_component_probe()
856 if (cs35l35->pdata.gain_zc) in cs35l35_component_probe()
857 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, in cs35l35_component_probe()
859 cs35l35->pdata.gain_zc << in cs35l35_component_probe()
862 if (cs35l35->pdata.aud_channel) in cs35l35_component_probe()
863 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
866 cs35l35->pdata.aud_channel << in cs35l35_component_probe()
869 if (cs35l35->pdata.stereo) { in cs35l35_component_probe()
870 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
873 cs35l35->pdata.adv_channel << in cs35l35_component_probe()
875 if (cs35l35->pdata.shared_bst) in cs35l35_component_probe()
876 regmap_update_bits(cs35l35->regmap, CS35L35_CLASS_H_CTL, in cs35l35_component_probe()
885 if (cs35l35->pdata.sp_drv_str) in cs35l35_component_probe()
886 regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL1, in cs35l35_component_probe()
888 cs35l35->pdata.sp_drv_str << in cs35l35_component_probe()
890 if (cs35l35->pdata.sp_drv_unused) in cs35l35_component_probe()
891 regmap_update_bits(cs35l35->regmap, CS35L35_SP_FMT_CTL3, in cs35l35_component_probe()
893 cs35l35->pdata.sp_drv_unused << in cs35l35_component_probe()
896 if (classh->classh_algo_enable) { in cs35l35_component_probe()
897 if (classh->classh_bst_override) in cs35l35_component_probe()
898 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
901 classh->classh_bst_override << in cs35l35_component_probe()
903 if (classh->classh_bst_max_limit) in cs35l35_component_probe()
904 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
907 classh->classh_bst_max_limit << in cs35l35_component_probe()
909 if (classh->classh_mem_depth) in cs35l35_component_probe()
910 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
913 classh->classh_mem_depth << in cs35l35_component_probe()
915 if (classh->classh_headroom) in cs35l35_component_probe()
916 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
919 classh->classh_headroom << in cs35l35_component_probe()
921 if (classh->classh_release_rate) in cs35l35_component_probe()
922 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
925 classh->classh_release_rate << in cs35l35_component_probe()
927 if (classh->classh_wk_fet_disable) in cs35l35_component_probe()
928 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
931 classh->classh_wk_fet_disable << in cs35l35_component_probe()
933 if (classh->classh_wk_fet_delay) in cs35l35_component_probe()
934 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
937 classh->classh_wk_fet_delay << in cs35l35_component_probe()
939 if (classh->classh_wk_fet_thld) in cs35l35_component_probe()
940 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
943 classh->classh_wk_fet_thld << in cs35l35_component_probe()
945 if (classh->classh_vpch_auto) in cs35l35_component_probe()
946 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
949 classh->classh_vpch_auto << in cs35l35_component_probe()
951 if (classh->classh_vpch_rate) in cs35l35_component_probe()
952 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
955 classh->classh_vpch_rate << in cs35l35_component_probe()
957 if (classh->classh_vpch_man) in cs35l35_component_probe()
958 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
961 classh->classh_vpch_man << in cs35l35_component_probe()
965 if (monitor_config->is_present) { in cs35l35_component_probe()
966 if (monitor_config->vmon_specs) { in cs35l35_component_probe()
967 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
970 monitor_config->vmon_dpth << in cs35l35_component_probe()
972 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
975 monitor_config->vmon_loc << in cs35l35_component_probe()
977 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
980 monitor_config->vmon_frm << in cs35l35_component_probe()
983 if (monitor_config->imon_specs) { in cs35l35_component_probe()
984 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
987 monitor_config->imon_dpth << in cs35l35_component_probe()
989 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
992 monitor_config->imon_loc << in cs35l35_component_probe()
994 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
997 monitor_config->imon_frm << in cs35l35_component_probe()
999 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1002 monitor_config->imon_scale << in cs35l35_component_probe()
1005 if (monitor_config->vpmon_specs) { in cs35l35_component_probe()
1006 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1009 monitor_config->vpmon_dpth << in cs35l35_component_probe()
1011 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1014 monitor_config->vpmon_loc << in cs35l35_component_probe()
1016 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1019 monitor_config->vpmon_frm << in cs35l35_component_probe()
1022 if (monitor_config->vbstmon_specs) { in cs35l35_component_probe()
1023 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1026 monitor_config->vpmon_dpth << in cs35l35_component_probe()
1028 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1031 monitor_config->vbstmon_loc << in cs35l35_component_probe()
1033 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1036 monitor_config->vbstmon_frm << in cs35l35_component_probe()
1039 if (monitor_config->vpbrstat_specs) { in cs35l35_component_probe()
1040 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1043 monitor_config->vpbrstat_dpth << in cs35l35_component_probe()
1045 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1048 monitor_config->vpbrstat_loc << in cs35l35_component_probe()
1050 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1053 monitor_config->vpbrstat_frm << in cs35l35_component_probe()
1056 if (monitor_config->zerofill_specs) { in cs35l35_component_probe()
1057 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1060 monitor_config->zerofill_dpth << in cs35l35_component_probe()
1062 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1065 monitor_config->zerofill_loc << in cs35l35_component_probe()
1067 regmap_update_bits(cs35l35->regmap, in cs35l35_component_probe()
1070 monitor_config->zerofill_frm << in cs35l35_component_probe()
1115 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_4, &sticky4); in cs35l35_irq()
1116 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_3, &sticky3); in cs35l35_irq()
1117 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_2, &sticky2); in cs35l35_irq()
1118 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_1, &sticky1); in cs35l35_irq()
1120 regmap_read(cs35l35->regmap, CS35L35_INT_MASK_4, &mask4); in cs35l35_irq()
1121 regmap_read(cs35l35->regmap, CS35L35_INT_MASK_3, &mask3); in cs35l35_irq()
1122 regmap_read(cs35l35->regmap, CS35L35_INT_MASK_2, &mask2); in cs35l35_irq()
1123 regmap_read(cs35l35->regmap, CS35L35_INT_MASK_1, &mask1); in cs35l35_irq()
1131 complete(&cs35l35->pdn_done); in cs35l35_irq()
1134 regmap_read(cs35l35->regmap, CS35L35_INT_STATUS_1, ¤t1); in cs35l35_irq()
1138 dev_crit(cs35l35->dev, "Calibration Error\n"); in cs35l35_irq()
1143 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1146 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1150 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1157 dev_crit(cs35l35->dev, "AMP Short Error\n"); in cs35l35_irq()
1160 dev_dbg(cs35l35->dev, "Amp short error release\n"); in cs35l35_irq()
1161 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1164 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1168 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1175 dev_warn(cs35l35->dev, "Over temperature warning\n"); in cs35l35_irq()
1179 dev_dbg(cs35l35->dev, "Over temperature warn release\n"); in cs35l35_irq()
1180 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1183 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1187 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1194 dev_crit(cs35l35->dev, "Over temperature error\n"); in cs35l35_irq()
1197 dev_dbg(cs35l35->dev, "Over temperature error release\n"); in cs35l35_irq()
1198 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1201 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1205 regmap_update_bits(cs35l35->regmap, in cs35l35_irq()
1212 dev_crit(cs35l35->dev, "VBST error: powering off!\n"); in cs35l35_irq()
1213 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_irq()
1215 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_irq()
1220 dev_crit(cs35l35->dev, "LBST error: powering off!\n"); in cs35l35_irq()
1221 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_irq()
1223 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL1, in cs35l35_irq()
1228 dev_dbg(cs35l35->dev, "Error: Reactive Brownout\n"); in cs35l35_irq()
1231 dev_dbg(cs35l35->dev, "Error: VMON overflow\n"); in cs35l35_irq()
1234 dev_dbg(cs35l35->dev, "Error: IMON overflow\n"); in cs35l35_irq()
1243 struct device_node *np = i2c_client->dev.of_node; in cs35l35_handle_of_data()
1245 struct classh_cfg *classh_config = &pdata->classh_algo; in cs35l35_handle_of_data()
1246 struct monitor_cfg *monitor_config = &pdata->mon_cfg; in cs35l35_handle_of_data()
1250 const int mon_array_size = imon_array_size - 1; in cs35l35_handle_of_data()
1256 pdata->bst_pdn_fet_on = of_property_read_bool(np, in cs35l35_handle_of_data()
1257 "cirrus,boost-pdn-fet-on"); in cs35l35_handle_of_data()
1259 ret = of_property_read_u32(np, "cirrus,boost-ctl-millivolt", &val32); in cs35l35_handle_of_data()
1262 dev_err(&i2c_client->dev, in cs35l35_handle_of_data()
1264 return -EINVAL; in cs35l35_handle_of_data()
1266 pdata->bst_vctl = ((val32 - 2600) / 100) + 1; in cs35l35_handle_of_data()
1269 ret = of_property_read_u32(np, "cirrus,boost-peak-milliamp", &val32); in cs35l35_handle_of_data()
1272 dev_err(&i2c_client->dev, in cs35l35_handle_of_data()
1274 return -EINVAL; in cs35l35_handle_of_data()
1277 pdata->bst_ipk = ((val32 - 1680) / 110) | CS35L35_VALID_PDATA; in cs35l35_handle_of_data()
1280 ret = of_property_read_u32(np, "cirrus,boost-ind-nanohenry", &val32); in cs35l35_handle_of_data()
1282 pdata->boost_ind = val32; in cs35l35_handle_of_data()
1284 dev_err(&i2c_client->dev, "Inductor not specified.\n"); in cs35l35_handle_of_data()
1285 return -EINVAL; in cs35l35_handle_of_data()
1288 if (of_property_read_u32(np, "cirrus,sp-drv-strength", &val32) >= 0) in cs35l35_handle_of_data()
1289 pdata->sp_drv_str = val32; in cs35l35_handle_of_data()
1290 if (of_property_read_u32(np, "cirrus,sp-drv-unused", &val32) >= 0) in cs35l35_handle_of_data()
1291 pdata->sp_drv_unused = val32 | CS35L35_VALID_PDATA; in cs35l35_handle_of_data()
1293 pdata->stereo = of_property_read_bool(np, "cirrus,stereo-config"); in cs35l35_handle_of_data()
1295 if (pdata->stereo) { in cs35l35_handle_of_data()
1296 ret = of_property_read_u32(np, "cirrus,audio-channel", &val32); in cs35l35_handle_of_data()
1298 pdata->aud_channel = val32; in cs35l35_handle_of_data()
1300 ret = of_property_read_u32(np, "cirrus,advisory-channel", in cs35l35_handle_of_data()
1303 pdata->adv_channel = val32; in cs35l35_handle_of_data()
1305 pdata->shared_bst = of_property_read_bool(np, in cs35l35_handle_of_data()
1306 "cirrus,shared-boost"); in cs35l35_handle_of_data()
1309 pdata->ext_bst = of_property_read_bool(np, "cirrus,external-boost"); in cs35l35_handle_of_data()
1311 pdata->gain_zc = of_property_read_bool(np, "cirrus,amp-gain-zc"); in cs35l35_handle_of_data()
1313 classh = of_get_child_by_name(np, "cirrus,classh-internal-algo"); in cs35l35_handle_of_data()
1314 classh_config->classh_algo_enable = classh ? true : false; in cs35l35_handle_of_data()
1316 if (classh_config->classh_algo_enable) { in cs35l35_handle_of_data()
1317 classh_config->classh_bst_override = in cs35l35_handle_of_data()
1318 of_property_read_bool(np, "cirrus,classh-bst-overide"); in cs35l35_handle_of_data()
1321 "cirrus,classh-bst-max-limit", in cs35l35_handle_of_data()
1325 classh_config->classh_bst_max_limit = val32; in cs35l35_handle_of_data()
1329 "cirrus,classh-bst-max-limit", in cs35l35_handle_of_data()
1333 classh_config->classh_bst_max_limit = val32; in cs35l35_handle_of_data()
1336 ret = of_property_read_u32(classh, "cirrus,classh-mem-depth", in cs35l35_handle_of_data()
1340 classh_config->classh_mem_depth = val32; in cs35l35_handle_of_data()
1343 ret = of_property_read_u32(classh, "cirrus,classh-release-rate", in cs35l35_handle_of_data()
1346 classh_config->classh_release_rate = val32; in cs35l35_handle_of_data()
1348 ret = of_property_read_u32(classh, "cirrus,classh-headroom", in cs35l35_handle_of_data()
1352 classh_config->classh_headroom = val32; in cs35l35_handle_of_data()
1356 "cirrus,classh-wk-fet-disable", in cs35l35_handle_of_data()
1359 classh_config->classh_wk_fet_disable = val32; in cs35l35_handle_of_data()
1361 ret = of_property_read_u32(classh, "cirrus,classh-wk-fet-delay", in cs35l35_handle_of_data()
1365 classh_config->classh_wk_fet_delay = val32; in cs35l35_handle_of_data()
1368 ret = of_property_read_u32(classh, "cirrus,classh-wk-fet-thld", in cs35l35_handle_of_data()
1371 classh_config->classh_wk_fet_thld = val32; in cs35l35_handle_of_data()
1373 ret = of_property_read_u32(classh, "cirrus,classh-vpch-auto", in cs35l35_handle_of_data()
1377 classh_config->classh_vpch_auto = val32; in cs35l35_handle_of_data()
1380 ret = of_property_read_u32(classh, "cirrus,classh-vpch-rate", in cs35l35_handle_of_data()
1384 classh_config->classh_vpch_rate = val32; in cs35l35_handle_of_data()
1387 ret = of_property_read_u32(classh, "cirrus,classh-vpch-man", in cs35l35_handle_of_data()
1390 classh_config->classh_vpch_man = val32; in cs35l35_handle_of_data()
1395 signal_format = of_get_child_by_name(np, "cirrus,monitor-signal-format"); in cs35l35_handle_of_data()
1396 monitor_config->is_present = signal_format ? true : false; in cs35l35_handle_of_data()
1397 if (monitor_config->is_present) { in cs35l35_handle_of_data()
1401 monitor_config->imon_specs = true; in cs35l35_handle_of_data()
1402 monitor_config->imon_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1403 monitor_config->imon_loc = monitor_array[1]; in cs35l35_handle_of_data()
1404 monitor_config->imon_frm = monitor_array[2]; in cs35l35_handle_of_data()
1405 monitor_config->imon_scale = monitor_array[3]; in cs35l35_handle_of_data()
1410 monitor_config->vmon_specs = true; in cs35l35_handle_of_data()
1411 monitor_config->vmon_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1412 monitor_config->vmon_loc = monitor_array[1]; in cs35l35_handle_of_data()
1413 monitor_config->vmon_frm = monitor_array[2]; in cs35l35_handle_of_data()
1418 monitor_config->vpmon_specs = true; in cs35l35_handle_of_data()
1419 monitor_config->vpmon_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1420 monitor_config->vpmon_loc = monitor_array[1]; in cs35l35_handle_of_data()
1421 monitor_config->vpmon_frm = monitor_array[2]; in cs35l35_handle_of_data()
1426 monitor_config->vbstmon_specs = true; in cs35l35_handle_of_data()
1427 monitor_config->vbstmon_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1428 monitor_config->vbstmon_loc = monitor_array[1]; in cs35l35_handle_of_data()
1429 monitor_config->vbstmon_frm = monitor_array[2]; in cs35l35_handle_of_data()
1434 monitor_config->vpbrstat_specs = true; in cs35l35_handle_of_data()
1435 monitor_config->vpbrstat_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1436 monitor_config->vpbrstat_loc = monitor_array[1]; in cs35l35_handle_of_data()
1437 monitor_config->vpbrstat_frm = monitor_array[2]; in cs35l35_handle_of_data()
1442 monitor_config->zerofill_specs = true; in cs35l35_handle_of_data()
1443 monitor_config->zerofill_dpth = monitor_array[0]; in cs35l35_handle_of_data()
1444 monitor_config->zerofill_loc = monitor_array[1]; in cs35l35_handle_of_data()
1445 monitor_config->zerofill_frm = monitor_array[2]; in cs35l35_handle_of_data()
1473 struct device *dev = &i2c_client->dev; in cs35l35_i2c_probe()
1482 return -ENOMEM; in cs35l35_i2c_probe()
1484 cs35l35->dev = dev; in cs35l35_i2c_probe()
1487 cs35l35->regmap = devm_regmap_init_i2c(i2c_client, &cs35l35_regmap); in cs35l35_i2c_probe()
1488 if (IS_ERR(cs35l35->regmap)) { in cs35l35_i2c_probe()
1489 ret = PTR_ERR(cs35l35->regmap); in cs35l35_i2c_probe()
1495 cs35l35->supplies[i].supply = cs35l35_supplies[i]; in cs35l35_i2c_probe()
1497 cs35l35->num_supplies = ARRAY_SIZE(cs35l35_supplies); in cs35l35_i2c_probe()
1499 ret = devm_regulator_bulk_get(dev, cs35l35->num_supplies, in cs35l35_i2c_probe()
1500 cs35l35->supplies); in cs35l35_i2c_probe()
1507 cs35l35->pdata = *pdata; in cs35l35_i2c_probe()
1512 return -ENOMEM; in cs35l35_i2c_probe()
1513 if (i2c_client->dev.of_node) { in cs35l35_i2c_probe()
1519 cs35l35->pdata = *pdata; in cs35l35_i2c_probe()
1522 ret = regulator_bulk_enable(cs35l35->num_supplies, in cs35l35_i2c_probe()
1523 cs35l35->supplies); in cs35l35_i2c_probe()
1530 cs35l35->reset_gpio = devm_gpiod_get_optional(dev, "reset", in cs35l35_i2c_probe()
1532 if (IS_ERR(cs35l35->reset_gpio)) { in cs35l35_i2c_probe()
1533 ret = PTR_ERR(cs35l35->reset_gpio); in cs35l35_i2c_probe()
1534 cs35l35->reset_gpio = NULL; in cs35l35_i2c_probe()
1535 if (ret == -EBUSY) { in cs35l35_i2c_probe()
1546 init_completion(&cs35l35->pdn_done); in cs35l35_i2c_probe()
1548 ret = devm_request_threaded_irq(dev, i2c_client->irq, NULL, cs35l35_irq, in cs35l35_i2c_probe()
1556 ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_AB, ®); in cs35l35_i2c_probe()
1559 ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_CD, ®); in cs35l35_i2c_probe()
1561 ret = regmap_read(cs35l35->regmap, CS35L35_DEVID_E, ®); in cs35l35_i2c_probe()
1567 ret = -ENODEV; in cs35l35_i2c_probe()
1571 ret = regmap_read(cs35l35->regmap, CS35L35_REV_ID, ®); in cs35l35_i2c_probe()
1577 ret = regmap_register_patch(cs35l35->regmap, cs35l35_errata_patch, in cs35l35_i2c_probe()
1588 regmap_write(cs35l35->regmap, CS35L35_INT_MASK_1, in cs35l35_i2c_probe()
1590 regmap_write(cs35l35->regmap, CS35L35_INT_MASK_2, in cs35l35_i2c_probe()
1592 regmap_write(cs35l35->regmap, CS35L35_INT_MASK_3, in cs35l35_i2c_probe()
1594 regmap_write(cs35l35->regmap, CS35L35_INT_MASK_4, in cs35l35_i2c_probe()
1597 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_i2c_probe()
1601 if (cs35l35->pdata.bst_pdn_fet_on) in cs35l35_i2c_probe()
1602 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_i2c_probe()
1606 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL2, in cs35l35_i2c_probe()
1610 regmap_update_bits(cs35l35->regmap, CS35L35_PWRCTL3, in cs35l35_i2c_probe()
1614 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, in cs35l35_i2c_probe()
1627 regulator_bulk_disable(cs35l35->num_supplies, in cs35l35_i2c_probe()
1628 cs35l35->supplies); in cs35l35_i2c_probe()
1629 gpiod_set_value_cansleep(cs35l35->reset_gpio, 0); in cs35l35_i2c_probe()
1638 regulator_bulk_disable(cs35l35->num_supplies, cs35l35->supplies); in cs35l35_i2c_remove()
1639 gpiod_set_value_cansleep(cs35l35->reset_gpio, 0); in cs35l35_i2c_remove()