Lines Matching +full:codec +full:- +full:aif1 +full:- +full:bclk
1 // SPDX-License-Identifier: GPL-2.0
72 struct snd_soc_component *component = codec_dai->component; in max98520_dai_set_fmt()
78 dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); in max98520_dai_set_fmt()
87 dev_err(component->dev, "DAI invert mode unsupported\n"); in max98520_dai_set_fmt()
88 return -EINVAL; in max98520_dai_set_fmt()
91 regmap_update_bits(max98520->regmap, in max98520_dai_set_fmt()
111 return -EINVAL; in max98520_dai_set_fmt()
114 regmap_update_bits(max98520->regmap, in max98520_dai_set_fmt()
127 static int max98520_get_bclk_sel(int bclk) in max98520_get_bclk_sel() argument
132 if (bclk_sel_table[i] == bclk) in max98520_get_bclk_sel()
143 /* BCLK/LRCLK ratio calculation */ in max98520_set_clock()
144 int blr_clk_ratio = params_channels(params) * max98520->ch_size; in max98520_set_clock()
147 if (!max98520->tdm_mode) { in max98520_set_clock()
148 /* BCLK configuration */ in max98520_set_clock()
151 dev_err(component->dev, "format unsupported %d\n", in max98520_set_clock()
153 return -EINVAL; in max98520_set_clock()
156 regmap_update_bits(max98520->regmap, in max98520_set_clock()
161 dev_dbg(component->dev, "%s tdm_mode:%d out\n", __func__, max98520->tdm_mode); in max98520_set_clock()
169 struct snd_soc_component *component = dai->component; in max98520_dai_hw_params()
187 dev_err(component->dev, "format unsupported %d\n", in max98520_dai_hw_params()
192 max98520->ch_size = snd_pcm_format_width(params_format(params)); in max98520_dai_hw_params()
194 regmap_update_bits(max98520->regmap, in max98520_dai_hw_params()
198 dev_dbg(component->dev, "format supported %d", in max98520_dai_hw_params()
243 dev_err(component->dev, "rate %d not supported\n", in max98520_dai_hw_params()
248 dev_dbg(component->dev, " %s ch_size: %d, sampling rate : %d out\n", __func__, in max98520_dai_hw_params()
251 regmap_update_bits(max98520->regmap, in max98520_dai_hw_params()
258 dev_dbg(component->dev, "%s out error", __func__); in max98520_dai_hw_params()
259 return -EINVAL; in max98520_dai_hw_params()
266 struct snd_soc_component *component = dai->component; in max98520_dai_tdm_slot()
273 max98520->tdm_mode = false; in max98520_dai_tdm_slot()
275 max98520->tdm_mode = true; in max98520_dai_tdm_slot()
277 /* BCLK configuration */ in max98520_dai_tdm_slot()
280 dev_err(component->dev, "BCLK %d not supported\n", in max98520_dai_tdm_slot()
282 return -EINVAL; in max98520_dai_tdm_slot()
285 regmap_update_bits(max98520->regmap, in max98520_dai_tdm_slot()
302 dev_err(component->dev, "format unsupported %d\n", in max98520_dai_tdm_slot()
304 return -EINVAL; in max98520_dai_tdm_slot()
307 regmap_update_bits(max98520->regmap, in max98520_dai_tdm_slot()
312 regmap_update_bits(max98520->regmap, in max98520_dai_tdm_slot()
316 regmap_update_bits(max98520->regmap, in max98520_dai_tdm_slot()
339 snd_soc_dapm_to_component(w->dapm); in max98520_dac_event()
345 dev_dbg(component->dev, " AMP ON\n"); in max98520_dac_event()
347 regmap_write(max98520->regmap, MAX98520_R209F_AMP_EN, 1); in max98520_dac_event()
348 regmap_write(max98520->regmap, MAX98520_R210F_GLOBAL_EN, 1); in max98520_dac_event()
352 dev_dbg(component->dev, " AMP OFF\n"); in max98520_dac_event()
354 regmap_write(max98520->regmap, MAX98520_R210F_GLOBAL_EN, 0); in max98520_dac_event()
355 regmap_write(max98520->regmap, MAX98520_R209F_AMP_EN, 0); in max98520_dac_event()
428 static const DECLARE_TLV_DB_SCALE(max98520_digital_tlv, -6300, 50, 1);
429 static const DECLARE_TLV_DB_SCALE(max98520_spk_tlv, -600, 300, 0);
432 0, 15, TLV_DB_SCALE_ITEM(-1500, 100, 0),
441 0, 1, TLV_DB_SCALE_ITEM(-1500, 300, 0),
442 2, 4, TLV_DB_SCALE_ITEM(-1000, 200, 0),
443 5, 10, TLV_DB_SCALE_ITEM(-500, 100, 0),
447 0, 16, TLV_DB_SCALE_ITEM(-2000, 250, 0),
451 1, 20, TLV_DB_SCALE_ITEM(-2000, 100, 0),
582 .name = "max98520-aif1",
601 regmap_write(max98520->regmap, MAX98520_R2000_SW_RESET, 1); in max98520_probe()
604 regmap_write(max98520->regmap, MAX98520_R2043_PCM_RX_SRC1, 0x2); in max98520_probe()
608 regmap_write(max98520->regmap, MAX98520_R2044_PCM_RX_SRC2, 0x10); in max98520_probe()
611 regmap_update_bits(max98520->regmap, MAX98520_R2092_AMP_DSP_CFG, 1, 1); in max98520_probe()
612 /* Enable Clock Monitor Auto-restart */ in max98520_probe()
613 regmap_write(max98520->regmap, MAX98520_R2030_CLK_MON_CTRL, 0x1); in max98520_probe()
616 regmap_update_bits(max98520->regmap, in max98520_probe()
628 regcache_cache_only(max98520->regmap, true); in max98520_suspend()
629 regcache_mark_dirty(max98520->regmap); in max98520_suspend()
637 regcache_cache_only(max98520->regmap, false); in max98520_resume()
638 regmap_write(max98520->regmap, MAX98520_R2000_SW_RESET, 1); in max98520_resume()
639 regcache_sync(max98520->regmap); in max98520_resume()
673 if (max98520->reset_gpio) in max98520_power_on()
674 gpiod_set_value_cansleep(max98520->reset_gpio, !poweron); in max98520_power_on()
682 struct i2c_adapter *adapter = to_i2c_adapter(i2c->dev.parent); in max98520_i2c_probe()
686 dev_err(&i2c->dev, "I2C check functionality failed\n"); in max98520_i2c_probe()
687 return -ENXIO; in max98520_i2c_probe()
690 max98520 = devm_kzalloc(&i2c->dev, sizeof(*max98520), GFP_KERNEL); in max98520_i2c_probe()
693 return -ENOMEM; in max98520_i2c_probe()
698 max98520->regmap = devm_regmap_init_i2c(i2c, &max98520_regmap); in max98520_i2c_probe()
699 if (IS_ERR(max98520->regmap)) { in max98520_i2c_probe()
700 ret = PTR_ERR(max98520->regmap); in max98520_i2c_probe()
701 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); in max98520_i2c_probe()
706 max98520->reset_gpio = devm_gpiod_get_optional(&i2c->dev, "reset", GPIOD_OUT_HIGH); in max98520_i2c_probe()
707 if (max98520->reset_gpio) { in max98520_i2c_probe()
708 if (IS_ERR(max98520->reset_gpio)) { in max98520_i2c_probe()
709 ret = PTR_ERR(max98520->reset_gpio); in max98520_i2c_probe()
710 dev_err(&i2c->dev, "Unable to request GPIO pin: %d.\n", ret); in max98520_i2c_probe()
718 ret = regmap_read(max98520->regmap, MAX98520_R21FF_REVISION_ID, ®); in max98520_i2c_probe()
720 dev_err(&i2c->dev, in max98520_i2c_probe()
724 dev_info(&i2c->dev, "MAX98520 revisionID: 0x%02X\n", reg); in max98520_i2c_probe()
726 /* codec registration */ in max98520_i2c_probe()
727 ret = devm_snd_soc_register_component(&i2c->dev, in max98520_i2c_probe()
731 dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); in max98520_i2c_probe()