1
2
3
4
5
6
7
8
9
10
11#include <linux/kernel.h>
12#include <linux/platform_device.h>
13#include <linux/dma-mapping.h>
14#include <linux/memblock.h>
15#include <linux/ioport.h>
16#include <linux/of_fdt.h>
17#include <linux/of.h>
18
19static struct platform_device s5p_device_mfc_l;
20static struct platform_device s5p_device_mfc_r;
21
22struct s5p_mfc_dt_meminfo {
23 unsigned long loff;
24 unsigned long lsize;
25 unsigned long roff;
26 unsigned long rsize;
27 char *compatible;
28};
29
30struct s5p_mfc_reserved_mem {
31 phys_addr_t base;
32 unsigned long size;
33 struct device *dev;
34};
35
36static struct s5p_mfc_reserved_mem s5p_mfc_mem[2] __initdata;
37
38
39static void __init s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize,
40 phys_addr_t lbase, unsigned int lsize)
41{
42 int i;
43
44 s5p_mfc_mem[0].dev = &s5p_device_mfc_r.dev;
45 s5p_mfc_mem[0].base = rbase;
46 s5p_mfc_mem[0].size = rsize;
47
48 s5p_mfc_mem[1].dev = &s5p_device_mfc_l.dev;
49 s5p_mfc_mem[1].base = lbase;
50 s5p_mfc_mem[1].size = lsize;
51
52 for (i = 0; i < ARRAY_SIZE(s5p_mfc_mem); i++) {
53 struct s5p_mfc_reserved_mem *area = &s5p_mfc_mem[i];
54 if (memblock_remove(area->base, area->size)) {
55 printk(KERN_ERR "Failed to reserve memory for MFC device (%ld bytes at 0x%08lx)\n",
56 area->size, (unsigned long) area->base);
57 area->base = 0;
58 }
59 }
60}
61
62int __init s5p_fdt_alloc_mfc_mem(unsigned long node, const char *uname,
63 int depth, void *data)
64{
65 const __be32 *prop;
66 int len;
67 struct s5p_mfc_dt_meminfo mfc_mem;
68
69 if (!data)
70 return 0;
71
72 if (!of_flat_dt_is_compatible(node, data))
73 return 0;
74
75 prop = of_get_flat_dt_prop(node, "samsung,mfc-l", &len);
76 if (!prop || (len != 2 * sizeof(unsigned long)))
77 return 0;
78
79 mfc_mem.loff = be32_to_cpu(prop[0]);
80 mfc_mem.lsize = be32_to_cpu(prop[1]);
81
82 prop = of_get_flat_dt_prop(node, "samsung,mfc-r", &len);
83 if (!prop || (len != 2 * sizeof(unsigned long)))
84 return 0;
85
86 mfc_mem.roff = be32_to_cpu(prop[0]);
87 mfc_mem.rsize = be32_to_cpu(prop[1]);
88
89 s5p_mfc_reserve_mem(mfc_mem.roff, mfc_mem.rsize,
90 mfc_mem.loff, mfc_mem.lsize);
91
92 return 1;
93}
94