Lines Matching +full:sense +full:- +full:freq
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * max98927.c -- MAX98927 ALSA Soc Audio driver
5 * Copyright (C) 2016-2017 Maxim Integrated Products
141 struct snd_soc_component *component = codec_dai->component; in max98927_dai_set_fmt()
148 dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); in max98927_dai_set_fmt()
155 max98927->master = true; in max98927_dai_set_fmt()
159 dev_err(component->dev, "DAI clock mode unsupported\n"); in max98927_dai_set_fmt()
160 return -EINVAL; in max98927_dai_set_fmt()
163 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
175 dev_err(component->dev, "DAI invert mode unsupported\n"); in max98927_dai_set_fmt()
176 return -EINVAL; in max98927_dai_set_fmt()
179 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
202 return -EINVAL; in max98927_dai_set_fmt()
204 max98927->iface = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in max98927_dai_set_fmt()
208 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
213 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
218 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
222 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
227 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
231 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
235 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
267 struct snd_soc_component *component = max98927->component; in max98927_set_clock()
269 int blr_clk_ratio = params_channels(params) * max98927->ch_size; in max98927_set_clock()
272 if (max98927->master) { in max98927_set_clock()
276 if (rate_table[i] >= max98927->sysclk) in max98927_set_clock()
280 dev_err(component->dev, "failed to find proper clock rate.\n"); in max98927_set_clock()
281 return -EINVAL; in max98927_set_clock()
283 regmap_update_bits(max98927->regmap, in max98927_set_clock()
289 if (!max98927->tdm_mode) { in max98927_set_clock()
293 dev_err(component->dev, "format unsupported %d\n", in max98927_set_clock()
295 return -EINVAL; in max98927_set_clock()
298 regmap_update_bits(max98927->regmap, in max98927_set_clock()
310 struct snd_soc_component *component = dai->component; in max98927_dai_hw_params()
327 dev_err(component->dev, "format unsupported %d\n", in max98927_dai_hw_params()
332 max98927->ch_size = snd_pcm_format_width(params_format(params)); in max98927_dai_hw_params()
334 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
338 dev_dbg(component->dev, "format supported %d", in max98927_dai_hw_params()
371 dev_err(component->dev, "rate %d not supported\n", in max98927_dai_hw_params()
376 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
380 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
386 if (max98927->interleave_mode && in max98927_dai_hw_params()
388 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
391 sampling_rate - 3); in max98927_dai_hw_params()
393 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
399 return -EINVAL; in max98927_dai_hw_params()
406 struct snd_soc_component *component = dai->component; in max98927_dai_tdm_slot()
411 max98927->tdm_mode = true; in max98927_dai_tdm_slot()
416 dev_err(component->dev, "BCLK %d not supported\n", in max98927_dai_tdm_slot()
418 return -EINVAL; in max98927_dai_tdm_slot()
421 regmap_update_bits(max98927->regmap, in max98927_dai_tdm_slot()
438 dev_err(component->dev, "format unsupported %d\n", in max98927_dai_tdm_slot()
440 return -EINVAL; in max98927_dai_tdm_slot()
443 regmap_update_bits(max98927->regmap, in max98927_dai_tdm_slot()
448 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
451 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
456 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
459 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
463 /* Tx slot Hi-Z configuration */ in max98927_dai_tdm_slot()
464 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
467 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
480 int clk_id, unsigned int freq, int dir) in max98927_dai_set_sysclk() argument
482 struct snd_soc_component *component = dai->component; in max98927_dai_set_sysclk()
485 max98927->sysclk = freq; in max98927_dai_set_sysclk()
499 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98927_dac_event()
504 max98927->tdm_mode = false; in max98927_dac_event()
507 regmap_update_bits(max98927->regmap, in max98927_dac_event()
510 regmap_update_bits(max98927->regmap, in max98927_dac_event()
515 regmap_update_bits(max98927->regmap, in max98927_dac_event()
518 regmap_update_bits(max98927->regmap, in max98927_dac_event()
549 SND_SOC_DAPM_AIF_OUT("Voltage Sense", "HiFi Capture", 0,
551 SND_SOC_DAPM_AIF_OUT("Current Sense", "HiFi Capture", 0,
553 SND_SOC_DAPM_SWITCH("VI Sense", SND_SOC_NOPM, 0, 0,
560 static DECLARE_TLV_DB_SCALE(max98927_digital_tlv, -1600, 25, 0);
628 0, (1<<MAX98927_AMP_VOL_WIDTH)-1, 0,
649 { "VI Sense", "Switch", "VMON" },
650 { "VI Sense", "Switch", "IMON" },
651 { "Voltage Sense", NULL, "VI Sense" },
652 { "Current Sense", NULL, "VI Sense" },
657 .name = "max98927-aif1",
680 max98927->component = component; in max98927_probe()
683 regmap_write(max98927->regmap, in max98927_probe()
687 regmap_write(max98927->regmap, in max98927_probe()
690 regmap_write(max98927->regmap, in max98927_probe()
693 regmap_write(max98927->regmap, in max98927_probe()
696 regmap_write(max98927->regmap, in max98927_probe()
700 regmap_write(max98927->regmap, in max98927_probe()
703 regmap_write(max98927->regmap, in max98927_probe()
707 regmap_write(max98927->regmap, in max98927_probe()
711 regmap_write(max98927->regmap, in max98927_probe()
715 regmap_write(max98927->regmap, in max98927_probe()
718 regmap_write(max98927->regmap, in max98927_probe()
722 regmap_write(max98927->regmap, in max98927_probe()
725 regmap_write(max98927->regmap, in max98927_probe()
728 regmap_write(max98927->regmap, in max98927_probe()
732 regmap_write(max98927->regmap, in max98927_probe()
736 regmap_write(max98927->regmap, in max98927_probe()
739 regmap_write(max98927->regmap, in max98927_probe()
742 regmap_write(max98927->regmap, in max98927_probe()
747 regmap_write(max98927->regmap, in max98927_probe()
749 (max98927->i_l_slot<<MAX98927_PCM_TX_CH_SRC_A_I_SHIFT| in max98927_probe()
750 max98927->v_l_slot)&0xFF); in max98927_probe()
752 if (max98927->v_l_slot < 8) { in max98927_probe()
753 regmap_update_bits(max98927->regmap, in max98927_probe()
755 1 << max98927->v_l_slot, 0); in max98927_probe()
756 regmap_update_bits(max98927->regmap, in max98927_probe()
758 1 << max98927->v_l_slot, in max98927_probe()
759 1 << max98927->v_l_slot); in max98927_probe()
761 regmap_update_bits(max98927->regmap, in max98927_probe()
763 1 << (max98927->v_l_slot - 8), 0); in max98927_probe()
764 regmap_update_bits(max98927->regmap, in max98927_probe()
766 1 << (max98927->v_l_slot - 8), in max98927_probe()
767 1 << (max98927->v_l_slot - 8)); in max98927_probe()
770 if (max98927->i_l_slot < 8) { in max98927_probe()
771 regmap_update_bits(max98927->regmap, in max98927_probe()
773 1 << max98927->i_l_slot, 0); in max98927_probe()
774 regmap_update_bits(max98927->regmap, in max98927_probe()
776 1 << max98927->i_l_slot, in max98927_probe()
777 1 << max98927->i_l_slot); in max98927_probe()
779 regmap_update_bits(max98927->regmap, in max98927_probe()
781 1 << (max98927->i_l_slot - 8), 0); in max98927_probe()
782 regmap_update_bits(max98927->regmap, in max98927_probe()
784 1 << (max98927->i_l_slot - 8), in max98927_probe()
785 1 << (max98927->i_l_slot - 8)); in max98927_probe()
789 if (max98927->interleave_mode) in max98927_probe()
790 regmap_update_bits(max98927->regmap, in max98927_probe()
802 regcache_cache_only(max98927->regmap, true); in max98927_suspend()
803 regcache_mark_dirty(max98927->regmap); in max98927_suspend()
810 regmap_write(max98927->regmap, in max98927_resume()
812 regcache_cache_only(max98927->regmap, false); in max98927_resume()
813 regcache_sync(max98927->regmap); in max98927_resume()
851 struct device *dev = &i2c->dev; in max98927_slot_config()
853 if (!device_property_read_u32(dev, "vmon-slot-no", &value)) in max98927_slot_config()
854 max98927->v_l_slot = value & 0xF; in max98927_slot_config()
856 max98927->v_l_slot = 0; in max98927_slot_config()
858 if (!device_property_read_u32(dev, "imon-slot-no", &value)) in max98927_slot_config()
859 max98927->i_l_slot = value & 0xF; in max98927_slot_config()
861 max98927->i_l_slot = 1; in max98927_slot_config()
872 max98927 = devm_kzalloc(&i2c->dev, in max98927_i2c_probe()
876 ret = -ENOMEM; in max98927_i2c_probe()
882 if (!of_property_read_u32(i2c->dev.of_node, in max98927_i2c_probe()
885 max98927->interleave_mode = true; in max98927_i2c_probe()
887 max98927->interleave_mode = false; in max98927_i2c_probe()
889 max98927->interleave_mode = false; in max98927_i2c_probe()
892 max98927->regmap in max98927_i2c_probe()
894 if (IS_ERR(max98927->regmap)) { in max98927_i2c_probe()
895 ret = PTR_ERR(max98927->regmap); in max98927_i2c_probe()
896 dev_err(&i2c->dev, in max98927_i2c_probe()
902 ret = regmap_read(max98927->regmap, in max98927_i2c_probe()
905 dev_err(&i2c->dev, in max98927_i2c_probe()
909 dev_info(&i2c->dev, "MAX98927 revisionID: 0x%02X\n", reg); in max98927_i2c_probe()
915 ret = devm_snd_soc_register_component(&i2c->dev, in max98927_i2c_probe()
919 dev_err(&i2c->dev, "Failed to register component: %d\n", ret); in max98927_i2c_probe()