Lines Matching refs:pcm512x

63 	struct pcm512x_priv *pcm512x = container_of(nb, struct pcm512x_priv, \
66 regcache_mark_dirty(pcm512x->regmap); \
67 regcache_cache_only(pcm512x->regmap, true); \
228 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_pll_get() local
230 ucontrol->value.integer.value[0] = pcm512x->overclock_pll; in pcm512x_overclock_pll_get()
238 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_pll_put() local
248 pcm512x->overclock_pll = ucontrol->value.integer.value[0]; in pcm512x_overclock_pll_put()
256 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_dsp_get() local
258 ucontrol->value.integer.value[0] = pcm512x->overclock_dsp; in pcm512x_overclock_dsp_get()
266 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_dsp_put() local
276 pcm512x->overclock_dsp = ucontrol->value.integer.value[0]; in pcm512x_overclock_dsp_put()
284 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_dac_get() local
286 ucontrol->value.integer.value[0] = pcm512x->overclock_dac; in pcm512x_overclock_dac_get()
294 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_dac_put() local
304 pcm512x->overclock_dac = ucontrol->value.integer.value[0]; in pcm512x_overclock_dac_put()
385 static int pcm512x_update_mute(struct pcm512x_priv *pcm512x) in pcm512x_update_mute() argument
388 pcm512x->regmap, PCM512x_MUTE, PCM512x_RQML | PCM512x_RQMR, in pcm512x_update_mute()
389 (!!(pcm512x->mute & 0x5) << PCM512x_RQML_SHIFT) in pcm512x_update_mute()
390 | (!!(pcm512x->mute & 0x3) << PCM512x_RQMR_SHIFT)); in pcm512x_update_mute()
397 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_digital_playback_switch_get() local
399 mutex_lock(&pcm512x->mutex); in pcm512x_digital_playback_switch_get()
400 ucontrol->value.integer.value[0] = !(pcm512x->mute & 0x4); in pcm512x_digital_playback_switch_get()
401 ucontrol->value.integer.value[1] = !(pcm512x->mute & 0x2); in pcm512x_digital_playback_switch_get()
402 mutex_unlock(&pcm512x->mutex); in pcm512x_digital_playback_switch_get()
411 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_digital_playback_switch_put() local
414 mutex_lock(&pcm512x->mutex); in pcm512x_digital_playback_switch_put()
416 if ((pcm512x->mute & 0x4) == (ucontrol->value.integer.value[0] << 2)) { in pcm512x_digital_playback_switch_put()
417 pcm512x->mute ^= 0x4; in pcm512x_digital_playback_switch_put()
420 if ((pcm512x->mute & 0x2) == (ucontrol->value.integer.value[1] << 1)) { in pcm512x_digital_playback_switch_put()
421 pcm512x->mute ^= 0x2; in pcm512x_digital_playback_switch_put()
426 ret = pcm512x_update_mute(pcm512x); in pcm512x_digital_playback_switch_put()
430 mutex_unlock(&pcm512x->mutex); in pcm512x_digital_playback_switch_put()
435 mutex_unlock(&pcm512x->mutex); in pcm512x_digital_playback_switch_put()
499 static unsigned long pcm512x_pll_max(struct pcm512x_priv *pcm512x) in pcm512x_pll_max() argument
501 return 25000000 + 25000000 * pcm512x->overclock_pll / 100; in pcm512x_pll_max()
504 static unsigned long pcm512x_dsp_max(struct pcm512x_priv *pcm512x) in pcm512x_dsp_max() argument
506 return 50000000 + 50000000 * pcm512x->overclock_dsp / 100; in pcm512x_dsp_max()
509 static unsigned long pcm512x_dac_max(struct pcm512x_priv *pcm512x, in pcm512x_dac_max() argument
512 return rate + rate * pcm512x->overclock_dac / 100; in pcm512x_dac_max()
515 static unsigned long pcm512x_sck_max(struct pcm512x_priv *pcm512x) in pcm512x_sck_max() argument
517 if (!pcm512x->pll_out) in pcm512x_sck_max()
519 return pcm512x_pll_max(pcm512x); in pcm512x_sck_max()
522 static unsigned long pcm512x_ncp_target(struct pcm512x_priv *pcm512x, in pcm512x_ncp_target() argument
535 return pcm512x_dac_max(pcm512x, 1536000); in pcm512x_ncp_target()
551 struct pcm512x_priv *pcm512x = rule->private; in pcm512x_hw_rule_rate() local
570 ranges[0].max = pcm512x_sck_max(pcm512x) / frame_size / 2; in pcm512x_hw_rule_rate()
586 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_dai_startup_master() local
591 if (IS_ERR(pcm512x->sclk)) { in pcm512x_dai_startup_master()
593 PTR_ERR(pcm512x->sclk)); in pcm512x_dai_startup_master()
594 return PTR_ERR(pcm512x->sclk); in pcm512x_dai_startup_master()
597 if (pcm512x->pll_out) in pcm512x_dai_startup_master()
601 pcm512x, in pcm512x_dai_startup_master()
614 rats_no_pll->num = clk_get_rate(pcm512x->sclk) / 64; in pcm512x_dai_startup_master()
628 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_dai_startup_slave() local
630 struct regmap *regmap = pcm512x->regmap; in pcm512x_dai_startup_slave()
632 if (IS_ERR(pcm512x->sclk)) { in pcm512x_dai_startup_slave()
634 PTR_ERR(pcm512x->sclk)); in pcm512x_dai_startup_slave()
654 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_dai_startup() local
656 switch (pcm512x->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { in pcm512x_dai_startup()
672 struct pcm512x_priv *pcm512x = dev_get_drvdata(component->dev); in pcm512x_set_bias_level() local
681 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_set_bias_level()
691 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_set_bias_level()
709 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_find_sck() local
720 pow2 = 1 << fls((pcm512x_pll_max(pcm512x) - 16000000) / bclk_rate); in pcm512x_find_sck()
722 sck_rate = rounddown(pcm512x_pll_max(pcm512x), in pcm512x_find_sck()
755 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_find_pll_coeff() local
789 pcm512x->real_pll = pll_rate; in pcm512x_find_pll_coeff()
819 pcm512x->real_pll = pll_rate; in pcm512x_find_pll_coeff()
847 pcm512x->real_pll = DIV_ROUND_DOWN_ULL((u64)K * pllin_rate, 10000 * P); in pcm512x_find_pll_coeff()
850 pcm512x->pll_r = R; in pcm512x_find_pll_coeff()
851 pcm512x->pll_j = J; in pcm512x_find_pll_coeff()
852 pcm512x->pll_d = D; in pcm512x_find_pll_coeff()
853 pcm512x->pll_p = P; in pcm512x_find_pll_coeff()
862 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_pllin_dac_rate() local
865 if (!pcm512x->pll_out) in pcm512x_pllin_dac_rate()
872 for (dac_rate = rounddown(pcm512x_dac_max(pcm512x, 6144000), osr_rate); in pcm512x_pllin_dac_rate()
893 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_set_dividers() local
914 if (pcm512x->bclk_ratio > 0) { in pcm512x_set_dividers()
915 lrclk_div = pcm512x->bclk_ratio; in pcm512x_set_dividers()
925 if (!pcm512x->pll_out) { in pcm512x_set_dividers()
926 sck_rate = clk_get_rate(pcm512x->sclk); in pcm512x_set_dividers()
943 pllin_rate = clk_get_rate(pcm512x->sclk); in pcm512x_set_dividers()
954 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
955 PCM512x_PLL_COEFF_0, pcm512x->pll_p - 1); in pcm512x_set_dividers()
961 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
962 PCM512x_PLL_COEFF_1, pcm512x->pll_j); in pcm512x_set_dividers()
968 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
969 PCM512x_PLL_COEFF_2, pcm512x->pll_d >> 8); in pcm512x_set_dividers()
975 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
976 PCM512x_PLL_COEFF_3, pcm512x->pll_d & 0xff); in pcm512x_set_dividers()
982 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
983 PCM512x_PLL_COEFF_4, pcm512x->pll_r - 1); in pcm512x_set_dividers()
989 mck_rate = pcm512x->real_pll; in pcm512x_set_dividers()
1004 dsp_div = mck_rate > pcm512x_dsp_max(pcm512x) ? 2 : 1; in pcm512x_set_dividers()
1014 ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, in pcm512x_set_dividers()
1022 gpio = PCM512x_GREF_GPIO1 + pcm512x->pll_in - 1; in pcm512x_set_dividers()
1023 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_DACIN, in pcm512x_set_dividers()
1028 pcm512x->pll_in, ret); in pcm512x_set_dividers()
1035 unsigned long dac_mul = pcm512x_dac_max(pcm512x, 6144000) in pcm512x_set_dividers()
1052 ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, in pcm512x_set_dividers()
1077 pcm512x_ncp_target(pcm512x, dac_rate)); in pcm512x_set_dividers()
1089 ret = regmap_write(pcm512x->regmap, PCM512x_DSP_CLKDIV, dsp_div - 1); in pcm512x_set_dividers()
1095 ret = regmap_write(pcm512x->regmap, PCM512x_DAC_CLKDIV, dac_div - 1); in pcm512x_set_dividers()
1101 ret = regmap_write(pcm512x->regmap, PCM512x_NCP_CLKDIV, ncp_div - 1); in pcm512x_set_dividers()
1107 ret = regmap_write(pcm512x->regmap, PCM512x_OSR_CLKDIV, osr_div - 1); in pcm512x_set_dividers()
1113 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
1120 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
1127 ret = regmap_write(pcm512x->regmap, PCM512x_IDAC_1, idac >> 8); in pcm512x_set_dividers()
1133 ret = regmap_write(pcm512x->regmap, PCM512x_IDAC_2, idac & 0xff); in pcm512x_set_dividers()
1139 if (sample_rate <= pcm512x_dac_max(pcm512x, 48000)) in pcm512x_set_dividers()
1141 else if (sample_rate <= pcm512x_dac_max(pcm512x, 96000)) in pcm512x_set_dividers()
1143 else if (sample_rate <= pcm512x_dac_max(pcm512x, 192000)) in pcm512x_set_dividers()
1147 ret = regmap_update_bits(pcm512x->regmap, PCM512x_FS_SPEED_MODE, in pcm512x_set_dividers()
1171 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_hw_params() local
1199 ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1, in pcm512x_hw_params()
1206 if ((pcm512x->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) == in pcm512x_hw_params()
1208 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, in pcm512x_hw_params()
1219 if (pcm512x->pll_out) { in pcm512x_hw_params()
1220 ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_A, 0x11); in pcm512x_hw_params()
1226 ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_B, 0xff); in pcm512x_hw_params()
1232 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, in pcm512x_hw_params()
1247 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, in pcm512x_hw_params()
1262 if (!pcm512x->force_pll_on) { in pcm512x_hw_params()
1263 ret = regmap_update_bits(pcm512x->regmap, in pcm512x_hw_params()
1269 ret = regmap_write(pcm512x->regmap, in pcm512x_hw_params()
1276 ret = regmap_write(pcm512x->regmap, in pcm512x_hw_params()
1283 ret = regmap_write(pcm512x->regmap, in pcm512x_hw_params()
1298 if (pcm512x->pll_out) { in pcm512x_hw_params()
1299 ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_REF, in pcm512x_hw_params()
1307 gpio = PCM512x_GREF_GPIO1 + pcm512x->pll_in - 1; in pcm512x_hw_params()
1308 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_PLLIN, in pcm512x_hw_params()
1313 pcm512x->pll_in, ret); in pcm512x_hw_params()
1317 ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, in pcm512x_hw_params()
1324 gpio = PCM512x_G1OE << (pcm512x->pll_out - 1); in pcm512x_hw_params()
1325 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN, in pcm512x_hw_params()
1329 pcm512x->pll_out, ret); in pcm512x_hw_params()
1333 gpio = PCM512x_GPIO_OUTPUT_1 + pcm512x->pll_out - 1; in pcm512x_hw_params()
1334 ret = regmap_update_bits(pcm512x->regmap, gpio, in pcm512x_hw_params()
1338 ret, pcm512x->pll_out); in pcm512x_hw_params()
1343 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, in pcm512x_hw_params()
1350 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, in pcm512x_hw_params()
1364 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_set_fmt() local
1388 ret = regmap_update_bits(pcm512x->regmap, PCM512x_BCLK_LRCLK_CFG, in pcm512x_set_fmt()
1396 ret = regmap_update_bits(pcm512x->regmap, PCM512x_MASTER_MODE, in pcm512x_set_fmt()
1422 pcm512x->fmt); in pcm512x_set_fmt()
1426 ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1, in pcm512x_set_fmt()
1433 ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_2, in pcm512x_set_fmt()
1440 pcm512x->fmt = fmt; in pcm512x_set_fmt()
1448 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_set_bclk_ratio() local
1453 pcm512x->bclk_ratio = ratio; in pcm512x_set_bclk_ratio()
1461 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_mute() local
1465 mutex_lock(&pcm512x->mutex); in pcm512x_mute()
1468 pcm512x->mute |= 0x1; in pcm512x_mute()
1469 ret = regmap_update_bits(pcm512x->regmap, PCM512x_MUTE, in pcm512x_mute()
1478 regmap_read_poll_timeout(pcm512x->regmap, in pcm512x_mute()
1483 pcm512x->mute &= ~0x1; in pcm512x_mute()
1484 ret = pcm512x_update_mute(pcm512x); in pcm512x_mute()
1491 regmap_read_poll_timeout(pcm512x->regmap, in pcm512x_mute()
1495 == ((~pcm512x->mute >> 1) & 0x3), in pcm512x_mute()
1500 mutex_unlock(&pcm512x->mutex); in pcm512x_mute()
1569 struct pcm512x_priv *pcm512x; in pcm512x_probe() local
1572 pcm512x = devm_kzalloc(dev, sizeof(struct pcm512x_priv), GFP_KERNEL); in pcm512x_probe()
1573 if (!pcm512x) in pcm512x_probe()
1576 mutex_init(&pcm512x->mutex); in pcm512x_probe()
1578 dev_set_drvdata(dev, pcm512x); in pcm512x_probe()
1579 pcm512x->regmap = regmap; in pcm512x_probe()
1581 for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) in pcm512x_probe()
1582 pcm512x->supplies[i].supply = pcm512x_supply_names[i]; in pcm512x_probe()
1584 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pcm512x->supplies), in pcm512x_probe()
1585 pcm512x->supplies); in pcm512x_probe()
1591 pcm512x->supply_nb[0].notifier_call = pcm512x_regulator_event_0; in pcm512x_probe()
1592 pcm512x->supply_nb[1].notifier_call = pcm512x_regulator_event_1; in pcm512x_probe()
1593 pcm512x->supply_nb[2].notifier_call = pcm512x_regulator_event_2; in pcm512x_probe()
1595 for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) { in pcm512x_probe()
1597 pcm512x->supplies[i].consumer, in pcm512x_probe()
1598 &pcm512x->supply_nb[i]); in pcm512x_probe()
1606 ret = regulator_bulk_enable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_probe()
1607 pcm512x->supplies); in pcm512x_probe()
1627 pcm512x->sclk = devm_clk_get(dev, NULL); in pcm512x_probe()
1628 if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER) { in pcm512x_probe()
1632 if (!IS_ERR(pcm512x->sclk)) { in pcm512x_probe()
1633 ret = clk_prepare_enable(pcm512x->sclk); in pcm512x_probe()
1641 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_probe()
1664 pcm512x->pll_in = val; in pcm512x_probe()
1673 pcm512x->pll_out = val; in pcm512x_probe()
1676 if (!pcm512x->pll_in != !pcm512x->pll_out) { in pcm512x_probe()
1682 if (pcm512x->pll_in && pcm512x->pll_in == pcm512x->pll_out) { in pcm512x_probe()
1690 pcm512x->force_pll_on = 1; in pcm512x_probe()
1707 if (!IS_ERR(pcm512x->sclk)) in pcm512x_probe()
1708 clk_disable_unprepare(pcm512x->sclk); in pcm512x_probe()
1710 regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_probe()
1711 pcm512x->supplies); in pcm512x_probe()
1718 struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); in pcm512x_remove() local
1721 if (!IS_ERR(pcm512x->sclk)) in pcm512x_remove()
1722 clk_disable_unprepare(pcm512x->sclk); in pcm512x_remove()
1723 regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_remove()
1724 pcm512x->supplies); in pcm512x_remove()
1731 struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); in pcm512x_suspend() local
1734 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_suspend()
1741 ret = regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_suspend()
1742 pcm512x->supplies); in pcm512x_suspend()
1748 if (!IS_ERR(pcm512x->sclk)) in pcm512x_suspend()
1749 clk_disable_unprepare(pcm512x->sclk); in pcm512x_suspend()
1756 struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); in pcm512x_resume() local
1759 if (!IS_ERR(pcm512x->sclk)) { in pcm512x_resume()
1760 ret = clk_prepare_enable(pcm512x->sclk); in pcm512x_resume()
1767 ret = regulator_bulk_enable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_resume()
1768 pcm512x->supplies); in pcm512x_resume()
1774 regcache_cache_only(pcm512x->regmap, false); in pcm512x_resume()
1775 ret = regcache_sync(pcm512x->regmap); in pcm512x_resume()
1781 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_resume()