upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv210 / dma.c
1 /*
2  * Copyright (C) 2010 Samsung Electronics Co. Ltd.
3  *      Jaswinder Singh <jassi.brar@samsung.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19
20 #include <linux/platform_device.h>
21 #include <linux/dma-mapping.h>
22
23 #include <plat/devs.h>
24 #include <plat/irqs.h>
25
26 #include <mach/map.h>
27 #include <mach/irqs.h>
28
29 #include <plat/s3c-pl330-pdata.h>
30
31 static u64 dma_dmamask = DMA_BIT_MASK(32);
32
33 static struct resource s5pv210_mdma_resource[] = {
34         [0] = {
35                 .start  = S5PV210_PA_MDMA,
36                 .end    = S5PV210_PA_MDMA + SZ_4K,
37                 .flags  = IORESOURCE_MEM,
38         },
39         [1] = {
40                 .start  = IRQ_MDMA,
41                 .end    = IRQ_MDMA,
42                 .flags  = IORESOURCE_IRQ,
43         },
44 };
45
46 static struct s3c_pl330_platdata s5pv210_mdma_pdata = {
47         .peri = {
48                 /* The DMAC can have max 8 channel so there
49                  * can be 8 M<->M requests served at any time.
50                  */
51                 [0] = DMACH_MTOM_0,
52                 [1] = DMACH_MTOM_1,
53                 [2] = DMACH_MTOM_2,
54                 [3] = DMACH_MTOM_3,
55                 [4] = DMACH_MTOM_4,
56                 [5] = DMACH_MTOM_5,
57                 [6] = DMACH_MTOM_6,
58                 [7] = DMACH_MTOM_7,
59                 [8] = DMACH_MAX,
60                 [9] = DMACH_MAX,
61                 [10] = DMACH_MAX,
62                 [11] = DMACH_MAX,
63                 [12] = DMACH_MAX,
64                 [13] = DMACH_MAX,
65                 [14] = DMACH_MAX,
66                 [15] = DMACH_MAX,
67                 [16] = DMACH_MAX,
68                 [17] = DMACH_MAX,
69                 [18] = DMACH_MAX,
70                 [19] = DMACH_MAX,
71                 [20] = DMACH_MAX,
72                 [21] = DMACH_MAX,
73                 [22] = DMACH_MAX,
74                 [23] = DMACH_MAX,
75                 [24] = DMACH_MAX,
76                 [25] = DMACH_MAX,
77                 [26] = DMACH_MAX,
78                 [27] = DMACH_MAX,
79                 [28] = DMACH_MAX,
80                 [29] = DMACH_MAX,
81                 [30] = DMACH_MAX,
82                 [31] = DMACH_MAX,
83         },
84 };
85
86 struct platform_device s5pv210_device_mdma = {
87         .name           = "s3c-pl330",
88         .id             = 0,
89         .num_resources  = ARRAY_SIZE(s5pv210_mdma_resource),
90         .resource       = s5pv210_mdma_resource,
91         .dev            = {
92                 .dma_mask = &dma_dmamask,
93                 .coherent_dma_mask = DMA_BIT_MASK(32),
94                 .platform_data = &s5pv210_mdma_pdata,
95         },
96 };
97
98 static struct resource s5pv210_pdma0_resource[] = {
99         [0] = {
100                 .start  = S5PV210_PA_PDMA0,
101                 .end    = S5PV210_PA_PDMA0 + SZ_4K,
102                 .flags = IORESOURCE_MEM,
103         },
104         [1] = {
105                 .start  = IRQ_PDMA0,
106                 .end    = IRQ_PDMA0,
107                 .flags  = IORESOURCE_IRQ,
108         },
109 };
110
111 static struct s3c_pl330_platdata s5pv210_pdma0_pdata = {
112         .peri = {
113                 [0] = DMACH_UART0_RX,
114                 [1] = DMACH_UART0_TX,
115                 [2] = DMACH_UART1_RX,
116                 [3] = DMACH_UART1_TX,
117                 [4] = DMACH_UART2_RX,
118                 [5] = DMACH_UART2_TX,
119                 [6] = DMACH_UART3_RX,
120                 [7] = DMACH_UART3_TX,
121                 [8] = DMACH_MAX,
122                 [9] = DMACH_I2S0_RX,
123                 [10] = DMACH_I2S0_TX,
124                 [11] = DMACH_I2S0S_TX,
125                 [12] = DMACH_I2S1_RX,
126                 [13] = DMACH_I2S1_TX,
127                 [14] = DMACH_MAX,
128                 [15] = DMACH_MAX,
129                 [16] = DMACH_SPI0_RX,
130                 [17] = DMACH_SPI0_TX,
131                 [18] = DMACH_SPI1_RX,
132                 [19] = DMACH_SPI1_TX,
133                 [20] = DMACH_MAX,
134                 [21] = DMACH_MAX,
135                 [22] = DMACH_AC97_MICIN,
136                 [23] = DMACH_AC97_PCMIN,
137                 [24] = DMACH_AC97_PCMOUT,
138                 [25] = DMACH_MAX,
139                 [26] = DMACH_PWM,
140                 [27] = DMACH_SPDIF,
141                 [28] = DMACH_MAX,
142                 [29] = DMACH_MAX,
143                 [30] = DMACH_MAX,
144                 [31] = DMACH_MAX,
145         },
146 };
147
148 static struct platform_device s5pv210_device_pdma0 = {
149         .name           = "s3c-pl330",
150         .id             = 1,
151         .num_resources  = ARRAY_SIZE(s5pv210_pdma0_resource),
152         .resource       = s5pv210_pdma0_resource,
153         .dev            = {
154                 .dma_mask = &dma_dmamask,
155                 .coherent_dma_mask = DMA_BIT_MASK(32),
156                 .platform_data = &s5pv210_pdma0_pdata,
157         },
158 };
159
160 static struct resource s5pv210_pdma1_resource[] = {
161         [0] = {
162                 .start  = S5PV210_PA_PDMA1,
163                 .end    = S5PV210_PA_PDMA1 + SZ_4K,
164                 .flags = IORESOURCE_MEM,
165         },
166         [1] = {
167                 .start  = IRQ_PDMA1,
168                 .end    = IRQ_PDMA1,
169                 .flags  = IORESOURCE_IRQ,
170         },
171 };
172
173 static struct s3c_pl330_platdata s5pv210_pdma1_pdata = {
174         .peri = {
175                 [0] = DMACH_UART0_RX,
176                 [1] = DMACH_UART0_TX,
177                 [2] = DMACH_UART1_RX,
178                 [3] = DMACH_UART1_TX,
179                 [4] = DMACH_UART2_RX,
180                 [5] = DMACH_UART2_TX,
181                 [6] = DMACH_UART3_RX,
182                 [7] = DMACH_UART3_TX,
183                 [8] = DMACH_MAX,
184                 [9] = DMACH_I2S0_RX,
185                 [10] = DMACH_I2S0_TX,
186                 [11] = DMACH_I2S0S_TX,
187                 [12] = DMACH_I2S1_RX,
188                 [13] = DMACH_I2S1_TX,
189                 [14] = DMACH_I2S2_RX,
190                 [15] = DMACH_I2S2_TX,
191                 [16] = DMACH_SPI0_RX,
192                 [17] = DMACH_SPI0_TX,
193                 [18] = DMACH_SPI1_RX,
194                 [19] = DMACH_SPI1_TX,
195                 [20] = DMACH_MAX,
196                 [21] = DMACH_MAX,
197                 [22] = DMACH_PCM0_RX,
198                 [23] = DMACH_PCM0_TX,
199                 [24] = DMACH_PCM1_RX,
200                 [25] = DMACH_PCM1_TX,
201                 [26] = DMACH_MSM_REQ0,
202                 [27] = DMACH_MSM_REQ1,
203                 [28] = DMACH_MSM_REQ2,
204                 [29] = DMACH_MSM_REQ3,
205                 [30] = DMACH_PCM2_RX,
206                 [31] = DMACH_PCM2_TX,
207         },
208 };
209
210 static struct platform_device s5pv210_device_pdma1 = {
211         .name           = "s3c-pl330",
212         .id             = 2,
213         .num_resources  = ARRAY_SIZE(s5pv210_pdma1_resource),
214         .resource       = s5pv210_pdma1_resource,
215         .dev            = {
216                 .dma_mask = &dma_dmamask,
217                 .coherent_dma_mask = DMA_BIT_MASK(32),
218                 .platform_data = &s5pv210_pdma1_pdata,
219         },
220 };
221
222 static struct platform_device *s5pv210_dmacs[] __initdata = {
223         &s5pv210_device_mdma,
224         &s5pv210_device_pdma0,
225         &s5pv210_device_pdma1,
226 };
227
228 static int __init s5pv210_dma_init(void)
229 {
230         platform_add_devices(s5pv210_dmacs, ARRAY_SIZE(s5pv210_dmacs));
231
232         return 0;
233 }
234 arch_initcall(s5pv210_dma_init);