diff options
-rw-r--r-- | arch/arm/plat-omap/common.c | 2 | ||||
-rw-r--r-- | arch/arm/plat-omap/fb.c | 140 | ||||
-rw-r--r-- | include/linux/omapfb.h | 1 |
3 files changed, 2 insertions, 141 deletions
diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c index 06383b51e655..2081f0f578e5 100644 --- a/arch/arm/plat-omap/common.c +++ b/arch/arm/plat-omap/common.c | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <linux/init.h> | 15 | #include <linux/init.h> |
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
18 | #include <linux/omapfb.h> | ||
19 | 18 | ||
20 | #include <plat/common.h> | 19 | #include <plat/common.h> |
21 | #include <plat/board.h> | 20 | #include <plat/board.h> |
@@ -65,7 +64,6 @@ const void *__init omap_get_var_config(u16 tag, size_t *len) | |||
65 | 64 | ||
66 | void __init omap_reserve(void) | 65 | void __init omap_reserve(void) |
67 | { | 66 | { |
68 | omapfb_reserve_sdram_memblock(); | ||
69 | omap_vram_reserve_sdram_memblock(); | 67 | omap_vram_reserve_sdram_memblock(); |
70 | omap_dsp_reserve_sdram_memblock(); | 68 | omap_dsp_reserve_sdram_memblock(); |
71 | omap_secure_ram_reserve_memblock(); | 69 | omap_secure_ram_reserve_memblock(); |
diff --git a/arch/arm/plat-omap/fb.c b/arch/arm/plat-omap/fb.c index a05ab5673556..a742b60912cd 100644 --- a/arch/arm/plat-omap/fb.c +++ b/arch/arm/plat-omap/fb.c | |||
@@ -38,8 +38,6 @@ | |||
38 | #if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE) | 38 | #if defined(CONFIG_FB_OMAP) || defined(CONFIG_FB_OMAP_MODULE) |
39 | 39 | ||
40 | static struct omapfb_platform_data omapfb_config; | 40 | static struct omapfb_platform_data omapfb_config; |
41 | static int config_invalid; | ||
42 | static int configured_regions; | ||
43 | 41 | ||
44 | static u64 omap_fb_dma_mask = ~(u32)0; | 42 | static u64 omap_fb_dma_mask = ~(u32)0; |
45 | 43 | ||
@@ -58,140 +56,14 @@ void omapfb_set_platform_data(struct omapfb_platform_data *data) | |||
58 | { | 56 | { |
59 | } | 57 | } |
60 | 58 | ||
61 | static inline int ranges_overlap(unsigned long start1, unsigned long size1, | ||
62 | unsigned long start2, unsigned long size2) | ||
63 | { | ||
64 | return (start1 >= start2 && start1 < start2 + size2) || | ||
65 | (start2 >= start1 && start2 < start1 + size1); | ||
66 | } | ||
67 | |||
68 | static inline int range_included(unsigned long start1, unsigned long size1, | ||
69 | unsigned long start2, unsigned long size2) | ||
70 | { | ||
71 | return start1 >= start2 && start1 + size1 <= start2 + size2; | ||
72 | } | ||
73 | |||
74 | /* | ||
75 | * Get the region_idx`th region from board config/ATAG and convert it to | ||
76 | * our internal format. | ||
77 | */ | ||
78 | static int __init get_fbmem_region(int region_idx, struct omapfb_mem_region *rg) | ||
79 | { | ||
80 | const struct omap_fbmem_config *conf; | ||
81 | u32 paddr; | ||
82 | |||
83 | conf = omap_get_nr_config(OMAP_TAG_FBMEM, | ||
84 | struct omap_fbmem_config, region_idx); | ||
85 | if (conf == NULL) | ||
86 | return -ENOENT; | ||
87 | |||
88 | paddr = conf->start; | ||
89 | /* | ||
90 | * Low bits encode the page allocation mode, if high bits | ||
91 | * are zero. Otherwise we need a page aligned fixed | ||
92 | * address. | ||
93 | */ | ||
94 | memset(rg, 0, sizeof(*rg)); | ||
95 | rg->type = paddr & ~PAGE_MASK; | ||
96 | rg->paddr = paddr & PAGE_MASK; | ||
97 | rg->size = PAGE_ALIGN(conf->size); | ||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | static int valid_sdram(unsigned long addr, unsigned long size) | ||
102 | { | ||
103 | return memblock_is_region_memory(addr, size); | ||
104 | } | ||
105 | |||
106 | static int reserve_sdram(unsigned long addr, unsigned long size) | ||
107 | { | ||
108 | if (memblock_is_region_reserved(addr, size)) | ||
109 | return -EBUSY; | ||
110 | if (memblock_reserve(addr, size)) | ||
111 | return -ENOMEM; | ||
112 | return 0; | ||
113 | } | ||
114 | |||
115 | /* | ||
116 | * Called from map_io. We need to call to this early enough so that we | ||
117 | * can reserve the fixed SDRAM regions before VM could get hold of them. | ||
118 | */ | ||
119 | void __init omapfb_reserve_sdram_memblock(void) | ||
120 | { | ||
121 | unsigned long reserved = 0; | ||
122 | int i; | ||
123 | |||
124 | if (config_invalid) | ||
125 | return; | ||
126 | |||
127 | for (i = 0; ; i++) { | ||
128 | struct omapfb_mem_region rg; | ||
129 | |||
130 | if (get_fbmem_region(i, &rg) < 0) | ||
131 | break; | ||
132 | |||
133 | if (i == OMAPFB_PLANE_NUM) { | ||
134 | pr_err("Extraneous FB mem configuration entries\n"); | ||
135 | config_invalid = 1; | ||
136 | return; | ||
137 | } | ||
138 | |||
139 | /* Check if it's our memory type. */ | ||
140 | if (rg.type != OMAPFB_MEMTYPE_SDRAM) | ||
141 | continue; | ||
142 | |||
143 | /* Check if the region falls within SDRAM */ | ||
144 | if (rg.paddr && !valid_sdram(rg.paddr, rg.size)) | ||
145 | continue; | ||
146 | |||
147 | if (rg.size == 0) { | ||
148 | pr_err("Zero size for FB region %d\n", i); | ||
149 | config_invalid = 1; | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | if (rg.paddr) { | ||
154 | if (reserve_sdram(rg.paddr, rg.size)) { | ||
155 | pr_err("Trying to use reserved memory for FB region %d\n", | ||
156 | i); | ||
157 | config_invalid = 1; | ||
158 | return; | ||
159 | } | ||
160 | reserved += rg.size; | ||
161 | } | ||
162 | |||
163 | if (omapfb_config.mem_desc.region[i].size) { | ||
164 | pr_err("FB region %d already set\n", i); | ||
165 | config_invalid = 1; | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | omapfb_config.mem_desc.region[i] = rg; | ||
170 | configured_regions++; | ||
171 | } | ||
172 | omapfb_config.mem_desc.region_cnt = i; | ||
173 | if (reserved) | ||
174 | pr_info("Reserving %lu bytes SDRAM for frame buffer\n", | ||
175 | reserved); | ||
176 | } | ||
177 | |||
178 | static int __init omap_init_fb(void) | 59 | static int __init omap_init_fb(void) |
179 | { | 60 | { |
180 | const struct omap_lcd_config *conf; | 61 | const struct omap_lcd_config *conf; |
181 | 62 | ||
182 | if (config_invalid) | ||
183 | return 0; | ||
184 | if (configured_regions != omapfb_config.mem_desc.region_cnt) { | ||
185 | printk(KERN_ERR "Invalid FB mem configuration entries\n"); | ||
186 | return 0; | ||
187 | } | ||
188 | conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config); | 63 | conf = omap_get_config(OMAP_TAG_LCD, struct omap_lcd_config); |
189 | if (conf == NULL) { | 64 | if (conf == NULL) |
190 | if (configured_regions) | ||
191 | /* FB mem config, but no LCD config? */ | ||
192 | printk(KERN_ERR "Missing LCD configuration\n"); | ||
193 | return 0; | 65 | return 0; |
194 | } | 66 | |
195 | omapfb_config.lcd = *conf; | 67 | omapfb_config.lcd = *conf; |
196 | 68 | ||
197 | return platform_device_register(&omap_fb_device); | 69 | return platform_device_register(&omap_fb_device); |
@@ -227,18 +99,10 @@ static int __init omap_init_fb(void) | |||
227 | 99 | ||
228 | arch_initcall(omap_init_fb); | 100 | arch_initcall(omap_init_fb); |
229 | 101 | ||
230 | void omapfb_reserve_sdram_memblock(void) | ||
231 | { | ||
232 | } | ||
233 | |||
234 | #else | 102 | #else |
235 | 103 | ||
236 | void omapfb_set_platform_data(struct omapfb_platform_data *data) | 104 | void omapfb_set_platform_data(struct omapfb_platform_data *data) |
237 | { | 105 | { |
238 | } | 106 | } |
239 | 107 | ||
240 | void omapfb_reserve_sdram_memblock(void) | ||
241 | { | ||
242 | } | ||
243 | |||
244 | #endif | 108 | #endif |
diff --git a/include/linux/omapfb.h b/include/linux/omapfb.h index 85cad31ca3d9..7ab9cebf9164 100644 --- a/include/linux/omapfb.h +++ b/include/linux/omapfb.h | |||
@@ -254,7 +254,6 @@ struct omapfb_platform_data { | |||
254 | 254 | ||
255 | /* in arch/arm/plat-omap/fb.c */ | 255 | /* in arch/arm/plat-omap/fb.c */ |
256 | extern void omapfb_set_platform_data(struct omapfb_platform_data *data); | 256 | extern void omapfb_set_platform_data(struct omapfb_platform_data *data); |
257 | extern void omapfb_reserve_sdram_memblock(void); | ||
258 | 257 | ||
259 | #endif | 258 | #endif |
260 | 259 | ||