35 #if defined(CONFIG_M5249) || defined(CONFIG_M5307) || defined(CONFIG_M5407) || \
36 defined(CONFIG_M523x) || defined(CONFIG_M527x) || \
37 defined(CONFIG_M528x) || defined(CONFIG_M525x)
39 #define MAX_M68K_DMA_CHANNELS 4
40 #elif defined(CONFIG_M5272)
41 #define MAX_M68K_DMA_CHANNELS 1
42 #elif defined(CONFIG_M532x)
43 #define MAX_M68K_DMA_CHANNELS 0
45 #define MAX_M68K_DMA_CHANNELS 2
51 #if !defined(CONFIG_M5272)
52 #define DMA_MODE_WRITE_BIT 0x01
53 #define DMA_MODE_WORD_BIT 0x02
54 #define DMA_MODE_LONG_BIT 0x04
55 #define DMA_MODE_SINGLE_BIT 0x08
58 #define DMA_MODE_READ 0
60 #define DMA_MODE_WRITE 1
62 #define DMA_MODE_READ_WORD 2
64 #define DMA_MODE_WRITE_WORD 3
66 #define DMA_MODE_READ_LONG 4
68 #define DMA_MODE_WRITE_LONG 5
70 #define DMA_MODE_READ_SINGLE 8
72 #define DMA_MODE_WRITE_SINGLE 9
74 #define DMA_MODE_READ_WORD_SINGLE 10
76 #define DMA_MODE_WRITE_WORD_SINGLE 11
78 #define DMA_MODE_READ_LONG_SINGLE 12
80 #define DMA_MODE_WRITE_LONG_SINGLE 13
85 #define DMA_MODE_SRC_SA_BIT 0x01
87 #define DMA_MODE_SSIZE_MASK 0x06
89 #define DMA_MODE_SSIZE_OFF 0x01
91 #define DMA_MODE_DES_SA_BIT 0x10
93 #define DMA_MODE_DSIZE_MASK 0x60
95 #define DMA_MODE_DSIZE_OFF 0x05
97 #define DMA_MODE_SIZE_LONG 0x00
98 #define DMA_MODE_SIZE_BYTE 0x01
99 #define DMA_MODE_SIZE_WORD 0x02
100 #define DMA_MODE_SIZE_LINE 0x03
109 #define DMA_MODE_READ ((DMA_MODE_SIZE_BYTE << DMA_MODE_DSIZE_OFF) | (DMA_MODE_SIZE_BYTE << DMA_MODE_SSIZE_OFF) | DMA_SRC_SA_BIT)
111 #define DMA_MODE_WRITE ((DMA_MODE_SIZE_BYTE << DMA_MODE_DSIZE_OFF) | (DMA_MODE_SIZE_BYTE << DMA_MODE_SSIZE_OFF) | DMA_DES_SA_BIT)
113 #define DMA_MODE_READ_WORD ((DMA_MODE_SIZE_WORD << DMA_MODE_DSIZE_OFF) | (DMA_MODE_SIZE_WORD << DMA_MODE_SSIZE_OFF) | DMA_SRC_SA_BIT)
115 #define DMA_MODE_WRITE_WORD ((DMA_MODE_SIZE_WORD << DMA_MODE_DSIZE_OFF) | (DMA_MODE_SIZE_WORD << DMA_MODE_SSIZE_OFF) | DMA_DES_SA_BIT)
117 #define DMA_MODE_READ_LONG ((DMA_MODE_SIZE_LONG << DMA_MODE_DSIZE_OFF) | (DMA_MODE_SIZE_LONG << DMA_MODE_SSIZE_OFF) | DMA_SRC_SA_BIT)
119 #define DMA_MODE_WRITE_LONG ((DMA_MODE_SIZE_LONG << DMA_MODE_DSIZE_OFF) | (DMA_MODE_SIZE_LONG << DMA_MODE_SSIZE_OFF) | DMA_DES_SA_BIT)
123 #if !defined(CONFIG_M5272)
127 volatile unsigned short *dmawp;
130 printk(
"enable_dma(dmanr=%d)\n", dmanr);
139 volatile unsigned short *dmawp;
140 volatile unsigned char *dmapb;
143 printk(
"disable_dma(dmanr=%d)\n", dmanr);
164 static __inline__ void clear_dma_ff(
unsigned int dmanr)
172 volatile unsigned char *dmabp;
173 volatile unsigned short *dmawp;
176 printk(
"set_dma_mode(dmanr=%d,mode=%d)\n", dmanr, mode);
205 printk(
"%s(%d): dmanr=%d DSR[%x]=%x DCR[%x]=%x\n", __FILE__, __LINE__,
206 dmanr, (
int) &dmabp[
MCFDMA_DSR], dmabp[MCFDMA_DSR],
212 static __inline__ void set_dma_addr(
unsigned int dmanr,
unsigned int a)
214 volatile unsigned short *dmawp;
215 volatile unsigned int *dmalp;
218 printk(
"set_dma_addr(dmanr=%d,a=%x)\n", dmanr, a);
238 printk(
"%s(%d): dmanr=%d DCR[%x]=%x SAR[%x]=%08x DAR[%x]=%08x\n",
239 __FILE__, __LINE__, dmanr, (
int) &dmawp[
MCFDMA_DCR], dmawp[MCFDMA_DCR],
249 static __inline__ void set_dma_device_addr(
unsigned int dmanr,
unsigned int a)
252 printk(
"set_dma_device_addr(dmanr=%d,a=%x)\n", dmanr, a);
263 volatile unsigned short *dmawp;
266 printk(
"set_dma_count(dmanr=%d,count=%d)\n", dmanr, count);
281 volatile unsigned short *dmawp;
282 unsigned short count;
285 printk(
"get_dma_residue(dmanr=%d)\n", dmanr);
320 volatile unsigned int *dmalp;
323 printk(
"enable_dma(dmanr=%d)\n", dmanr);
327 dmalp[MCFDMA_DMR] |= MCFDMA_DMR_EN;
332 volatile unsigned int *dmalp;
335 printk(
"disable_dma(dmanr=%d)\n", dmanr);
341 dmalp[MCFDMA_DMR] &= ~MCFDMA_DMR_EN;
342 dmalp[MCFDMA_DMR] |= MCFDMA_DMR_RESET;
355 static __inline__ void clear_dma_ff(
unsigned int dmanr)
363 volatile unsigned int *dmalp;
364 volatile unsigned short *dmawp;
367 printk(
"set_dma_mode(dmanr=%d,mode=%d)\n", dmanr, mode);
373 dmalp[MCFDMA_DMR] |= MCFDMA_DMR_RESET;
377 MCFDMA_DMR_RQM_DUAL |
381 ((mode & DMA_MODE_SRC_SA_BIT) ? MCFDMA_DMR_SRCM_SA : MCFDMA_DMR_SRCM_IA) |
383 ((mode & DMA_MODE_DES_SA_BIT) ? MCFDMA_DMR_DSTM_SA : MCFDMA_DMR_DSTM_IA) |
385 (((mode & DMA_MODE_SSIZE_MASK) >> DMA_MODE_SSIZE_OFF) << MCFDMA_DMR_DSTS_OFF) |
386 (((mode & DMA_MODE_SSIZE_MASK) >> DMA_MODE_SSIZE_OFF) << MCFDMA_DMR_SRCS_OFF);
388 dmawp[MCFDMA_DIR] |= MCFDMA_DIR_ASCEN;
391 printk(
"%s(%d): dmanr=%d DMR[%x]=%x DIR[%x]=%x\n", __FILE__, __LINE__,
392 dmanr, (
int) &dmalp[MCFDMA_DMR], dmabp[MCFDMA_DMR],
393 (
int) &dmawp[MCFDMA_DIR], dmawp[MCFDMA_DIR]);
398 static __inline__ void set_dma_addr(
unsigned int dmanr,
unsigned int a)
400 volatile unsigned int *dmalp;
403 printk(
"set_dma_addr(dmanr=%d,a=%x)\n", dmanr, a);
409 if (dmalp[MCFDMA_DMR] & MCFDMA_DMR_SRCM) {
411 dmalp[MCFDMA_DSAR] =
a;
416 dmalp[MCFDMA_DDAR] =
a;
422 printk(
"%s(%d): dmanr=%d DMR[%x]=%x SAR[%x]=%08x DAR[%x]=%08x\n",
423 __FILE__, __LINE__, dmanr, (
int) &dmawp[MCFDMA_DMR], dmawp[MCFDMA_DMR],
424 (
int) &dmalp[MCFDMA_DSAR], dmalp[MCFDMA_DSAR],
425 (
int) &dmalp[MCFDMA_DDAR], dmalp[MCFDMA_DDAR]);
433 static __inline__ void set_dma_device_addr(
unsigned int dmanr,
unsigned int a)
436 printk(
"set_dma_device_addr(dmanr=%d,a=%x)\n", dmanr, a);
449 volatile unsigned int *dmalp;
452 printk(
"set_dma_count(dmanr=%d,count=%d)\n", dmanr, count);
456 dmalp[MCFDMA_DBCR] =
count;
467 volatile unsigned int *dmalp;
471 printk(
"get_dma_residue(dmanr=%d)\n", dmanr);
475 count = dmalp[MCFDMA_DBCR];
484 #define MAX_DMA_ADDRESS PAGE_OFFSET
486 #define MAX_DMA_CHANNELS 8
489 extern void free_dma(
unsigned int dmanr);
494 #define isa_dma_bridge_buggy (0)