Lines Matching refs:spdif_priv
222 static void spdif_irq_dpll_lock(struct fsl_spdif_priv *spdif_priv) in spdif_irq_dpll_lock() argument
224 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_dpll_lock()
225 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_dpll_lock()
234 spdif_priv->dpll_locked = locked ? true : false; in spdif_irq_dpll_lock()
236 if (spdif_priv->snd_card && spdif_priv->rxrate_kcontrol) { in spdif_irq_dpll_lock()
237 snd_ctl_notify(spdif_priv->snd_card, in spdif_irq_dpll_lock()
239 &spdif_priv->rxrate_kcontrol->id); in spdif_irq_dpll_lock()
244 static void spdif_irq_sym_error(struct fsl_spdif_priv *spdif_priv) in spdif_irq_sym_error() argument
246 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_sym_error()
247 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_sym_error()
252 if (!spdif_priv->dpll_locked) in spdif_irq_sym_error()
257 static void spdif_irq_uqrx_full(struct fsl_spdif_priv *spdif_priv, char name) in spdif_irq_uqrx_full() argument
259 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uqrx_full()
260 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_uqrx_full()
261 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uqrx_full()
296 static void spdif_irq_uq_sync(struct fsl_spdif_priv *spdif_priv) in spdif_irq_uq_sync() argument
298 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uq_sync()
299 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uq_sync()
312 static void spdif_irq_uq_err(struct fsl_spdif_priv *spdif_priv) in spdif_irq_uq_err() argument
314 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uq_err()
315 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_uq_err()
316 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uq_err()
332 static u32 spdif_intr_status_clear(struct fsl_spdif_priv *spdif_priv) in spdif_intr_status_clear() argument
334 struct regmap *regmap = spdif_priv->regmap; in spdif_intr_status_clear()
347 struct fsl_spdif_priv *spdif_priv = (struct fsl_spdif_priv *)devid; in spdif_isr() local
348 struct platform_device *pdev = spdif_priv->pdev; in spdif_isr()
351 sis = spdif_intr_status_clear(spdif_priv); in spdif_isr()
354 spdif_irq_dpll_lock(spdif_priv); in spdif_isr()
369 spdif_irq_sym_error(spdif_priv); in spdif_isr()
375 spdif_irq_uqrx_full(spdif_priv, 'U'); in spdif_isr()
381 spdif_irq_uqrx_full(spdif_priv, 'Q'); in spdif_isr()
387 spdif_irq_uq_sync(spdif_priv); in spdif_isr()
390 spdif_irq_uq_err(spdif_priv); in spdif_isr()
399 spdif_irq_dpll_lock(spdif_priv); in spdif_isr()
412 static int spdif_softreset(struct fsl_spdif_priv *spdif_priv) in spdif_softreset() argument
414 struct regmap *regmap = spdif_priv->regmap; in spdif_softreset()
446 static void spdif_write_channel_status(struct fsl_spdif_priv *spdif_priv) in spdif_write_channel_status() argument
448 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_write_channel_status()
449 struct regmap *regmap = spdif_priv->regmap; in spdif_write_channel_status()
450 struct platform_device *pdev = spdif_priv->pdev; in spdif_write_channel_status()
465 if (spdif_priv->soc->cchannel_192b) { in spdif_write_channel_status()
484 static int spdif_set_rx_clksrc(struct fsl_spdif_priv *spdif_priv, in spdif_set_rx_clksrc() argument
487 struct regmap *regmap = spdif_priv->regmap; in spdif_set_rx_clksrc()
488 u8 clksrc = spdif_priv->rxclk_src; in spdif_set_rx_clksrc()
500 static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv, enum spdif_txrate index);
506 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in spdif_set_sample_rate() local
507 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_set_sample_rate()
508 struct regmap *regmap = spdif_priv->regmap; in spdif_set_sample_rate()
509 struct platform_device *pdev = spdif_priv->pdev; in spdif_set_sample_rate()
550 ret = fsl_spdif_probe_txclk(spdif_priv, rate); in spdif_set_sample_rate()
554 clk = spdif_priv->txclk_src[rate]; in spdif_set_sample_rate()
560 txclk_df = spdif_priv->txclk_df[rate]; in spdif_set_sample_rate()
566 sysclk_df = spdif_priv->sysclk_df[rate]; in spdif_set_sample_rate()
568 if (!fsl_spdif_can_set_clk_rate(spdif_priv, clk)) in spdif_set_sample_rate()
572 ret = clk_set_rate(spdif_priv->txclk[clk], in spdif_set_sample_rate()
583 clk_get_rate(spdif_priv->txclk[clk])); in spdif_set_sample_rate()
596 spdif_priv->txrate[rate], sample_rate); in spdif_set_sample_rate()
605 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in fsl_spdif_startup() local
606 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_startup()
607 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_startup()
613 ret = spdif_softreset(spdif_priv); in fsl_spdif_startup()
647 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in fsl_spdif_shutdown() local
648 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_shutdown()
667 spdif_intr_status_clear(spdif_priv); in fsl_spdif_shutdown()
673 static int spdif_reparent_rootclk(struct fsl_spdif_priv *spdif_priv, unsigned int sample_rate) in spdif_reparent_rootclk() argument
675 struct platform_device *pdev = spdif_priv->pdev; in spdif_reparent_rootclk()
680 if (!fsl_spdif_can_set_clk_rate(spdif_priv, STC_TXCLK_SPDIF_ROOT)) in spdif_reparent_rootclk()
684 clk = spdif_priv->txclk[STC_TXCLK_SPDIF_ROOT]; in spdif_reparent_rootclk()
688 fsl_asoc_reparent_pll_clocks(&pdev->dev, clk, spdif_priv->pll8k_clk, in spdif_reparent_rootclk()
689 spdif_priv->pll11k_clk, sample_rate); in spdif_reparent_rootclk()
701 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in fsl_spdif_hw_params() local
702 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_hw_params()
703 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_hw_params()
708 ret = spdif_reparent_rootclk(spdif_priv, sample_rate); in fsl_spdif_hw_params()
723 spdif_write_channel_status(spdif_priv); in fsl_spdif_hw_params()
726 ret = spdif_set_rx_clksrc(spdif_priv, SPDIF_DEFAULT_GAINSEL, 1); in fsl_spdif_hw_params()
736 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in fsl_spdif_trigger() local
737 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_trigger()
793 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_pb_get() local
794 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_pb_get()
808 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_pb_put() local
809 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_pb_put()
816 spdif_write_channel_status(spdif_priv); in fsl_spdif_pb_put()
826 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_capture_get() local
827 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_capture_get()
858 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_subcode_get() local
859 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_subcode_get()
890 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_qget() local
891 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_qget()
912 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_rx_vbit_get() local
913 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_vbit_get()
927 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_tx_vbit_get() local
928 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_tx_vbit_get()
943 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_tx_vbit_put() local
944 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_tx_vbit_put()
956 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_rx_rcm_get() local
957 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_rcm_get()
971 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_rx_rcm_put() local
972 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_rcm_put()
1065 static int spdif_get_rxclk_rate(struct fsl_spdif_priv *spdif_priv, in spdif_get_rxclk_rate() argument
1068 struct regmap *regmap = spdif_priv->regmap; in spdif_get_rxclk_rate()
1069 struct platform_device *pdev = spdif_priv->pdev; in spdif_get_rxclk_rate()
1081 busclk_freq = clk_get_rate(spdif_priv->sysclk); in spdif_get_rxclk_rate()
1104 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_rxrate_get() local
1107 if (spdif_priv->dpll_locked) in fsl_spdif_rxrate_get()
1108 rate = spdif_get_rxclk_rate(spdif_priv, SPDIF_DEFAULT_GAINSEL); in fsl_spdif_rxrate_get()
1124 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_usync_get() local
1125 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_usync_get()
1143 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_usync_put() local
1144 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_usync_put()
1421 static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, in fsl_spdif_txclk_caldiv() argument
1427 bool is_sysclk = clk_is_match(clk, spdif_priv->sysclk); in fsl_spdif_txclk_caldiv()
1451 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1452 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1453 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1462 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1463 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1464 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1472 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1473 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1474 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1483 static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv, in fsl_spdif_probe_txclk() argument
1488 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_probe_txclk()
1495 clk = spdif_priv->txclk[i]; in fsl_spdif_probe_txclk()
1503 ret = fsl_spdif_txclk_caldiv(spdif_priv, clk, savesub, index, in fsl_spdif_probe_txclk()
1504 fsl_spdif_can_set_clk_rate(spdif_priv, i)); in fsl_spdif_probe_txclk()
1509 spdif_priv->txclk_src[index] = i; in fsl_spdif_probe_txclk()
1517 spdif_priv->txclk_src[index], rate[index]); in fsl_spdif_probe_txclk()
1519 spdif_priv->txclk_df[index], rate[index]); in fsl_spdif_probe_txclk()
1520 if (clk_is_match(spdif_priv->txclk[spdif_priv->txclk_src[index]], spdif_priv->sysclk)) in fsl_spdif_probe_txclk()
1522 spdif_priv->sysclk_df[index], rate[index]); in fsl_spdif_probe_txclk()
1524 rate[index], spdif_priv->txrate[index]); in fsl_spdif_probe_txclk()
1531 struct fsl_spdif_priv *spdif_priv; in fsl_spdif_probe() local
1538 spdif_priv = devm_kzalloc(&pdev->dev, sizeof(*spdif_priv), GFP_KERNEL); in fsl_spdif_probe()
1539 if (!spdif_priv) in fsl_spdif_probe()
1542 spdif_priv->pdev = pdev; in fsl_spdif_probe()
1544 spdif_priv->soc = of_device_get_match_data(&pdev->dev); in fsl_spdif_probe()
1547 memcpy(&spdif_priv->cpu_dai_drv, &fsl_spdif_dai, sizeof(fsl_spdif_dai)); in fsl_spdif_probe()
1548 spdif_priv->cpu_dai_drv.name = dev_name(&pdev->dev); in fsl_spdif_probe()
1549 spdif_priv->cpu_dai_drv.playback.formats = in fsl_spdif_probe()
1550 spdif_priv->soc->tx_formats; in fsl_spdif_probe()
1557 spdif_priv->regmap = devm_regmap_init_mmio(&pdev->dev, regs, &fsl_spdif_regmap_config); in fsl_spdif_probe()
1558 if (IS_ERR(spdif_priv->regmap)) { in fsl_spdif_probe()
1560 return PTR_ERR(spdif_priv->regmap); in fsl_spdif_probe()
1563 for (i = 0; i < spdif_priv->soc->interrupts; i++) { in fsl_spdif_probe()
1569 dev_name(&pdev->dev), spdif_priv); in fsl_spdif_probe()
1578 spdif_priv->txclk[i] = devm_clk_get(&pdev->dev, tmp); in fsl_spdif_probe()
1579 if (IS_ERR(spdif_priv->txclk[i])) { in fsl_spdif_probe()
1581 return PTR_ERR(spdif_priv->txclk[i]); in fsl_spdif_probe()
1586 spdif_priv->sysclk = spdif_priv->txclk[5]; in fsl_spdif_probe()
1587 if (IS_ERR(spdif_priv->sysclk)) { in fsl_spdif_probe()
1589 return PTR_ERR(spdif_priv->sysclk); in fsl_spdif_probe()
1593 spdif_priv->coreclk = devm_clk_get(&pdev->dev, "core"); in fsl_spdif_probe()
1594 if (IS_ERR(spdif_priv->coreclk)) { in fsl_spdif_probe()
1596 return PTR_ERR(spdif_priv->coreclk); in fsl_spdif_probe()
1599 spdif_priv->spbaclk = devm_clk_get(&pdev->dev, "spba"); in fsl_spdif_probe()
1600 if (IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_probe()
1604 spdif_priv->rxclk = spdif_priv->txclk[1]; in fsl_spdif_probe()
1605 if (IS_ERR(spdif_priv->rxclk)) { in fsl_spdif_probe()
1607 return PTR_ERR(spdif_priv->rxclk); in fsl_spdif_probe()
1609 spdif_priv->rxclk_src = DEFAULT_RXCLK_SRC; in fsl_spdif_probe()
1611 fsl_asoc_get_pll_clocks(&pdev->dev, &spdif_priv->pll8k_clk, in fsl_spdif_probe()
1612 &spdif_priv->pll11k_clk); in fsl_spdif_probe()
1615 ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_probe()
1626 spdif_priv->dpll_locked = false; in fsl_spdif_probe()
1628 spdif_priv->dma_params_tx.maxburst = spdif_priv->soc->tx_burst; in fsl_spdif_probe()
1629 spdif_priv->dma_params_rx.maxburst = spdif_priv->soc->rx_burst; in fsl_spdif_probe()
1630 spdif_priv->dma_params_tx.addr = res->start + REG_SPDIF_STL; in fsl_spdif_probe()
1631 spdif_priv->dma_params_rx.addr = res->start + REG_SPDIF_SRL; in fsl_spdif_probe()
1634 dev_set_drvdata(&pdev->dev, spdif_priv); in fsl_spdif_probe()
1636 regcache_cache_only(spdif_priv->regmap, true); in fsl_spdif_probe()
1649 &spdif_priv->cpu_dai_drv, 1); in fsl_spdif_probe()
1672 struct fsl_spdif_priv *spdif_priv = dev_get_drvdata(dev); in fsl_spdif_runtime_suspend() local
1676 regmap_update_bits(spdif_priv->regmap, REG_SPDIF_SIE, 0xffffff, 0); in fsl_spdif_runtime_suspend()
1678 regmap_read(spdif_priv->regmap, REG_SPDIF_SRPC, in fsl_spdif_runtime_suspend()
1679 &spdif_priv->regcache_srpc); in fsl_spdif_runtime_suspend()
1680 regcache_cache_only(spdif_priv->regmap, true); in fsl_spdif_runtime_suspend()
1683 clk_disable_unprepare(spdif_priv->txclk[i]); in fsl_spdif_runtime_suspend()
1685 if (!IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_runtime_suspend()
1686 clk_disable_unprepare(spdif_priv->spbaclk); in fsl_spdif_runtime_suspend()
1687 clk_disable_unprepare(spdif_priv->coreclk); in fsl_spdif_runtime_suspend()
1694 struct fsl_spdif_priv *spdif_priv = dev_get_drvdata(dev); in fsl_spdif_runtime_resume() local
1698 ret = clk_prepare_enable(spdif_priv->coreclk); in fsl_spdif_runtime_resume()
1704 if (!IS_ERR(spdif_priv->spbaclk)) { in fsl_spdif_runtime_resume()
1705 ret = clk_prepare_enable(spdif_priv->spbaclk); in fsl_spdif_runtime_resume()
1713 ret = clk_prepare_enable(spdif_priv->txclk[i]); in fsl_spdif_runtime_resume()
1718 regcache_cache_only(spdif_priv->regmap, false); in fsl_spdif_runtime_resume()
1719 regcache_mark_dirty(spdif_priv->regmap); in fsl_spdif_runtime_resume()
1721 regmap_update_bits(spdif_priv->regmap, REG_SPDIF_SRPC, in fsl_spdif_runtime_resume()
1723 spdif_priv->regcache_srpc); in fsl_spdif_runtime_resume()
1725 ret = regcache_sync(spdif_priv->regmap); in fsl_spdif_runtime_resume()
1733 clk_disable_unprepare(spdif_priv->txclk[i]); in fsl_spdif_runtime_resume()
1734 if (!IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_runtime_resume()
1735 clk_disable_unprepare(spdif_priv->spbaclk); in fsl_spdif_runtime_resume()
1737 clk_disable_unprepare(spdif_priv->coreclk); in fsl_spdif_runtime_resume()