Commit | Line | Data |
---|---|---|
d9c452f4 | 1 | /* |
0f75a96b KD |
2 | * Copyright (C) 2010-2011 Samsung Electronics Co.Ltd |
3 | * | |
4 | * Base S5P MFC resource and device definitions | |
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 | ||
0f75a96b | 11 | #include <linux/kernel.h> |
0f75a96b KD |
12 | #include <linux/platform_device.h> |
13 | #include <linux/dma-mapping.h> | |
14 | #include <linux/memblock.h> | |
15 | #include <linux/ioport.h> | |
2eae613b AK |
16 | #include <linux/of_fdt.h> |
17 | #include <linux/of.h> | |
0f75a96b | 18 | |
07fbe13d TF |
19 | static struct platform_device s5p_device_mfc_l; |
20 | static struct platform_device s5p_device_mfc_r; | |
d78c16cc TF |
21 | |
22 | struct s5p_mfc_dt_meminfo { | |
23 | unsigned long loff; | |
24 | unsigned long lsize; | |
25 | unsigned long roff; | |
26 | unsigned long rsize; | |
27 | char *compatible; | |
28 | }; | |
f76da510 | 29 | |
0f75a96b KD |
30 | struct s5p_mfc_reserved_mem { |
31 | phys_addr_t base; | |
32 | unsigned long size; | |
33 | struct device *dev; | |
34 | }; | |
35 | ||
36 | static struct s5p_mfc_reserved_mem s5p_mfc_mem[2] __initdata; | |
37 | ||
07fbe13d | 38 | |
d78c16cc | 39 | static void __init s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize, |
0f75a96b KD |
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 | ||
8b3e8bbd | 62 | int __init s5p_fdt_alloc_mfc_mem(unsigned long node, const char *uname, |
2eae613b AK |
63 | int depth, void *data) |
64 | { | |
9d0c4dfe RH |
65 | const __be32 *prop; |
66 | int len; | |
8b3e8bbd | 67 | struct s5p_mfc_dt_meminfo mfc_mem; |
2eae613b AK |
68 | |
69 | if (!data) | |
70 | return 0; | |
71 | ||
8b3e8bbd | 72 | if (!of_flat_dt_is_compatible(node, data)) |
2eae613b AK |
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 | ||
8b3e8bbd TB |
79 | mfc_mem.loff = be32_to_cpu(prop[0]); |
80 | mfc_mem.lsize = be32_to_cpu(prop[1]); | |
2eae613b AK |
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 | ||
8b3e8bbd TB |
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); | |
2eae613b AK |
91 | |
92 | return 1; | |
93 | } |