Lines Matching refs:spdif_priv

211 static void spdif_irq_dpll_lock(struct fsl_spdif_priv *spdif_priv)  in spdif_irq_dpll_lock()  argument
213 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_dpll_lock()
214 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_dpll_lock()
223 spdif_priv->dpll_locked = locked ? true : false; in spdif_irq_dpll_lock()
227 static void spdif_irq_sym_error(struct fsl_spdif_priv *spdif_priv) in spdif_irq_sym_error() argument
229 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_sym_error()
230 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_sym_error()
235 if (!spdif_priv->dpll_locked) in spdif_irq_sym_error()
240 static void spdif_irq_uqrx_full(struct fsl_spdif_priv *spdif_priv, char name) in spdif_irq_uqrx_full() argument
242 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uqrx_full()
243 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_uqrx_full()
244 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uqrx_full()
279 static void spdif_irq_uq_sync(struct fsl_spdif_priv *spdif_priv) in spdif_irq_uq_sync() argument
281 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uq_sync()
282 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uq_sync()
295 static void spdif_irq_uq_err(struct fsl_spdif_priv *spdif_priv) in spdif_irq_uq_err() argument
297 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_irq_uq_err()
298 struct regmap *regmap = spdif_priv->regmap; in spdif_irq_uq_err()
299 struct platform_device *pdev = spdif_priv->pdev; in spdif_irq_uq_err()
315 static u32 spdif_intr_status_clear(struct fsl_spdif_priv *spdif_priv) in spdif_intr_status_clear() argument
317 struct regmap *regmap = spdif_priv->regmap; in spdif_intr_status_clear()
330 struct fsl_spdif_priv *spdif_priv = (struct fsl_spdif_priv *)devid; in spdif_isr() local
331 struct platform_device *pdev = spdif_priv->pdev; in spdif_isr()
334 sis = spdif_intr_status_clear(spdif_priv); in spdif_isr()
337 spdif_irq_dpll_lock(spdif_priv); in spdif_isr()
352 spdif_irq_sym_error(spdif_priv); in spdif_isr()
358 spdif_irq_uqrx_full(spdif_priv, 'U'); in spdif_isr()
364 spdif_irq_uqrx_full(spdif_priv, 'Q'); in spdif_isr()
370 spdif_irq_uq_sync(spdif_priv); in spdif_isr()
373 spdif_irq_uq_err(spdif_priv); in spdif_isr()
382 spdif_irq_dpll_lock(spdif_priv); in spdif_isr()
395 static int spdif_softreset(struct fsl_spdif_priv *spdif_priv) in spdif_softreset() argument
397 struct regmap *regmap = spdif_priv->regmap; in spdif_softreset()
429 static void spdif_write_channel_status(struct fsl_spdif_priv *spdif_priv) in spdif_write_channel_status() argument
431 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_write_channel_status()
432 struct regmap *regmap = spdif_priv->regmap; in spdif_write_channel_status()
433 struct platform_device *pdev = spdif_priv->pdev; in spdif_write_channel_status()
448 if (spdif_priv->soc->cchannel_192b) { in spdif_write_channel_status()
467 static int spdif_set_rx_clksrc(struct fsl_spdif_priv *spdif_priv, in spdif_set_rx_clksrc() argument
470 struct regmap *regmap = spdif_priv->regmap; in spdif_set_rx_clksrc()
471 u8 clksrc = spdif_priv->rxclk_src; in spdif_set_rx_clksrc()
487 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in spdif_set_sample_rate() local
488 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in spdif_set_sample_rate()
489 struct regmap *regmap = spdif_priv->regmap; in spdif_set_sample_rate()
490 struct platform_device *pdev = spdif_priv->pdev; in spdif_set_sample_rate()
531 clk = spdif_priv->txclk_src[rate]; in spdif_set_sample_rate()
537 txclk_df = spdif_priv->txclk_df[rate]; in spdif_set_sample_rate()
543 sysclk_df = spdif_priv->sysclk_df[rate]; in spdif_set_sample_rate()
545 if (!fsl_spdif_can_set_clk_rate(spdif_priv, clk)) in spdif_set_sample_rate()
549 ret = clk_set_rate(spdif_priv->txclk[clk], in spdif_set_sample_rate()
560 clk_get_rate(spdif_priv->txclk[clk])); in spdif_set_sample_rate()
573 spdif_priv->txrate[rate], sample_rate); in spdif_set_sample_rate()
582 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in fsl_spdif_startup() local
583 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_startup()
584 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_startup()
590 ret = spdif_softreset(spdif_priv); in fsl_spdif_startup()
624 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in fsl_spdif_shutdown() local
625 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_shutdown()
644 spdif_intr_status_clear(spdif_priv); in fsl_spdif_shutdown()
655 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in fsl_spdif_hw_params() local
656 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_hw_params()
657 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_hw_params()
670 spdif_write_channel_status(spdif_priv); in fsl_spdif_hw_params()
673 ret = spdif_set_rx_clksrc(spdif_priv, SPDIF_DEFAULT_GAINSEL, 1); in fsl_spdif_hw_params()
683 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(asoc_rtd_to_cpu(rtd, 0)); in fsl_spdif_trigger() local
684 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_trigger()
740 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_pb_get() local
741 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_pb_get()
755 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_pb_put() local
756 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_pb_put()
763 spdif_write_channel_status(spdif_priv); in fsl_spdif_pb_put()
773 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_capture_get() local
774 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_capture_get()
805 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_subcode_get() local
806 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_subcode_get()
837 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_qget() local
838 struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_qget()
859 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_rx_vbit_get() local
860 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_vbit_get()
874 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_tx_vbit_get() local
875 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_tx_vbit_get()
890 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_tx_vbit_put() local
891 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_tx_vbit_put()
903 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_rx_rcm_get() local
904 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_rcm_get()
918 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_rx_rcm_put() local
919 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_rx_rcm_put()
1012 static int spdif_get_rxclk_rate(struct fsl_spdif_priv *spdif_priv, in spdif_get_rxclk_rate() argument
1015 struct regmap *regmap = spdif_priv->regmap; in spdif_get_rxclk_rate()
1016 struct platform_device *pdev = spdif_priv->pdev; in spdif_get_rxclk_rate()
1028 busclk_freq = clk_get_rate(spdif_priv->sysclk); in spdif_get_rxclk_rate()
1051 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_rxrate_get() local
1054 if (spdif_priv->dpll_locked) in fsl_spdif_rxrate_get()
1055 rate = spdif_get_rxclk_rate(spdif_priv, SPDIF_DEFAULT_GAINSEL); in fsl_spdif_rxrate_get()
1071 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_usync_get() local
1072 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_usync_get()
1090 struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); in fsl_spdif_usync_put() local
1091 struct regmap *regmap = spdif_priv->regmap; in fsl_spdif_usync_put()
1360 static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, in fsl_spdif_txclk_caldiv() argument
1366 bool is_sysclk = clk_is_match(clk, spdif_priv->sysclk); in fsl_spdif_txclk_caldiv()
1390 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1391 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1392 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1401 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1402 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1403 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1411 spdif_priv->txclk_df[index] = txclk_df; in fsl_spdif_txclk_caldiv()
1412 spdif_priv->sysclk_df[index] = sysclk_df; in fsl_spdif_txclk_caldiv()
1413 spdif_priv->txrate[index] = arate; in fsl_spdif_txclk_caldiv()
1422 static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv, in fsl_spdif_probe_txclk() argument
1427 struct platform_device *pdev = spdif_priv->pdev; in fsl_spdif_probe_txclk()
1434 clk = spdif_priv->txclk[i]; in fsl_spdif_probe_txclk()
1442 ret = fsl_spdif_txclk_caldiv(spdif_priv, clk, savesub, index, in fsl_spdif_probe_txclk()
1443 fsl_spdif_can_set_clk_rate(spdif_priv, i)); in fsl_spdif_probe_txclk()
1448 spdif_priv->txclk_src[index] = i; in fsl_spdif_probe_txclk()
1456 spdif_priv->txclk_src[index], rate[index]); in fsl_spdif_probe_txclk()
1458 spdif_priv->txclk_df[index], rate[index]); in fsl_spdif_probe_txclk()
1459 if (clk_is_match(spdif_priv->txclk[spdif_priv->txclk_src[index]], spdif_priv->sysclk)) in fsl_spdif_probe_txclk()
1461 spdif_priv->sysclk_df[index], rate[index]); in fsl_spdif_probe_txclk()
1463 rate[index], spdif_priv->txrate[index]); in fsl_spdif_probe_txclk()
1470 struct fsl_spdif_priv *spdif_priv; in fsl_spdif_probe() local
1477 spdif_priv = devm_kzalloc(&pdev->dev, sizeof(*spdif_priv), GFP_KERNEL); in fsl_spdif_probe()
1478 if (!spdif_priv) in fsl_spdif_probe()
1481 spdif_priv->pdev = pdev; in fsl_spdif_probe()
1483 spdif_priv->soc = of_device_get_match_data(&pdev->dev); in fsl_spdif_probe()
1486 memcpy(&spdif_priv->cpu_dai_drv, &fsl_spdif_dai, sizeof(fsl_spdif_dai)); in fsl_spdif_probe()
1487 spdif_priv->cpu_dai_drv.name = dev_name(&pdev->dev); in fsl_spdif_probe()
1488 spdif_priv->cpu_dai_drv.playback.formats = in fsl_spdif_probe()
1489 spdif_priv->soc->tx_formats; in fsl_spdif_probe()
1496 spdif_priv->regmap = devm_regmap_init_mmio(&pdev->dev, regs, &fsl_spdif_regmap_config); in fsl_spdif_probe()
1497 if (IS_ERR(spdif_priv->regmap)) { in fsl_spdif_probe()
1499 return PTR_ERR(spdif_priv->regmap); in fsl_spdif_probe()
1502 for (i = 0; i < spdif_priv->soc->interrupts; i++) { in fsl_spdif_probe()
1508 dev_name(&pdev->dev), spdif_priv); in fsl_spdif_probe()
1517 spdif_priv->txclk[i] = devm_clk_get(&pdev->dev, tmp); in fsl_spdif_probe()
1518 if (IS_ERR(spdif_priv->txclk[i])) { in fsl_spdif_probe()
1520 return PTR_ERR(spdif_priv->txclk[i]); in fsl_spdif_probe()
1525 spdif_priv->sysclk = spdif_priv->txclk[5]; in fsl_spdif_probe()
1526 if (IS_ERR(spdif_priv->sysclk)) { in fsl_spdif_probe()
1528 return PTR_ERR(spdif_priv->sysclk); in fsl_spdif_probe()
1532 spdif_priv->coreclk = devm_clk_get(&pdev->dev, "core"); in fsl_spdif_probe()
1533 if (IS_ERR(spdif_priv->coreclk)) { in fsl_spdif_probe()
1535 return PTR_ERR(spdif_priv->coreclk); in fsl_spdif_probe()
1538 spdif_priv->spbaclk = devm_clk_get(&pdev->dev, "spba"); in fsl_spdif_probe()
1539 if (IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_probe()
1543 spdif_priv->rxclk = spdif_priv->txclk[1]; in fsl_spdif_probe()
1544 if (IS_ERR(spdif_priv->rxclk)) { in fsl_spdif_probe()
1546 return PTR_ERR(spdif_priv->rxclk); in fsl_spdif_probe()
1548 spdif_priv->rxclk_src = DEFAULT_RXCLK_SRC; in fsl_spdif_probe()
1551 ret = fsl_spdif_probe_txclk(spdif_priv, i); in fsl_spdif_probe()
1557 ctrl = &spdif_priv->fsl_spdif_control; in fsl_spdif_probe()
1568 spdif_priv->dpll_locked = false; in fsl_spdif_probe()
1570 spdif_priv->dma_params_tx.maxburst = spdif_priv->soc->tx_burst; in fsl_spdif_probe()
1571 spdif_priv->dma_params_rx.maxburst = spdif_priv->soc->rx_burst; in fsl_spdif_probe()
1572 spdif_priv->dma_params_tx.addr = res->start + REG_SPDIF_STL; in fsl_spdif_probe()
1573 spdif_priv->dma_params_rx.addr = res->start + REG_SPDIF_SRL; in fsl_spdif_probe()
1576 dev_set_drvdata(&pdev->dev, spdif_priv); in fsl_spdif_probe()
1578 regcache_cache_only(spdif_priv->regmap, true); in fsl_spdif_probe()
1591 &spdif_priv->cpu_dai_drv, 1); in fsl_spdif_probe()
1614 struct fsl_spdif_priv *spdif_priv = dev_get_drvdata(dev); in fsl_spdif_runtime_suspend() local
1618 regmap_update_bits(spdif_priv->regmap, REG_SPDIF_SIE, 0xffffff, 0); in fsl_spdif_runtime_suspend()
1620 regmap_read(spdif_priv->regmap, REG_SPDIF_SRPC, in fsl_spdif_runtime_suspend()
1621 &spdif_priv->regcache_srpc); in fsl_spdif_runtime_suspend()
1622 regcache_cache_only(spdif_priv->regmap, true); in fsl_spdif_runtime_suspend()
1625 clk_disable_unprepare(spdif_priv->txclk[i]); in fsl_spdif_runtime_suspend()
1627 if (!IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_runtime_suspend()
1628 clk_disable_unprepare(spdif_priv->spbaclk); in fsl_spdif_runtime_suspend()
1629 clk_disable_unprepare(spdif_priv->coreclk); in fsl_spdif_runtime_suspend()
1636 struct fsl_spdif_priv *spdif_priv = dev_get_drvdata(dev); in fsl_spdif_runtime_resume() local
1640 ret = clk_prepare_enable(spdif_priv->coreclk); in fsl_spdif_runtime_resume()
1646 if (!IS_ERR(spdif_priv->spbaclk)) { in fsl_spdif_runtime_resume()
1647 ret = clk_prepare_enable(spdif_priv->spbaclk); in fsl_spdif_runtime_resume()
1655 ret = clk_prepare_enable(spdif_priv->txclk[i]); in fsl_spdif_runtime_resume()
1660 regcache_cache_only(spdif_priv->regmap, false); in fsl_spdif_runtime_resume()
1661 regcache_mark_dirty(spdif_priv->regmap); in fsl_spdif_runtime_resume()
1663 regmap_update_bits(spdif_priv->regmap, REG_SPDIF_SRPC, in fsl_spdif_runtime_resume()
1665 spdif_priv->regcache_srpc); in fsl_spdif_runtime_resume()
1667 ret = regcache_sync(spdif_priv->regmap); in fsl_spdif_runtime_resume()
1675 clk_disable_unprepare(spdif_priv->txclk[i]); in fsl_spdif_runtime_resume()
1676 if (!IS_ERR(spdif_priv->spbaclk)) in fsl_spdif_runtime_resume()
1677 clk_disable_unprepare(spdif_priv->spbaclk); in fsl_spdif_runtime_resume()
1679 clk_disable_unprepare(spdif_priv->coreclk); in fsl_spdif_runtime_resume()