Lines Matching refs:pcm512x

62 	struct pcm512x_priv *pcm512x = container_of(nb, struct pcm512x_priv, \
65 regcache_mark_dirty(pcm512x->regmap); \
66 regcache_cache_only(pcm512x->regmap, true); \
227 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_pll_get() local
229 ucontrol->value.integer.value[0] = pcm512x->overclock_pll; in pcm512x_overclock_pll_get()
237 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_pll_put() local
247 pcm512x->overclock_pll = ucontrol->value.integer.value[0]; in pcm512x_overclock_pll_put()
255 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_dsp_get() local
257 ucontrol->value.integer.value[0] = pcm512x->overclock_dsp; in pcm512x_overclock_dsp_get()
265 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_dsp_put() local
275 pcm512x->overclock_dsp = ucontrol->value.integer.value[0]; in pcm512x_overclock_dsp_put()
283 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_dac_get() local
285 ucontrol->value.integer.value[0] = pcm512x->overclock_dac; in pcm512x_overclock_dac_get()
293 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_overclock_dac_put() local
303 pcm512x->overclock_dac = ucontrol->value.integer.value[0]; in pcm512x_overclock_dac_put()
384 static int pcm512x_update_mute(struct pcm512x_priv *pcm512x) in pcm512x_update_mute() argument
387 pcm512x->regmap, PCM512x_MUTE, PCM512x_RQML | PCM512x_RQMR, in pcm512x_update_mute()
388 (!!(pcm512x->mute & 0x5) << PCM512x_RQML_SHIFT) in pcm512x_update_mute()
389 | (!!(pcm512x->mute & 0x3) << PCM512x_RQMR_SHIFT)); in pcm512x_update_mute()
396 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_digital_playback_switch_get() local
398 mutex_lock(&pcm512x->mutex); in pcm512x_digital_playback_switch_get()
399 ucontrol->value.integer.value[0] = !(pcm512x->mute & 0x4); in pcm512x_digital_playback_switch_get()
400 ucontrol->value.integer.value[1] = !(pcm512x->mute & 0x2); in pcm512x_digital_playback_switch_get()
401 mutex_unlock(&pcm512x->mutex); in pcm512x_digital_playback_switch_get()
410 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_digital_playback_switch_put() local
413 mutex_lock(&pcm512x->mutex); in pcm512x_digital_playback_switch_put()
415 if ((pcm512x->mute & 0x4) == (ucontrol->value.integer.value[0] << 2)) { in pcm512x_digital_playback_switch_put()
416 pcm512x->mute ^= 0x4; in pcm512x_digital_playback_switch_put()
419 if ((pcm512x->mute & 0x2) == (ucontrol->value.integer.value[1] << 1)) { in pcm512x_digital_playback_switch_put()
420 pcm512x->mute ^= 0x2; in pcm512x_digital_playback_switch_put()
425 ret = pcm512x_update_mute(pcm512x); in pcm512x_digital_playback_switch_put()
429 mutex_unlock(&pcm512x->mutex); in pcm512x_digital_playback_switch_put()
434 mutex_unlock(&pcm512x->mutex); in pcm512x_digital_playback_switch_put()
498 static unsigned long pcm512x_pll_max(struct pcm512x_priv *pcm512x) in pcm512x_pll_max() argument
500 return 25000000 + 25000000 * pcm512x->overclock_pll / 100; in pcm512x_pll_max()
503 static unsigned long pcm512x_dsp_max(struct pcm512x_priv *pcm512x) in pcm512x_dsp_max() argument
505 return 50000000 + 50000000 * pcm512x->overclock_dsp / 100; in pcm512x_dsp_max()
508 static unsigned long pcm512x_dac_max(struct pcm512x_priv *pcm512x, in pcm512x_dac_max() argument
511 return rate + rate * pcm512x->overclock_dac / 100; in pcm512x_dac_max()
514 static unsigned long pcm512x_sck_max(struct pcm512x_priv *pcm512x) in pcm512x_sck_max() argument
516 if (!pcm512x->pll_out) in pcm512x_sck_max()
518 return pcm512x_pll_max(pcm512x); in pcm512x_sck_max()
521 static unsigned long pcm512x_ncp_target(struct pcm512x_priv *pcm512x, in pcm512x_ncp_target() argument
534 return pcm512x_dac_max(pcm512x, 1536000); in pcm512x_ncp_target()
550 struct pcm512x_priv *pcm512x = rule->private; in pcm512x_hw_rule_rate() local
569 ranges[0].max = pcm512x_sck_max(pcm512x) / frame_size / 2; in pcm512x_hw_rule_rate()
585 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_dai_startup_master() local
590 if (IS_ERR(pcm512x->sclk)) { in pcm512x_dai_startup_master()
592 PTR_ERR(pcm512x->sclk)); in pcm512x_dai_startup_master()
593 return PTR_ERR(pcm512x->sclk); in pcm512x_dai_startup_master()
596 if (pcm512x->pll_out) in pcm512x_dai_startup_master()
600 pcm512x, in pcm512x_dai_startup_master()
613 rats_no_pll->num = clk_get_rate(pcm512x->sclk) / 64; in pcm512x_dai_startup_master()
627 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_dai_startup_slave() local
629 struct regmap *regmap = pcm512x->regmap; in pcm512x_dai_startup_slave()
631 if (IS_ERR(pcm512x->sclk)) { in pcm512x_dai_startup_slave()
633 PTR_ERR(pcm512x->sclk)); in pcm512x_dai_startup_slave()
653 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_dai_startup() local
655 switch (pcm512x->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) { in pcm512x_dai_startup()
671 struct pcm512x_priv *pcm512x = dev_get_drvdata(component->dev); in pcm512x_set_bias_level() local
680 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_set_bias_level()
690 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_set_bias_level()
708 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_find_sck() local
719 pow2 = 1 << fls((pcm512x_pll_max(pcm512x) - 16000000) / bclk_rate); in pcm512x_find_sck()
721 sck_rate = rounddown(pcm512x_pll_max(pcm512x), in pcm512x_find_sck()
754 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_find_pll_coeff() local
788 pcm512x->real_pll = pll_rate; in pcm512x_find_pll_coeff()
818 pcm512x->real_pll = pll_rate; in pcm512x_find_pll_coeff()
846 pcm512x->real_pll = DIV_ROUND_DOWN_ULL((u64)K * pllin_rate, 10000 * P); in pcm512x_find_pll_coeff()
849 pcm512x->pll_r = R; in pcm512x_find_pll_coeff()
850 pcm512x->pll_j = J; in pcm512x_find_pll_coeff()
851 pcm512x->pll_d = D; in pcm512x_find_pll_coeff()
852 pcm512x->pll_p = P; in pcm512x_find_pll_coeff()
861 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_pllin_dac_rate() local
864 if (!pcm512x->pll_out) in pcm512x_pllin_dac_rate()
871 for (dac_rate = rounddown(pcm512x_dac_max(pcm512x, 6144000), osr_rate); in pcm512x_pllin_dac_rate()
892 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_set_dividers() local
913 if (pcm512x->bclk_ratio > 0) { in pcm512x_set_dividers()
914 lrclk_div = pcm512x->bclk_ratio; in pcm512x_set_dividers()
924 if (!pcm512x->pll_out) { in pcm512x_set_dividers()
925 sck_rate = clk_get_rate(pcm512x->sclk); in pcm512x_set_dividers()
942 pllin_rate = clk_get_rate(pcm512x->sclk); in pcm512x_set_dividers()
953 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
954 PCM512x_PLL_COEFF_0, pcm512x->pll_p - 1); in pcm512x_set_dividers()
960 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
961 PCM512x_PLL_COEFF_1, pcm512x->pll_j); in pcm512x_set_dividers()
967 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
968 PCM512x_PLL_COEFF_2, pcm512x->pll_d >> 8); in pcm512x_set_dividers()
974 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
975 PCM512x_PLL_COEFF_3, pcm512x->pll_d & 0xff); in pcm512x_set_dividers()
981 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
982 PCM512x_PLL_COEFF_4, pcm512x->pll_r - 1); in pcm512x_set_dividers()
988 mck_rate = pcm512x->real_pll; in pcm512x_set_dividers()
1003 dsp_div = mck_rate > pcm512x_dsp_max(pcm512x) ? 2 : 1; in pcm512x_set_dividers()
1013 ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, in pcm512x_set_dividers()
1021 gpio = PCM512x_GREF_GPIO1 + pcm512x->pll_in - 1; in pcm512x_set_dividers()
1022 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_DACIN, in pcm512x_set_dividers()
1027 pcm512x->pll_in, ret); in pcm512x_set_dividers()
1034 unsigned long dac_mul = pcm512x_dac_max(pcm512x, 6144000) in pcm512x_set_dividers()
1051 ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, in pcm512x_set_dividers()
1076 pcm512x_ncp_target(pcm512x, dac_rate)); in pcm512x_set_dividers()
1088 ret = regmap_write(pcm512x->regmap, PCM512x_DSP_CLKDIV, dsp_div - 1); in pcm512x_set_dividers()
1094 ret = regmap_write(pcm512x->regmap, PCM512x_DAC_CLKDIV, dac_div - 1); in pcm512x_set_dividers()
1100 ret = regmap_write(pcm512x->regmap, PCM512x_NCP_CLKDIV, ncp_div - 1); in pcm512x_set_dividers()
1106 ret = regmap_write(pcm512x->regmap, PCM512x_OSR_CLKDIV, osr_div - 1); in pcm512x_set_dividers()
1112 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
1119 ret = regmap_write(pcm512x->regmap, in pcm512x_set_dividers()
1126 ret = regmap_write(pcm512x->regmap, PCM512x_IDAC_1, idac >> 8); in pcm512x_set_dividers()
1132 ret = regmap_write(pcm512x->regmap, PCM512x_IDAC_2, idac & 0xff); in pcm512x_set_dividers()
1138 if (sample_rate <= pcm512x_dac_max(pcm512x, 48000)) in pcm512x_set_dividers()
1140 else if (sample_rate <= pcm512x_dac_max(pcm512x, 96000)) in pcm512x_set_dividers()
1142 else if (sample_rate <= pcm512x_dac_max(pcm512x, 192000)) in pcm512x_set_dividers()
1146 ret = regmap_update_bits(pcm512x->regmap, PCM512x_FS_SPEED_MODE, in pcm512x_set_dividers()
1170 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_hw_params() local
1198 ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1, in pcm512x_hw_params()
1205 if ((pcm512x->fmt & SND_SOC_DAIFMT_CLOCK_PROVIDER_MASK) == in pcm512x_hw_params()
1207 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, in pcm512x_hw_params()
1218 if (pcm512x->pll_out) { in pcm512x_hw_params()
1219 ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_A, 0x11); in pcm512x_hw_params()
1225 ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_B, 0xff); in pcm512x_hw_params()
1231 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, in pcm512x_hw_params()
1246 ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, in pcm512x_hw_params()
1261 ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, in pcm512x_hw_params()
1273 if (pcm512x->pll_out) { in pcm512x_hw_params()
1274 ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_REF, in pcm512x_hw_params()
1282 gpio = PCM512x_GREF_GPIO1 + pcm512x->pll_in - 1; in pcm512x_hw_params()
1283 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_PLLIN, in pcm512x_hw_params()
1288 pcm512x->pll_in, ret); in pcm512x_hw_params()
1292 ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, in pcm512x_hw_params()
1299 gpio = PCM512x_G1OE << (pcm512x->pll_out - 1); in pcm512x_hw_params()
1300 ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN, in pcm512x_hw_params()
1304 pcm512x->pll_out, ret); in pcm512x_hw_params()
1308 gpio = PCM512x_GPIO_OUTPUT_1 + pcm512x->pll_out - 1; in pcm512x_hw_params()
1309 ret = regmap_update_bits(pcm512x->regmap, gpio, in pcm512x_hw_params()
1313 ret, pcm512x->pll_out); in pcm512x_hw_params()
1318 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, in pcm512x_hw_params()
1325 ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, in pcm512x_hw_params()
1339 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_set_fmt() local
1363 ret = regmap_update_bits(pcm512x->regmap, PCM512x_BCLK_LRCLK_CFG, in pcm512x_set_fmt()
1371 ret = regmap_update_bits(pcm512x->regmap, PCM512x_MASTER_MODE, in pcm512x_set_fmt()
1397 pcm512x->fmt); in pcm512x_set_fmt()
1401 ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1, in pcm512x_set_fmt()
1408 ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_2, in pcm512x_set_fmt()
1415 pcm512x->fmt = fmt; in pcm512x_set_fmt()
1423 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_set_bclk_ratio() local
1428 pcm512x->bclk_ratio = ratio; in pcm512x_set_bclk_ratio()
1436 struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); in pcm512x_mute() local
1440 mutex_lock(&pcm512x->mutex); in pcm512x_mute()
1443 pcm512x->mute |= 0x1; in pcm512x_mute()
1444 ret = regmap_update_bits(pcm512x->regmap, PCM512x_MUTE, in pcm512x_mute()
1453 regmap_read_poll_timeout(pcm512x->regmap, in pcm512x_mute()
1458 pcm512x->mute &= ~0x1; in pcm512x_mute()
1459 ret = pcm512x_update_mute(pcm512x); in pcm512x_mute()
1466 regmap_read_poll_timeout(pcm512x->regmap, in pcm512x_mute()
1470 == ((~pcm512x->mute >> 1) & 0x3), in pcm512x_mute()
1475 mutex_unlock(&pcm512x->mutex); in pcm512x_mute()
1544 struct pcm512x_priv *pcm512x; in pcm512x_probe() local
1547 pcm512x = devm_kzalloc(dev, sizeof(struct pcm512x_priv), GFP_KERNEL); in pcm512x_probe()
1548 if (!pcm512x) in pcm512x_probe()
1551 mutex_init(&pcm512x->mutex); in pcm512x_probe()
1553 dev_set_drvdata(dev, pcm512x); in pcm512x_probe()
1554 pcm512x->regmap = regmap; in pcm512x_probe()
1556 for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) in pcm512x_probe()
1557 pcm512x->supplies[i].supply = pcm512x_supply_names[i]; in pcm512x_probe()
1559 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pcm512x->supplies), in pcm512x_probe()
1560 pcm512x->supplies); in pcm512x_probe()
1566 pcm512x->supply_nb[0].notifier_call = pcm512x_regulator_event_0; in pcm512x_probe()
1567 pcm512x->supply_nb[1].notifier_call = pcm512x_regulator_event_1; in pcm512x_probe()
1568 pcm512x->supply_nb[2].notifier_call = pcm512x_regulator_event_2; in pcm512x_probe()
1570 for (i = 0; i < ARRAY_SIZE(pcm512x->supplies); i++) { in pcm512x_probe()
1572 pcm512x->supplies[i].consumer, in pcm512x_probe()
1573 &pcm512x->supply_nb[i]); in pcm512x_probe()
1581 ret = regulator_bulk_enable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_probe()
1582 pcm512x->supplies); in pcm512x_probe()
1602 pcm512x->sclk = devm_clk_get(dev, NULL); in pcm512x_probe()
1603 if (PTR_ERR(pcm512x->sclk) == -EPROBE_DEFER) { in pcm512x_probe()
1607 if (!IS_ERR(pcm512x->sclk)) { in pcm512x_probe()
1608 ret = clk_prepare_enable(pcm512x->sclk); in pcm512x_probe()
1616 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_probe()
1639 pcm512x->pll_in = val; in pcm512x_probe()
1648 pcm512x->pll_out = val; in pcm512x_probe()
1651 if (!pcm512x->pll_in != !pcm512x->pll_out) { in pcm512x_probe()
1657 if (pcm512x->pll_in && pcm512x->pll_in == pcm512x->pll_out) { in pcm512x_probe()
1677 if (!IS_ERR(pcm512x->sclk)) in pcm512x_probe()
1678 clk_disable_unprepare(pcm512x->sclk); in pcm512x_probe()
1680 regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_probe()
1681 pcm512x->supplies); in pcm512x_probe()
1688 struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); in pcm512x_remove() local
1691 if (!IS_ERR(pcm512x->sclk)) in pcm512x_remove()
1692 clk_disable_unprepare(pcm512x->sclk); in pcm512x_remove()
1693 regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_remove()
1694 pcm512x->supplies); in pcm512x_remove()
1701 struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); in pcm512x_suspend() local
1704 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_suspend()
1711 ret = regulator_bulk_disable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_suspend()
1712 pcm512x->supplies); in pcm512x_suspend()
1718 if (!IS_ERR(pcm512x->sclk)) in pcm512x_suspend()
1719 clk_disable_unprepare(pcm512x->sclk); in pcm512x_suspend()
1726 struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); in pcm512x_resume() local
1729 if (!IS_ERR(pcm512x->sclk)) { in pcm512x_resume()
1730 ret = clk_prepare_enable(pcm512x->sclk); in pcm512x_resume()
1737 ret = regulator_bulk_enable(ARRAY_SIZE(pcm512x->supplies), in pcm512x_resume()
1738 pcm512x->supplies); in pcm512x_resume()
1744 regcache_cache_only(pcm512x->regmap, false); in pcm512x_resume()
1745 ret = regcache_sync(pcm512x->regmap); in pcm512x_resume()
1751 ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, in pcm512x_resume()