--- zzzz-none-000/linux-3.10.107/sound/soc/spear/spdif_in.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/soc/spear/spdif_in.c 2021-02-04 17:41:59.000000000 +0000 @@ -18,12 +18,14 @@ #include #include #include +#include #include #include #include #include #include #include "spdif_in_regs.h" +#include "spear_pcm.h" struct spdif_in_params { u32 format; @@ -37,6 +39,8 @@ struct device *dev; void (*reset_perip)(void); int irq; + struct snd_dmaengine_dai_dma_data dma_params_rx; + struct snd_dmaengine_pcm_config config; }; static void spdif_in_configure(struct spdif_in_dev *host) @@ -49,15 +53,13 @@ writel(0xF, host->io_base + SPDIF_IN_IRQ_MASK); } -static int spdif_in_startup(struct snd_pcm_substream *substream, - struct snd_soc_dai *cpu_dai) +static int spdif_in_dai_probe(struct snd_soc_dai *dai) { - struct spdif_in_dev *host = snd_soc_dai_get_drvdata(cpu_dai); + struct spdif_in_dev *host = snd_soc_dai_get_drvdata(dai); - if (substream->stream != SNDRV_PCM_STREAM_CAPTURE) - return -EINVAL; + host->dma_params_rx.filter_data = &host->dma_params; + dai->capture_dma_data = &host->dma_params_rx; - snd_soc_dai_set_dma_data(cpu_dai, substream, (void *)&host->dma_params); return 0; } @@ -70,7 +72,6 @@ return; writel(0x0, host->io_base + SPDIF_IN_IRQ_MASK); - snd_soc_dai_set_dma_data(dai, substream, NULL); } static void spdif_in_format(struct spdif_in_dev *host, u32 format) @@ -151,13 +152,13 @@ } static struct snd_soc_dai_ops spdif_in_dai_ops = { - .startup = spdif_in_startup, .shutdown = spdif_in_shutdown, .trigger = spdif_in_trigger, .hw_params = spdif_in_hw_params, }; -struct snd_soc_dai_driver spdif_in_dai = { +static struct snd_soc_dai_driver spdif_in_dai = { + .probe = spdif_in_dai_probe, .capture = { .channels_min = 2, .channels_max = 2, @@ -202,40 +203,30 @@ struct spdif_in_dev *host; struct spear_spdif_platform_data *pdata; struct resource *res, *res_fifo; + void __iomem *io_base; int ret; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) - return -EINVAL; + io_base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(io_base)) + return PTR_ERR(io_base); res_fifo = platform_get_resource(pdev, IORESOURCE_IO, 0); if (!res_fifo) return -EINVAL; - if (!devm_request_mem_region(&pdev->dev, res->start, - resource_size(res), pdev->name)) { - dev_warn(&pdev->dev, "Failed to get memory resourse\n"); - return -ENOENT; - } - host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); if (!host) { dev_warn(&pdev->dev, "kzalloc fail\n"); return -ENOMEM; } - host->io_base = devm_ioremap(&pdev->dev, res->start, - resource_size(res)); - if (!host->io_base) { - dev_warn(&pdev->dev, "ioremap failed\n"); - return -ENOMEM; - } - + host->io_base = io_base; host->irq = platform_get_irq(pdev, 0); if (host->irq < 0) return -EINVAL; - host->clk = clk_get(&pdev->dev, NULL); + host->clk = devm_clk_get(&pdev->dev, NULL); if (IS_ERR(host->clk)) return PTR_ERR(host->clk); @@ -248,7 +239,6 @@ host->dma_params.addr = res_fifo->start; host->dma_params.max_burst = 16; host->dma_params.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - host->dma_params.filter = pdata->filter; host->reset_perip = pdata->reset_perip; host->dev = &pdev->dev; @@ -257,40 +247,23 @@ ret = devm_request_irq(&pdev->dev, host->irq, spdif_in_irq, 0, "spdif-in", host); if (ret) { - clk_put(host->clk); dev_warn(&pdev->dev, "request_irq failed\n"); return ret; } - ret = snd_soc_register_component(&pdev->dev, &spdif_in_component, - &spdif_in_dai, 1); - if (ret != 0) { - clk_put(host->clk); + ret = devm_snd_soc_register_component(&pdev->dev, &spdif_in_component, + &spdif_in_dai, 1); + if (ret) return ret; - } - return 0; + return devm_spear_pcm_platform_register(&pdev->dev, &host->config, + pdata->filter); } -static int spdif_in_remove(struct platform_device *pdev) -{ - struct spdif_in_dev *host = dev_get_drvdata(&pdev->dev); - - snd_soc_unregister_component(&pdev->dev); - dev_set_drvdata(&pdev->dev, NULL); - - clk_put(host->clk); - - return 0; -} - - static struct platform_driver spdif_in_driver = { .probe = spdif_in_probe, - .remove = spdif_in_remove, .driver = { .name = "spdif-in", - .owner = THIS_MODULE, }, };