aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-s5p/dev-mfc.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-s5p/dev-mfc.c')
-rw-r--r--arch/arm/plat-s5p/dev-mfc.c123
1 files changed, 123 insertions, 0 deletions
diff --git a/arch/arm/plat-s5p/dev-mfc.c b/arch/arm/plat-s5p/dev-mfc.c
new file mode 100644
index 00000000000..94226a0010f
--- /dev/null
+++ b/arch/arm/plat-s5p/dev-mfc.c
@@ -0,0 +1,123 @@
1/* linux/arch/arm/plat-s5p/dev-mfc.c
2 *
3 * Copyright (C) 2010-2011 Samsung Electronics Co.Ltd
4 *
5 * Base S5P MFC resource and device definitions
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12
13#include <linux/kernel.h>
14#include <linux/interrupt.h>
15#include <linux/platform_device.h>
16#include <linux/dma-mapping.h>
17#include <linux/memblock.h>
18#include <linux/ioport.h>
19
20#include <mach/map.h>
21#include <plat/devs.h>
22#include <plat/irqs.h>
23#include <plat/mfc.h>
24
25static struct resource s5p_mfc_resource[] = {
26 [0] = {
27 .start = S5P_PA_MFC,
28 .end = S5P_PA_MFC + SZ_64K - 1,
29 .flags = IORESOURCE_MEM,
30 },
31 [1] = {
32 .start = IRQ_MFC,
33 .end = IRQ_MFC,
34 .flags = IORESOURCE_IRQ,
35 }
36};
37
38struct platform_device s5p_device_mfc = {
39 .name = "s5p-mfc",
40 .id = -1,
41 .num_resources = ARRAY_SIZE(s5p_mfc_resource),
42 .resource = s5p_mfc_resource,
43};
44
45/*
46 * MFC hardware has 2 memory interfaces which are modelled as two separate
47 * platform devices to let dma-mapping distinguish between them.
48 *
49 * MFC parent device (s5p_device_mfc) must be registered before memory
50 * interface specific devices (s5p_device_mfc_l and s5p_device_mfc_r).
51 */
52
53static u64 s5p_mfc_dma_mask = DMA_BIT_MASK(32);
54
55struct platform_device s5p_device_mfc_l = {
56 .name = "s5p-mfc-l",
57 .id = -1,
58 .dev = {
59 .parent = &s5p_device_mfc.dev,
60 .dma_mask = &s5p_mfc_dma_mask,
61 .coherent_dma_mask = DMA_BIT_MASK(32),
62 },
63};
64
65struct platform_device s5p_device_mfc_r = {
66 .name = "s5p-mfc-r",
67 .id = -1,
68 .dev = {
69 .parent = &s5p_device_mfc.dev,
70 .dma_mask = &s5p_mfc_dma_mask,
71 .coherent_dma_mask = DMA_BIT_MASK(32),
72 },
73};
74
75struct s5p_mfc_reserved_mem {
76 phys_addr_t base;
77 unsigned long size;
78 struct device *dev;
79};
80
81static struct s5p_mfc_reserved_mem s5p_mfc_mem[2] __initdata;
82
83void __init s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize,
84 phys_addr_t lbase, unsigned int lsize)
85{
86 int i;
87
88 s5p_mfc_mem[0].dev = &s5p_device_mfc_r.dev;
89 s5p_mfc_mem[0].base = rbase;
90 s5p_mfc_mem[0].size = rsize;
91
92 s5p_mfc_mem[1].dev = &s5p_device_mfc_l.dev;
93 s5p_mfc_mem[1].base = lbase;
94 s5p_mfc_mem[1].size = lsize;
95
96 for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
97 struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
98 if (memblock_remove(area->base, area->size)) {
99 printk(KERN_ERR "Failed to reserve memory for MFC device (%ld bytes at 0x%08lx)\n",
100 area->size, (unsigned long) area->base);
101 area->base = 0;
102 }
103 }
104}
105
106static int __init s5p_mfc_memory_init(void)
107{
108 int i;
109
110 for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
111 struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
112 if (!area->base)
113 continue;
114
115 if (dma_declare_coherent_memory(area->dev, area->base,
116 area->base, area->size,
117 DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0)
118 printk(KERN_ERR "Failed to declare coherent memory for MFC device (%ld bytes at 0x%08lx)\n",
119 area->size, (unsigned long) area->base);
120 }
121 return 0;
122}
123device_initcall(s5p_mfc_memory_init);