9 #include <linux/errno.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
15 #include <linux/sched.h>
20 #include <asm/cacheflush.h>
22 #include <asm/uaccess.h>
33 static int __init blackfin_dma_init(
void)
48 #if defined(CH_MEM_STREAM3_SRC) && defined(CONFIG_BF60x)
58 #if defined(CONFIG_DEB_DMA_URGENT)
68 static int proc_dma_show(
struct seq_file *
m,
void *
v)
85 .
open = proc_dma_open,
91 static int __init proc_dma_init(
void)
93 proc_create(
"dma", 0,
NULL, &proc_dma_operations);
99 static void set_dma_peripheral_map(
unsigned int channel,
const char *
device_id)
102 unsigned int per_map;
112 if (
strncmp(device_id,
"BFIN_UART", 9) == 0)
124 pr_debug(
"request_dma() : BEGIN\n");
126 if (device_id ==
NULL)
129 #if defined(CONFIG_BF561) && ANOMALY_05000182
133 "Request IMDMA failed due to ANOMALY 05000182\n");
144 set_dma_peripheral_map(channel, device_id);
162 BUG_ON(channel >= MAX_DMA_CHANNELS || !callback ||
183 static void clear_dma_buffer(
unsigned int channel)
193 BUG_ON(channel >= MAX_DMA_CHANNELS ||
198 clear_dma_buffer(channel);
211 # ifndef MAX_DMA_SUSPEND_CHANNELS
212 # define MAX_DMA_SUSPEND_CHANNELS MAX_DMA_CHANNELS
214 # ifndef CONFIG_BF60x
215 int blackfin_dma_suspend(
void)
234 void blackfin_dma_resume(
void)
248 int blackfin_dma_suspend(
void)
253 void blackfin_dma_resume(
void)
274 unsigned long dst = (
unsigned long)pdst;
275 unsigned long src = (
unsigned long)psrc;
310 __builtin_bfin_ssync();
329 __builtin_bfin_ssync();
361 __builtin_bfin_ssync();
364 #if defined(CH_MEM_STREAM3_SRC) && defined(CONFIG_BF60x)
365 #define bfin_read_MDMA_S_CONFIG bfin_read_MDMA_S3_CONFIG
366 #define bfin_write_MDMA_S_CONFIG bfin_write_MDMA_S3_CONFIG
367 #define bfin_write_MDMA_S_START_ADDR bfin_write_MDMA_S3_START_ADDR
368 #define bfin_write_MDMA_S_IRQ_STATUS bfin_write_MDMA_S3_IRQ_STATUS
369 #define bfin_write_MDMA_S_X_COUNT bfin_write_MDMA_S3_X_COUNT
370 #define bfin_write_MDMA_S_X_MODIFY bfin_write_MDMA_S3_X_MODIFY
371 #define bfin_write_MDMA_S_Y_COUNT bfin_write_MDMA_S3_Y_COUNT
372 #define bfin_write_MDMA_S_Y_MODIFY bfin_write_MDMA_S3_Y_MODIFY
373 #define bfin_write_MDMA_D_CONFIG bfin_write_MDMA_D3_CONFIG
374 #define bfin_write_MDMA_D_START_ADDR bfin_write_MDMA_D3_START_ADDR
375 #define bfin_read_MDMA_D_IRQ_STATUS bfin_read_MDMA_D3_IRQ_STATUS
376 #define bfin_write_MDMA_D_IRQ_STATUS bfin_write_MDMA_D3_IRQ_STATUS
377 #define bfin_write_MDMA_D_X_COUNT bfin_write_MDMA_D3_X_COUNT
378 #define bfin_write_MDMA_D_X_MODIFY bfin_write_MDMA_D3_X_MODIFY
379 #define bfin_write_MDMA_D_Y_COUNT bfin_write_MDMA_D3_Y_COUNT
380 #define bfin_write_MDMA_D_Y_MODIFY bfin_write_MDMA_D3_Y_MODIFY
382 #define bfin_read_MDMA_S_CONFIG bfin_read_MDMA_S0_CONFIG
383 #define bfin_write_MDMA_S_CONFIG bfin_write_MDMA_S0_CONFIG
384 #define bfin_write_MDMA_S_START_ADDR bfin_write_MDMA_S0_START_ADDR
385 #define bfin_write_MDMA_S_IRQ_STATUS bfin_write_MDMA_S0_IRQ_STATUS
386 #define bfin_write_MDMA_S_X_COUNT bfin_write_MDMA_S0_X_COUNT
387 #define bfin_write_MDMA_S_X_MODIFY bfin_write_MDMA_S0_X_MODIFY
388 #define bfin_write_MDMA_S_Y_COUNT bfin_write_MDMA_S0_Y_COUNT
389 #define bfin_write_MDMA_S_Y_MODIFY bfin_write_MDMA_S0_Y_MODIFY
390 #define bfin_write_MDMA_D_CONFIG bfin_write_MDMA_D0_CONFIG
391 #define bfin_write_MDMA_D_START_ADDR bfin_write_MDMA_D0_START_ADDR
392 #define bfin_read_MDMA_D_IRQ_STATUS bfin_read_MDMA_D0_IRQ_STATUS
393 #define bfin_write_MDMA_D_IRQ_STATUS bfin_write_MDMA_D0_IRQ_STATUS
394 #define bfin_write_MDMA_D_X_COUNT bfin_write_MDMA_D0_X_COUNT
395 #define bfin_write_MDMA_D_X_MODIFY bfin_write_MDMA_D0_X_MODIFY
396 #define bfin_write_MDMA_D_Y_COUNT bfin_write_MDMA_D0_Y_COUNT
397 #define bfin_write_MDMA_D_Y_MODIFY bfin_write_MDMA_D0_Y_MODIFY
420 __builtin_bfin_ssync();
435 u32 shift =
abs(dmod) >> 1;
436 size_t ycnt = cnt >> (16 - shift);
437 cnt = 1 << (16 - shift);
460 spin_unlock_irqrestore(&mdma_lock, flags);
482 static void *_dma_memcpy(
void *pdst,
const void *psrc,
size_t size)
486 unsigned long dst = (
unsigned long)pdst;
487 unsigned long src = (
unsigned long)psrc;
492 if (dst % 4 == 0 && src % 4 == 0 && size % 4 == 0) {
495 }
else if (dst % 2 == 0 && src % 2 == 0 && size % 2 == 0) {
515 #ifndef DMA_MMR_SIZE_32
520 __dma_memcpy(dst, mod, src, mod, size, conf);
534 unsigned long dst = (
unsigned long)pdst;
535 unsigned long src = (
unsigned long)psrc;
537 if (bfin_addr_dcacheable(src))
540 if (bfin_addr_dcacheable(dst))
557 #ifdef DMA_MMR_SIZE_32
558 _dma_memcpy(pdst, psrc, size);
562 bulk = size & ~0xffff;
565 _dma_memcpy(pdst, psrc, bulk);
566 _dma_memcpy(pdst + bulk, psrc + bulk, rest);
591 __dma_memcpy(addr, 0, buf, size, len, dma_size);
598 __dma_memcpy(buf, size, addr, 0, len, dma_size);
601 #define MAKE_DMA_IO(io, bwl, isize, dmasize, cnst) \
602 void dma_##io##s##bwl(unsigned long addr, cnst void *buf, unsigned DMA_MMR_SIZE_TYPE len) \
604 _dma_##io(addr, (unsigned long)buf, len, isize, WDSIZE_##dmasize); \
606 EXPORT_SYMBOL(dma_##io##s##bwl)