Lines Matching +full:pll +full:- +full:master
1 // SPDX-License-Identifier: GPL-2.0-only
3 * nau8810.c -- NAU8810 ALSA Soc Audio driver
169 struct soc_bytes_ext *params = (void *)kcontrol->private_value; in nau8810_eq_get()
174 val = (u16 *)ucontrol->value.bytes.data; in nau8810_eq_get()
176 for (i = 0; i < params->max / sizeof(u16); i++) { in nau8810_eq_get()
177 regmap_read(nau8810->regmap, reg + i, ®_val); in nau8810_eq_get()
178 /* conversion of 16-bit integers between native CPU format in nau8810_eq_get()
190 * cut-off frequency, bandwidth control, and equalizer path.
201 struct soc_bytes_ext *params = (void *)kcontrol->private_value; in nau8810_eq_put()
207 data = kmemdup(ucontrol->value.bytes.data, in nau8810_eq_put()
208 params->max, GFP_KERNEL | GFP_DMA); in nau8810_eq_put()
210 return -ENOMEM; in nau8810_eq_put()
214 for (i = 0; i < params->max / sizeof(u16); i++) { in nau8810_eq_put()
215 /* conversion of 16-bit integers between native CPU format in nau8810_eq_put()
220 ret = regmap_write(nau8810->regmap, reg + i, value); in nau8810_eq_put()
222 dev_err(component->dev, "EQ configuration fail, register: %x ret: %d\n", in nau8810_eq_put()
234 "Off", "NC", "u-law", "A-law" };
263 static const DECLARE_TLV_DB_SCALE(digital_tlv, -12750, 50, 1);
264 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
265 static const DECLARE_TLV_DB_SCALE(inpga_tlv, -1200, 75, 0);
266 static const DECLARE_TLV_DB_SCALE(spk_tlv, -5700, 100, 0);
271 SOC_ENUM("DAC De-emphasis", nau8810_deemp_enum),
407 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in check_mclk_select_pll()
411 regmap_read(nau8810->regmap, NAU8810_REG_CLOCK, &value); in check_mclk_select_pll()
419 snd_soc_dapm_to_component(source->dapm); in check_mic_enabled()
423 regmap_read(nau8810->regmap, NAU8810_REG_INPUT_SIGNAL, &value); in check_mic_enabled()
426 regmap_read(nau8810->regmap, NAU8810_REG_ADCBOOST, &value); in check_mic_enabled()
461 SND_SOC_DAPM_SUPPLY("PLL", NAU8810_REG_POWER1,
476 {"DAC", NULL, "PLL", check_mclk_select_pll},
498 {"ADC", NULL, "PLL", check_mclk_select_pll},
518 struct snd_soc_component *component = dai->component; in nau8810_set_sysclk()
521 nau8810->clk_id = clk_id; in nau8810_set_sysclk()
522 nau8810->sysclk = freq; in nau8810_set_sysclk()
523 dev_dbg(nau8810->dev, "master sysclk %dHz, source %s\n", in nau8810_set_sysclk()
524 freq, clk_id == NAU8810_SCLK_PLL ? "PLL" : "MCLK"); in nau8810_set_sysclk()
536 return -EINVAL; in nau8810_calc_pll()
550 return -EINVAL; in nau8810_calc_pll()
551 pll_param->mclk_scaler = scal_sel; in nau8810_calc_pll()
554 /* Calculate the PLL 4-bit integer input and the PLL 24-bit fractional in nau8810_calc_pll()
558 pll_param->pre_factor = 0; in nau8810_calc_pll()
561 pll_param->pre_factor = 1; in nau8810_calc_pll()
563 pll_param->pll_int = (pll_ratio >> 28) & 0xF; in nau8810_calc_pll()
564 pll_param->pll_frac = ((pll_ratio & 0xFFFFFFF) >> 4); in nau8810_calc_pll()
572 struct snd_soc_component *component = codec_dai->component; in nau8810_set_pll()
574 struct regmap *map = nau8810->regmap; in nau8810_set_pll()
575 struct nau8810_pll *pll_param = &nau8810->pll; in nau8810_set_pll()
581 dev_err(nau8810->dev, "Unsupported input clock %d\n", freq_in); in nau8810_set_pll()
584 dev_info(nau8810->dev, "pll_int=%x pll_frac=%x mclk_scaler=%x pre_factor=%x\n", in nau8810_set_pll()
585 pll_param->pll_int, pll_param->pll_frac, pll_param->mclk_scaler, in nau8810_set_pll()
586 pll_param->pre_factor); in nau8810_set_pll()
590 (pll_param->pre_factor ? NAU8810_PLLMCLK_DIV2 : 0) | in nau8810_set_pll()
591 pll_param->pll_int); in nau8810_set_pll()
593 (pll_param->pll_frac >> NAU8810_PLLK1_SFT) & in nau8810_set_pll()
596 (pll_param->pll_frac >> NAU8810_PLLK2_SFT) & in nau8810_set_pll()
599 pll_param->pll_frac & NAU8810_PLLK3_MASK); in nau8810_set_pll()
601 pll_param->mclk_scaler << NAU8810_MCLKSEL_SFT); in nau8810_set_pll()
611 struct snd_soc_component *component = codec_dai->component; in nau8810_set_dai_fmt()
622 return -EINVAL; in nau8810_set_dai_fmt()
638 return -EINVAL; in nau8810_set_dai_fmt()
654 return -EINVAL; in nau8810_set_dai_fmt()
657 regmap_update_bits(nau8810->regmap, NAU8810_REG_IFACE, in nau8810_set_dai_fmt()
660 regmap_update_bits(nau8810->regmap, NAU8810_REG_CLOCK, in nau8810_set_dai_fmt()
670 if (!nau8810->sysclk) { in nau8810_mclk_clkdiv()
671 dev_err(nau8810->dev, "Make mclk div configuration fail because of invalid system clock\n"); in nau8810_mclk_clkdiv()
672 return -EINVAL; in nau8810_mclk_clkdiv()
675 /* Configure the master clock prescaler div to make system in nau8810_mclk_clkdiv()
676 * clock to approximate the internal master clock (IMCLK); in nau8810_mclk_clkdiv()
680 sclk = (nau8810->sysclk * 10) / in nau8810_mclk_clkdiv()
686 dev_dbg(nau8810->dev, in nau8810_mclk_clkdiv()
687 "master clock prescaler %x for fs %d\n", div, rate); in nau8810_mclk_clkdiv()
689 /* master clock from MCLK and disable PLL */ in nau8810_mclk_clkdiv()
690 regmap_update_bits(nau8810->regmap, NAU8810_REG_CLOCK, in nau8810_mclk_clkdiv()
692 regmap_update_bits(nau8810->regmap, NAU8810_REG_CLOCK, in nau8810_mclk_clkdiv()
701 struct snd_soc_component *component = dai->component; in nau8810_pcm_hw_params()
706 /* Select BCLK configuration if the codec as master. */ in nau8810_pcm_hw_params()
707 regmap_read(nau8810->regmap, NAU8810_REG_CLOCK, &ctrl_val); in nau8810_pcm_hw_params()
718 return -EINVAL; in nau8810_pcm_hw_params()
719 regmap_update_bits(nau8810->regmap, NAU8810_REG_CLOCK, in nau8810_pcm_hw_params()
758 regmap_update_bits(nau8810->regmap, NAU8810_REG_IFACE, in nau8810_pcm_hw_params()
760 regmap_update_bits(nau8810->regmap, NAU8810_REG_SMPLR, in nau8810_pcm_hw_params()
763 /* If the master clock is from MCLK, provide the runtime FS for driver in nau8810_pcm_hw_params()
764 * to get the master clock prescaler configuration. in nau8810_pcm_hw_params()
766 if (nau8810->clk_id == NAU8810_SCLK_MCLK) { in nau8810_pcm_hw_params()
769 dev_err(nau8810->dev, "MCLK div configuration fail\n"); in nau8810_pcm_hw_params()
779 struct regmap *map = nau8810->regmap; in nau8810_set_bias_level()
827 .name = "nau8810-hifi",
876 struct device *dev = &i2c->dev; in nau8810_i2c_probe()
882 return -ENOMEM; in nau8810_i2c_probe()
886 nau8810->regmap = devm_regmap_init_i2c(i2c, &nau8810_regmap_config); in nau8810_i2c_probe()
887 if (IS_ERR(nau8810->regmap)) in nau8810_i2c_probe()
888 return PTR_ERR(nau8810->regmap); in nau8810_i2c_probe()
889 nau8810->dev = dev; in nau8810_i2c_probe()
891 regmap_write(nau8810->regmap, NAU8810_REG_RESET, 0x00); in nau8810_i2c_probe()