--- zzzz-none-000/linux-3.10.107/sound/soc/samsung/s3c2412-i2s.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/soc/samsung/s3c2412-i2s.c 2021-02-04 17:41:59.000000000 +0000 @@ -26,30 +26,22 @@ #include #include +#include +#include #include "dma.h" #include "regs-i2s-v2.h" #include "s3c2412-i2s.h" -static struct s3c2410_dma_client s3c2412_dma_client_out = { - .name = "I2S PCM Stereo out" -}; - -static struct s3c2410_dma_client s3c2412_dma_client_in = { - .name = "I2S PCM Stereo in" -}; - static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { - .client = &s3c2412_dma_client_out, - .channel = DMACH_I2S_OUT, - .dma_addr = S3C2410_PA_IIS + S3C2412_IISTXD, + .slave = (void *)(uintptr_t)DMACH_I2S_OUT, + .ch_name = "tx", .dma_size = 4, }; static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { - .client = &s3c2412_dma_client_in, - .channel = DMACH_I2S_IN, - .dma_addr = S3C2410_PA_IIS + S3C2412_IISRXD, + .slave = (void *)(uintptr_t)DMACH_I2S_IN, + .ch_name = "rx", .dma_size = 4, }; @@ -61,6 +53,9 @@ pr_debug("Entered %s\n", __func__); + samsung_asoc_init_dma_data(dai, &s3c2412_i2s_pcm_stereo_out, + &s3c2412_i2s_pcm_stereo_in); + ret = s3c_i2sv2_probe(dai, &s3c2412_i2s, S3C2410_PA_IIS); if (ret) return ret; @@ -68,17 +63,16 @@ s3c2412_i2s.dma_capture = &s3c2412_i2s_pcm_stereo_in; s3c2412_i2s.dma_playback = &s3c2412_i2s_pcm_stereo_out; - s3c2412_i2s.iis_cclk = clk_get(dai->dev, "i2sclk"); + s3c2412_i2s.iis_cclk = devm_clk_get(dai->dev, "i2sclk"); if (IS_ERR(s3c2412_i2s.iis_cclk)) { pr_err("failed to get i2sclk clock\n"); - iounmap(s3c2412_i2s.regs); return PTR_ERR(s3c2412_i2s.iis_cclk); } /* Set MPLL as the source for IIS CLK */ clk_set_parent(s3c2412_i2s.iis_cclk, clk_get(NULL, "mpll")); - clk_enable(s3c2412_i2s.iis_cclk); + clk_prepare_enable(s3c2412_i2s.iis_cclk); s3c2412_i2s.iis_cclk = s3c2412_i2s.iis_pclk; @@ -91,9 +85,7 @@ static int s3c2412_i2s_remove(struct snd_soc_dai *dai) { - clk_disable(s3c2412_i2s.iis_cclk); - clk_put(s3c2412_i2s.iis_cclk); - iounmap(s3c2412_i2s.regs); + clk_disable_unprepare(s3c2412_i2s.iis_cclk); return 0; } @@ -103,26 +95,18 @@ struct snd_soc_dai *cpu_dai) { struct s3c_i2sv2_info *i2s = snd_soc_dai_get_drvdata(cpu_dai); - struct s3c_dma_params *dma_data; u32 iismod; pr_debug("Entered %s\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dma_data = i2s->dma_playback; - else - dma_data = i2s->dma_capture; - - snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data); - iismod = readl(i2s->regs + S3C2412_IISMOD); pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S8: + switch (params_width(params)) { + case 8: iismod |= S3C2412_IISMOD_8BIT; break; - case SNDRV_PCM_FORMAT_S16_LE: + case 16: iismod &= ~S3C2412_IISMOD_8BIT; break; } @@ -167,6 +151,15 @@ static int s3c2412_iis_dev_probe(struct platform_device *pdev) { int ret = 0; + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + s3c2412_i2s.regs = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(s3c2412_i2s.regs)) + return PTR_ERR(s3c2412_i2s.regs); + + s3c2412_i2s_pcm_stereo_out.dma_addr = res->start + S3C2412_IISTXD; + s3c2412_i2s_pcm_stereo_in.dma_addr = res->start + S3C2412_IISRXD; ret = s3c_i2sv2_register_component(&pdev->dev, -1, &s3c2412_i2s_component, @@ -176,31 +169,17 @@ return ret; } - ret = asoc_dma_platform_register(&pdev->dev); - if (ret) { + ret = samsung_asoc_dma_platform_register(&pdev->dev); + if (ret) pr_err("failed to register the DMA: %d\n", ret); - goto err; - } - return 0; -err: - snd_soc_unregister_component(&pdev->dev); return ret; } -static int s3c2412_iis_dev_remove(struct platform_device *pdev) -{ - asoc_dma_platform_unregister(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - return 0; -} - static struct platform_driver s3c2412_iis_driver = { .probe = s3c2412_iis_dev_probe, - .remove = s3c2412_iis_dev_remove, .driver = { .name = "s3c2412-iis", - .owner = THIS_MODULE, }, };