Lines Matching +full:pll +full:- +full:master
1 // SPDX-License-Identifier: GPL-2.0
22 #include <sound/soc-dapm.h>
43 regcache_mark_dirty(max9860->regmap); in max9860_dvddio_event()
44 regcache_cache_only(max9860->regmap, true); in max9860_dvddio_event()
126 static const DECLARE_TLV_DB_SCALE(dva_tlv, -9100, 100, 1);
128 static const DECLARE_TLV_DB_SCALE(adc_tlv, -1200, 100, 0);
130 0, MAX9860_PAM_MAX - 1, TLV_DB_SCALE_ITEM(-2000, 2000, 1),
133 static const DECLARE_TLV_DB_SCALE(anth_tlv, -7600, 400, 1);
134 static const DECLARE_TLV_DB_SCALE(agcth_tlv, -1800, 100, 0);
181 SOC_SINGLE_TLV("Master Playback Volume", MAX9860_DACATTN,
255 struct snd_soc_component *component = dai->component; in max9860_hw_params()
257 u8 master; in max9860_hw_params() local
264 dev_dbg(component->dev, "hw_params %u Hz, %u channels\n", in max9860_hw_params()
271 switch (max9860->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { in max9860_hw_params()
273 master = 0; in max9860_hw_params()
276 master = MAX9860_MASTER; in max9860_hw_params()
279 return -EINVAL; in max9860_hw_params()
281 ifc1a |= master; in max9860_hw_params()
283 if (master) { in max9860_hw_params()
290 switch (max9860->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in max9860_hw_params()
300 dev_err(component->dev, in max9860_hw_params()
302 return -EINVAL; in max9860_hw_params()
309 dev_err(component->dev, in max9860_hw_params()
311 return -EINVAL; in max9860_hw_params()
316 return -EINVAL; in max9860_hw_params()
319 switch (max9860->fmt & SND_SOC_DAIFMT_INV_MASK) { in max9860_hw_params()
323 switch (max9860->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in max9860_hw_params()
326 return -EINVAL; in max9860_hw_params()
331 switch (max9860->fmt & SND_SOC_DAIFMT_FORMAT_MASK) { in max9860_hw_params()
334 return -EINVAL; in max9860_hw_params()
343 return -EINVAL; in max9860_hw_params()
346 dev_dbg(component->dev, "IFC1A %02x\n", ifc1a); in max9860_hw_params()
347 ret = regmap_write(max9860->regmap, MAX9860_IFC1A, ifc1a); in max9860_hw_params()
349 dev_err(component->dev, "Failed to set IFC1A: %d\n", ret); in max9860_hw_params()
352 dev_dbg(component->dev, "IFC1B %02x\n", ifc1b); in max9860_hw_params()
353 ret = regmap_write(max9860->regmap, MAX9860_IFC1B, ifc1b); in max9860_hw_params()
355 dev_err(component->dev, "Failed to set IFC1B: %d\n", ret); in max9860_hw_params()
366 if (master) { in max9860_hw_params()
367 switch (max9860->pclk_rate) { in max9860_hw_params()
381 * code below for PLL mode. in max9860_hw_params()
393 * 65536 * 96 * 48kHz / 10MHz -> 30199 in max9860_hw_params()
395 * 65536 * 96 * 8kHz / 20MHz -> 2517 in max9860_hw_params()
399 max9860->pclk_rate); in max9860_hw_params()
402 /* PLL mode */ in max9860_hw_params()
406 if (!master) in max9860_hw_params()
407 n |= 1; /* trigger rapid pll lock mode */ in max9860_hw_params()
410 sysclk |= max9860->psclk; in max9860_hw_params()
411 dev_dbg(component->dev, "SYSCLK %02x\n", sysclk); in max9860_hw_params()
412 ret = regmap_write(max9860->regmap, in max9860_hw_params()
415 dev_err(component->dev, "Failed to set SYSCLK: %d\n", ret); in max9860_hw_params()
418 dev_dbg(component->dev, "N %lu\n", n); in max9860_hw_params()
419 ret = regmap_write(max9860->regmap, in max9860_hw_params()
422 dev_err(component->dev, "Failed to set NHI: %d\n", ret); in max9860_hw_params()
425 ret = regmap_write(max9860->regmap, in max9860_hw_params()
428 dev_err(component->dev, "Failed to set NLO: %d\n", ret); in max9860_hw_params()
432 if (!master) { in max9860_hw_params()
433 dev_dbg(component->dev, "Enable PLL\n"); in max9860_hw_params()
434 ret = regmap_update_bits(max9860->regmap, MAX9860_AUDIOCLKHIGH, in max9860_hw_params()
437 dev_err(component->dev, "Failed to enable PLL: %d\n", in max9860_hw_params()
448 struct snd_soc_component *component = dai->component; in max9860_set_fmt()
454 max9860->fmt = fmt; in max9860_set_fmt()
458 return -EINVAL; in max9860_set_fmt()
468 .name = "max9860-hifi",
498 struct max9860_priv *max9860 = dev_get_drvdata(component->dev); in max9860_set_bias_level()
507 ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, in max9860_set_bias_level()
510 dev_err(component->dev, "Failed to remove SHDN: %d\n", in max9860_set_bias_level()
517 ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, in max9860_set_bias_level()
520 dev_err(component->dev, "Failed to request SHDN: %d\n", in max9860_set_bias_level()
548 ret = regmap_update_bits(max9860->regmap, MAX9860_SYSCLK, in max9860_suspend()
555 regulator_disable(max9860->dvddio); in max9860_suspend()
565 ret = regulator_enable(max9860->dvddio); in max9860_resume()
571 regcache_cache_only(max9860->regmap, false); in max9860_resume()
572 ret = regcache_sync(max9860->regmap); in max9860_resume()
578 ret = regmap_update_bits(max9860->regmap, MAX9860_SYSCLK, in max9860_resume()
579 MAX9860_PSCLK, max9860->psclk); in max9860_resume()
595 struct device *dev = &i2c->dev; in max9860_probe()
605 return -ENOMEM; in max9860_probe()
607 max9860->dvddio = devm_regulator_get(dev, "DVDDIO"); in max9860_probe()
608 if (IS_ERR(max9860->dvddio)) in max9860_probe()
609 return dev_err_probe(dev, PTR_ERR(max9860->dvddio), in max9860_probe()
612 max9860->dvddio_nb.notifier_call = max9860_dvddio_event; in max9860_probe()
614 ret = devm_regulator_register_notifier(max9860->dvddio, in max9860_probe()
615 &max9860->dvddio_nb); in max9860_probe()
619 ret = regulator_enable(max9860->dvddio); in max9860_probe()
625 max9860->regmap = devm_regmap_init_i2c(i2c, &max9860_regmap); in max9860_probe()
626 if (IS_ERR(max9860->regmap)) { in max9860_probe()
627 ret = PTR_ERR(max9860->regmap); in max9860_probe()
650 dev_err(dev, "Bad mclk %luHz (needs 10MHz - 60MHz)\n", in max9860_probe()
652 ret = -EINVAL; in max9860_probe()
656 max9860->psclk = 3; in max9860_probe()
658 max9860->psclk = 2; in max9860_probe()
660 max9860->psclk = 1; in max9860_probe()
661 max9860->pclk_rate = mclk_rate >> (max9860->psclk - 1); in max9860_probe()
662 max9860->psclk <<= MAX9860_PSCLK_SHIFT; in max9860_probe()
663 dev_dbg(dev, "mclk %lu pclk %lu\n", mclk_rate, max9860->pclk_rate); in max9860_probe()
665 regcache_cache_bypass(max9860->regmap, true); in max9860_probe()
667 ret = regmap_write(max9860->regmap, in max9860_probe()
676 regcache_cache_bypass(max9860->regmap, false); in max9860_probe()
678 ret = regmap_read(max9860->regmap, MAX9860_INTRSTATUS, &intr); in max9860_probe()
700 regulator_disable(max9860->dvddio); in max9860_probe()
706 struct device *dev = &i2c->dev; in max9860_remove()
710 regulator_disable(max9860->dvddio); in max9860_remove()