aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sh/include/asm/dma-register.h51
-rw-r--r--arch/sh/include/asm/dma-sh.h95
-rw-r--r--arch/sh/include/asm/dmaengine.h73
-rw-r--r--arch/sh/include/asm/siu.h2
-rw-r--r--arch/sh/include/cpu-sh3/cpu/dma-register.h41
-rw-r--r--arch/sh/include/cpu-sh3/cpu/dma.h27
-rw-r--r--arch/sh/include/cpu-sh4/cpu/dma-register.h116
-rw-r--r--arch/sh/include/cpu-sh4/cpu/dma-sh4a.h62
-rw-r--r--arch/sh/include/cpu-sh4/cpu/dma.h36
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7722.c20
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7724.c21
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7780.c21
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7785.c21
-rw-r--r--drivers/dma/shdma.c79
-rw-r--r--drivers/dma/shdma.h4
-rw-r--r--sound/soc/sh/siu.h2
-rw-r--r--sound/soc/sh/siu_pcm.c2
17 files changed, 415 insertions, 258 deletions
diff --git a/arch/sh/include/asm/dma-register.h b/arch/sh/include/asm/dma-register.h
new file mode 100644
index 000000000000..51cd78feacff
--- /dev/null
+++ b/arch/sh/include/asm/dma-register.h
@@ -0,0 +1,51 @@
1/*
2 * Common header for the legacy SH DMA driver and the new dmaengine driver
3 *
4 * extracted from arch/sh/include/asm/dma-sh.h:
5 *
6 * Copyright (C) 2000 Takashi YOSHII
7 * Copyright (C) 2003 Paul Mundt
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#ifndef DMA_REGISTER_H
14#define DMA_REGISTER_H
15
16/* DMA register */
17#define SAR 0x00
18#define DAR 0x04
19#define TCR 0x08
20#define CHCR 0x0C
21#define DMAOR 0x40
22
23/* DMAOR definitions */
24#define DMAOR_AE 0x00000004
25#define DMAOR_NMIF 0x00000002
26#define DMAOR_DME 0x00000001
27
28/* Definitions for the SuperH DMAC */
29#define REQ_L 0x00000000
30#define REQ_E 0x00080000
31#define RACK_H 0x00000000
32#define RACK_L 0x00040000
33#define ACK_R 0x00000000
34#define ACK_W 0x00020000
35#define ACK_H 0x00000000
36#define ACK_L 0x00010000
37#define DM_INC 0x00004000
38#define DM_DEC 0x00008000
39#define DM_FIX 0x0000c000
40#define SM_INC 0x00001000
41#define SM_DEC 0x00002000
42#define SM_FIX 0x00003000
43#define RS_IN 0x00000200
44#define RS_OUT 0x00000300
45#define TS_BLK 0x00000040
46#define TM_BUR 0x00000020
47#define CHCR_DE 0x00000001
48#define CHCR_TE 0x00000002
49#define CHCR_IE 0x00000004
50
51#endif
diff --git a/arch/sh/include/asm/dma-sh.h b/arch/sh/include/asm/dma-sh.h
index 2e3631d6e273..f3acb8e34c6b 100644
--- a/arch/sh/include/asm/dma-sh.h
+++ b/arch/sh/include/asm/dma-sh.h
@@ -11,7 +11,8 @@
11#ifndef __DMA_SH_H 11#ifndef __DMA_SH_H
12#define __DMA_SH_H 12#define __DMA_SH_H
13 13
14#include <asm/dma.h> 14#include <asm/dma-register.h>
15#include <cpu/dma-register.h>
15#include <cpu/dma.h> 16#include <cpu/dma.h>
16 17
17/* DMAOR contorl: The DMAOR access size is different by CPU.*/ 18/* DMAOR contorl: The DMAOR access size is different by CPU.*/
@@ -53,34 +54,6 @@ static int dmte_irq_map[] __maybe_unused = {
53#endif 54#endif
54}; 55};
55 56
56/* Definitions for the SuperH DMAC */
57#define REQ_L 0x00000000
58#define REQ_E 0x00080000
59#define RACK_H 0x00000000
60#define RACK_L 0x00040000
61#define ACK_R 0x00000000
62#define ACK_W 0x00020000
63#define ACK_H 0x00000000
64#define ACK_L 0x00010000
65#define DM_INC 0x00004000
66#define DM_DEC 0x00008000
67#define DM_FIX 0x0000c000
68#define SM_INC 0x00001000
69#define SM_DEC 0x00002000
70#define SM_FIX 0x00003000
71#define RS_IN 0x00000200
72#define RS_OUT 0x00000300
73#define TS_BLK 0x00000040
74#define TM_BUR 0x00000020
75#define CHCR_DE 0x00000001
76#define CHCR_TE 0x00000002
77#define CHCR_IE 0x00000004
78
79/* DMAOR definitions */
80#define DMAOR_AE 0x00000004
81#define DMAOR_NMIF 0x00000002
82#define DMAOR_DME 0x00000001
83
84/* 57/*
85 * Define the default configuration for dual address memory-memory transfer. 58 * Define the default configuration for dual address memory-memory transfer.
86 * The 0x400 value represents auto-request, external->external. 59 * The 0x400 value represents auto-request, external->external.
@@ -111,68 +84,4 @@ static u32 dma_base_addr[] __maybe_unused = {
111#endif 84#endif
112}; 85};
113 86
114/* DMA register */
115#define SAR 0x00
116#define DAR 0x04
117#define TCR 0x08
118#define CHCR 0x0C
119#define DMAOR 0x40
120
121/*
122 * for dma engine
123 *
124 * SuperH DMA mode
125 */
126#define SHDMA_MIX_IRQ (1 << 1)
127#define SHDMA_DMAOR1 (1 << 2)
128#define SHDMA_DMAE1 (1 << 3)
129
130enum sh_dmae_slave_chan_id {
131 SHDMA_SLAVE_SCIF0_TX,
132 SHDMA_SLAVE_SCIF0_RX,
133 SHDMA_SLAVE_SCIF1_TX,
134 SHDMA_SLAVE_SCIF1_RX,
135 SHDMA_SLAVE_SCIF2_TX,
136 SHDMA_SLAVE_SCIF2_RX,
137 SHDMA_SLAVE_SCIF3_TX,
138 SHDMA_SLAVE_SCIF3_RX,
139 SHDMA_SLAVE_SCIF4_TX,
140 SHDMA_SLAVE_SCIF4_RX,
141 SHDMA_SLAVE_SCIF5_TX,
142 SHDMA_SLAVE_SCIF5_RX,
143 SHDMA_SLAVE_SIUA_TX,
144 SHDMA_SLAVE_SIUA_RX,
145 SHDMA_SLAVE_SIUB_TX,
146 SHDMA_SLAVE_SIUB_RX,
147 SHDMA_SLAVE_NUMBER, /* Must stay last */
148};
149
150struct sh_dmae_slave_config {
151 enum sh_dmae_slave_chan_id slave_id;
152 dma_addr_t addr;
153 u32 chcr;
154 char mid_rid;
155};
156
157struct sh_dmae_channel {
158 unsigned int offset;
159 unsigned int dmars;
160 unsigned int dmars_bit;
161};
162
163struct sh_dmae_pdata {
164 struct sh_dmae_slave_config *slave;
165 int slave_num;
166 struct sh_dmae_channel *channel;
167 int channel_num;
168};
169
170struct device;
171
172struct sh_dmae_slave {
173 enum sh_dmae_slave_chan_id slave_id; /* Set by the platform */
174 struct device *dma_dev; /* Set by the platform */
175 struct sh_dmae_slave_config *config; /* Set by the driver */
176};
177
178#endif /* __DMA_SH_H */ 87#endif /* __DMA_SH_H */
diff --git a/arch/sh/include/asm/dmaengine.h b/arch/sh/include/asm/dmaengine.h
new file mode 100644
index 000000000000..9586e4a482b1
--- /dev/null
+++ b/arch/sh/include/asm/dmaengine.h
@@ -0,0 +1,73 @@
1/*
2 * Header for the new SH dmaengine driver
3 *
4 * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef ASM_DMAENGINE_H
11#define ASM_DMAENGINE_H
12
13#include <asm/dma-register.h>
14
15#define SH_DMAC_MAX_CHANNELS 6
16
17enum sh_dmae_slave_chan_id {
18 SHDMA_SLAVE_SCIF0_TX,
19 SHDMA_SLAVE_SCIF0_RX,
20 SHDMA_SLAVE_SCIF1_TX,
21 SHDMA_SLAVE_SCIF1_RX,
22 SHDMA_SLAVE_SCIF2_TX,
23 SHDMA_SLAVE_SCIF2_RX,
24 SHDMA_SLAVE_SCIF3_TX,
25 SHDMA_SLAVE_SCIF3_RX,
26 SHDMA_SLAVE_SCIF4_TX,
27 SHDMA_SLAVE_SCIF4_RX,
28 SHDMA_SLAVE_SCIF5_TX,
29 SHDMA_SLAVE_SCIF5_RX,
30 SHDMA_SLAVE_SIUA_TX,
31 SHDMA_SLAVE_SIUA_RX,
32 SHDMA_SLAVE_SIUB_TX,
33 SHDMA_SLAVE_SIUB_RX,
34 SHDMA_SLAVE_NUMBER, /* Must stay last */
35};
36
37struct sh_dmae_slave_config {
38 enum sh_dmae_slave_chan_id slave_id;
39 dma_addr_t addr;
40 u32 chcr;
41 char mid_rid;
42};
43
44struct sh_dmae_channel {
45 unsigned int offset;
46 unsigned int dmars;
47 unsigned int dmars_bit;
48};
49
50struct sh_dmae_pdata {
51 struct sh_dmae_slave_config *slave;
52 int slave_num;
53 struct sh_dmae_channel *channel;
54 int channel_num;
55 unsigned int ts_low_shift;
56 unsigned int ts_low_mask;
57 unsigned int ts_high_shift;
58 unsigned int ts_high_mask;
59 unsigned int *ts_shift;
60 int ts_shift_num;
61 u16 dmaor_init;
62};
63
64struct device;
65
66/* Used by slave DMA clients to request DMA to/from a specific peripheral */
67struct sh_dmae_slave {
68 enum sh_dmae_slave_chan_id slave_id; /* Set by the platform */
69 struct device *dma_dev; /* Set by the platform */
70 struct sh_dmae_slave_config *config; /* Set by the driver */
71};
72
73#endif
diff --git a/arch/sh/include/asm/siu.h b/arch/sh/include/asm/siu.h
index 57565a3b551f..f1b1e6944a5f 100644
--- a/arch/sh/include/asm/siu.h
+++ b/arch/sh/include/asm/siu.h
@@ -11,7 +11,7 @@
11#ifndef ASM_SIU_H 11#ifndef ASM_SIU_H
12#define ASM_SIU_H 12#define ASM_SIU_H
13 13
14#include <asm/dma-sh.h> 14#include <asm/dmaengine.h>
15 15
16struct device; 16struct device;
17 17
diff --git a/arch/sh/include/cpu-sh3/cpu/dma-register.h b/arch/sh/include/cpu-sh3/cpu/dma-register.h
new file mode 100644
index 000000000000..2349e488c9a6
--- /dev/null
+++ b/arch/sh/include/cpu-sh3/cpu/dma-register.h
@@ -0,0 +1,41 @@
1/*
2 * SH3 CPU-specific DMA definitions, used by both DMA drivers
3 *
4 * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef CPU_DMA_REGISTER_H
11#define CPU_DMA_REGISTER_H
12
13#define CHCR_TS_LOW_MASK 0x18
14#define CHCR_TS_LOW_SHIFT 3
15#define CHCR_TS_HIGH_MASK 0
16#define CHCR_TS_HIGH_SHIFT 0
17
18#define DMAOR_INIT DMAOR_DME
19
20/*
21 * The SuperH DMAC supports a number of transmit sizes, we list them here,
22 * with their respective values as they appear in the CHCR registers.
23 */
24enum {
25 XMIT_SZ_8BIT,
26 XMIT_SZ_16BIT,
27 XMIT_SZ_32BIT,
28 XMIT_SZ_128BIT,
29};
30
31/* log2(size / 8) - used to calculate number of transfers */
32#define TS_SHIFT { \
33 [XMIT_SZ_8BIT] = 0, \
34 [XMIT_SZ_16BIT] = 1, \
35 [XMIT_SZ_32BIT] = 2, \
36 [XMIT_SZ_128BIT] = 4, \
37}
38
39#define TS_INDEX2VAL(i) (((i) & 3) << CHCR_TS_LOW_SHIFT)
40
41#endif
diff --git a/arch/sh/include/cpu-sh3/cpu/dma.h b/arch/sh/include/cpu-sh3/cpu/dma.h
index 207811a7a650..24e28b91c9d5 100644
--- a/arch/sh/include/cpu-sh3/cpu/dma.h
+++ b/arch/sh/include/cpu-sh3/cpu/dma.h
@@ -20,31 +20,4 @@
20#define TS_32 0x00000010 20#define TS_32 0x00000010
21#define TS_128 0x00000018 21#define TS_128 0x00000018
22 22
23#define CHCR_TS_LOW_MASK 0x18
24#define CHCR_TS_LOW_SHIFT 3
25#define CHCR_TS_HIGH_MASK 0
26#define CHCR_TS_HIGH_SHIFT 0
27
28#define DMAOR_INIT DMAOR_DME
29
30/*
31 * The SuperH DMAC supports a number of transmit sizes, we list them here,
32 * with their respective values as they appear in the CHCR registers.
33 */
34enum {
35 XMIT_SZ_8BIT,
36 XMIT_SZ_16BIT,
37 XMIT_SZ_32BIT,
38 XMIT_SZ_128BIT,
39};
40
41#define TS_SHIFT { \
42 [XMIT_SZ_8BIT] = 0, \
43 [XMIT_SZ_16BIT] = 1, \
44 [XMIT_SZ_32BIT] = 2, \
45 [XMIT_SZ_128BIT] = 4, \
46}
47
48#define TS_INDEX2VAL(i) (((i) & 3) << CHCR_TS_LOW_SHIFT)
49
50#endif /* __ASM_CPU_SH3_DMA_H */ 23#endif /* __ASM_CPU_SH3_DMA_H */
diff --git a/arch/sh/include/cpu-sh4/cpu/dma-register.h b/arch/sh/include/cpu-sh4/cpu/dma-register.h
new file mode 100644
index 000000000000..008e7fc8f6c0
--- /dev/null
+++ b/arch/sh/include/cpu-sh4/cpu/dma-register.h
@@ -0,0 +1,116 @@
1/*
2 * SH4 CPU-specific DMA definitions, used by both DMA drivers
3 *
4 * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef CPU_DMA_REGISTER_H
11#define CPU_DMA_REGISTER_H
12
13/* SH7751/7760/7780 DMA IRQ sources */
14
15#ifdef CONFIG_CPU_SH4A
16
17#define DMAOR_INIT DMAOR_DME
18
19#if defined(CONFIG_CPU_SUBTYPE_SH7343) || \
20 defined(CONFIG_CPU_SUBTYPE_SH7730)
21#define CHCR_TS_LOW_MASK 0x00000018
22#define CHCR_TS_LOW_SHIFT 3
23#define CHCR_TS_HIGH_MASK 0
24#define CHCR_TS_HIGH_SHIFT 0
25#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
26#define CHCR_TS_LOW_MASK 0x00000018
27#define CHCR_TS_LOW_SHIFT 3
28#define CHCR_TS_HIGH_MASK 0x00300000
29#define CHCR_TS_HIGH_SHIFT (20 - 2) /* 2 bits for shifted low TS */
30#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
31 defined(CONFIG_CPU_SUBTYPE_SH7764)
32#define CHCR_TS_LOW_MASK 0x00000018
33#define CHCR_TS_LOW_SHIFT 3
34#define CHCR_TS_HIGH_MASK 0
35#define CHCR_TS_HIGH_SHIFT 0
36#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
37#define CHCR_TS_LOW_MASK 0x00000018
38#define CHCR_TS_LOW_SHIFT 3
39#define CHCR_TS_HIGH_MASK 0
40#define CHCR_TS_HIGH_SHIFT 0
41#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
42#define CHCR_TS_LOW_MASK 0x00000018
43#define CHCR_TS_LOW_SHIFT 3
44#define CHCR_TS_HIGH_MASK 0x00600000
45#define CHCR_TS_HIGH_SHIFT (20 - 2) /* 2 bits for shifted low TS */
46#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
47#define CHCR_TS_LOW_MASK 0x00000018
48#define CHCR_TS_LOW_SHIFT 3
49#define CHCR_TS_HIGH_MASK 0
50#define CHCR_TS_HIGH_SHIFT 0
51#else /* SH7785 */
52#define CHCR_TS_LOW_MASK 0x00000018
53#define CHCR_TS_LOW_SHIFT 3
54#define CHCR_TS_HIGH_MASK 0
55#define CHCR_TS_HIGH_SHIFT 0
56#endif
57
58/* Transmit sizes and respective CHCR register values */
59enum {
60 XMIT_SZ_8BIT = 0,
61 XMIT_SZ_16BIT = 1,
62 XMIT_SZ_32BIT = 2,
63 XMIT_SZ_64BIT = 7,
64 XMIT_SZ_128BIT = 3,
65 XMIT_SZ_256BIT = 4,
66 XMIT_SZ_128BIT_BLK = 0xb,
67 XMIT_SZ_256BIT_BLK = 0xc,
68};
69
70/* log2(size / 8) - used to calculate number of transfers */
71#define TS_SHIFT { \
72 [XMIT_SZ_8BIT] = 0, \
73 [XMIT_SZ_16BIT] = 1, \
74 [XMIT_SZ_32BIT] = 2, \
75 [XMIT_SZ_64BIT] = 3, \
76 [XMIT_SZ_128BIT] = 4, \
77 [XMIT_SZ_256BIT] = 5, \
78 [XMIT_SZ_128BIT_BLK] = 4, \
79 [XMIT_SZ_256BIT_BLK] = 5, \
80}
81
82#define TS_INDEX2VAL(i) ((((i) & 3) << CHCR_TS_LOW_SHIFT) | \
83 ((((i) >> 2) & 3) << CHCR_TS_HIGH_SHIFT))
84
85#else /* CONFIG_CPU_SH4A */
86
87#define DMAOR_INIT (0x8000 | DMAOR_DME)
88
89#define CHCR_TS_LOW_MASK 0x70
90#define CHCR_TS_LOW_SHIFT 4
91#define CHCR_TS_HIGH_MASK 0
92#define CHCR_TS_HIGH_SHIFT 0
93
94/* Transmit sizes and respective CHCR register values */
95enum {
96 XMIT_SZ_8BIT = 1,
97 XMIT_SZ_16BIT = 2,
98 XMIT_SZ_32BIT = 3,
99 XMIT_SZ_64BIT = 0,
100 XMIT_SZ_256BIT = 4,
101};
102
103/* log2(size / 8) - used to calculate number of transfers */
104#define TS_SHIFT { \
105 [XMIT_SZ_8BIT] = 0, \
106 [XMIT_SZ_16BIT] = 1, \
107 [XMIT_SZ_32BIT] = 2, \
108 [XMIT_SZ_64BIT] = 3, \
109 [XMIT_SZ_256BIT] = 5, \
110}
111
112#define TS_INDEX2VAL(i) (((i) & 7) << CHCR_TS_LOW_SHIFT)
113
114#endif /* CONFIG_CPU_SH4A */
115
116#endif
diff --git a/arch/sh/include/cpu-sh4/cpu/dma-sh4a.h b/arch/sh/include/cpu-sh4/cpu/dma-sh4a.h
index e734ea47d8a0..9647e681fd27 100644
--- a/arch/sh/include/cpu-sh4/cpu/dma-sh4a.h
+++ b/arch/sh/include/cpu-sh4/cpu/dma-sh4a.h
@@ -8,20 +8,12 @@
8#define DMAE0_IRQ 78 /* DMA Error IRQ*/ 8#define DMAE0_IRQ 78 /* DMA Error IRQ*/
9#define SH_DMAC_BASE0 0xFE008020 9#define SH_DMAC_BASE0 0xFE008020
10#define SH_DMARS_BASE0 0xFE009000 10#define SH_DMARS_BASE0 0xFE009000
11#define CHCR_TS_LOW_MASK 0x00000018
12#define CHCR_TS_LOW_SHIFT 3
13#define CHCR_TS_HIGH_MASK 0
14#define CHCR_TS_HIGH_SHIFT 0
15#elif defined(CONFIG_CPU_SUBTYPE_SH7722) 11#elif defined(CONFIG_CPU_SUBTYPE_SH7722)
16#define DMTE0_IRQ 48 12#define DMTE0_IRQ 48
17#define DMTE4_IRQ 76 13#define DMTE4_IRQ 76
18#define DMAE0_IRQ 78 /* DMA Error IRQ*/ 14#define DMAE0_IRQ 78 /* DMA Error IRQ*/
19#define SH_DMAC_BASE0 0xFE008020 15#define SH_DMAC_BASE0 0xFE008020
20#define SH_DMARS_BASE0 0xFE009000 16#define SH_DMARS_BASE0 0xFE009000
21#define CHCR_TS_LOW_MASK 0x00000018
22#define CHCR_TS_LOW_SHIFT 3
23#define CHCR_TS_HIGH_MASK 0x00300000
24#define CHCR_TS_HIGH_SHIFT 20
25#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \ 17#elif defined(CONFIG_CPU_SUBTYPE_SH7763) || \
26 defined(CONFIG_CPU_SUBTYPE_SH7764) 18 defined(CONFIG_CPU_SUBTYPE_SH7764)
27#define DMTE0_IRQ 34 19#define DMTE0_IRQ 34
@@ -29,10 +21,6 @@
29#define DMAE0_IRQ 38 21#define DMAE0_IRQ 38
30#define SH_DMAC_BASE0 0xFF608020 22#define SH_DMAC_BASE0 0xFF608020
31#define SH_DMARS_BASE0 0xFF609000 23#define SH_DMARS_BASE0 0xFF609000
32#define CHCR_TS_LOW_MASK 0x00000018
33#define CHCR_TS_LOW_SHIFT 3
34#define CHCR_TS_HIGH_MASK 0
35#define CHCR_TS_HIGH_SHIFT 0
36#elif defined(CONFIG_CPU_SUBTYPE_SH7723) 24#elif defined(CONFIG_CPU_SUBTYPE_SH7723)
37#define DMTE0_IRQ 48 /* DMAC0A*/ 25#define DMTE0_IRQ 48 /* DMAC0A*/
38#define DMTE4_IRQ 76 /* DMAC0B */ 26#define DMTE4_IRQ 76 /* DMAC0B */
@@ -46,10 +34,6 @@
46#define SH_DMAC_BASE0 0xFE008020 34#define SH_DMAC_BASE0 0xFE008020
47#define SH_DMAC_BASE1 0xFDC08020 35#define SH_DMAC_BASE1 0xFDC08020
48#define SH_DMARS_BASE0 0xFDC09000 36#define SH_DMARS_BASE0 0xFDC09000
49#define CHCR_TS_LOW_MASK 0x00000018
50#define CHCR_TS_LOW_SHIFT 3
51#define CHCR_TS_HIGH_MASK 0
52#define CHCR_TS_HIGH_SHIFT 0
53#elif defined(CONFIG_CPU_SUBTYPE_SH7724) 37#elif defined(CONFIG_CPU_SUBTYPE_SH7724)
54#define DMTE0_IRQ 48 /* DMAC0A*/ 38#define DMTE0_IRQ 48 /* DMAC0A*/
55#define DMTE4_IRQ 76 /* DMAC0B */ 39#define DMTE4_IRQ 76 /* DMAC0B */
@@ -64,10 +48,6 @@
64#define SH_DMAC_BASE1 0xFDC08020 48#define SH_DMAC_BASE1 0xFDC08020
65#define SH_DMARS_BASE0 0xFE009000 49#define SH_DMARS_BASE0 0xFE009000
66#define SH_DMARS_BASE1 0xFDC09000 50#define SH_DMARS_BASE1 0xFDC09000
67#define CHCR_TS_LOW_MASK 0x00000018
68#define CHCR_TS_LOW_SHIFT 3
69#define CHCR_TS_HIGH_MASK 0x00600000
70#define CHCR_TS_HIGH_SHIFT 21
71#elif defined(CONFIG_CPU_SUBTYPE_SH7780) 51#elif defined(CONFIG_CPU_SUBTYPE_SH7780)
72#define DMTE0_IRQ 34 52#define DMTE0_IRQ 34
73#define DMTE4_IRQ 44 53#define DMTE4_IRQ 44
@@ -80,10 +60,6 @@
80#define SH_DMAC_BASE0 0xFC808020 60#define SH_DMAC_BASE0 0xFC808020
81#define SH_DMAC_BASE1 0xFC818020 61#define SH_DMAC_BASE1 0xFC818020
82#define SH_DMARS_BASE0 0xFC809000 62#define SH_DMARS_BASE0 0xFC809000
83#define CHCR_TS_LOW_MASK 0x00000018
84#define CHCR_TS_LOW_SHIFT 3
85#define CHCR_TS_HIGH_MASK 0
86#define CHCR_TS_HIGH_SHIFT 0
87#else /* SH7785 */ 63#else /* SH7785 */
88#define DMTE0_IRQ 33 64#define DMTE0_IRQ 33
89#define DMTE4_IRQ 37 65#define DMTE4_IRQ 37
@@ -97,10 +73,6 @@
97#define SH_DMAC_BASE0 0xFC808020 73#define SH_DMAC_BASE0 0xFC808020
98#define SH_DMAC_BASE1 0xFCC08020 74#define SH_DMAC_BASE1 0xFCC08020
99#define SH_DMARS_BASE0 0xFC809000 75#define SH_DMARS_BASE0 0xFC809000
100#define CHCR_TS_LOW_MASK 0x00000018
101#define CHCR_TS_LOW_SHIFT 3
102#define CHCR_TS_HIGH_MASK 0
103#define CHCR_TS_HIGH_SHIFT 0
104#endif 76#endif
105 77
106#define REQ_HE 0x000000C0 78#define REQ_HE 0x000000C0
@@ -108,38 +80,4 @@
108#define REQ_LE 0x00000040 80#define REQ_LE 0x00000040
109#define TM_BURST 0x00000020 81#define TM_BURST 0x00000020
110 82
111/*
112 * The SuperH DMAC supports a number of transmit sizes, we list them here,
113 * with their respective values as they appear in the CHCR registers.
114 *
115 * Defaults to a 64-bit transfer size.
116 */
117enum {
118 XMIT_SZ_8BIT = 0,
119 XMIT_SZ_16BIT = 1,
120 XMIT_SZ_32BIT = 2,
121 XMIT_SZ_64BIT = 7,
122 XMIT_SZ_128BIT = 3,
123 XMIT_SZ_256BIT = 4,
124 XMIT_SZ_128BIT_BLK = 0xb,
125 XMIT_SZ_256BIT_BLK = 0xc,
126};
127
128/*
129 * The DMA count is defined as the number of bytes to transfer.
130 */
131#define TS_SHIFT { \
132 [XMIT_SZ_8BIT] = 0, \
133 [XMIT_SZ_16BIT] = 1, \
134 [XMIT_SZ_32BIT] = 2, \
135 [XMIT_SZ_64BIT] = 3, \
136 [XMIT_SZ_128BIT] = 4, \
137 [XMIT_SZ_256BIT] = 5, \
138 [XMIT_SZ_128BIT_BLK] = 4, \
139 [XMIT_SZ_256BIT_BLK] = 5, \
140}
141
142#define TS_INDEX2VAL(i) ((((i) & 3) << CHCR_TS_LOW_SHIFT) | \
143 ((((i) >> 2) & 3) << CHCR_TS_HIGH_SHIFT))
144
145#endif /* __ASM_SH_CPU_SH4_DMA_SH7780_H */ 83#endif /* __ASM_SH_CPU_SH4_DMA_SH7780_H */
diff --git a/arch/sh/include/cpu-sh4/cpu/dma.h b/arch/sh/include/cpu-sh4/cpu/dma.h
index 114a369705bc..ca747e93c2ed 100644
--- a/arch/sh/include/cpu-sh4/cpu/dma.h
+++ b/arch/sh/include/cpu-sh4/cpu/dma.h
@@ -5,9 +5,8 @@
5 5
6#ifdef CONFIG_CPU_SH4A 6#ifdef CONFIG_CPU_SH4A
7 7
8#define DMAOR_INIT (DMAOR_DME)
9
10#include <cpu/dma-sh4a.h> 8#include <cpu/dma-sh4a.h>
9
11#else /* CONFIG_CPU_SH4A */ 10#else /* CONFIG_CPU_SH4A */
12/* 11/*
13 * SH7750/SH7751/SH7760 12 * SH7750/SH7751/SH7760
@@ -17,7 +16,6 @@
17#define DMTE6_IRQ 46 16#define DMTE6_IRQ 46
18#define DMAE0_IRQ 38 17#define DMAE0_IRQ 38
19 18
20#define DMAOR_INIT (0x8000|DMAOR_DME)
21#define SH_DMAC_BASE0 0xffa00000 19#define SH_DMAC_BASE0 0xffa00000
22#define SH_DMAC_BASE1 0xffa00070 20#define SH_DMAC_BASE1 0xffa00070
23/* Definitions for the SuperH DMAC */ 21/* Definitions for the SuperH DMAC */
@@ -27,40 +25,8 @@
27#define TS_32 0x00000030 25#define TS_32 0x00000030
28#define TS_64 0x00000000 26#define TS_64 0x00000000
29 27
30#define CHCR_TS_LOW_MASK 0x70
31#define CHCR_TS_LOW_SHIFT 4
32#define CHCR_TS_HIGH_MASK 0
33#define CHCR_TS_HIGH_SHIFT 0
34
35#define DMAOR_COD 0x00000008 28#define DMAOR_COD 0x00000008
36 29
37/*
38 * The SuperH DMAC supports a number of transmit sizes, we list them here,
39 * with their respective values as they appear in the CHCR registers.
40 *
41 * Defaults to a 64-bit transfer size.
42 */
43enum {
44 XMIT_SZ_8BIT = 1,
45 XMIT_SZ_16BIT = 2,
46 XMIT_SZ_32BIT = 3,
47 XMIT_SZ_64BIT = 0,
48 XMIT_SZ_256BIT = 4,
49};
50
51/*
52 * The DMA count is defined as the number of bytes to transfer.
53 */
54#define TS_SHIFT { \
55 [XMIT_SZ_8BIT] = 0, \
56 [XMIT_SZ_16BIT] = 1, \
57 [XMIT_SZ_32BIT] = 2, \
58 [XMIT_SZ_64BIT] = 3, \
59 [XMIT_SZ_256BIT] = 5, \
60}
61
62#define TS_INDEX2VAL(i) (((i) & 7) << CHCR_TS_LOW_SHIFT)
63
64#endif 30#endif
65 31
66#endif /* __ASM_CPU_SH4_DMA_H */ 32#endif /* __ASM_CPU_SH4_DMA_H */
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
index aec182bed8a1..89f84911c356 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
@@ -7,18 +7,21 @@
7 * License. See the file "COPYING" in the main directory of this archive 7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details. 8 * for more details.
9 */ 9 */
10#include <linux/platform_device.h>
11#include <linux/init.h> 10#include <linux/init.h>
11#include <linux/mm.h>
12#include <linux/platform_device.h>
12#include <linux/serial.h> 13#include <linux/serial.h>
13#include <linux/serial_sci.h> 14#include <linux/serial_sci.h>
14#include <linux/mm.h> 15#include <linux/sh_timer.h>
15#include <linux/uio_driver.h> 16#include <linux/uio_driver.h>
16#include <linux/usb/m66592.h> 17#include <linux/usb/m66592.h>
17#include <linux/sh_timer.h> 18
18#include <asm/clock.h> 19#include <asm/clock.h>
20#include <asm/dmaengine.h>
19#include <asm/mmzone.h> 21#include <asm/mmzone.h>
20#include <asm/dma-sh.h>
21#include <asm/siu.h> 22#include <asm/siu.h>
23
24#include <cpu/dma-register.h>
22#include <cpu/sh7722.h> 25#include <cpu/sh7722.h>
23 26
24static struct sh_dmae_slave_config sh7722_dmae_slaves[] = { 27static struct sh_dmae_slave_config sh7722_dmae_slaves[] = {
@@ -103,11 +106,20 @@ static struct sh_dmae_channel sh7722_dmae_channels[] = {
103 } 106 }
104}; 107};
105 108
109static unsigned int ts_shift[] = TS_SHIFT;
110
106static struct sh_dmae_pdata dma_platform_data = { 111static struct sh_dmae_pdata dma_platform_data = {
107 .slave = sh7722_dmae_slaves, 112 .slave = sh7722_dmae_slaves,
108 .slave_num = ARRAY_SIZE(sh7722_dmae_slaves), 113 .slave_num = ARRAY_SIZE(sh7722_dmae_slaves),
109 .channel = sh7722_dmae_channels, 114 .channel = sh7722_dmae_channels,
110 .channel_num = ARRAY_SIZE(sh7722_dmae_channels), 115 .channel_num = ARRAY_SIZE(sh7722_dmae_channels),
116 .ts_low_shift = CHCR_TS_LOW_SHIFT,
117 .ts_low_mask = CHCR_TS_LOW_MASK,
118 .ts_high_shift = CHCR_TS_HIGH_SHIFT,
119 .ts_high_mask = CHCR_TS_HIGH_MASK,
120 .ts_shift = ts_shift,
121 .ts_shift_num = ARRAY_SIZE(ts_shift),
122 .dmaor_init = DMAOR_INIT,
111}; 123};
112 124
113static struct resource sh7722_dmae_resources[] = { 125static struct resource sh7722_dmae_resources[] = {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
index aca1fb2c571b..d9cb2c471a31 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
@@ -21,10 +21,13 @@
21#include <linux/sh_timer.h> 21#include <linux/sh_timer.h>
22#include <linux/io.h> 22#include <linux/io.h>
23#include <linux/notifier.h> 23#include <linux/notifier.h>
24
24#include <asm/suspend.h> 25#include <asm/suspend.h>
25#include <asm/clock.h> 26#include <asm/clock.h>
26#include <asm/dma-sh.h> 27#include <asm/dmaengine.h>
27#include <asm/mmzone.h> 28#include <asm/mmzone.h>
29
30#include <cpu/dma-register.h>
28#include <cpu/sh7724.h> 31#include <cpu/sh7724.h>
29 32
30/* DMA */ 33/* DMA */
@@ -84,14 +87,30 @@ static struct sh_dmae_channel sh7724_dmae1_channels[] = {
84 } 87 }
85}; 88};
86 89
90static unsigned int ts_shift[] = TS_SHIFT;
91
87static struct sh_dmae_pdata dma0_platform_data = { 92static struct sh_dmae_pdata dma0_platform_data = {
88 .channel = sh7724_dmae0_channels, 93 .channel = sh7724_dmae0_channels,
89 .channel_num = ARRAY_SIZE(sh7724_dmae0_channels), 94 .channel_num = ARRAY_SIZE(sh7724_dmae0_channels),
95 .ts_low_shift = CHCR_TS_LOW_SHIFT,
96 .ts_low_mask = CHCR_TS_LOW_MASK,
97 .ts_high_shift = CHCR_TS_HIGH_SHIFT,
98 .ts_high_mask = CHCR_TS_HIGH_MASK,
99 .ts_shift = ts_shift,
100 .ts_shift_num = ARRAY_SIZE(ts_shift),
101 .dmaor_init = DMAOR_INIT,
90}; 102};
91 103
92static struct sh_dmae_pdata dma1_platform_data = { 104static struct sh_dmae_pdata dma1_platform_data = {
93 .channel = sh7724_dmae1_channels, 105 .channel = sh7724_dmae1_channels,
94 .channel_num = ARRAY_SIZE(sh7724_dmae1_channels), 106 .channel_num = ARRAY_SIZE(sh7724_dmae1_channels),
107 .ts_low_shift = CHCR_TS_LOW_SHIFT,
108 .ts_low_mask = CHCR_TS_LOW_MASK,
109 .ts_high_shift = CHCR_TS_HIGH_SHIFT,
110 .ts_high_mask = CHCR_TS_HIGH_MASK,
111 .ts_shift = ts_shift,
112 .ts_shift_num = ARRAY_SIZE(ts_shift),
113 .dmaor_init = DMAOR_INIT,
95}; 114};
96 115
97/* Resource order important! */ 116/* Resource order important! */
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
index 338dfc2c2bb5..02e792c90de6 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
@@ -13,7 +13,10 @@
13#include <linux/io.h> 13#include <linux/io.h>
14#include <linux/serial_sci.h> 14#include <linux/serial_sci.h>
15#include <linux/sh_timer.h> 15#include <linux/sh_timer.h>
16#include <asm/dma-sh.h> 16
17#include <asm/dmaengine.h>
18
19#include <cpu/dma-register.h>
17 20
18static struct plat_sci_port scif0_platform_data = { 21static struct plat_sci_port scif0_platform_data = {
19 .mapbase = 0xffe00000, 22 .mapbase = 0xffe00000,
@@ -292,14 +295,30 @@ static struct sh_dmae_channel sh7780_dmae1_channels[] = {
292 } 295 }
293}; 296};
294 297
298static unsigned int ts_shift[] = TS_SHIFT;
299
295static struct sh_dmae_pdata dma0_platform_data = { 300static struct sh_dmae_pdata dma0_platform_data = {
296 .channel = sh7780_dmae0_channels, 301 .channel = sh7780_dmae0_channels,
297 .channel_num = ARRAY_SIZE(sh7780_dmae0_channels), 302 .channel_num = ARRAY_SIZE(sh7780_dmae0_channels),
303 .ts_low_shift = CHCR_TS_LOW_SHIFT,
304 .ts_low_mask = CHCR_TS_LOW_MASK,
305 .ts_high_shift = CHCR_TS_HIGH_SHIFT,
306 .ts_high_mask = CHCR_TS_HIGH_MASK,
307 .ts_shift = ts_shift,
308 .ts_shift_num = ARRAY_SIZE(ts_shift),
309 .dmaor_init = DMAOR_INIT,
298}; 310};
299 311
300static struct sh_dmae_pdata dma1_platform_data = { 312static struct sh_dmae_pdata dma1_platform_data = {
301 .channel = sh7780_dmae1_channels, 313 .channel = sh7780_dmae1_channels,
302 .channel_num = ARRAY_SIZE(sh7780_dmae1_channels), 314 .channel_num = ARRAY_SIZE(sh7780_dmae1_channels),
315 .ts_low_shift = CHCR_TS_LOW_SHIFT,
316 .ts_low_mask = CHCR_TS_LOW_MASK,
317 .ts_high_shift = CHCR_TS_HIGH_SHIFT,
318 .ts_high_mask = CHCR_TS_HIGH_MASK,
319 .ts_shift = ts_shift,
320 .ts_shift_num = ARRAY_SIZE(ts_shift),
321 .dmaor_init = DMAOR_INIT,
303}; 322};
304 323
305static struct resource sh7780_dmae0_resources[] = { 324static struct resource sh7780_dmae0_resources[] = {
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
index fbb5d1f51f1a..1fcd88b1671e 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
@@ -14,9 +14,12 @@
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/mm.h> 15#include <linux/mm.h>
16#include <linux/sh_timer.h> 16#include <linux/sh_timer.h>
17#include <asm/dma-sh.h> 17
18#include <asm/dmaengine.h>
18#include <asm/mmzone.h> 19#include <asm/mmzone.h>
19 20
21#include <cpu/dma-register.h>
22
20static struct plat_sci_port scif0_platform_data = { 23static struct plat_sci_port scif0_platform_data = {
21 .mapbase = 0xffea0000, 24 .mapbase = 0xffea0000,
22 .flags = UPF_BOOT_AUTOCONF, 25 .flags = UPF_BOOT_AUTOCONF,
@@ -340,14 +343,30 @@ static struct sh_dmae_channel sh7785_dmae1_channels[] = {
340 } 343 }
341}; 344};
342 345
346static unsigned int ts_shift[] = TS_SHIFT;
347
343static struct sh_dmae_pdata dma0_platform_data = { 348static struct sh_dmae_pdata dma0_platform_data = {
344 .channel = sh7785_dmae0_channels, 349 .channel = sh7785_dmae0_channels,
345 .channel_num = ARRAY_SIZE(sh7785_dmae0_channels), 350 .channel_num = ARRAY_SIZE(sh7785_dmae0_channels),
351 .ts_low_shift = CHCR_TS_LOW_SHIFT,
352 .ts_low_mask = CHCR_TS_LOW_MASK,
353 .ts_high_shift = CHCR_TS_HIGH_SHIFT,
354 .ts_high_mask = CHCR_TS_HIGH_MASK,
355 .ts_shift = ts_shift,
356 .ts_shift_num = ARRAY_SIZE(ts_shift),
357 .dmaor_init = DMAOR_INIT,
346}; 358};
347 359
348static struct sh_dmae_pdata dma1_platform_data = { 360static struct sh_dmae_pdata dma1_platform_data = {
349 .channel = sh7785_dmae1_channels, 361 .channel = sh7785_dmae1_channels,
350 .channel_num = ARRAY_SIZE(sh7785_dmae1_channels), 362 .channel_num = ARRAY_SIZE(sh7785_dmae1_channels),
363 .ts_low_shift = CHCR_TS_LOW_SHIFT,
364 .ts_low_mask = CHCR_TS_LOW_MASK,
365 .ts_high_shift = CHCR_TS_HIGH_SHIFT,
366 .ts_high_mask = CHCR_TS_HIGH_MASK,
367 .ts_shift = ts_shift,
368 .ts_shift_num = ARRAY_SIZE(ts_shift),
369 .dmaor_init = DMAOR_INIT,
351}; 370};
352 371
353static struct resource sh7785_dmae0_resources[] = { 372static struct resource sh7785_dmae0_resources[] = {
diff --git a/drivers/dma/shdma.c b/drivers/dma/shdma.c
index ab12fa5a1296..b419afaa2389 100644
--- a/drivers/dma/shdma.c
+++ b/drivers/dma/shdma.c
@@ -24,8 +24,7 @@
24#include <linux/delay.h> 24#include <linux/delay.h>
25#include <linux/dma-mapping.h> 25#include <linux/dma-mapping.h>
26#include <linux/platform_device.h> 26#include <linux/platform_device.h>
27#include <cpu/dma.h> 27#include <asm/dmaengine.h>
28#include <asm/dma-sh.h>
29#include "shdma.h" 28#include "shdma.h"
30 29
31/* DMA descriptor control */ 30/* DMA descriptor control */
@@ -38,15 +37,8 @@ enum sh_dmae_desc_status {
38}; 37};
39 38
40#define NR_DESCS_PER_CHANNEL 32 39#define NR_DESCS_PER_CHANNEL 32
41/* 40/* Default MEMCPY transfer size = 2^2 = 4 bytes */
42 * Define the default configuration for dual address memory-memory transfer. 41#define LOG2_DEFAULT_XFER_SIZE 2
43 * The 0x400 value represents auto-request, external->external.
44 *
45 * And this driver set 4byte burst mode.
46 * If you want to change mode, you need to change RS_DEFAULT of value.
47 * (ex 1byte burst mode -> (RS_DUAL & ~TS_32)
48 */
49#define RS_DEFAULT (RS_DUAL)
50 42
51/* A bitmask with bits enough for enum sh_dmae_slave_chan_id */ 43/* A bitmask with bits enough for enum sh_dmae_slave_chan_id */
52static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SHDMA_SLAVE_NUMBER)]; 44static unsigned long sh_dmae_slave_used[BITS_TO_LONGS(SHDMA_SLAVE_NUMBER)];
@@ -90,7 +82,7 @@ static int sh_dmae_rst(struct sh_dmae_device *shdev)
90 unsigned short dmaor; 82 unsigned short dmaor;
91 83
92 sh_dmae_ctl_stop(shdev); 84 sh_dmae_ctl_stop(shdev);
93 dmaor = dmaor_read(shdev) | DMAOR_INIT; 85 dmaor = dmaor_read(shdev) | shdev->pdata->dmaor_init;
94 86
95 dmaor_write(shdev, dmaor); 87 dmaor_write(shdev, dmaor);
96 if (dmaor_read(shdev) & (DMAOR_AE | DMAOR_NMIF)) { 88 if (dmaor_read(shdev) & (DMAOR_AE | DMAOR_NMIF)) {
@@ -110,13 +102,36 @@ static bool dmae_is_busy(struct sh_dmae_chan *sh_chan)
110 return false; /* waiting */ 102 return false; /* waiting */
111} 103}
112 104
113static unsigned int ts_shift[] = TS_SHIFT; 105static unsigned int calc_xmit_shift(struct sh_dmae_chan *sh_chan, u32 chcr)
114static inline unsigned int calc_xmit_shift(u32 chcr)
115{ 106{
116 int cnt = ((chcr & CHCR_TS_LOW_MASK) >> CHCR_TS_LOW_SHIFT) | 107 struct sh_dmae_device *shdev = container_of(sh_chan->common.device,
117 ((chcr & CHCR_TS_HIGH_MASK) >> CHCR_TS_HIGH_SHIFT); 108 struct sh_dmae_device, common);
109 struct sh_dmae_pdata *pdata = shdev->pdata;
110 int cnt = ((chcr & pdata->ts_low_mask) >> pdata->ts_low_shift) |
111 ((chcr & pdata->ts_high_mask) >> pdata->ts_high_shift);
112
113 if (cnt >= pdata->ts_shift_num)
114 cnt = 0;
118 115
119 return ts_shift[cnt]; 116 return pdata->ts_shift[cnt];
117}
118
119static u32 log2size_to_chcr(struct sh_dmae_chan *sh_chan, int l2size)
120{
121 struct sh_dmae_device *shdev = container_of(sh_chan->common.device,
122 struct sh_dmae_device, common);
123 struct sh_dmae_pdata *pdata = shdev->pdata;
124 int i;
125
126 for (i = 0; i < pdata->ts_shift_num; i++)
127 if (pdata->ts_shift[i] == l2size)
128 break;
129
130 if (i == pdata->ts_shift_num)
131 i = 0;
132
133 return ((i << pdata->ts_low_shift) & pdata->ts_low_mask) |
134 ((i << pdata->ts_high_shift) & pdata->ts_high_mask);
120} 135}
121 136
122static void dmae_set_reg(struct sh_dmae_chan *sh_chan, struct sh_dmae_regs *hw) 137static void dmae_set_reg(struct sh_dmae_chan *sh_chan, struct sh_dmae_regs *hw)
@@ -144,8 +159,13 @@ static void dmae_halt(struct sh_dmae_chan *sh_chan)
144 159
145static void dmae_init(struct sh_dmae_chan *sh_chan) 160static void dmae_init(struct sh_dmae_chan *sh_chan)
146{ 161{
147 u32 chcr = RS_DEFAULT; /* default is DUAL mode */ 162 /*
148 sh_chan->xmit_shift = calc_xmit_shift(chcr); 163 * Default configuration for dual address memory-memory transfer.
164 * 0x400 represents auto-request.
165 */
166 u32 chcr = DM_INC | SM_INC | 0x400 | log2size_to_chcr(sh_chan,
167 LOG2_DEFAULT_XFER_SIZE);
168 sh_chan->xmit_shift = calc_xmit_shift(sh_chan, chcr);
149 sh_dmae_writel(sh_chan, chcr, CHCR); 169 sh_dmae_writel(sh_chan, chcr, CHCR);
150} 170}
151 171
@@ -155,7 +175,7 @@ static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
155 if (dmae_is_busy(sh_chan)) 175 if (dmae_is_busy(sh_chan))
156 return -EBUSY; 176 return -EBUSY;
157 177
158 sh_chan->xmit_shift = calc_xmit_shift(val); 178 sh_chan->xmit_shift = calc_xmit_shift(sh_chan, val);
159 sh_dmae_writel(sh_chan, val, CHCR); 179 sh_dmae_writel(sh_chan, val, CHCR);
160 180
161 return 0; 181 return 0;
@@ -285,9 +305,8 @@ static int sh_dmae_alloc_chan_resources(struct dma_chan *chan)
285 305
286 dmae_set_dmars(sh_chan, cfg->mid_rid); 306 dmae_set_dmars(sh_chan, cfg->mid_rid);
287 dmae_set_chcr(sh_chan, cfg->chcr); 307 dmae_set_chcr(sh_chan, cfg->chcr);
288 } else { 308 } else if ((sh_dmae_readl(sh_chan, CHCR) & 0xf00) != 0x400) {
289 if ((sh_dmae_readl(sh_chan, CHCR) & 0x700) != 0x400) 309 dmae_init(sh_chan);
290 dmae_set_chcr(sh_chan, RS_DEFAULT);
291 } 310 }
292 311
293 spin_lock_bh(&sh_chan->desc_lock); 312 spin_lock_bh(&sh_chan->desc_lock);
@@ -757,7 +776,7 @@ static irqreturn_t sh_dmae_err(int irq, void *data)
757 sh_dmae_ctl_stop(shdev); 776 sh_dmae_ctl_stop(shdev);
758 777
759 /* We cannot detect, which channel caused the error, have to reset all */ 778 /* We cannot detect, which channel caused the error, have to reset all */
760 for (i = 0; i < MAX_DMA_CHANNELS; i++) { 779 for (i = 0; i < SH_DMAC_MAX_CHANNELS; i++) {
761 struct sh_dmae_chan *sh_chan = shdev->chan[i]; 780 struct sh_dmae_chan *sh_chan = shdev->chan[i];
762 if (sh_chan) { 781 if (sh_chan) {
763 struct sh_desc *desc; 782 struct sh_desc *desc;
@@ -822,6 +841,9 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id,
822 return -ENOMEM; 841 return -ENOMEM;
823 } 842 }
824 843
844 /* copy struct dma_device */
845 new_sh_chan->common.device = &shdev->common;
846
825 new_sh_chan->dev = shdev->common.dev; 847 new_sh_chan->dev = shdev->common.dev;
826 new_sh_chan->id = id; 848 new_sh_chan->id = id;
827 new_sh_chan->irq = irq; 849 new_sh_chan->irq = irq;
@@ -840,9 +862,6 @@ static int __devinit sh_dmae_chan_probe(struct sh_dmae_device *shdev, int id,
840 INIT_LIST_HEAD(&new_sh_chan->ld_queue); 862 INIT_LIST_HEAD(&new_sh_chan->ld_queue);
841 INIT_LIST_HEAD(&new_sh_chan->ld_free); 863 INIT_LIST_HEAD(&new_sh_chan->ld_free);
842 864
843 /* copy struct dma_device */
844 new_sh_chan->common.device = &shdev->common;
845
846 /* Add the channel to DMA device channel list */ 865 /* Add the channel to DMA device channel list */
847 list_add_tail(&new_sh_chan->common.device_node, 866 list_add_tail(&new_sh_chan->common.device_node,
848 &shdev->common.channels); 867 &shdev->common.channels);
@@ -896,8 +915,8 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
896{ 915{
897 struct sh_dmae_pdata *pdata = pdev->dev.platform_data; 916 struct sh_dmae_pdata *pdata = pdev->dev.platform_data;
898 unsigned long irqflags = IRQF_DISABLED, 917 unsigned long irqflags = IRQF_DISABLED,
899 chan_flag[MAX_DMA_CHANNELS] = {}; 918 chan_flag[SH_DMAC_MAX_CHANNELS] = {};
900 int errirq, chan_irq[MAX_DMA_CHANNELS]; 919 int errirq, chan_irq[SH_DMAC_MAX_CHANNELS];
901 int err, i, irq_cnt = 0, irqres = 0; 920 int err, i, irq_cnt = 0, irqres = 0;
902 struct sh_dmae_device *shdev; 921 struct sh_dmae_device *shdev;
903 struct resource *chan, *dmars, *errirq_res, *chanirq_res; 922 struct resource *chan, *dmars, *errirq_res, *chanirq_res;
@@ -983,7 +1002,7 @@ static int __init sh_dmae_probe(struct platform_device *pdev)
983 1002
984 shdev->common.dev = &pdev->dev; 1003 shdev->common.dev = &pdev->dev;
985 /* Default transfer size of 32 bytes requires 32-byte alignment */ 1004 /* Default transfer size of 32 bytes requires 32-byte alignment */
986 shdev->common.copy_align = 5; 1005 shdev->common.copy_align = LOG2_DEFAULT_XFER_SIZE;
987 1006
988#if defined(CONFIG_CPU_SH4) 1007#if defined(CONFIG_CPU_SH4)
989 chanirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 1); 1008 chanirq_res = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
diff --git a/drivers/dma/shdma.h b/drivers/dma/shdma.h
index 800fd884be83..9f0897f7fe34 100644
--- a/drivers/dma/shdma.h
+++ b/drivers/dma/shdma.h
@@ -17,6 +17,8 @@
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/list.h> 18#include <linux/list.h>
19 19
20#include <asm/dmaengine.h>
21
20#define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */ 22#define SH_DMA_TCR_MAX 0x00FFFFFF /* 16MB */
21 23
22struct sh_dmae_regs { 24struct sh_dmae_regs {
@@ -55,7 +57,7 @@ struct sh_dmae_chan {
55 57
56struct sh_dmae_device { 58struct sh_dmae_device {
57 struct dma_device common; 59 struct dma_device common;
58 struct sh_dmae_chan *chan[MAX_DMA_CHANNELS]; 60 struct sh_dmae_chan *chan[SH_DMAC_MAX_CHANNELS];
59 struct sh_dmae_pdata *pdata; 61 struct sh_dmae_pdata *pdata;
60 u32 __iomem *chan_reg; 62 u32 __iomem *chan_reg;
61 u16 __iomem *dmars; 63 u16 __iomem *dmars;
diff --git a/sound/soc/sh/siu.h b/sound/soc/sh/siu.h
index 9cc04ab2bce7..c0bfab8fed3d 100644
--- a/sound/soc/sh/siu.h
+++ b/sound/soc/sh/siu.h
@@ -72,7 +72,7 @@ struct siu_firmware {
72#include <linux/interrupt.h> 72#include <linux/interrupt.h>
73#include <linux/io.h> 73#include <linux/io.h>
74 74
75#include <asm/dma-sh.h> 75#include <asm/dmaengine.h>
76 76
77#include <sound/core.h> 77#include <sound/core.h>
78#include <sound/pcm.h> 78#include <sound/pcm.h>
diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c
index c5efc30f0136..ba7f8d05d977 100644
--- a/sound/soc/sh/siu_pcm.c
+++ b/sound/soc/sh/siu_pcm.c
@@ -32,7 +32,7 @@
32#include <sound/pcm_params.h> 32#include <sound/pcm_params.h>
33#include <sound/soc-dai.h> 33#include <sound/soc-dai.h>
34 34
35#include <asm/dma-sh.h> 35#include <asm/dmaengine.h>
36#include <asm/siu.h> 36#include <asm/siu.h>
37 37
38#include "siu.h" 38#include "siu.h"