Lines Matching +full:idma +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0+
3 // idma.c - I2S0 internal DMA driver
10 #include <linux/dma-mapping.h>
18 #include "idma.h"
19 #include "i2s-regs.h"
54 } idma; variable
60 *src = idma.lp_tx_addr + in idma_getpos()
61 (readl(idma.regs + I2STRNCNT) & 0xffffff) * 4; in idma_getpos()
66 struct snd_pcm_runtime *runtime = substream->runtime; in idma_enqueue()
67 struct idma_ctrl *prtd = substream->runtime->private_data; in idma_enqueue()
70 spin_lock(&prtd->lock); in idma_enqueue()
71 prtd->token = (void *) substream; in idma_enqueue()
72 spin_unlock(&prtd->lock); in idma_enqueue()
75 val = idma.lp_tx_addr + prtd->periodsz; in idma_enqueue()
76 writel(val, idma.regs + I2SLVL0ADDR); in idma_enqueue()
79 val = idma.lp_tx_addr; in idma_enqueue()
80 writel(val, idma.regs + I2SSTR0); in idma_enqueue()
86 val = readl(idma.regs + I2SSIZE); in idma_enqueue()
88 val |= (((runtime->dma_bytes >> 2) & in idma_enqueue()
90 writel(val, idma.regs + I2SSIZE); in idma_enqueue()
92 val = readl(idma.regs + I2SAHB); in idma_enqueue()
94 writel(val, idma.regs + I2SAHB); in idma_enqueue()
102 struct idma_ctrl *prtd = substream->runtime->private_data; in idma_setcallbk()
104 spin_lock(&prtd->lock); in idma_setcallbk()
105 prtd->cb = cb; in idma_setcallbk()
106 spin_unlock(&prtd->lock); in idma_setcallbk()
111 u32 val = readl(idma.regs + I2SAHB); in idma_control()
113 spin_lock(&idma.lock); in idma_control()
123 spin_unlock(&idma.lock); in idma_control()
127 writel(val, idma.regs + I2SAHB); in idma_control()
128 spin_unlock(&idma.lock); in idma_control()
134 struct idma_ctrl *prtd = substream->runtime->private_data; in idma_done()
136 if (prtd && (prtd->state & ST_RUNNING)) in idma_done()
144 struct snd_pcm_runtime *runtime = substream->runtime; in idma_hw_params()
145 struct idma_ctrl *prtd = substream->runtime->private_data; in idma_hw_params()
146 u32 mod = readl(idma.regs + I2SMOD); in idma_hw_params()
147 u32 ahb = readl(idma.regs + I2SAHB); in idma_hw_params()
151 writel(ahb, idma.regs + I2SAHB); in idma_hw_params()
152 writel(mod, idma.regs + I2SMOD); in idma_hw_params()
154 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); in idma_hw_params()
155 runtime->dma_bytes = params_buffer_bytes(params); in idma_hw_params()
157 prtd->start = prtd->pos = runtime->dma_addr; in idma_hw_params()
158 prtd->period = params_periods(params); in idma_hw_params()
159 prtd->periodsz = params_period_bytes(params); in idma_hw_params()
160 prtd->end = runtime->dma_addr + runtime->dma_bytes; in idma_hw_params()
178 struct idma_ctrl *prtd = substream->runtime->private_data; in idma_prepare()
180 prtd->pos = prtd->start; in idma_prepare()
192 struct idma_ctrl *prtd = substream->runtime->private_data; in idma_trigger()
195 spin_lock(&prtd->lock); in idma_trigger()
201 prtd->state |= ST_RUNNING; in idma_trigger()
208 prtd->state &= ~ST_RUNNING; in idma_trigger()
213 ret = -EINVAL; in idma_trigger()
217 spin_unlock(&prtd->lock); in idma_trigger()
226 struct snd_pcm_runtime *runtime = substream->runtime; in idma_pointer()
227 struct idma_ctrl *prtd = runtime->private_data; in idma_pointer()
231 spin_lock(&prtd->lock); in idma_pointer()
234 res = src - prtd->start; in idma_pointer()
236 spin_unlock(&prtd->lock); in idma_pointer()
238 return bytes_to_frames(substream->runtime, res); in idma_pointer()
245 struct snd_pcm_runtime *runtime = substream->runtime; in idma_mmap()
249 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); in idma_mmap()
250 size = vma->vm_end - vma->vm_start; in idma_mmap()
251 offset = vma->vm_pgoff << PAGE_SHIFT; in idma_mmap()
252 return io_remap_pfn_range(vma, vma->vm_start, in idma_mmap()
253 (runtime->dma_addr + offset) >> PAGE_SHIFT, in idma_mmap()
254 size, vma->vm_page_prot); in idma_mmap()
260 u32 iisahb, val, addr; in iis_irq() local
262 iisahb = readl(idma.regs + I2SAHB); in iis_irq()
268 writel(iisahb, idma.regs + I2SAHB); in iis_irq()
270 addr = readl(idma.regs + I2SLVL0ADDR) - idma.lp_tx_addr; in iis_irq()
271 addr += prtd->periodsz; in iis_irq()
272 addr %= (u32)(prtd->end - prtd->start); in iis_irq()
273 addr += idma.lp_tx_addr; in iis_irq()
275 writel(addr, idma.regs + I2SLVL0ADDR); in iis_irq()
277 if (prtd->cb) in iis_irq()
278 prtd->cb(prtd->token, prtd->period); in iis_irq()
287 struct snd_pcm_runtime *runtime = substream->runtime; in idma_open()
295 return -ENOMEM; in idma_open()
304 spin_lock_init(&prtd->lock); in idma_open()
306 runtime->private_data = prtd; in idma_open()
314 struct snd_pcm_runtime *runtime = substream->runtime; in idma_close()
315 struct idma_ctrl *prtd = runtime->private_data; in idma_close()
333 substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; in idma_free()
337 buf = &substream->dma_buffer; in idma_free()
338 if (!buf->area) in idma_free()
341 iounmap((void __iomem *)buf->area); in idma_free()
343 buf->area = NULL; in idma_free()
344 buf->addr = 0; in idma_free()
349 struct snd_pcm_substream *substream = pcm->streams[stream].substream; in preallocate_idma_buffer()
350 struct snd_dma_buffer *buf = &substream->dma_buffer; in preallocate_idma_buffer()
352 buf->dev.dev = pcm->card->dev; in preallocate_idma_buffer()
353 buf->private_data = NULL; in preallocate_idma_buffer()
356 buf->dev.type = SNDRV_DMA_TYPE_CONTINUOUS; in preallocate_idma_buffer()
357 buf->addr = idma.lp_tx_addr; in preallocate_idma_buffer()
358 buf->bytes = idma_hardware.buffer_bytes_max; in preallocate_idma_buffer()
359 buf->area = (unsigned char * __force)ioremap(buf->addr, buf->bytes); in preallocate_idma_buffer()
360 if (!buf->area) in preallocate_idma_buffer()
361 return -ENOMEM; in preallocate_idma_buffer()
369 struct snd_card *card = rtd->card->snd_card; in idma_new()
370 struct snd_pcm *pcm = rtd->pcm; in idma_new()
373 ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); in idma_new()
377 if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { in idma_new()
385 void idma_reg_addr_init(void __iomem *regs, dma_addr_t addr) in idma_reg_addr_init() argument
387 spin_lock_init(&idma.lock); in idma_reg_addr_init()
388 idma.regs = regs; in idma_reg_addr_init()
389 idma.lp_tx_addr = addr; in idma_reg_addr_init()
412 return devm_snd_soc_register_component(&pdev->dev, &asoc_idma_platform, in asoc_idma_platform_probe()
418 .name = "samsung-idma",
427 MODULE_DESCRIPTION("Samsung ASoC IDMA Driver");