Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
dma.c
Go to the documentation of this file.
1 /* linux/arch/arm/mach-exynos4/dma.c
2  *
3  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4  * http://www.samsung.com
5  *
6  * Copyright (C) 2010 Samsung Electronics Co. Ltd.
7  * Jaswinder Singh <[email protected]>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23 
24 #include <linux/dma-mapping.h>
25 #include <linux/amba/bus.h>
26 #include <linux/amba/pl330.h>
27 #include <linux/of.h>
28 
29 #include <asm/irq.h>
30 #include <plat/devs.h>
31 #include <plat/irqs.h>
32 #include <plat/cpu.h>
33 
34 #include <mach/map.h>
35 #include <mach/irqs.h>
36 #include <mach/dma.h>
37 
38 static u8 exynos4210_pdma0_peri[] = {
69 };
70 
71 static u8 exynos4212_pdma0_peri[] = {
104 };
105 
106 static u8 exynos5250_pdma0_peri[] = {
139 };
140 
141 static struct dma_pl330_platdata exynos_pdma0_pdata;
142 
143 static AMBA_AHB_DEVICE(exynos_pdma0, "dma-pl330.0", 0x00041330,
144  EXYNOS4_PA_PDMA0, {EXYNOS4_IRQ_PDMA0}, &exynos_pdma0_pdata);
145 
146 static u8 exynos4210_pdma1_peri[] = {
172 };
173 
174 static u8 exynos4212_pdma1_peri[] = {
202  DMACH_SPDIF,
205 };
206 
207 static u8 exynos5250_pdma1_peri[] = {
214  DMACH_PWM,
215  DMACH_SPDIF,
235  DMACH_DISP1,
240 };
241 
242 static struct dma_pl330_platdata exynos_pdma1_pdata;
243 
244 static AMBA_AHB_DEVICE(exynos_pdma1, "dma-pl330.1", 0x00041330,
245  EXYNOS4_PA_PDMA1, {EXYNOS4_IRQ_PDMA1}, &exynos_pdma1_pdata);
246 
247 static u8 mdma_peri[] = {
248  DMACH_MTOM_0,
249  DMACH_MTOM_1,
250  DMACH_MTOM_2,
251  DMACH_MTOM_3,
252  DMACH_MTOM_4,
253  DMACH_MTOM_5,
254  DMACH_MTOM_6,
255  DMACH_MTOM_7,
256 };
257 
258 static struct dma_pl330_platdata exynos_mdma1_pdata = {
259  .nr_valid_peri = ARRAY_SIZE(mdma_peri),
260  .peri_id = mdma_peri,
261 };
262 
263 static AMBA_AHB_DEVICE(exynos_mdma1, "dma-pl330.2", 0x00041330,
264  EXYNOS4_PA_MDMA1, {EXYNOS4_IRQ_MDMA1}, &exynos_mdma1_pdata);
265 
266 static int __init exynos_dma_init(void)
267 {
268  if (of_have_populated_dt())
269  return 0;
270 
271  if (soc_is_exynos4210()) {
272  exynos_pdma0_pdata.nr_valid_peri =
273  ARRAY_SIZE(exynos4210_pdma0_peri);
274  exynos_pdma0_pdata.peri_id = exynos4210_pdma0_peri;
275  exynos_pdma1_pdata.nr_valid_peri =
276  ARRAY_SIZE(exynos4210_pdma1_peri);
277  exynos_pdma1_pdata.peri_id = exynos4210_pdma1_peri;
278 
279  if (samsung_rev() == EXYNOS4210_REV_0)
280  exynos_mdma1_device.res.start = EXYNOS4_PA_S_MDMA1;
281  } else if (soc_is_exynos4212() || soc_is_exynos4412()) {
282  exynos_pdma0_pdata.nr_valid_peri =
283  ARRAY_SIZE(exynos4212_pdma0_peri);
284  exynos_pdma0_pdata.peri_id = exynos4212_pdma0_peri;
285  exynos_pdma1_pdata.nr_valid_peri =
286  ARRAY_SIZE(exynos4212_pdma1_peri);
287  exynos_pdma1_pdata.peri_id = exynos4212_pdma1_peri;
288  } else if (soc_is_exynos5250()) {
289  exynos_pdma0_pdata.nr_valid_peri =
290  ARRAY_SIZE(exynos5250_pdma0_peri);
291  exynos_pdma0_pdata.peri_id = exynos5250_pdma0_peri;
292  exynos_pdma1_pdata.nr_valid_peri =
293  ARRAY_SIZE(exynos5250_pdma1_peri);
294  exynos_pdma1_pdata.peri_id = exynos5250_pdma1_peri;
295 
296  exynos_pdma0_device.res.start = EXYNOS5_PA_PDMA0;
297  exynos_pdma0_device.res.end = EXYNOS5_PA_PDMA0 + SZ_4K;
298  exynos_pdma0_device.irq[0] = EXYNOS5_IRQ_PDMA0;
299  exynos_pdma1_device.res.start = EXYNOS5_PA_PDMA1;
300  exynos_pdma1_device.res.end = EXYNOS5_PA_PDMA1 + SZ_4K;
301  exynos_pdma0_device.irq[0] = EXYNOS5_IRQ_PDMA1;
302  exynos_mdma1_device.res.start = EXYNOS5_PA_MDMA1;
303  exynos_mdma1_device.res.end = EXYNOS5_PA_MDMA1 + SZ_4K;
304  exynos_pdma0_device.irq[0] = EXYNOS5_IRQ_MDMA1;
305  }
306 
307  dma_cap_set(DMA_SLAVE, exynos_pdma0_pdata.cap_mask);
308  dma_cap_set(DMA_CYCLIC, exynos_pdma0_pdata.cap_mask);
309  dma_cap_set(DMA_PRIVATE, exynos_pdma0_pdata.cap_mask);
310  amba_device_register(&exynos_pdma0_device, &iomem_resource);
311 
312  dma_cap_set(DMA_SLAVE, exynos_pdma1_pdata.cap_mask);
313  dma_cap_set(DMA_CYCLIC, exynos_pdma1_pdata.cap_mask);
314  dma_cap_set(DMA_PRIVATE, exynos_pdma1_pdata.cap_mask);
315  amba_device_register(&exynos_pdma1_device, &iomem_resource);
316 
317  dma_cap_set(DMA_MEMCPY, exynos_mdma1_pdata.cap_mask);
318  amba_device_register(&exynos_mdma1_device, &iomem_resource);
319 
320  return 0;
321 }
322 arch_initcall(exynos_dma_init);