Lines Matching +full:static +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0
27 static const char *cs530x_supply_names[CS530X_NUM_SUPPLIES] = {
28 "vdd-a",
29 "vdd-io",
32 static const struct reg_default cs530x_reg_defaults[] = {
55 static bool cs530x_read_and_write_regs(unsigned int reg) in cs530x_read_and_write_regs()
84 static bool cs530x_readable_register(struct device *dev, unsigned int reg) in cs530x_readable_register()
95 static bool cs530x_writeable_register(struct device *dev, unsigned int reg) in cs530x_writeable_register()
106 static int cs530x_put_volsw_vu(struct snd_kcontrol *kcontrol, in cs530x_put_volsw_vu()
112 struct regmap *regmap = cs530x->regmap; in cs530x_put_volsw_vu()
130 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -1270, 50, 0);
132 static const char * const cs530x_in_filter_text[] = {
133 "Min Phase Slow Roll-off",
134 "Min Phase Fast Roll-off",
135 "Linear Phase Slow Roll-off",
136 "Linear Phase Fast Roll-off",
139 static SOC_ENUM_SINGLE_DECL(cs530x_in_filter_enum, CS530X_IN_FILTER,
143 static const char * const cs530x_in_4ch_sum_text[] = {
149 static SOC_ENUM_SINGLE_DECL(cs530x_in_sum_ch4_enum, CS530X_IN_RAMP_SUM,
153 static const struct snd_kcontrol_new cs530x_in_sum_4ch_controls[] = {
157 static const char * const cs530x_in_8ch_sum_text[] = {
164 static SOC_ENUM_SINGLE_DECL(cs530x_in_sum_ch8_enum, CS530X_IN_RAMP_SUM,
168 static const struct snd_kcontrol_new cs530x_in_sum_8ch_controls[] = {
173 static const char * const cs530x_vol_ramp_text[] = {
178 static SOC_ENUM_SINGLE_DECL(cs530x_ramp_inc_enum, CS530X_IN_RAMP_SUM,
182 static SOC_ENUM_SINGLE_DECL(cs530x_ramp_dec_enum, CS530X_IN_RAMP_SUM,
186 static const struct snd_kcontrol_new cs530x_in_1_to_2_controls[] = {
200 static const struct snd_kcontrol_new cs530x_in_3_to_4_controls[] = {
210 static const struct snd_kcontrol_new cs530x_in_5_to_8_controls[] = {
226 static int cs530x_adc_event(struct snd_soc_dapm_widget *w, in cs530x_adc_event()
229 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in cs530x_adc_event()
231 struct regmap *regmap = cs530x->regmap; in cs530x_adc_event()
235 cs530x->adc_pairs_count++; in cs530x_adc_event()
239 (w->shift * 2), CS530X_IN_MUTE); in cs530x_adc_event()
241 ((w->shift+1) * 2), CS530X_IN_MUTE); in cs530x_adc_event()
243 cs530x->adc_pairs_count--; in cs530x_adc_event()
244 if (!cs530x->adc_pairs_count) { in cs530x_adc_event()
252 (w->shift * 2), CS530X_IN_MUTE); in cs530x_adc_event()
254 ((w->shift+1) * 2), CS530X_IN_MUTE); in cs530x_adc_event()
258 return -EINVAL; in cs530x_adc_event()
264 static const struct snd_kcontrol_new adc12_ctrl =
267 static const struct snd_kcontrol_new adc34_ctrl =
270 static const struct snd_kcontrol_new adc56_ctrl =
273 static const struct snd_kcontrol_new adc78_ctrl =
276 static const struct snd_kcontrol_new in_hpf_ctrl =
280 static const struct snd_soc_dapm_widget cs530x_gen_dapm_widgets[] = {
281 SND_SOC_DAPM_SUPPLY("Global Enable", CS530X_CHIP_ENABLE, 0, 0, NULL, 0),
285 static const struct snd_soc_dapm_widget cs530x_adc_ch12_dapm_widgets[] = {
293 SND_SOC_DAPM_SWITCH("ADC12 Enable", SND_SOC_NOPM, 0, 0, &adc12_ctrl),
299 static const struct snd_soc_dapm_widget cs530x_adc_ch34_dapm_widgets[] = {
307 SND_SOC_DAPM_SWITCH("ADC34 Enable", SND_SOC_NOPM, 0, 0, &adc34_ctrl),
311 static const struct snd_soc_dapm_widget cs530x_adc_ch58_dapm_widgets[] = {
321 SND_SOC_DAPM_SWITCH("ADC56 Enable", SND_SOC_NOPM, 0, 0, &adc56_ctrl),
327 SND_SOC_DAPM_SWITCH("ADC78 Enable", SND_SOC_NOPM, 0, 0, &adc78_ctrl),
330 static const struct snd_soc_dapm_route adc_ch1_2_routes[] = {
331 { "ADC1", NULL, "Global Enable" },
332 { "ADC2", NULL, "Global Enable" },
334 { "ADC12 Enable", "Switch", "IN1" },
335 { "ADC12 Enable", "Switch", "IN2" },
336 { "ADC1", NULL, "ADC12 Enable" },
337 { "ADC2", NULL, "ADC12 Enable" },
346 static const struct snd_soc_dapm_route adc_ch3_4_routes[] = {
347 { "ADC3", NULL, "Global Enable" },
348 { "ADC4", NULL, "Global Enable" },
350 { "ADC34 Enable", "Switch", "IN3" },
351 { "ADC34 Enable", "Switch", "IN4" },
352 { "ADC3", NULL, "ADC34 Enable" },
353 { "ADC4", NULL, "ADC34 Enable" },
361 static const struct snd_soc_dapm_route adc_ch5_8_routes[] = {
362 { "ADC5", NULL, "Global Enable" },
363 { "ADC6", NULL, "Global Enable" },
364 { "ADC7", NULL, "Global Enable" },
365 { "ADC8", NULL, "Global Enable" },
367 { "ADC56 Enable", "Switch", "IN5" },
368 { "ADC56 Enable", "Switch", "IN6" },
369 { "ADC5", NULL, "ADC56 Enable" },
370 { "ADC6", NULL, "ADC56 Enable" },
377 { "ADC78 Enable", "Switch", "IN7" },
378 { "ADC78 Enable", "Switch", "IN8" },
379 { "ADC7", NULL, "ADC78 Enable" },
380 { "ADC8", NULL, "ADC78 Enable" },
388 static void cs530x_add_12_adc_widgets(struct snd_soc_component *component) in cs530x_add_12_adc_widgets()
403 static void cs530x_add_34_adc_widgets(struct snd_soc_component *component) in cs530x_add_34_adc_widgets()
418 static int cs530x_set_bclk(struct snd_soc_component *component, const int freq) in cs530x_set_bclk()
421 struct regmap *regmap = cs530x->regmap; in cs530x_set_bclk()
442 dev_err(component->dev, "Invalid BCLK frequency %d\n", freq); in cs530x_set_bclk()
443 return -EINVAL; in cs530x_set_bclk()
446 dev_dbg(component->dev, "BCLK frequency is %d\n", freq); in cs530x_set_bclk()
452 static int cs530x_set_pll_refclk(struct snd_soc_component *component, in cs530x_set_pll_refclk()
456 struct regmap *regmap = priv->regmap; in cs530x_set_pll_refclk()
477 dev_err(component->dev, "Invalid PLL refclk %d\n", freq); in cs530x_set_pll_refclk()
478 return -EINVAL; in cs530x_set_pll_refclk()
485 static int cs530x_hw_params(struct snd_pcm_substream *substream, in cs530x_hw_params()
489 struct snd_soc_component *component = dai->component; in cs530x_hw_params()
491 struct regmap *regmap = cs530x->regmap; in cs530x_hw_params()
521 dev_err(component->dev, "Invalid sample rate %d\n", fs); in cs530x_hw_params()
522 return -EINVAL; in cs530x_hw_params()
525 cs530x->fs = fs; in cs530x_hw_params()
532 dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n", in cs530x_hw_params()
533 cs530x->tdm_slots, cs530x->tdm_width); in cs530x_hw_params()
535 cs530x->tdm_width, in cs530x_hw_params()
536 cs530x->tdm_slots, in cs530x_hw_params()
552 static int cs530x_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) in cs530x_set_fmt()
554 struct snd_soc_component *component = dai->component; in cs530x_set_fmt()
556 struct regmap *regmap = priv->regmap; in cs530x_set_fmt()
566 return -EINVAL; in cs530x_set_fmt()
580 return -EINVAL; in cs530x_set_fmt()
590 return -EINVAL; in cs530x_set_fmt()
601 static bool cs530x_check_mclk_freq(struct snd_soc_component *component, in cs530x_check_mclk_freq()
611 dev_err(component->dev, "Invalid MCLK %d\n", freq); in cs530x_check_mclk_freq()
616 static int cs530x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, in cs530x_set_tdm_slot()
619 struct snd_soc_component *component = dai->component; in cs530x_set_tdm_slot()
621 struct regmap *regmap = cs530x->regmap; in cs530x_set_tdm_slot()
656 dev_err(component->dev, "Invalid TX slot(s) 0x%x\n", tx_mask); in cs530x_set_tdm_slot()
657 return -EINVAL; in cs530x_set_tdm_slot()
660 cs530x->tdm_width = slot_width; in cs530x_set_tdm_slot()
661 cs530x->tdm_slots = slots; in cs530x_set_tdm_slot()
668 static const struct snd_soc_dai_ops cs530x_dai_ops = {
674 static const struct snd_soc_dai_driver cs530x_dai = {
675 .name = "cs530x-dai",
688 static int cs530x_set_pll(struct snd_soc_component *component, int pll_id, in cs530x_set_pll()
693 struct regmap *regmap = cs530x->regmap; in cs530x_set_pll()
706 return -EINVAL; in cs530x_set_pll()
716 dev_err(component->dev, "Invalid PLL source %d\n", source); in cs530x_set_pll()
717 return -EINVAL; in cs530x_set_pll()
724 static int cs530x_component_probe(struct snd_soc_component *component) in cs530x_component_probe()
733 switch (cs530x->devtype) { in cs530x_component_probe()
769 dev_err(component->dev, "Invalid device type %d\n", in cs530x_component_probe()
770 cs530x->devtype); in cs530x_component_probe()
771 return -EINVAL; in cs530x_component_probe()
777 static int cs530x_set_sysclk(struct snd_soc_component *component, int clk_id, in cs530x_set_sysclk()
781 struct regmap *regmap = cs530x->regmap; in cs530x_set_sysclk()
786 dev_err(component->dev, "Invalid MCLK source rate %d\n", in cs530x_set_sysclk()
788 return -EINVAL; in cs530x_set_sysclk()
791 cs530x->mclk_rate = freq; in cs530x_set_sysclk()
796 dev_err(component->dev, "Invalid clock id %d\n", clk_id); in cs530x_set_sysclk()
797 return -EINVAL; in cs530x_set_sysclk()
805 static const struct snd_soc_component_driver soc_component_dev_cs530x = {
826 static int cs530x_check_device_id(struct cs530x_priv *cs530x) in cs530x_check_device_id()
828 struct device *dev = cs530x->dev; in cs530x_check_device_id()
832 ret = regmap_read(cs530x->regmap, CS530X_DEVID, &dev_id); in cs530x_check_device_id()
836 ret = regmap_read(cs530x->regmap, CS530X_REVID, &rev); in cs530x_check_device_id()
844 cs530x->num_adcs = 2; in cs530x_check_device_id()
847 cs530x->num_adcs = 4; in cs530x_check_device_id()
850 cs530x->num_adcs = 8; in cs530x_check_device_id()
853 return dev_err_probe(dev, -EINVAL, "Invalid device ID 0x%x\n", in cs530x_check_device_id()
860 static int cs530x_parse_device_properties(struct cs530x_priv *cs530x) in cs530x_parse_device_properties()
862 struct regmap *regmap = cs530x->regmap; in cs530x_parse_device_properties()
863 struct device *dev = cs530x->dev; in cs530x_parse_device_properties()
866 switch (cs530x->num_adcs) { in cs530x_parse_device_properties()
868 if (device_property_read_bool(dev, "cirrus,in-hiz-pin78")) in cs530x_parse_device_properties()
871 if (device_property_read_bool(dev, "cirrus,in-hiz-pin56")) in cs530x_parse_device_properties()
876 if (device_property_read_bool(dev, "cirrus,in-hiz-pin34")) in cs530x_parse_device_properties()
881 if (device_property_read_bool(dev, "cirrus,in-hiz-pin12")) in cs530x_parse_device_properties()
886 return dev_err_probe(dev, -EINVAL, in cs530x_parse_device_properties()
888 cs530x->num_adcs); in cs530x_parse_device_properties()
894 struct device *dev = cs530x->dev; in cs530x_probe()
897 cs530x->dev_dai = devm_kmemdup(dev, &cs530x_dai, in cs530x_probe()
898 sizeof(*(cs530x->dev_dai)), in cs530x_probe()
900 if (!cs530x->dev_dai) in cs530x_probe()
901 return -ENOMEM; in cs530x_probe()
903 for (i = 0; i < ARRAY_SIZE(cs530x->supplies); i++) in cs530x_probe()
904 cs530x->supplies[i].supply = cs530x_supply_names[i]; in cs530x_probe()
906 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(cs530x->supplies), in cs530x_probe()
907 cs530x->supplies); in cs530x_probe()
911 ret = regulator_bulk_enable(ARRAY_SIZE(cs530x->supplies), in cs530x_probe()
912 cs530x->supplies); in cs530x_probe()
914 return dev_err_probe(dev, ret, "Failed to enable supplies"); in cs530x_probe()
916 cs530x->reset_gpio = devm_gpiod_get_optional(dev, "reset", in cs530x_probe()
918 if (IS_ERR(cs530x->reset_gpio)) { in cs530x_probe()
919 ret = dev_err_probe(dev, PTR_ERR(cs530x->reset_gpio), in cs530x_probe()
924 if (cs530x->reset_gpio) { in cs530x_probe()
926 gpiod_set_value_cansleep(cs530x->reset_gpio, 0); in cs530x_probe()
934 if (!cs530x->reset_gpio) { in cs530x_probe()
935 ret = regmap_write(cs530x->regmap, CS530X_SW_RESET, in cs530x_probe()
947 cs530x->dev_dai->capture.channels_max = cs530x->num_adcs; in cs530x_probe()
950 &soc_component_dev_cs530x, cs530x->dev_dai, 1); in cs530x_probe()
959 gpiod_set_value_cansleep(cs530x->reset_gpio, 1); in cs530x_probe()
962 regulator_bulk_disable(ARRAY_SIZE(cs530x->supplies), in cs530x_probe()
963 cs530x->supplies); in cs530x_probe()