• Home
  • Raw
  • Download

Lines Matching +full:sun4i +full:- +full:a10 +full:- +full:spdif

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ALSA SoC SPDIF Audio Layer
170 * struct sun4i_spdif_quirks - Differences between SoC variants.
197 const struct sun4i_spdif_quirks *quirks = host->quirks; in sun4i_spdif_configure()
199 /* soft reset SPDIF */ in sun4i_spdif_configure()
200 regmap_write(host->regmap, SUN4I_SPDIF_CTL, SUN4I_SPDIF_CTL_RESET); in sun4i_spdif_configure()
203 regmap_update_bits(host->regmap, SUN4I_SPDIF_FCTL, in sun4i_spdif_configure()
204 quirks->val_fctl_ftx, quirks->val_fctl_ftx); in sun4i_spdif_configure()
207 regmap_write(host->regmap, SUN4I_SPDIF_TXCNT, 0); in sun4i_spdif_configure()
213 if (substream->runtime->channels == 1) in sun4i_snd_txctrl_on()
214 regmap_update_bits(host->regmap, SUN4I_SPDIF_TXCFG, in sun4i_snd_txctrl_on()
218 /* SPDIF TX ENABLE */ in sun4i_snd_txctrl_on()
219 regmap_update_bits(host->regmap, SUN4I_SPDIF_TXCFG, in sun4i_snd_txctrl_on()
223 regmap_update_bits(host->regmap, SUN4I_SPDIF_INT, in sun4i_snd_txctrl_on()
227 regmap_update_bits(host->regmap, SUN4I_SPDIF_CTL, in sun4i_snd_txctrl_on()
234 /* SPDIF TX DISABLE */ in sun4i_snd_txctrl_off()
235 regmap_update_bits(host->regmap, SUN4I_SPDIF_TXCFG, in sun4i_snd_txctrl_off()
239 regmap_update_bits(host->regmap, SUN4I_SPDIF_INT, in sun4i_snd_txctrl_off()
243 regmap_update_bits(host->regmap, SUN4I_SPDIF_CTL, in sun4i_snd_txctrl_off()
253 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in sun4i_spdif_startup()
254 return -EINVAL; in sun4i_spdif_startup()
272 struct platform_device *pdev = host->pdev; in sun4i_spdif_hw_params()
284 return -EINVAL; in sun4i_spdif_hw_params()
298 return -EINVAL; in sun4i_spdif_hw_params()
316 return -EINVAL; in sun4i_spdif_hw_params()
318 mclk *= host->quirks->mclk_multiplier; in sun4i_spdif_hw_params()
320 ret = clk_set_rate(host->spdif_clk, mclk); in sun4i_spdif_hw_params()
322 dev_err(&pdev->dev, in sun4i_spdif_hw_params()
323 "Setting SPDIF clock rate for %d Hz failed!\n", mclk); in sun4i_spdif_hw_params()
327 regmap_update_bits(host->regmap, SUN4I_SPDIF_FCTL, in sun4i_spdif_hw_params()
351 return -EINVAL; in sun4i_spdif_hw_params()
353 mclk_div *= host->quirks->mclk_multiplier; in sun4i_spdif_hw_params()
359 reg_val |= SUN4I_SPDIF_TXCFG_TXRATIO(mclk_div - 1); in sun4i_spdif_hw_params()
360 regmap_write(host->regmap, SUN4I_SPDIF_TXCFG, reg_val); in sun4i_spdif_hw_params()
371 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in sun4i_spdif_trigger()
372 return -EINVAL; in sun4i_spdif_trigger()
388 ret = -EINVAL; in sun4i_spdif_trigger()
397 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in sun4i_spdif_info()
398 uinfo->count = 1; in sun4i_spdif_info()
406 u8 *status = ucontrol->value.iec958.status; in sun4i_spdif_get_status_mask()
423 u8 *status = ucontrol->value.iec958.status; in sun4i_spdif_get_status()
427 spin_lock_irqsave(&host->lock, flags); in sun4i_spdif_get_status()
429 regmap_read(host->regmap, SUN4I_SPDIF_TXCHSTA0, &reg); in sun4i_spdif_get_status()
436 regmap_read(host->regmap, SUN4I_SPDIF_TXCHSTA1, &reg); in sun4i_spdif_get_status()
441 spin_unlock_irqrestore(&host->lock, flags); in sun4i_spdif_get_status()
451 u8 *status = ucontrol->value.iec958.status; in sun4i_spdif_set_status()
456 spin_lock_irqsave(&host->lock, flags); in sun4i_spdif_set_status()
463 regmap_update_bits_check(host->regmap, SUN4I_SPDIF_TXCHSTA0, in sun4i_spdif_set_status()
469 regmap_update_bits_check(host->regmap, SUN4I_SPDIF_TXCHSTA1, in sun4i_spdif_set_status()
476 regmap_update_bits(host->regmap, SUN4I_SPDIF_TXCFG, in sun4i_spdif_set_status()
480 spin_unlock_irqrestore(&host->lock, flags); in sun4i_spdif_set_status()
506 snd_soc_dai_init_dma_data(dai, &host->dma_params_tx, NULL); in sun4i_spdif_soc_dai_probe()
541 .name = "spdif",
573 .compatible = "allwinner,sun4i-a10-spdif",
577 .compatible = "allwinner,sun6i-a31-spdif",
581 .compatible = "allwinner,sun8i-h3-spdif",
585 .compatible = "allwinner,sun50i-h6-spdif",
589 .compatible = "allwinner,sun50i-h616-spdif",
598 .name = "sun4i-spdif",
606 clk_disable_unprepare(host->spdif_clk); in sun4i_spdif_runtime_suspend()
607 clk_disable_unprepare(host->apb_clk); in sun4i_spdif_runtime_suspend()
617 ret = clk_prepare_enable(host->spdif_clk); in sun4i_spdif_runtime_resume()
620 ret = clk_prepare_enable(host->apb_clk); in sun4i_spdif_runtime_resume()
622 clk_disable_unprepare(host->spdif_clk); in sun4i_spdif_runtime_resume()
635 dev_dbg(&pdev->dev, "Entered %s\n", __func__); in sun4i_spdif_probe()
637 host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); in sun4i_spdif_probe()
639 return -ENOMEM; in sun4i_spdif_probe()
641 host->pdev = pdev; in sun4i_spdif_probe()
642 spin_lock_init(&host->lock); in sun4i_spdif_probe()
645 memcpy(&host->cpu_dai_drv, &sun4i_spdif_dai, sizeof(sun4i_spdif_dai)); in sun4i_spdif_probe()
646 host->cpu_dai_drv.name = dev_name(&pdev->dev); in sun4i_spdif_probe()
653 quirks = of_device_get_match_data(&pdev->dev); in sun4i_spdif_probe()
655 dev_err(&pdev->dev, "Failed to determine the quirks to use\n"); in sun4i_spdif_probe()
656 return -ENODEV; in sun4i_spdif_probe()
658 host->quirks = quirks; in sun4i_spdif_probe()
660 host->regmap = devm_regmap_init_mmio(&pdev->dev, base, in sun4i_spdif_probe()
664 host->apb_clk = devm_clk_get(&pdev->dev, "apb"); in sun4i_spdif_probe()
665 if (IS_ERR(host->apb_clk)) { in sun4i_spdif_probe()
666 dev_err(&pdev->dev, "failed to get a apb clock.\n"); in sun4i_spdif_probe()
667 return PTR_ERR(host->apb_clk); in sun4i_spdif_probe()
670 host->spdif_clk = devm_clk_get(&pdev->dev, "spdif"); in sun4i_spdif_probe()
671 if (IS_ERR(host->spdif_clk)) { in sun4i_spdif_probe()
672 dev_err(&pdev->dev, "failed to get a spdif clock.\n"); in sun4i_spdif_probe()
673 return PTR_ERR(host->spdif_clk); in sun4i_spdif_probe()
676 host->dma_params_tx.addr = res->start + quirks->reg_dac_txdata; in sun4i_spdif_probe()
677 host->dma_params_tx.maxburst = 8; in sun4i_spdif_probe()
678 host->dma_params_tx.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; in sun4i_spdif_probe()
682 if (quirks->has_reset) { in sun4i_spdif_probe()
683 host->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, in sun4i_spdif_probe()
685 if (PTR_ERR(host->rst) == -EPROBE_DEFER) { in sun4i_spdif_probe()
686 ret = -EPROBE_DEFER; in sun4i_spdif_probe()
687 dev_err(&pdev->dev, "Failed to get reset: %d\n", ret); in sun4i_spdif_probe()
690 if (!IS_ERR(host->rst)) in sun4i_spdif_probe()
691 reset_control_deassert(host->rst); in sun4i_spdif_probe()
694 ret = devm_snd_soc_register_component(&pdev->dev, in sun4i_spdif_probe()
699 pm_runtime_enable(&pdev->dev); in sun4i_spdif_probe()
700 if (!pm_runtime_enabled(&pdev->dev)) { in sun4i_spdif_probe()
701 ret = sun4i_spdif_runtime_resume(&pdev->dev); in sun4i_spdif_probe()
706 ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); in sun4i_spdif_probe()
711 if (!pm_runtime_status_suspended(&pdev->dev)) in sun4i_spdif_probe()
712 sun4i_spdif_runtime_suspend(&pdev->dev); in sun4i_spdif_probe()
714 pm_runtime_disable(&pdev->dev); in sun4i_spdif_probe()
720 pm_runtime_disable(&pdev->dev); in sun4i_spdif_remove()
721 if (!pm_runtime_status_suspended(&pdev->dev)) in sun4i_spdif_remove()
722 sun4i_spdif_runtime_suspend(&pdev->dev); in sun4i_spdif_remove()
732 .name = "sun4i-spdif",
744 MODULE_DESCRIPTION("Allwinner sun4i SPDIF SoC Interface");
746 MODULE_ALIAS("platform:sun4i-spdif");