--- zzzz-none-000/linux-3.10.107/sound/soc/samsung/s3c24xx-i2s.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/sound/soc/samsung/s3c24xx-i2s.c 2021-02-04 17:41:59.000000000 +0000 @@ -24,30 +24,22 @@ #include #include +#include +#include #include "regs-iis.h" #include "dma.h" #include "s3c24xx-i2s.h" -static struct s3c2410_dma_client s3c24xx_dma_client_out = { - .name = "I2S PCM Stereo out" -}; - -static struct s3c2410_dma_client s3c24xx_dma_client_in = { - .name = "I2S PCM Stereo in" -}; - static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { - .client = &s3c24xx_dma_client_out, - .channel = DMACH_I2S_OUT, - .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, + .slave = (void *)(uintptr_t)DMACH_I2S_OUT, + .ch_name = "tx", .dma_size = 2, }; static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { - .client = &s3c24xx_dma_client_in, - .channel = DMACH_I2S_IN, - .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, + .slave = (void *)(uintptr_t)DMACH_I2S_IN, + .ch_name = "rx", .dma_size = 2, }; @@ -229,31 +221,25 @@ struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct s3c_dma_params *dma_data; + struct snd_dmaengine_dai_dma_data *dma_data; u32 iismod; pr_debug("Entered %s\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - dma_data = &s3c24xx_i2s_pcm_stereo_out; - else - dma_data = &s3c24xx_i2s_pcm_stereo_in; - - snd_soc_dai_set_dma_data(rtd->cpu_dai, substream, dma_data); + dma_data = snd_soc_dai_get_dma_data(dai, substream); /* Working copies of register */ iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); pr_debug("hw_params r: IISMOD: %x\n", iismod); - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S8: + switch (params_width(params)) { + case 8: iismod &= ~S3C2410_IISMOD_16BIT; - dma_data->dma_size = 1; + dma_data->addr_width = 1; break; - case SNDRV_PCM_FORMAT_S16_LE: + case 16: iismod |= S3C2410_IISMOD_16BIT; - dma_data->dma_size = 2; + dma_data->addr_width = 2; break; default: return -EINVAL; @@ -268,8 +254,6 @@ struct snd_soc_dai *dai) { int ret = 0; - struct s3c_dma_params *dma_data = - snd_soc_dai_get_dma_data(dai, substream); pr_debug("Entered %s\n", __func__); @@ -288,7 +272,6 @@ else s3c24xx_snd_txctrl(1); - s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: @@ -378,17 +361,15 @@ { pr_debug("Entered %s\n", __func__); - s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100); - if (s3c24xx_i2s.regs == NULL) - return -ENXIO; + samsung_asoc_init_dma_data(dai, &s3c24xx_i2s_pcm_stereo_out, + &s3c24xx_i2s_pcm_stereo_in); - s3c24xx_i2s.iis_clk = clk_get(dai->dev, "iis"); + s3c24xx_i2s.iis_clk = devm_clk_get(dai->dev, "iis"); if (IS_ERR(s3c24xx_i2s.iis_clk)) { pr_err("failed to get iis_clock\n"); - iounmap(s3c24xx_i2s.regs); return PTR_ERR(s3c24xx_i2s.iis_clk); } - clk_enable(s3c24xx_i2s.iis_clk); + clk_prepare_enable(s3c24xx_i2s.iis_clk); /* Configure the I2S pins (GPE0...GPE4) in correct mode */ s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2), @@ -412,7 +393,7 @@ s3c24xx_i2s.iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); s3c24xx_i2s.iispsr = readl(s3c24xx_i2s.regs + S3C2410_IISPSR); - clk_disable(s3c24xx_i2s.iis_clk); + clk_disable_unprepare(s3c24xx_i2s.iis_clk); return 0; } @@ -420,7 +401,7 @@ static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) { pr_debug("Entered %s\n", __func__); - clk_enable(s3c24xx_i2s.iis_clk); + clk_prepare_enable(s3c24xx_i2s.iis_clk); writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); writel(s3c24xx_i2s.iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); @@ -472,39 +453,38 @@ static int s3c24xx_iis_dev_probe(struct platform_device *pdev) { int ret = 0; + struct resource *res; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "Can't get IO resource.\n"); + return -ENOENT; + } + s3c24xx_i2s.regs = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(s3c24xx_i2s.regs)) + return PTR_ERR(s3c24xx_i2s.regs); + + s3c24xx_i2s_pcm_stereo_out.dma_addr = res->start + S3C2410_IISFIFO; + s3c24xx_i2s_pcm_stereo_in.dma_addr = res->start + S3C2410_IISFIFO; - ret = snd_soc_register_component(&pdev->dev, &s3c24xx_i2s_component, - &s3c24xx_i2s_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &s3c24xx_i2s_component, &s3c24xx_i2s_dai, 1); if (ret) { pr_err("failed to register the dai\n"); 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 s3c24xx_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 s3c24xx_iis_driver = { .probe = s3c24xx_iis_dev_probe, - .remove = s3c24xx_iis_dev_remove, .driver = { .name = "s3c24xx-iis", - .owner = THIS_MODULE, }, };