Lines Matching +full:vmon +full:- +full:slot +full:- +full:no

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
142 struct snd_soc_component *component = codec_dai->component; in max98927_dai_set_fmt()
149 dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); in max98927_dai_set_fmt()
153 max98927->provider = false; in max98927_dai_set_fmt()
157 max98927->provider = true; in max98927_dai_set_fmt()
161 dev_err(component->dev, "DAI clock mode unsupported\n"); in max98927_dai_set_fmt()
162 return -EINVAL; in max98927_dai_set_fmt()
165 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
177 dev_err(component->dev, "DAI invert mode unsupported\n"); in max98927_dai_set_fmt()
178 return -EINVAL; in max98927_dai_set_fmt()
181 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
204 return -EINVAL; in max98927_dai_set_fmt()
206 max98927->iface = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in max98927_dai_set_fmt()
210 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
215 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
220 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
224 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
229 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
233 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
237 regmap_update_bits(max98927->regmap, in max98927_dai_set_fmt()
269 struct snd_soc_component *component = max98927->component; in max98927_set_clock()
271 int blr_clk_ratio = params_channels(params) * max98927->ch_size; in max98927_set_clock()
274 if (max98927->provider) { in max98927_set_clock()
278 if (rate_table[i] >= max98927->sysclk) in max98927_set_clock()
282 dev_err(component->dev, "failed to find proper clock rate.\n"); in max98927_set_clock()
283 return -EINVAL; in max98927_set_clock()
285 regmap_update_bits(max98927->regmap, in max98927_set_clock()
291 if (!max98927->tdm_mode) { in max98927_set_clock()
295 dev_err(component->dev, "format unsupported %d\n", in max98927_set_clock()
297 return -EINVAL; in max98927_set_clock()
300 regmap_update_bits(max98927->regmap, in max98927_set_clock()
312 struct snd_soc_component *component = dai->component; in max98927_dai_hw_params()
329 dev_err(component->dev, "format unsupported %d\n", in max98927_dai_hw_params()
334 max98927->ch_size = snd_pcm_format_width(params_format(params)); in max98927_dai_hw_params()
336 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
340 dev_dbg(component->dev, "format supported %d", in max98927_dai_hw_params()
373 dev_err(component->dev, "rate %d not supported\n", in max98927_dai_hw_params()
378 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
382 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
388 if (max98927->interleave_mode && in max98927_dai_hw_params()
390 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
393 sampling_rate - 3); in max98927_dai_hw_params()
395 regmap_update_bits(max98927->regmap, in max98927_dai_hw_params()
401 return -EINVAL; in max98927_dai_hw_params()
408 struct snd_soc_component *component = dai->component; in max98927_dai_tdm_slot()
413 max98927->tdm_mode = true; in max98927_dai_tdm_slot()
418 dev_err(component->dev, "BCLK %d not supported\n", in max98927_dai_tdm_slot()
420 return -EINVAL; in max98927_dai_tdm_slot()
423 regmap_update_bits(max98927->regmap, in max98927_dai_tdm_slot()
440 dev_err(component->dev, "format unsupported %d\n", in max98927_dai_tdm_slot()
442 return -EINVAL; in max98927_dai_tdm_slot()
445 regmap_update_bits(max98927->regmap, in max98927_dai_tdm_slot()
449 /* Rx slot configuration */ in max98927_dai_tdm_slot()
450 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
453 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
457 /* Tx slot configuration */ in max98927_dai_tdm_slot()
458 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
461 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
465 /* Tx slot Hi-Z configuration */ in max98927_dai_tdm_slot()
466 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
469 regmap_write(max98927->regmap, in max98927_dai_tdm_slot()
484 struct snd_soc_component *component = dai->component; in max98927_dai_set_sysclk()
487 max98927->sysclk = freq; in max98927_dai_set_sysclk()
501 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in max98927_dac_event()
506 max98927->tdm_mode = false; in max98927_dac_event()
509 regmap_update_bits(max98927->regmap, in max98927_dac_event()
512 regmap_update_bits(max98927->regmap, in max98927_dac_event()
517 regmap_update_bits(max98927->regmap, in max98927_dac_event()
520 regmap_update_bits(max98927->regmap, in max98927_dac_event()
557 SND_SOC_DAPM_SIGGEN("VMON"),
562 static DECLARE_TLV_DB_SCALE(max98927_digital_tlv, -1600, 25, 0);
630 0, (1<<MAX98927_AMP_VOL_WIDTH)-1, 0,
651 { "VI Sense", "Switch", "VMON" },
659 .name = "max98927-aif1",
682 max98927->component = component; in max98927_probe()
685 regmap_write(max98927->regmap, in max98927_probe()
688 /* IV default slot configuration */ in max98927_probe()
689 regmap_write(max98927->regmap, in max98927_probe()
692 regmap_write(max98927->regmap, in max98927_probe()
695 regmap_write(max98927->regmap, in max98927_probe()
698 regmap_write(max98927->regmap, in max98927_probe()
702 regmap_write(max98927->regmap, in max98927_probe()
705 regmap_write(max98927->regmap, in max98927_probe()
709 regmap_write(max98927->regmap, in max98927_probe()
712 /* Enable IMON VMON DC blocker */ in max98927_probe()
713 regmap_write(max98927->regmap, in max98927_probe()
717 regmap_write(max98927->regmap, in max98927_probe()
720 regmap_write(max98927->regmap, in max98927_probe()
724 regmap_write(max98927->regmap, in max98927_probe()
727 regmap_write(max98927->regmap, in max98927_probe()
730 regmap_write(max98927->regmap, in max98927_probe()
734 regmap_write(max98927->regmap, in max98927_probe()
738 regmap_write(max98927->regmap, in max98927_probe()
741 regmap_write(max98927->regmap, in max98927_probe()
744 regmap_write(max98927->regmap, in max98927_probe()
748 /* voltage, current slot configuration */ in max98927_probe()
749 regmap_write(max98927->regmap, in max98927_probe()
751 (max98927->i_l_slot<<MAX98927_PCM_TX_CH_SRC_A_I_SHIFT| in max98927_probe()
752 max98927->v_l_slot)&0xFF); in max98927_probe()
754 if (max98927->v_l_slot < 8) { in max98927_probe()
755 regmap_update_bits(max98927->regmap, in max98927_probe()
757 1 << max98927->v_l_slot, 0); in max98927_probe()
758 regmap_update_bits(max98927->regmap, in max98927_probe()
760 1 << max98927->v_l_slot, in max98927_probe()
761 1 << max98927->v_l_slot); in max98927_probe()
763 regmap_update_bits(max98927->regmap, in max98927_probe()
765 1 << (max98927->v_l_slot - 8), 0); in max98927_probe()
766 regmap_update_bits(max98927->regmap, in max98927_probe()
768 1 << (max98927->v_l_slot - 8), in max98927_probe()
769 1 << (max98927->v_l_slot - 8)); in max98927_probe()
772 if (max98927->i_l_slot < 8) { in max98927_probe()
773 regmap_update_bits(max98927->regmap, in max98927_probe()
775 1 << max98927->i_l_slot, 0); in max98927_probe()
776 regmap_update_bits(max98927->regmap, in max98927_probe()
778 1 << max98927->i_l_slot, in max98927_probe()
779 1 << max98927->i_l_slot); in max98927_probe()
781 regmap_update_bits(max98927->regmap, in max98927_probe()
783 1 << (max98927->i_l_slot - 8), 0); in max98927_probe()
784 regmap_update_bits(max98927->regmap, in max98927_probe()
786 1 << (max98927->i_l_slot - 8), in max98927_probe()
787 1 << (max98927->i_l_slot - 8)); in max98927_probe()
791 if (max98927->interleave_mode) in max98927_probe()
792 regmap_update_bits(max98927->regmap, in max98927_probe()
804 regcache_cache_only(max98927->regmap, true); in max98927_suspend()
805 regcache_mark_dirty(max98927->regmap); in max98927_suspend()
812 regmap_write(max98927->regmap, in max98927_resume()
814 regcache_cache_only(max98927->regmap, false); in max98927_resume()
815 regcache_sync(max98927->regmap); in max98927_resume()
852 struct device *dev = &i2c->dev; in max98927_slot_config()
854 if (!device_property_read_u32(dev, "vmon-slot-no", &value)) in max98927_slot_config()
855 max98927->v_l_slot = value & 0xF; in max98927_slot_config()
857 max98927->v_l_slot = 0; in max98927_slot_config()
859 if (!device_property_read_u32(dev, "imon-slot-no", &value)) in max98927_slot_config()
860 max98927->i_l_slot = value & 0xF; in max98927_slot_config()
862 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()
901 max98927->reset_gpio in max98927_i2c_probe()
902 = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_HIGH); in max98927_i2c_probe()
903 if (IS_ERR(max98927->reset_gpio)) { in max98927_i2c_probe()
904 ret = PTR_ERR(max98927->reset_gpio); in max98927_i2c_probe()
905 return dev_err_probe(&i2c->dev, ret, "failed to request GPIO reset pin"); in max98927_i2c_probe()
908 if (max98927->reset_gpio) { in max98927_i2c_probe()
909 gpiod_set_value_cansleep(max98927->reset_gpio, 0); in max98927_i2c_probe()
915 ret = regmap_read(max98927->regmap, in max98927_i2c_probe()
918 dev_err(&i2c->dev, in max98927_i2c_probe()
922 dev_info(&i2c->dev, "MAX98927 revisionID: 0x%02X\n", reg); in max98927_i2c_probe()
924 /* voltage/current slot configuration */ in max98927_i2c_probe()
928 ret = devm_snd_soc_register_component(&i2c->dev, in max98927_i2c_probe()
932 dev_err(&i2c->dev, "Failed to register component: %d\n", ret); in max98927_i2c_probe()
941 if (max98927->reset_gpio) { in max98927_i2c_remove()
942 gpiod_set_value_cansleep(max98927->reset_gpio, 1); in max98927_i2c_remove()