Lines Matching refs:spdifrx

253 	struct stm32_spdifrx_data *spdifrx = (struct stm32_spdifrx_data *)data;  in stm32_spdifrx_dma_complete()  local
254 struct platform_device *pdev = spdifrx->pdev; in stm32_spdifrx_dma_complete()
255 u32 *p_start = (u32 *)spdifrx->dmab->area; in stm32_spdifrx_dma_complete()
258 u16 *ub_ptr = (short *)spdifrx->ub; in stm32_spdifrx_dma_complete()
261 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, in stm32_spdifrx_dma_complete()
265 if (!spdifrx->dmab->area) in stm32_spdifrx_dma_complete()
280 spdifrx->cs[i] = (unsigned char)SPDIFRX_CSR_CSGET(*ptr); in stm32_spdifrx_dma_complete()
289 complete(&spdifrx->cs_completion); in stm32_spdifrx_dma_complete()
292 static int stm32_spdifrx_dma_ctrl_start(struct stm32_spdifrx_data *spdifrx) in stm32_spdifrx_dma_ctrl_start() argument
297 spdifrx->desc = dmaengine_prep_slave_single(spdifrx->ctrl_chan, in stm32_spdifrx_dma_ctrl_start()
298 spdifrx->dmab->addr, in stm32_spdifrx_dma_ctrl_start()
302 if (!spdifrx->desc) in stm32_spdifrx_dma_ctrl_start()
305 spdifrx->desc->callback = stm32_spdifrx_dma_complete; in stm32_spdifrx_dma_ctrl_start()
306 spdifrx->desc->callback_param = spdifrx; in stm32_spdifrx_dma_ctrl_start()
307 cookie = dmaengine_submit(spdifrx->desc); in stm32_spdifrx_dma_ctrl_start()
312 dma_async_issue_pending(spdifrx->ctrl_chan); in stm32_spdifrx_dma_ctrl_start()
317 static void stm32_spdifrx_dma_ctrl_stop(struct stm32_spdifrx_data *spdifrx) in stm32_spdifrx_dma_ctrl_stop() argument
319 dmaengine_terminate_async(spdifrx->ctrl_chan); in stm32_spdifrx_dma_ctrl_stop()
322 static int stm32_spdifrx_start_sync(struct stm32_spdifrx_data *spdifrx) in stm32_spdifrx_start_sync() argument
329 ret = regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_IMR, imr, imr); in stm32_spdifrx_start_sync()
333 spin_lock_irqsave(&spdifrx->lock, flags); in stm32_spdifrx_start_sync()
335 spdifrx->refcount++; in stm32_spdifrx_start_sync()
337 regmap_read(spdifrx->regmap, STM32_SPDIFRX_CR, &cr); in stm32_spdifrx_start_sync()
344 dev_dbg(&spdifrx->pdev->dev, "start synchronization\n"); in stm32_spdifrx_start_sync()
361 ret = regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, in stm32_spdifrx_start_sync()
364 dev_err(&spdifrx->pdev->dev, in stm32_spdifrx_start_sync()
368 spin_unlock_irqrestore(&spdifrx->lock, flags); in stm32_spdifrx_start_sync()
373 static void stm32_spdifrx_stop(struct stm32_spdifrx_data *spdifrx) in stm32_spdifrx_stop() argument
378 spin_lock_irqsave(&spdifrx->lock, flags); in stm32_spdifrx_stop()
380 if (--spdifrx->refcount) { in stm32_spdifrx_stop()
381 spin_unlock_irqrestore(&spdifrx->lock, flags); in stm32_spdifrx_stop()
388 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, cr_mask, cr); in stm32_spdifrx_stop()
390 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_IMR, in stm32_spdifrx_stop()
393 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_IFCR, in stm32_spdifrx_stop()
397 regmap_read(spdifrx->regmap, STM32_SPDIFRX_DR, &reg); in stm32_spdifrx_stop()
398 regmap_read(spdifrx->regmap, STM32_SPDIFRX_CSR, &reg); in stm32_spdifrx_stop()
400 spin_unlock_irqrestore(&spdifrx->lock, flags); in stm32_spdifrx_stop()
404 struct stm32_spdifrx_data *spdifrx) in stm32_spdifrx_dma_ctrl_register() argument
408 spdifrx->ctrl_chan = dma_request_chan(dev, "rx-ctrl"); in stm32_spdifrx_dma_ctrl_register()
409 if (IS_ERR(spdifrx->ctrl_chan)) in stm32_spdifrx_dma_ctrl_register()
410 return dev_err_probe(dev, PTR_ERR(spdifrx->ctrl_chan), in stm32_spdifrx_dma_ctrl_register()
413 spdifrx->dmab = devm_kzalloc(dev, sizeof(struct snd_dma_buffer), in stm32_spdifrx_dma_ctrl_register()
415 if (!spdifrx->dmab) in stm32_spdifrx_dma_ctrl_register()
418 spdifrx->dmab->dev.type = SNDRV_DMA_TYPE_DEV_IRAM; in stm32_spdifrx_dma_ctrl_register()
419 spdifrx->dmab->dev.dev = dev; in stm32_spdifrx_dma_ctrl_register()
420 ret = snd_dma_alloc_pages(spdifrx->dmab->dev.type, dev, in stm32_spdifrx_dma_ctrl_register()
421 SPDIFRX_CSR_BUF_LENGTH, spdifrx->dmab); in stm32_spdifrx_dma_ctrl_register()
427 spdifrx->slave_config.direction = DMA_DEV_TO_MEM; in stm32_spdifrx_dma_ctrl_register()
428 spdifrx->slave_config.src_addr = (dma_addr_t)(spdifrx->phys_addr + in stm32_spdifrx_dma_ctrl_register()
430 spdifrx->slave_config.dst_addr = spdifrx->dmab->addr; in stm32_spdifrx_dma_ctrl_register()
431 spdifrx->slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in stm32_spdifrx_dma_ctrl_register()
432 spdifrx->slave_config.src_maxburst = 1; in stm32_spdifrx_dma_ctrl_register()
434 ret = dmaengine_slave_config(spdifrx->ctrl_chan, in stm32_spdifrx_dma_ctrl_register()
435 &spdifrx->slave_config); in stm32_spdifrx_dma_ctrl_register()
438 spdifrx->ctrl_chan = NULL; in stm32_spdifrx_dma_ctrl_register()
479 static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx) in stm32_spdifrx_get_ctrl_data() argument
483 memset(spdifrx->cs, 0, SPDIFRX_CS_BYTES_NB); in stm32_spdifrx_get_ctrl_data()
484 memset(spdifrx->ub, 0, SPDIFRX_UB_BYTES_NB); in stm32_spdifrx_get_ctrl_data()
486 ret = stm32_spdifrx_dma_ctrl_start(spdifrx); in stm32_spdifrx_get_ctrl_data()
490 ret = clk_prepare_enable(spdifrx->kclk); in stm32_spdifrx_get_ctrl_data()
492 dev_err(&spdifrx->pdev->dev, "Enable kclk failed: %d\n", ret); in stm32_spdifrx_get_ctrl_data()
496 ret = regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, in stm32_spdifrx_get_ctrl_data()
501 ret = stm32_spdifrx_start_sync(spdifrx); in stm32_spdifrx_get_ctrl_data()
505 if (wait_for_completion_interruptible_timeout(&spdifrx->cs_completion, in stm32_spdifrx_get_ctrl_data()
508 dev_dbg(&spdifrx->pdev->dev, "Failed to get control data\n"); in stm32_spdifrx_get_ctrl_data()
512 stm32_spdifrx_stop(spdifrx); in stm32_spdifrx_get_ctrl_data()
513 stm32_spdifrx_dma_ctrl_stop(spdifrx); in stm32_spdifrx_get_ctrl_data()
516 clk_disable_unprepare(spdifrx->kclk); in stm32_spdifrx_get_ctrl_data()
525 struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai); in stm32_spdifrx_capture_get() local
527 stm32_spdifrx_get_ctrl_data(spdifrx); in stm32_spdifrx_capture_get()
529 ucontrol->value.iec958.status[0] = spdifrx->cs[0]; in stm32_spdifrx_capture_get()
530 ucontrol->value.iec958.status[1] = spdifrx->cs[1]; in stm32_spdifrx_capture_get()
531 ucontrol->value.iec958.status[2] = spdifrx->cs[2]; in stm32_spdifrx_capture_get()
532 ucontrol->value.iec958.status[3] = spdifrx->cs[3]; in stm32_spdifrx_capture_get()
533 ucontrol->value.iec958.status[4] = spdifrx->cs[4]; in stm32_spdifrx_capture_get()
542 struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai); in stm32_spdif_user_bits_get() local
544 stm32_spdifrx_get_ctrl_data(spdifrx); in stm32_spdif_user_bits_get()
546 ucontrol->value.iec958.status[0] = spdifrx->ub[0]; in stm32_spdif_user_bits_get()
547 ucontrol->value.iec958.status[1] = spdifrx->ub[1]; in stm32_spdif_user_bits_get()
548 ucontrol->value.iec958.status[2] = spdifrx->ub[2]; in stm32_spdif_user_bits_get()
549 ucontrol->value.iec958.status[3] = spdifrx->ub[3]; in stm32_spdif_user_bits_get()
550 ucontrol->value.iec958.status[4] = spdifrx->ub[4]; in stm32_spdif_user_bits_get()
597 struct stm32_spdifrx_data *spdifrx = dev_get_drvdata(cpu_dai->dev); in stm32_spdifrx_dai_probe() local
599 spdifrx->dma_params.addr = (dma_addr_t)(spdifrx->phys_addr + in stm32_spdifrx_dai_probe()
601 spdifrx->dma_params.maxburst = 1; in stm32_spdifrx_dai_probe()
603 snd_soc_dai_init_dma_data(cpu_dai, NULL, &spdifrx->dma_params); in stm32_spdifrx_dai_probe()
667 struct stm32_spdifrx_data *spdifrx = (struct stm32_spdifrx_data *)devid; in stm32_spdifrx_isr() local
668 struct platform_device *pdev = spdifrx->pdev; in stm32_spdifrx_isr()
673 regmap_read(spdifrx->regmap, STM32_SPDIFRX_SR, &sr); in stm32_spdifrx_isr()
674 regmap_read(spdifrx->regmap, STM32_SPDIFRX_IMR, &imr); in stm32_spdifrx_isr()
689 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_IFCR, in stm32_spdifrx_isr()
710 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, in stm32_spdifrx_isr()
730 regmap_read(spdifrx->regmap, STM32_SPDIFRX_CR, &cr); in stm32_spdifrx_isr()
736 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, in stm32_spdifrx_isr()
742 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, in stm32_spdifrx_isr()
747 spin_lock(&spdifrx->irq_lock); in stm32_spdifrx_isr()
748 if (spdifrx->substream) in stm32_spdifrx_isr()
749 snd_pcm_stop(spdifrx->substream, in stm32_spdifrx_isr()
751 spin_unlock(&spdifrx->irq_lock); in stm32_spdifrx_isr()
756 spin_lock(&spdifrx->irq_lock); in stm32_spdifrx_isr()
757 if (err_xrun && spdifrx->substream) in stm32_spdifrx_isr()
758 snd_pcm_stop_xrun(spdifrx->substream); in stm32_spdifrx_isr()
759 spin_unlock(&spdifrx->irq_lock); in stm32_spdifrx_isr()
767 struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai); in stm32_spdifrx_startup() local
771 spin_lock_irqsave(&spdifrx->irq_lock, flags); in stm32_spdifrx_startup()
772 spdifrx->substream = substream; in stm32_spdifrx_startup()
773 spin_unlock_irqrestore(&spdifrx->irq_lock, flags); in stm32_spdifrx_startup()
775 ret = clk_prepare_enable(spdifrx->kclk); in stm32_spdifrx_startup()
777 dev_err(&spdifrx->pdev->dev, "Enable kclk failed: %d\n", ret); in stm32_spdifrx_startup()
786 struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai); in stm32_spdifrx_hw_params() local
798 dev_err(&spdifrx->pdev->dev, "Unexpected data format\n"); in stm32_spdifrx_hw_params()
807 spdifrx->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; in stm32_spdifrx_hw_params()
808 snd_soc_dai_init_dma_data(cpu_dai, NULL, &spdifrx->dma_params); in stm32_spdifrx_hw_params()
810 return regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, in stm32_spdifrx_hw_params()
818 struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai); in stm32_spdifrx_trigger() local
825 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_IMR, in stm32_spdifrx_trigger()
828 regmap_update_bits(spdifrx->regmap, STM32_SPDIFRX_CR, in stm32_spdifrx_trigger()
831 ret = stm32_spdifrx_start_sync(spdifrx); in stm32_spdifrx_trigger()
836 stm32_spdifrx_stop(spdifrx); in stm32_spdifrx_trigger()
848 struct stm32_spdifrx_data *spdifrx = snd_soc_dai_get_drvdata(cpu_dai); in stm32_spdifrx_shutdown() local
851 spin_lock_irqsave(&spdifrx->irq_lock, flags); in stm32_spdifrx_shutdown()
852 spdifrx->substream = NULL; in stm32_spdifrx_shutdown()
853 spin_unlock_irqrestore(&spdifrx->irq_lock, flags); in stm32_spdifrx_shutdown()
855 clk_disable_unprepare(spdifrx->kclk); in stm32_spdifrx_shutdown()
908 struct stm32_spdifrx_data *spdifrx) in stm32_spdifrx_parse_of() argument
919 spdifrx->regmap_conf = in stm32_spdifrx_parse_of()
924 spdifrx->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in stm32_spdifrx_parse_of()
925 if (IS_ERR(spdifrx->base)) in stm32_spdifrx_parse_of()
926 return PTR_ERR(spdifrx->base); in stm32_spdifrx_parse_of()
928 spdifrx->phys_addr = res->start; in stm32_spdifrx_parse_of()
930 spdifrx->kclk = devm_clk_get(&pdev->dev, "kclk"); in stm32_spdifrx_parse_of()
931 if (IS_ERR(spdifrx->kclk)) in stm32_spdifrx_parse_of()
932 return dev_err_probe(&pdev->dev, PTR_ERR(spdifrx->kclk), in stm32_spdifrx_parse_of()
935 spdifrx->irq = platform_get_irq(pdev, 0); in stm32_spdifrx_parse_of()
936 if (spdifrx->irq < 0) in stm32_spdifrx_parse_of()
937 return spdifrx->irq; in stm32_spdifrx_parse_of()
944 struct stm32_spdifrx_data *spdifrx = platform_get_drvdata(pdev); in stm32_spdifrx_remove() local
946 if (spdifrx->ctrl_chan) in stm32_spdifrx_remove()
947 dma_release_channel(spdifrx->ctrl_chan); in stm32_spdifrx_remove()
949 if (spdifrx->dmab) in stm32_spdifrx_remove()
950 snd_dma_free_pages(spdifrx->dmab); in stm32_spdifrx_remove()
959 struct stm32_spdifrx_data *spdifrx; in stm32_spdifrx_probe() local
965 spdifrx = devm_kzalloc(&pdev->dev, sizeof(*spdifrx), GFP_KERNEL); in stm32_spdifrx_probe()
966 if (!spdifrx) in stm32_spdifrx_probe()
969 spdifrx->pdev = pdev; in stm32_spdifrx_probe()
970 init_completion(&spdifrx->cs_completion); in stm32_spdifrx_probe()
971 spin_lock_init(&spdifrx->lock); in stm32_spdifrx_probe()
972 spin_lock_init(&spdifrx->irq_lock); in stm32_spdifrx_probe()
974 platform_set_drvdata(pdev, spdifrx); in stm32_spdifrx_probe()
976 ret = stm32_spdifrx_parse_of(pdev, spdifrx); in stm32_spdifrx_probe()
980 spdifrx->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "kclk", in stm32_spdifrx_probe()
981 spdifrx->base, in stm32_spdifrx_probe()
982 spdifrx->regmap_conf); in stm32_spdifrx_probe()
983 if (IS_ERR(spdifrx->regmap)) in stm32_spdifrx_probe()
984 return dev_err_probe(&pdev->dev, PTR_ERR(spdifrx->regmap), in stm32_spdifrx_probe()
987 ret = devm_request_irq(&pdev->dev, spdifrx->irq, stm32_spdifrx_isr, 0, in stm32_spdifrx_probe()
988 dev_name(&pdev->dev), spdifrx); in stm32_spdifrx_probe()
1017 ret = stm32_spdifrx_dma_ctrl_register(&pdev->dev, spdifrx); in stm32_spdifrx_probe()
1021 ret = regmap_read(spdifrx->regmap, STM32_SPDIFRX_IDR, &idr); in stm32_spdifrx_probe()
1026 ret = regmap_read(spdifrx->regmap, STM32_SPDIFRX_VERR, &ver); in stm32_spdifrx_probe()
1050 struct stm32_spdifrx_data *spdifrx = dev_get_drvdata(dev); in stm32_spdifrx_suspend() local
1052 regcache_cache_only(spdifrx->regmap, true); in stm32_spdifrx_suspend()
1053 regcache_mark_dirty(spdifrx->regmap); in stm32_spdifrx_suspend()
1060 struct stm32_spdifrx_data *spdifrx = dev_get_drvdata(dev); in stm32_spdifrx_resume() local
1062 regcache_cache_only(spdifrx->regmap, false); in stm32_spdifrx_resume()
1064 return regcache_sync(spdifrx->regmap); in stm32_spdifrx_resume()